feat(recommend): 新增分区流全部短剧与剧单
This commit is contained in:
1 parent
0ef2438100
commit
f1b5418954
22 files changed
+1426
-722
No files matched your search
@@ -79,7 +79,6 @@ void main() {
|
||||
catalogRepository: catalog,
|
||||
categoryRepository: _GridCategoryRepository(),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('theater-category-7')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -187,38 +186,6 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_load_next_theater_page_near_scroll_bottom', (
|
||||
tester,
|
||||
) async {
|
||||
final catalog = _PagedTheaterCatalog([
|
||||
FeedPage(dramas: _pageDramas(0, 20), nextCursor: '20', hasMore: true),
|
||||
FeedPage(dramas: _pageDramas(20, 20)),
|
||||
]);
|
||||
await _pumpTheater(
|
||||
tester,
|
||||
catalogRepository: catalog,
|
||||
categoryRepository: _GridCategoryRepository(),
|
||||
);
|
||||
final position = tester
|
||||
.state<ScrollableState>(
|
||||
find
|
||||
.descendant(
|
||||
of: find.byKey(const Key('discover-refresh')),
|
||||
matching: find.byType(Scrollable),
|
||||
)
|
||||
.first,
|
||||
)
|
||||
.position;
|
||||
|
||||
position.jumpTo(position.maxScrollExtent);
|
||||
await tester.pump();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(catalog.calls, 2);
|
||||
expect(catalog.requestedCursors, [null, '20']);
|
||||
expect(find.byKey(const Key('home-drama-card-page-39')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_refresh_feed_when_pulled_down', (tester) async {
|
||||
final counter = _CountingCategoryRepository(
|
||||
_GridCategoryRepository(discoverFeed: _tallDiscoverFeed),
|
||||
@@ -656,34 +623,6 @@ class _CountingTheaterCatalog extends _TheaterOnlyCatalog {
|
||||
}
|
||||
}
|
||||
|
||||
class _PagedTheaterCatalog extends _TheaterOnlyCatalog {
|
||||
_PagedTheaterCatalog(this.pages);
|
||||
|
||||
final List<FeedPage> pages;
|
||||
final List<String?> requestedCursors = [];
|
||||
|
||||
int get calls => requestedCursors.length;
|
||||
|
||||
@override
|
||||
Future<FeedPage> fetchFeed({
|
||||
List<String> types = const [],
|
||||
String? categoryId,
|
||||
String? cursor,
|
||||
int size = 10,
|
||||
}) async {
|
||||
if (size != 20) {
|
||||
return super.fetchFeed(
|
||||
types: types,
|
||||
categoryId: categoryId,
|
||||
cursor: cursor,
|
||||
size: size,
|
||||
);
|
||||
}
|
||||
requestedCursors.add(cursor);
|
||||
return pages.removeAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
class _FailingTheaterCatalog extends _TheaterOnlyCatalog {
|
||||
@override
|
||||
Future<FeedPage> fetchFeed({
|
||||
@@ -703,14 +642,3 @@ class _FailingTheaterCatalog extends _TheaterOnlyCatalog {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
List<Drama> _pageDramas(int start, int count) => [
|
||||
for (var index = start; index < start + count; index++)
|
||||
Drama(
|
||||
id: 'page-$index',
|
||||
title: 'Page $index',
|
||||
synopsis: 'Page $index synopsis',
|
||||
posterUrl: '',
|
||||
genre: 'Drama',
|
||||
),
|
||||
];
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart
|
||||
import 'package:fruitshorts/core/data/services/playback_session.dart';
|
||||
import 'package:fruitshorts/core/theme/app_colors.dart';
|
||||
import 'package:fruitshorts/pages/auth/auth_view.dart';
|
||||
import 'package:fruitshorts/pages/player/player_view.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/player_center_toggle.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/seek_progress_bar.dart';
|
||||
|
||||
@@ -41,17 +42,16 @@ void main() {
|
||||
await _pumpApp(tester);
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('home-feed-full-series')));
|
||||
await tester.tap(
|
||||
find.byKey(const Key('recommend-card-hits-the-signal-demo')),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
_expectFullscreenOverlay(tester);
|
||||
expect(
|
||||
tester.widget<PlayerPage>(find.byType(PlayerPage).last).homeMode,
|
||||
isTrue,
|
||||
);
|
||||
expect(find.byType(PageView), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('player-more')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('player-more-quality-AUTO')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-more-offline')), findsOneWidget);
|
||||
await tester.tapAt(const Offset(10, 10));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
@@ -61,7 +61,6 @@ void main() {
|
||||
await _pumpApp(tester);
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
_expectPlayerNavigationBar(tester);
|
||||
|
||||
await _openSeriesPlayer(tester);
|
||||
_expectPlayerNavigationBar(tester);
|
||||
@@ -81,7 +80,12 @@ void main() {
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(
|
||||
find.byKey(const Key('recommend-card-hits-the-signal-demo')),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
final ticketLoading = find.byKey(const Key('player-ticket-loading'));
|
||||
expect(ticketLoading, findsOneWidget);
|
||||
@@ -166,6 +170,10 @@ void main() {
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(
|
||||
find.byKey(const Key('recommend-card-hits-the-signal-demo')),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final player = players.firstWhere((item) => item.playing);
|
||||
expect(player.playing, isTrue);
|
||||
|
||||
@@ -220,10 +228,8 @@ void main() {
|
||||
'auth.user': '{"uid":"9","nickname":"Viewer","avatarUrl":""}',
|
||||
});
|
||||
await _pumpApp(tester);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('rail-comments')));
|
||||
await _openSeriesPlayer(tester);
|
||||
await tester.tap(find.byKey(const Key('player-rail-comments')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('player-comments-sheet')), findsOneWidget);
|
||||
@@ -266,34 +272,6 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_update_home_feed_favorite_count_after_toggle', (
|
||||
tester,
|
||||
) async {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.withData({
|
||||
'auth.accessToken': 'access',
|
||||
'auth.refreshToken': 'refresh',
|
||||
'auth.user': '{"uid":"9","nickname":"Viewer","avatarUrl":""}',
|
||||
});
|
||||
final catalog = FakeCatalogRepository(dramas: [_countingDrama]);
|
||||
await _pumpApp(tester, catalog: catalog);
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
tester.widget<Text>(find.byKey(const Key('rail-save-count'))).data,
|
||||
'2',
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('rail-save')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
tester.widget<Text>(find.byKey(const Key('rail-save-count'))).data,
|
||||
'3',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_show_center_toggle_only_when_paused', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await _openSeriesPlayer(tester);
|
||||
@@ -1392,27 +1370,6 @@ Future<void> _pumpApp(
|
||||
if (settle) await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
const _countingDrama = Drama(
|
||||
id: 'counting-demo',
|
||||
title: 'Counting Demo',
|
||||
synopsis: 'Counting interaction totals',
|
||||
posterUrl: '/files/counting-demo.png',
|
||||
genre: 'Romance',
|
||||
detailLoaded: true,
|
||||
favoriteCount: 2,
|
||||
commentCount: 3,
|
||||
likeCount: 4,
|
||||
episodes: [
|
||||
Episode(
|
||||
id: 'counting-demo-1',
|
||||
number: 1,
|
||||
title: 'Episode 1',
|
||||
isFree: true,
|
||||
videoUrl: 'https://example.test/counting-1.mp4',
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
class _RecordingPlayer implements PlayerPort {
|
||||
bool playing = false;
|
||||
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/app.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/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';
|
||||
|
||||
import '../support/fake_catalog.dart';
|
||||
import '../support/fake_category.dart';
|
||||
import '../support/fake_haptics.dart';
|
||||
import '../support/fake_interaction_repositories.dart';
|
||||
import '../support/widget_player.dart';
|
||||
|
||||
void main() {
|
||||
setUp(() {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.empty();
|
||||
});
|
||||
|
||||
testWidgets('should_render_three_recommend_sections_and_horizontal_cards', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpRecommend(tester);
|
||||
|
||||
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);
|
||||
expect(find.byKey(const Key('recommend-more-hits')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-more-new')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-more-costume')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-row-hits')), findsOneWidget);
|
||||
expect(
|
||||
find.byKey(const Key('recommend-card-hits-the-signal-demo')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text("This Week's Hits"), findsOneWidget);
|
||||
expect(find.text('New This Week'), findsOneWidget);
|
||||
expect(find.text('Costume Drama Awards'), findsOneWidget);
|
||||
expect(find.byType(AppBottomNav), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_switch_inner_tabs_without_losing_grid_filter_state', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpRecommend(tester);
|
||||
|
||||
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(find.byKey(const Key('all-filter-local')), findsNothing);
|
||||
expect(find.byKey(const Key('all-filter-subtitles')), findsNothing);
|
||||
await tester.tap(find.byKey(const Key('all-sort-new')));
|
||||
await tester.pump();
|
||||
expect(_textStyle(tester, 'New').fontWeight, FontWeight.w700);
|
||||
|
||||
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(_textStyle(tester, 'New').fontWeight, FontWeight.w700);
|
||||
expect(find.byKey(const Key('all-dramas-grid')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_open_player_and_search_from_recommend_page', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpRecommend(tester);
|
||||
|
||||
await tester.tap(
|
||||
find.byKey(const Key('recommend-card-hits-the-signal-demo')),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final player = tester.widget<PlayerPage>(find.byType(PlayerPage).last);
|
||||
expect(player.homeMode, isTrue);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('recommend-search')));
|
||||
await tester.pumpAndSettle();
|
||||
final search = tester.widget<TextField>(
|
||||
find.byKey(const Key('discover-search')),
|
||||
);
|
||||
expect(search.focusNode?.hasFocus, isTrue);
|
||||
});
|
||||
}
|
||||
|
||||
TextStyle _textStyle(WidgetTester tester, String text) {
|
||||
return tester
|
||||
.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('all-sort-new')),
|
||||
matching: find.text(text),
|
||||
),
|
||||
)
|
||||
.style!;
|
||||
}
|
||||
|
||||
Future<void> _pumpRecommend(WidgetTester tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final catalog = FakeCatalogRepository();
|
||||
await tester.pumpWidget(
|
||||
LumaDramaApp(
|
||||
playerFactory: createWidgetPlayer,
|
||||
catalogRepository: catalog,
|
||||
categoryRepository: FakeCategoryRepository(catalog: catalog),
|
||||
watchHistoryRepository: InMemoryWatchHistoryRepository(),
|
||||
favoriteRepository: InMemoryFavoriteRepository(cards: catalog.dramas),
|
||||
playbackRepository: FakePlaybackRepository(),
|
||||
commentRepository: FakeCommentRepository(),
|
||||
interactionRepository: FakeInteractionRepository(),
|
||||
haptics: FakeHaptics(),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
+18
-22
@@ -66,7 +66,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
// 首页 feed 启动会创建首个播放器,先清掉再统计剧场播放器。
|
||||
created.clear();
|
||||
await _openRecommendFullPlayer(tester);
|
||||
await _openFullPlayerFromHomeGrid(tester);
|
||||
|
||||
expect(created, isNotEmpty);
|
||||
final createdBeforeSwipe = created.length;
|
||||
@@ -79,7 +79,7 @@ void main() {
|
||||
contains('Episode 2'),
|
||||
);
|
||||
expect(created.length, greaterThan(createdBeforeSwipe));
|
||||
expect(created, contains('the-signal-demo-2'));
|
||||
expect(created, contains('city-lights-demo-2'));
|
||||
});
|
||||
|
||||
testWidgets('should_open_fullscreen_player_when_theater_card_is_tapped', (
|
||||
@@ -87,7 +87,7 @@ void main() {
|
||||
) async {
|
||||
await tester.pumpWidget(appUnderTest());
|
||||
await tester.pumpAndSettle();
|
||||
await _openRecommendFullPlayer(tester);
|
||||
await _openFullPlayerFromHomeGrid(tester);
|
||||
|
||||
final player = tester.widget<PlayerPage>(find.byType(PlayerPage).last);
|
||||
expect(player.homeMode, isFalse);
|
||||
@@ -104,23 +104,17 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(appUnderTest());
|
||||
await tester.pumpAndSettle();
|
||||
await _openRecommendFullPlayer(tester);
|
||||
await _openFullPlayerFromHomeGrid(tester);
|
||||
expect(find.byType(PlayerPage), findsOneWidget);
|
||||
|
||||
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-grid')), findsOneWidget);
|
||||
expect(
|
||||
Navigator.of(
|
||||
tester.element(find.byKey(const Key('home-feed-title'))),
|
||||
).canPop(),
|
||||
Navigator.of(tester.element(find.byKey(const Key('home-grid')))).canPop(),
|
||||
isFalse,
|
||||
);
|
||||
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-grid')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('favorites-page')), findsOneWidget);
|
||||
@@ -184,7 +178,7 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(appUnderTest());
|
||||
await tester.pumpAndSettle();
|
||||
await _openRecommendFullPlayer(tester);
|
||||
await _openFullPlayerFromHomeGrid(tester);
|
||||
|
||||
expect(find.byKey(const Key('progress-loading')), findsNothing);
|
||||
expect(find.byKey(const Key('progress-inactive')), findsOneWidget);
|
||||
@@ -241,7 +235,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await _openRecommendFullPlayer(tester);
|
||||
await _openFullPlayerFromHomeGrid(tester);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-rail-comments')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -261,13 +255,13 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-rail-like')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(interactions.likeTargets, contains('EPISODE:the-signal-demo-1'));
|
||||
expect(interactions.likeTargets, contains('EPISODE:city-lights-demo-1'));
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-rail-save')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('player-rail-share')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(sharedText, contains('The Signal'));
|
||||
expect(sharedText, contains('City Lights & Velvet Nights'));
|
||||
expect(sharedText, contains('FruitShorts'));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
@@ -281,7 +275,7 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(appUnderTest(interactionRepository: interactions));
|
||||
await tester.pumpAndSettle();
|
||||
await _openRecommendFullPlayer(tester);
|
||||
await _openFullPlayerFromHomeGrid(tester);
|
||||
await tester.tap(find.byKey(const Key('player-rail-like')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -297,7 +291,7 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(appUnderTest());
|
||||
await tester.pumpAndSettle();
|
||||
await _openRecommendFullPlayer(tester);
|
||||
await _openFullPlayerFromHomeGrid(tester);
|
||||
await tester.tap(find.byKey(const Key('player-rail-save')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -308,13 +302,15 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('mine-watchlist')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('The Signal'), findsWidgets);
|
||||
expect(find.text('City Lights & Velvet Nights'), findsWidgets);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _openRecommendFullPlayer(WidgetTester tester) async {
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
Future<void> _openFullPlayerFromHomeGrid(WidgetTester tester) async {
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('home-feed-full-series')));
|
||||
final card = find.byKey(const Key('home-feed-card-city-lights-demo'));
|
||||
await tester.ensureVisible(card);
|
||||
await tester.tap(card);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
Reference in new issue
Block a user