feat(flutter): 应用克莱因蓝主题与印尼语适配
This commit is contained in:
1 parent
e1147cfcba
commit
10d448c8ba
31 files changed
+891
-521
No files matched your search
@@ -32,35 +32,41 @@ Drama _drama(String id, {List<int> numbers = const [1, 2, 3]}) => Drama(
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
test('should_keep_requested_section_and_read_episode_one_when_constructed', () async {
|
||||
final history = FakeWatchHistory()..saved = const Duration(seconds: 7);
|
||||
final logic = MineLogic(
|
||||
history: history,
|
||||
drama: _drama('signal'),
|
||||
initialSection: 1,
|
||||
);
|
||||
test(
|
||||
'should_keep_requested_section_and_read_episode_one_when_constructed',
|
||||
() async {
|
||||
final history = FakeWatchHistory()..saved = const Duration(seconds: 7);
|
||||
final logic = MineLogic(
|
||||
history: history,
|
||||
drama: _drama('signal'),
|
||||
initialSection: 1,
|
||||
);
|
||||
|
||||
expect(logic.section, 1);
|
||||
expect(logic.filter, 0);
|
||||
expect(await logic.position, const Duration(seconds: 7));
|
||||
expect(history.reads, ['signal']);
|
||||
logic.dispose();
|
||||
});
|
||||
expect(logic.section, 1);
|
||||
expect(logic.filter, 0);
|
||||
expect(await logic.position, const Duration(seconds: 7));
|
||||
expect(history.reads, ['signal']);
|
||||
logic.dispose();
|
||||
},
|
||||
);
|
||||
|
||||
test('should_resume_from_last_watch_when_list_card_has_no_episodes', () async {
|
||||
final history = FakeWatchHistory()
|
||||
..saved = const Duration(seconds: 7)
|
||||
..lastEpisode = 'signal-3';
|
||||
final logic = MineLogic(
|
||||
history: history,
|
||||
drama: _drama('signal', numbers: const []),
|
||||
initialSection: 1,
|
||||
);
|
||||
test(
|
||||
'should_resume_from_last_watch_when_list_card_has_no_episodes',
|
||||
() async {
|
||||
final history = FakeWatchHistory()
|
||||
..saved = const Duration(seconds: 7)
|
||||
..lastEpisode = 'signal-3';
|
||||
final logic = MineLogic(
|
||||
history: history,
|
||||
drama: _drama('signal', numbers: const []),
|
||||
initialSection: 1,
|
||||
);
|
||||
|
||||
expect(await logic.position, const Duration(seconds: 7));
|
||||
expect(history.reads, ['signal']);
|
||||
logic.dispose();
|
||||
});
|
||||
expect(await logic.position, const Duration(seconds: 7));
|
||||
expect(history.reads, ['signal']);
|
||||
logic.dispose();
|
||||
},
|
||||
);
|
||||
|
||||
test('should_notify_when_section_and_filter_are_selected', () {
|
||||
final logic = MineLogic(
|
||||
@@ -114,7 +120,12 @@ void main() {
|
||||
expect(logic.drama.id, 'city');
|
||||
|
||||
history.reads.clear();
|
||||
sync(_drama('vengeance'), active: true, wasActive: true, dramaChanged: true);
|
||||
sync(
|
||||
_drama('vengeance'),
|
||||
active: true,
|
||||
wasActive: true,
|
||||
dramaChanged: true,
|
||||
);
|
||||
expect(logic.drama.id, 'vengeance');
|
||||
expect(history.reads, ['vengeance']);
|
||||
|
||||
@@ -125,26 +136,29 @@ void main() {
|
||||
logic.dispose();
|
||||
});
|
||||
|
||||
test('should_reset_section_when_section_request_arrives_while_page_is_inactive', () {
|
||||
final logic = MineLogic(
|
||||
history: FakeWatchHistory(),
|
||||
drama: _drama('s'),
|
||||
initialSection: 0,
|
||||
);
|
||||
test(
|
||||
'should_reset_section_when_section_request_arrives_while_page_is_inactive',
|
||||
() {
|
||||
final logic = MineLogic(
|
||||
history: FakeWatchHistory(),
|
||||
drama: _drama('s'),
|
||||
initialSection: 0,
|
||||
);
|
||||
|
||||
logic.syncPage(
|
||||
active: false,
|
||||
wasActive: false,
|
||||
nextDrama: logic.drama,
|
||||
dramaChanged: false,
|
||||
sectionRequest: 1,
|
||||
previousSectionRequest: 0,
|
||||
initialSection: 1,
|
||||
);
|
||||
logic.syncPage(
|
||||
active: false,
|
||||
wasActive: false,
|
||||
nextDrama: logic.drama,
|
||||
dramaChanged: false,
|
||||
sectionRequest: 1,
|
||||
previousSectionRequest: 0,
|
||||
initialSection: 1,
|
||||
);
|
||||
|
||||
expect(logic.section, 1);
|
||||
logic.dispose();
|
||||
});
|
||||
expect(logic.section, 1);
|
||||
logic.dispose();
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('should_return_choice_and_forward_it_when_act_runs_embedded', (
|
||||
tester,
|
||||
@@ -197,7 +211,9 @@ void main() {
|
||||
logic.dispose();
|
||||
});
|
||||
|
||||
testWidgets('should_switch_app_locale_when_language_sheet_is_used', (tester) async {
|
||||
testWidgets('should_switch_app_locale_when_language_sheet_is_used', (
|
||||
tester,
|
||||
) async {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.empty();
|
||||
final locale = LocaleController();
|
||||
@@ -231,7 +247,14 @@ void main() {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
expect(find.text(l10n.english), findsOneWidget);
|
||||
expect(find.text(l10n.simplifiedChinese), findsOneWidget);
|
||||
expect(find.text('Bahasa Indonesia'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Bahasa Indonesia'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(locale.locale, const Locale('id'));
|
||||
|
||||
unawaited(logic.showLanguage(context));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text(l10n.simplifiedChinese));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
|
||||
Reference in new issue
Block a user