feat(flutter): 重设计剧场与首页 Hero
This commit is contained in:
1 parent
678b976ce1
commit
73aef4e44e
19 files changed
+339
-312
No files matched your search
@@ -38,6 +38,18 @@ void main() {
|
||||
);
|
||||
await _pumpApp(tester, catalog);
|
||||
expect(find.byKey(const Key('feed-banner-carousel')), findsOneWidget);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('home-hero-banner'))).height,
|
||||
greaterThanOrEqualTo(230),
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<Text>(find.byKey(const Key('home-hero-title-0')))
|
||||
.style
|
||||
?.fontSize,
|
||||
28,
|
||||
);
|
||||
expect(find.byKey(const Key('feed-banner-dot-0')), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('feed-banner-0')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
|
||||
@@ -24,37 +24,27 @@ void main() {
|
||||
InMemorySharedPreferencesAsync.empty();
|
||||
});
|
||||
|
||||
testWidgets('should_show_search_categories_ranking_and_all_dramas', (
|
||||
testWidgets('should_show_search_category_language_chips_and_drama_grid', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpTheater(tester, categoryRepository: _GridCategoryRepository());
|
||||
|
||||
expect(find.text('Continue Watching'), findsNothing);
|
||||
expect(find.byKey(const Key('discover-search')), findsOneWidget);
|
||||
expect(find.byKey(const Key('discover-category-grid')), findsOneWidget);
|
||||
expect(find.byKey(const Key('discover-ranking-section')), findsOneWidget);
|
||||
expect(find.byKey(const Key('theater-category-chips')), findsOneWidget);
|
||||
expect(find.byKey(const Key('theater-language-chips')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
|
||||
expect(find.byKey(const Key('ranking-tab-hot')), findsOneWidget);
|
||||
expect(find.byKey(const Key('ranking-tab-new')), findsOneWidget);
|
||||
|
||||
final grid = tester.widget<GridView>(
|
||||
find.byKey(const Key('discover-category-grid')),
|
||||
);
|
||||
final delegate =
|
||||
grid.gridDelegate as SliverGridDelegateWithFixedCrossAxisCount;
|
||||
expect(delegate.crossAxisCount, 3);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('should_open_category_dramas_page_when_tile_is_tapped', (
|
||||
testWidgets('should_filter_grid_when_category_chip_is_tapped', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpTheater(tester, categoryRepository: _GridCategoryRepository());
|
||||
|
||||
await tester.tap(find.byKey(const Key('discover-category-7')));
|
||||
await tester.tap(find.byKey(const Key('theater-category-7')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('category-dramas-page')), findsOneWidget);
|
||||
expect(
|
||||
find.byKey(const Key('home-drama-card-city-lights-demo')),
|
||||
findsOneWidget,
|
||||
@@ -76,22 +66,23 @@ void main() {
|
||||
);
|
||||
|
||||
final headerBefore = tester.getTopLeft(
|
||||
find.byKey(const Key('discover-search-button')),
|
||||
find.byKey(const Key('discover-search')),
|
||||
);
|
||||
final contentBefore = tester.getTopLeft(
|
||||
find.byKey(const Key('discover-category-grid')),
|
||||
final scrollable = find.descendant(
|
||||
of: find.byKey(const Key('discover-refresh')),
|
||||
matching: find.byType(Scrollable),
|
||||
);
|
||||
|
||||
await tester.drag(find.byType(ListView), const Offset(0, -140));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
tester.getTopLeft(find.byKey(const Key('discover-search-button'))),
|
||||
tester.getTopLeft(find.byKey(const Key('discover-search'))),
|
||||
headerBefore,
|
||||
);
|
||||
expect(
|
||||
tester.getTopLeft(find.byKey(const Key('discover-category-grid'))).dy,
|
||||
lessThan(contentBefore.dy),
|
||||
tester.state<ScrollableState>(scrollable).position.pixels,
|
||||
greaterThan(0),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -79,6 +79,26 @@ void main() {
|
||||
expect(field.focusNode?.hasFocus, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('should_select_theater_language_without_filtering_catalog', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
await tester.tap(find.byKey(const Key('tab-theater')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(_chip(tester, 'theater-language-all').selected, isTrue);
|
||||
expect(_chip(tester, 'theater-language-id').selected, isFalse);
|
||||
await tester.tap(find.byKey(const Key('theater-language-id')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(_chip(tester, 'theater-language-all').selected, isFalse);
|
||||
expect(_chip(tester, 'theater-language-id').selected, isTrue);
|
||||
expect(
|
||||
find.byKey(const Key('home-drama-card-the-signal-demo')),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_open_fullscreen_player_when_home_card_is_tapped', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -174,8 +194,8 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-theater')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('discover-category-grid')), findsOneWidget);
|
||||
expect(find.byKey(const Key('discover-ranking-section')), findsOneWidget);
|
||||
expect(find.byKey(const Key('theater-category-chips')), findsOneWidget);
|
||||
expect(find.byKey(const Key('theater-language-chips')), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('should_render_existing_theater_layout_on_same_route_tab', (
|
||||
testWidgets('should_render_theater_filters_and_grid_on_same_route_tab', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(360, 720);
|
||||
@@ -189,10 +189,10 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('tab-theater')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('discover-category-grid')), findsOneWidget);
|
||||
expect(find.byKey(const Key('discover-ranking-section')), findsOneWidget);
|
||||
expect(find.byKey(const Key('discover-search')), findsOneWidget);
|
||||
expect(find.byKey(const Key('theater-category-chips')), findsOneWidget);
|
||||
expect(find.byKey(const Key('theater-language-chips')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget);
|
||||
expect(find.byKey(const Key('discover-search-button')), findsOneWidget);
|
||||
expect(find.byKey(const Key('discover-profile')), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user