feat(flutter): 重构播放页并增加语言切换
This commit is contained in:
1 parent
f1efbc5be8
commit
8c43e9e385
34 files changed
+1331
-879
No files matched your search
@@ -0,0 +1,39 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/data/services/locale_controller.dart';
|
||||
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
|
||||
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
|
||||
|
||||
void main() {
|
||||
setUp(() {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.empty();
|
||||
});
|
||||
|
||||
test('should_restore_saved_locale_when_controller_loads', () async {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.withData({
|
||||
LocaleController.preferenceKey: 'zh',
|
||||
});
|
||||
final controller = LocaleController();
|
||||
|
||||
await controller.load();
|
||||
|
||||
expect(controller.locale?.languageCode, 'zh');
|
||||
controller.dispose();
|
||||
});
|
||||
|
||||
test('should_persist_selected_locale_for_next_launch', () async {
|
||||
final controller = LocaleController();
|
||||
await controller.select(const Locale('id'));
|
||||
|
||||
final restored = LocaleController();
|
||||
await restored.load();
|
||||
|
||||
expect(restored.locale?.languageCode, 'id');
|
||||
controller.dispose();
|
||||
restored.dispose();
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user