From 2c9f6037f7820bda0b9670931f46a1a18adcb88a Mon Sep 17 00:00:00 2001 From: Akiba So Date: Tue, 23 Jun 2026 09:51:10 +0800 Subject: [PATCH] test: fix gamma default + localized home 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. --- test/pen_config_test.dart | 8 +++++++- test/widget_test.dart | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/test/pen_config_test.dart b/test/pen_config_test.dart index bd366cf..eb49d90 100644 --- a/test/pen_config_test.dart +++ b/test/pen_config_test.dart @@ -7,6 +7,8 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:badnote/editor/engine/stroke_geometry.dart' show kDefaultPenThinning; import 'package:badnote/editor/input/pen_config.dart'; +import 'package:badnote/editor/input/pressure_curve.dart' + show kNaturalPressureGamma; void main() { group('applyPressureCurve', () { @@ -56,7 +58,8 @@ void main() { final restored = PenConfig.fromJson({}); expect(restored.sideButton, 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.fingerDrawing, false); expect(restored.penWidth, 0.004); @@ -64,6 +67,9 @@ void main() { // Missing pressureSensitivity defaults to the shared thinning constant, // preserving the pre-existing stroke feel + export golden (plan M4). 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', () { diff --git a/test/widget_test.dart b/test/widget_test.dart index dc3c96d..54819d8 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:badnote/l10n/app_localizations.dart'; import 'package:badnote/screens/home_screen.dart'; void main() { @@ -17,7 +18,14 @@ void main() { SharedPreferences.setMockInitialValues({}); 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();