feat(flutter): 应用克莱因蓝主题与印尼语适配

This commit is contained in:
Zhou Weidong committed 2026-10-17 15:58:17 +08:00
1 parent e1147cfcba
commit 10d448c8ba
31 files changed
+891 -521

No files matched your search

+51 -21
View File
@@ -32,18 +32,42 @@ void main() {
expect(reopened.locale, const Locale('zh'));
});
test('should_clear_stored_chinese_preference_when_english_is_selected', () async {
await LocaleController().select('zh');
test('should_restore_indonesian_when_selected_and_app_restarts', () async {
final first = LocaleController();
await first.select('id');
expect(first.locale, const Locale('id'));
final reopened = LocaleController();
await reopened.load();
await reopened.select('en');
final third = LocaleController();
await third.load();
expect(third.locale, const Locale('en'));
expect(reopened.locale, const Locale('id'));
});
test('should_fallback_to_indonesian_when_system_language_is_unsupported', () {
expect(resolveAppLocale(null, const Locale('en')), const Locale('en'));
expect(resolveAppLocale(null, const Locale('id')), const Locale('id'));
expect(resolveAppLocale(null, const Locale('fr')), const Locale('id'));
expect(resolveAppLocale(null, const Locale('in')), const Locale('id'));
expect(
resolveAppLocale(const Locale('zh'), const Locale('fr')),
const Locale('zh'),
);
});
test(
'should_clear_stored_chinese_preference_when_english_is_selected',
() async {
await LocaleController().select('zh');
final reopened = LocaleController();
await reopened.load();
await reopened.select('en');
final third = LocaleController();
await third.load();
expect(third.locale, const Locale('en'));
},
);
test('should_clear_locale_when_code_is_unsupported', () async {
final controller = LocaleController();
await controller.select('zh');
@@ -54,25 +78,31 @@ void main() {
expect(controller.locale, isNull);
});
test('should_resolve_to_device_locale_when_stored_code_is_unsupported', () async {
await SharedPreferencesAsync().setString('ui.locale', 'fr');
test(
'should_resolve_to_device_locale_when_stored_code_is_unsupported',
() async {
await SharedPreferencesAsync().setString('ui.locale', 'fr');
final controller = LocaleController();
await controller.load();
final controller = LocaleController();
await controller.load();
expect(controller.locale, isNull);
});
expect(controller.locale, isNull);
},
);
test('should_survive_load_and_select_when_preference_store_is_broken', () async {
SharedPreferencesAsyncPlatform.instance = _BrokenPreferences();
final controller = LocaleController();
test(
'should_survive_load_and_select_when_preference_store_is_broken',
() async {
SharedPreferencesAsyncPlatform.instance = _BrokenPreferences();
final controller = LocaleController();
await controller.load();
expect(controller.locale, isNull);
await controller.load();
expect(controller.locale, isNull);
await controller.select('zh');
expect(controller.locale, const Locale('zh'));
});
await controller.select('zh');
expect(controller.locale, const Locale('zh'));
},
);
}
/// Stands in for a platform whose preference store is unavailable.