test: fix gamma default + localized home
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:
2026-06-23 09:51:10 +08:00
parent 4fb431727e
commit 2c9f6037f7
2 changed files with 16 additions and 2 deletions

View File

@@ -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', () {

View File

@@ -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();