test: fix gamma default + localized home
Some checks failed
CI / Windows build (push) Has been cancelled
Some checks failed
CI / Windows build (push) Has been cancelled
Two tests asserted pre-refactor behavior: - pen_config_test expected the old pressureGamma default of 1.0; it is now the natural curve (the pen-feel feature). Also assert the new eraser defaults. - widget_test pumped HomeScreen without localization delegates, which the now-localized app bar requires. Provide the delegates. Full suite: 258/258 pass.
This commit is contained in:
@@ -7,6 +7,8 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import 'package:badnote/editor/engine/stroke_geometry.dart'
|
import 'package:badnote/editor/engine/stroke_geometry.dart'
|
||||||
show kDefaultPenThinning;
|
show kDefaultPenThinning;
|
||||||
import 'package:badnote/editor/input/pen_config.dart';
|
import 'package:badnote/editor/input/pen_config.dart';
|
||||||
|
import 'package:badnote/editor/input/pressure_curve.dart'
|
||||||
|
show kNaturalPressureGamma;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('applyPressureCurve', () {
|
group('applyPressureCurve', () {
|
||||||
@@ -56,7 +58,8 @@ void main() {
|
|||||||
final restored = PenConfig.fromJson({});
|
final restored = PenConfig.fromJson({});
|
||||||
expect(restored.sideButton, PenButtonAction.eraser);
|
expect(restored.sideButton, PenButtonAction.eraser);
|
||||||
expect(restored.eraserEnd, PenButtonAction.eraser);
|
expect(restored.eraserEnd, PenButtonAction.eraser);
|
||||||
expect(restored.pressureGamma, 1.0);
|
// Default gamma is the natural pen curve (<1) — the rnote-like feel.
|
||||||
|
expect(restored.pressureGamma, kNaturalPressureGamma);
|
||||||
expect(restored.palmRejectionMs, 150.0);
|
expect(restored.palmRejectionMs, 150.0);
|
||||||
expect(restored.fingerDrawing, false);
|
expect(restored.fingerDrawing, false);
|
||||||
expect(restored.penWidth, 0.004);
|
expect(restored.penWidth, 0.004);
|
||||||
@@ -64,6 +67,9 @@ void main() {
|
|||||||
// Missing pressureSensitivity defaults to the shared thinning constant,
|
// Missing pressureSensitivity defaults to the shared thinning constant,
|
||||||
// preserving the pre-existing stroke feel + export golden (plan M4).
|
// preserving the pre-existing stroke feel + export golden (plan M4).
|
||||||
expect(restored.pressureSensitivity, kDefaultPenThinning);
|
expect(restored.pressureSensitivity, kDefaultPenThinning);
|
||||||
|
// Eraser defaults: legacy fixed radius + segment (not whole-stroke) mode.
|
||||||
|
expect(restored.eraserRadius, kDefaultEraserRadius);
|
||||||
|
expect(restored.eraserWholeStroke, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('fromJson falls back to defaults for unknown enum names', () {
|
test('fromJson falls back to defaults for unknown enum names', () {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
import 'package:badnote/l10n/app_localizations.dart';
|
||||||
import 'package:badnote/screens/home_screen.dart';
|
import 'package:badnote/screens/home_screen.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@@ -17,7 +18,14 @@ void main() {
|
|||||||
SharedPreferences.setMockInitialValues({});
|
SharedPreferences.setMockInitialValues({});
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const ProviderScope(child: MaterialApp(home: HomeScreen())),
|
ProviderScope(
|
||||||
|
child: MaterialApp(
|
||||||
|
// The screen is now localized; provide the delegates it depends on.
|
||||||
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||||
|
supportedLocales: AppLocalizations.supportedLocales,
|
||||||
|
home: const HomeScreen(),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user