// Proves i18n is real, not just wired: the SAME widget resolves English under // Locale('en') and Chinese under Locale('zh'), through the generated // AppLocalizations delegates. Guards against ARB keys drifting out of sync. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:badnote/l10n/app_localizations.dart'; class _Probe extends StatelessWidget { const _Probe(); @override Widget build(BuildContext context) { final l = AppLocalizations.of(context); return Directionality( textDirection: TextDirection.ltr, child: Column(children: [ Text(l.settings), Text(l.toolEraser), Text(l.importPdf), ]), ); } } Future _pump(WidgetTester tester, Locale locale) { return tester.pumpWidget(MaterialApp( locale: locale, localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, home: const _Probe(), )); } void main() { testWidgets('English locale resolves English strings', (tester) async { await _pump(tester, const Locale('en')); expect(find.text('Settings'), findsOneWidget); expect(find.text('Eraser'), findsOneWidget); expect(find.text('Import PDF'), findsOneWidget); }); testWidgets('Chinese locale resolves Chinese strings', (tester) async { await _pump(tester, const Locale('zh')); expect(find.text('设置'), findsOneWidget); expect(find.text('橡皮擦'), findsOneWidget); expect(find.text('导入 PDF'), findsOneWidget); }); test('both locales are supported', () { final langs = AppLocalizations.supportedLocales.map((l) => l.languageCode).toSet(); expect(langs.containsAll({'en', 'zh'}), isTrue); }); }