Files
BadNote/test/widget_test.dart
Akiba So 2c9f6037f7
Some checks failed
CI / Windows build (push) Has been cancelled
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.
2026-06-23 09:51:10 +08:00

36 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
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() {
testWidgets('Home screen renders its app bar title', (
WidgetTester tester,
) async {
// The note list is backed by the on-device database, which is not
// available in the widget-test environment; the body therefore shows a
// loading/error state. The app-bar chrome renders regardless, so we assert
// on that. The home screen must be wrapped in a ProviderScope, which the
// app's real entrypoint (main.dart) provides.
SharedPreferences.setMockInitialValues({});
await tester.pumpWidget(
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();
expect(find.text('BadNote'), findsOneWidget);
expect(find.byTooltip('Search'), findsOneWidget);
});
}