feat(recommend): 新增分区流全部短剧与剧单
This commit is contained in:
1 parent
0ef2438100
commit
f1b5418954
22 files changed
+1426
-722
No files matched your search
@@ -124,7 +124,7 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(repository.cursors, contains('page1'));
|
||||
expect(repository.requestedSizes.every((size) => size <= 10), isTrue);
|
||||
expect(repository.requestedSizes.every((size) => size <= 20), isTrue);
|
||||
|
||||
await tester.scrollUntilVisible(
|
||||
find.byKey(const Key('home-feed-card-page2-1')),
|
||||
|
||||
@@ -213,7 +213,7 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-page')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -96,7 +96,9 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_immersive_player_on_recommend_tab', (tester) async {
|
||||
testWidgets('should_show_section_feed_and_open_player_from_recommend', (
|
||||
tester,
|
||||
) async {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.empty();
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
@@ -123,9 +125,18 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('home-grid')), findsNothing);
|
||||
expect(find.byType(PageView), findsOneWidget);
|
||||
expect(tester.widget<PlayerPage>(find.byType(PlayerPage)).homeMode, isTrue);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-page')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-section-hits')), findsOneWidget);
|
||||
expect(find.byType(PlayerPage), findsNothing);
|
||||
|
||||
await tester.tap(
|
||||
find.byKey(const Key('recommend-card-hits-the-signal-demo')),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.widget<PlayerPage>(find.byType(PlayerPage).last).homeMode,
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_render_new_feed_structure_with_formatted_counts', (
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/app.dart';
|
||||
import 'package:fruitshorts/core/data/models/feed_page.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/favorite_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/playback_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart';
|
||||
import 'package:fruitshorts/core/widgets/app_bottom_nav.dart';
|
||||
import 'package:fruitshorts/pages/home/home_feed_channel.dart';
|
||||
import 'package:fruitshorts/pages/player/player_view.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';
|
||||
@@ -37,7 +33,6 @@ void main() {
|
||||
expect(find.byKey(key), findsOneWidget);
|
||||
}
|
||||
expect(find.byKey(const Key('tab-create')), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -52,21 +47,17 @@ void main() {
|
||||
expect(find.byKey(const Key('home-grid')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-grid-cards')), findsOneWidget);
|
||||
expect(find.byType(PageView), findsNothing);
|
||||
expect(
|
||||
tester.widget<Scaffold>(find.byType(Scaffold).first).backgroundColor,
|
||||
Colors.transparent,
|
||||
);
|
||||
expect(find.byKey(const Key('home-page-gradient')), findsNothing);
|
||||
expect(_hasLightStatusBar(tester), isTrue);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_home_feed_size_when_keyboard_insets_change', (
|
||||
testWidgets('should_keep_home_grid_when_keyboard_insets_change', (
|
||||
tester,
|
||||
) async {
|
||||
addTearDown(tester.view.resetViewInsets);
|
||||
await _pumpApp(tester);
|
||||
final feed = find.byKey(const Key('home-grid'));
|
||||
final before = tester.getRect(feed);
|
||||
final grid = find.byKey(const Key('home-grid'));
|
||||
final before = tester.getRect(grid);
|
||||
|
||||
tester.view.viewInsets = const FakeViewPadding(bottom: 300);
|
||||
await tester.pump();
|
||||
@@ -77,338 +68,83 @@ void main() {
|
||||
.resizeToAvoidBottomInset,
|
||||
isFalse,
|
||||
);
|
||||
expect(tester.getRect(feed), before);
|
||||
expect(tester.getRect(grid), before);
|
||||
});
|
||||
|
||||
testWidgets('should_open_full_player_from_full_series_bar', (tester) async {
|
||||
await _pumpApp(tester, recommend: true);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-full-series')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final player = tester.widget<PlayerPage>(find.byType(PlayerPage).last);
|
||||
expect(player.homeMode, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('should_switch_to_anime_channel', (tester) async {
|
||||
await _pumpApp(tester, recommend: true);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-tab-anime')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Coming soon'), findsNothing);
|
||||
expect(
|
||||
tester.widget<Text>(find.text('Anime')).style?.fontWeight,
|
||||
FontWeight.w800,
|
||||
);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_player_when_first_anime_switch_is_loading', (
|
||||
testWidgets('should_render_recommend_sections_and_inner_top_nav', (
|
||||
tester,
|
||||
) async {
|
||||
final catalog = _PendingAnimeCatalog();
|
||||
await _pumpApp(tester, catalog: catalog, recommend: true);
|
||||
for (var attempt = 0; attempt < 5 && catalog.animeCalls == 0; attempt++) {
|
||||
await tester.pump();
|
||||
await _pumpApp(tester);
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('recommend-page')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-tab-recommend')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-tab-playlist')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-tab-all')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-section-hits')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-section-new')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-section-costume')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_switch_playlist_and_all_dramas_in_recommend', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('recommend-tab-playlist')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('ranking-page')), findsOneWidget);
|
||||
expect(find.byType(AppBottomNav), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('recommend-tab-all')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('all-dramas-grid')), findsOneWidget);
|
||||
for (var row = 0; row < 4; row++) {
|
||||
expect(find.byKey(Key('all-filter-row-$row')), findsOneWidget);
|
||||
}
|
||||
expect(catalog.animeCalls, 1);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-tab-anime')));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(PlayerPage), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-channel-loading')), findsOneWidget);
|
||||
|
||||
catalog.anime.complete(FeedPage(dramas: [demoDramas[1]]));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('home-feed-channel-loading')), findsNothing);
|
||||
expect(
|
||||
tester.widget<PlayerPage>(find.byType(PlayerPage)).feedChannel,
|
||||
HomeFeedChannel.anime,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_show_empty_state_when_anime_has_no_dramas', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester, catalog: _EmptyAnimeCatalog(), recommend: true);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-tab-anime')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(PlayerPage), findsNothing);
|
||||
expect(find.text('No stories available yet.'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_refresh_feed_without_blank_loading', (tester) async {
|
||||
await _pumpApp(tester, recommend: true);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-refresh')));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(CircularProgressIndicator), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_feed_rail_above_bottom_panels', (tester) async {
|
||||
await _pumpApp(tester, recommend: true);
|
||||
final railTop = tester.getCenter(find.byKey(const Key('rail-save'))).dy;
|
||||
final railBottom = tester
|
||||
.getRect(find.byKey(const Key('rail-share')))
|
||||
.bottom;
|
||||
final seriesTop = tester
|
||||
.getRect(find.byKey(const Key('home-feed-full-series')))
|
||||
.top;
|
||||
final titleRight = tester
|
||||
.getRect(find.byKey(const Key('home-feed-title')))
|
||||
.right;
|
||||
final railLeft = tester.getRect(find.byKey(const Key('rail-save'))).left;
|
||||
|
||||
expect(railTop, greaterThan(844 * 0.45));
|
||||
expect(seriesTop - railBottom, closeTo(12, 1));
|
||||
expect(titleRight, lessThanOrEqualTo(railLeft + 2));
|
||||
});
|
||||
|
||||
testWidgets('should_keep_feed_header_and_progress_after_clear', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester, recommend: true);
|
||||
final gesture = await tester.startGesture(const Offset(195, 300));
|
||||
await tester.pump(const Duration(milliseconds: 700));
|
||||
await tester.pump();
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('player-more-clear')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('home-feed-refresh')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-tab-recommend')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-search')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-full-series')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-progress')), findsOneWidget);
|
||||
expect(find.byKey(const Key('rail-save')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsNothing);
|
||||
final exit = tester.getRect(
|
||||
find.byKey(const Key('home-feed-exit-clear-screen')),
|
||||
);
|
||||
expect(exit.right, greaterThan(340));
|
||||
expect(exit.center.dy, greaterThan(600));
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-exit-clear-screen')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('rail-save')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_boost_feed_on_side_long_press', (tester) async {
|
||||
await _pumpApp(tester, recommend: true);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
|
||||
final gesture = await tester.startGesture(const Offset(60, 300));
|
||||
await tester.pump(const Duration(milliseconds: 700));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byKey(const Key('home-feed-speed-boost-hint')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-full-series')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsNothing);
|
||||
expect(find.byKey(const Key('rail-save')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-search')), findsNothing);
|
||||
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-feed-speed-boost-hint')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
expect(find.byKey(const Key('rail-save')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-search')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_hide_exit_clear_button_while_boosting', (tester) async {
|
||||
await _pumpApp(tester, recommend: true);
|
||||
final moreGesture = await tester.startGesture(const Offset(195, 300));
|
||||
await tester.pump(const Duration(milliseconds: 700));
|
||||
await tester.pump();
|
||||
await moreGesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('player-more-clear')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.byKey(const Key('home-feed-exit-clear-screen')),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
final boostGesture = await tester.startGesture(const Offset(60, 300));
|
||||
await tester.pump(const Duration(milliseconds: 700));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byKey(const Key('home-feed-speed-boost-hint')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-full-series')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-progress')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-exit-clear-screen')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-search')), findsNothing);
|
||||
|
||||
await boostGesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('home-feed-speed-boost-hint')), findsNothing);
|
||||
expect(
|
||||
find.byKey(const Key('home-feed-exit-clear-screen')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(const Key('home-feed-search')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_resume_playback_when_boosting_while_paused', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester, recommend: true);
|
||||
await tester.tap(find.byKey(const Key('home-feed-video-toggle')));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
|
||||
final gesture = await tester.startGesture(const Offset(60, 300));
|
||||
await tester.pump(const Duration(milliseconds: 700));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byKey(const Key('home-feed-speed-boost-hint')), findsOneWidget);
|
||||
expect(find.textContaining('2.0'), findsWidgets);
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
|
||||
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-feed-speed-boost-hint')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_open_more_sheet_on_center_long_press', (tester) async {
|
||||
await _pumpApp(tester, recommend: true);
|
||||
|
||||
final gesture = await tester.startGesture(const Offset(195, 300));
|
||||
await tester.pump(const Duration(milliseconds: 700));
|
||||
await tester.pump();
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('player-more-sheet')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-clear')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-download')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-pip')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_light_status_bar_in_grid_and_recommend', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('should_open_search_from_home_and_recommend', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
expect(_hasLightStatusBar(tester), isTrue);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-page-gradient')), findsNothing);
|
||||
expect(_hasLightStatusBar(tester), isTrue);
|
||||
});
|
||||
|
||||
testWidgets('should_switch_feed_drama_when_swiped_up', (tester) async {
|
||||
await _pumpApp(tester, recommend: true);
|
||||
final before = tester
|
||||
.widget<Text>(find.byKey(const Key('home-feed-title')))
|
||||
.data;
|
||||
|
||||
await tester.drag(find.byType(PageView).first, const Offset(0, -600));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final after = tester
|
||||
.widget<Text>(find.byKey(const Key('home-feed-title')))
|
||||
.data;
|
||||
expect(after, isNot(before));
|
||||
});
|
||||
|
||||
testWidgets('should_keep_feed_header_fixed_when_swiping', (tester) async {
|
||||
await _pumpApp(tester, recommend: true);
|
||||
final before = tester.getRect(find.byKey(const Key('home-feed-search')));
|
||||
|
||||
await tester.drag(find.byType(PageView).first, const Offset(0, -600));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final after = tester.getRect(find.byKey(const Key('home-feed-search')));
|
||||
expect(after.top, closeTo(before.top, 0.5));
|
||||
expect(find.byKey(const Key('home-feed-tab-recommend')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-refresh')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_resume_feed_after_returning_from_full_player', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester, recommend: true);
|
||||
await tester.tap(find.byKey(const Key('home-feed-video-toggle')));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-full-series')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.widget<PlayerPage>(find.byType(PlayerPage).last).homeMode,
|
||||
isFalse,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-back')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_switch_from_grid_to_recommend_player', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
expect(find.byKey(const Key('home-grid')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('home-grid')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_open_discover_search_from_home_search', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-search-entry')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final field = tester.widget<TextField>(
|
||||
find.byKey(const Key('discover-search')),
|
||||
expect(
|
||||
tester
|
||||
.widget<TextField>(find.byKey(const Key('discover-search')))
|
||||
.focusNode
|
||||
?.hasFocus,
|
||||
isTrue,
|
||||
);
|
||||
expect(field.focusNode?.hasFocus, isTrue);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('recommend-search')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('discover-search')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_open_player_when_home_grid_card_is_tapped', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('should_open_player_from_home_grid_card', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
final card = find.byKey(const Key('home-feed-card-the-signal-demo'));
|
||||
await tester.ensureVisible(card);
|
||||
await tester.tap(card);
|
||||
await tester.tap(find.byKey(const Key('home-feed-card-the-signal-demo')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final player = tester.widget<PlayerPage>(find.byType(PlayerPage).last);
|
||||
expect(player.homeMode, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('should_fit_home_grid_and_recommend_on_320_width', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('should_fit_home_and_recommend_on_320_width', (tester) async {
|
||||
await _pumpApp(tester, size: const Size(320, 568));
|
||||
|
||||
expect(find.byKey(const Key('home-grid-cards')), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-section-hits')), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
@@ -429,21 +165,19 @@ bool _hasLightStatusBar(WidgetTester tester) => tester
|
||||
Future<void> _pumpApp(
|
||||
WidgetTester tester, {
|
||||
Size size = const Size(390, 844),
|
||||
FakeCatalogRepository? catalog,
|
||||
bool recommend = false,
|
||||
}) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final repository = catalog ?? FakeCatalogRepository();
|
||||
final catalog = FakeCatalogRepository();
|
||||
await tester.pumpWidget(
|
||||
LumaDramaApp(
|
||||
playerFactory: createWidgetPlayer,
|
||||
catalogRepository: repository,
|
||||
categoryRepository: FakeCategoryRepository(catalog: repository),
|
||||
catalogRepository: catalog,
|
||||
categoryRepository: FakeCategoryRepository(catalog: catalog),
|
||||
watchHistoryRepository: InMemoryWatchHistoryRepository(),
|
||||
favoriteRepository: InMemoryFavoriteRepository(cards: repository.dramas),
|
||||
favoriteRepository: InMemoryFavoriteRepository(cards: catalog.dramas),
|
||||
playbackRepository: FakePlaybackRepository(),
|
||||
commentRepository: FakeCommentRepository(),
|
||||
interactionRepository: FakeInteractionRepository(),
|
||||
@@ -451,52 +185,4 @@ Future<void> _pumpApp(
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
if (recommend) {
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
}
|
||||
|
||||
class _PendingAnimeCatalog extends FakeCatalogRepository {
|
||||
final anime = Completer<FeedPage>();
|
||||
int animeCalls = 0;
|
||||
|
||||
@override
|
||||
Future<FeedPage> fetchFeed({
|
||||
List<String> types = const [],
|
||||
String? categoryId,
|
||||
String? cursor,
|
||||
int size = 10,
|
||||
}) {
|
||||
if (types.contains('ANIME')) {
|
||||
animeCalls++;
|
||||
return anime.future;
|
||||
}
|
||||
return super.fetchFeed(
|
||||
types: types,
|
||||
categoryId: categoryId,
|
||||
cursor: cursor,
|
||||
size: size,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _EmptyAnimeCatalog extends FakeCatalogRepository {
|
||||
@override
|
||||
Future<FeedPage> fetchFeed({
|
||||
List<String> types = const [],
|
||||
String? categoryId,
|
||||
String? cursor,
|
||||
int size = 10,
|
||||
}) {
|
||||
if (types.contains('ANIME')) {
|
||||
return Future.value(const FeedPage(dramas: []));
|
||||
}
|
||||
return super.fetchFeed(
|
||||
types: types,
|
||||
categoryId: categoryId,
|
||||
cursor: cursor,
|
||||
size: size,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user