feat(flutter): 重构四 Tab 与浏览页
This commit is contained in:
1 parent
99c72e2c32
commit
959edc0a32
41 files changed
+2148
-1179
No files matched your search
@@ -19,8 +19,9 @@ import '../support/widget_player.dart';
|
||||
const _keys = [
|
||||
Key('home-tabs-bar'),
|
||||
Key('tab-home'),
|
||||
Key('tab-discover'),
|
||||
Key('tab-my'),
|
||||
Key('tab-theater'),
|
||||
Key('tab-create'),
|
||||
Key('tab-mine'),
|
||||
];
|
||||
|
||||
void main() {
|
||||
@@ -33,7 +34,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('should_theme_three_tabs_and_switch_selected_state_when_tapped', (
|
||||
testWidgets('should_theme_four_tabs_and_switch_selected_state_when_tapped', (
|
||||
tester,
|
||||
) async {
|
||||
final haptics = FakeHaptics();
|
||||
@@ -68,20 +69,20 @@ void main() {
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-home')),
|
||||
matching: find.byIcon(Icons.play_circle_fill_rounded),
|
||||
matching: find.byIcon(Icons.home_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-discover')));
|
||||
await tester.tap(find.byKey(const Key('tab-theater')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(haptics.selectionClicks, 1);
|
||||
await tester.tap(find.byKey(const Key('tab-discover')));
|
||||
await tester.tap(find.byKey(const Key('tab-theater')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(haptics.selectionClicks, 1);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-discover')),
|
||||
of: find.byKey(const Key('tab-theater')),
|
||||
matching: find.byIcon(Icons.explore_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
@@ -89,25 +90,32 @@ void main() {
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-home')),
|
||||
matching: find.byIcon(Icons.play_circle_outline_rounded),
|
||||
matching: find.byIcon(Icons.home_outlined),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_map_three_tabs_to_home_discover_and_me', (tester) async {
|
||||
testWidgets('should_map_four_tabs_to_home_theater_create_and_me', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
|
||||
expect(find.byKey(const Key('tab-home')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-discover')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-my')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-info-card')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-theater')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-create')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-mine')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-browse-page')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-discover')));
|
||||
await tester.tap(find.byKey(const Key('tab-theater')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-my')));
|
||||
await tester.tap(find.byKey(const Key('tab-create')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('create-page')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-mine')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Viewer'), findsOneWidget);
|
||||
expect(find.byKey(const Key('mine-menu')), findsOneWidget);
|
||||
@@ -116,7 +124,7 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-feed-info-card')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-browse-page')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_not_haptic_when_ordinary_list_item_is_opened', (
|
||||
@@ -124,7 +132,7 @@ void main() {
|
||||
) async {
|
||||
final haptics = FakeHaptics();
|
||||
await _pumpApp(tester, haptics);
|
||||
await tester.tap(find.byKey(const Key('tab-my')));
|
||||
await tester.tap(find.byKey(const Key('tab-mine')));
|
||||
await tester.pumpAndSettle();
|
||||
haptics.reset();
|
||||
|
||||
|
||||
Reference in new issue
Block a user