fix(player): 独立全屏路由复用播放会话
This commit is contained in:
1 parent
23e80dd637
commit
9d2d3b97a1
4 files changed
+219
-103
No files matched your search
@@ -23,6 +23,7 @@ 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/player_render_stack.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/player_video_surface.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/seek_progress_bar.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
|
||||
@@ -104,13 +105,15 @@ void main() {
|
||||
expect(recommendPlayer, findsOneWidget);
|
||||
expect(renderStack, findsOneWidget);
|
||||
final playerState = tester.state(recommendPlayer);
|
||||
final renderState = tester.state(renderStack);
|
||||
final currentSurface = find.descendant(
|
||||
of: recommendPlayer,
|
||||
matching: find.byKey(
|
||||
const ValueKey('player-render-slot-current'),
|
||||
),
|
||||
);
|
||||
final sourceRender = tester.widget<PlayerRenderStack>(renderStack);
|
||||
final sourceIndex =
|
||||
sourceRender.slots[PlayerRenderSlotRole.current]?.index;
|
||||
final controller = factory.created.first.controller;
|
||||
final createdBefore = factory.created.length;
|
||||
final requestsBefore = playback.requests.length;
|
||||
@@ -126,19 +129,37 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('home-feed-full-series')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(PlayerPage), findsOneWidget);
|
||||
final fullPlayer = tester.widget<PlayerPage>(find.byType(PlayerPage));
|
||||
expect(fullPlayer.homeMode, isFalse);
|
||||
expect(fullPlayer.handoff, isNotNull);
|
||||
expect(fullPlayer.handoff!.initialIndex, sourceIndex);
|
||||
expect(fullPlayer.handoff!.logic.session.currentIndex, sourceIndex);
|
||||
expect(find.byKey(const Key('home-tabs-bar')), findsNothing);
|
||||
expect(find.byKey(const Key('recommend-top-nav')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-gesture')), findsNothing);
|
||||
expect(find.byKey(const Key('player-back')), findsOneWidget);
|
||||
expect(factory.created.length, createdBefore);
|
||||
expect(playback.requests.length, requestsBefore);
|
||||
expect(controller.value.position, const Duration(seconds: 5));
|
||||
final fullCurrentSurface = find.descendant(
|
||||
of: find.byType(PlayerPage),
|
||||
matching: find.byKey(
|
||||
const ValueKey('player-render-slot-current'),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: currentSurface,
|
||||
of: fullCurrentSurface,
|
||||
matching: find.byKey(const Key('player-single-placeholder')),
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
expect(
|
||||
tester.widget<PlayerVideoSurface>(fullCurrentSurface).controller,
|
||||
same(controller),
|
||||
);
|
||||
|
||||
tester.state<NavigatorState>(find.byType(Navigator).first).pop();
|
||||
await tester.tap(find.byKey(const Key('player-back')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('recommend-page')), findsOneWidget);
|
||||
@@ -147,8 +168,9 @@ void main() {
|
||||
expect(factory.created.length, createdBefore);
|
||||
expect(playback.requests.length, requestsBefore);
|
||||
expect(controller.value.position, const Duration(seconds: 5));
|
||||
expect(find.byKey(const Key('home-tabs-bar')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-top-nav')), findsOneWidget);
|
||||
expect(tester.state(recommendPlayer), same(playerState));
|
||||
expect(tester.state(renderStack), same(renderState));
|
||||
expect(find.byKey(const Key('recommend-feed-skeleton')), findsNothing);
|
||||
expect(
|
||||
find.descendant(
|
||||
@@ -157,6 +179,10 @@ void main() {
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
expect(
|
||||
tester.widget<PlayerVideoSurface>(currentSurface).controller,
|
||||
same(controller),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_swipe_full_player_without_creating_another_session', (
|
||||
@@ -179,6 +205,35 @@ void main() {
|
||||
expect(find.byType(PlayerPage), findsOneWidget);
|
||||
expect(factory.created.length, lessThanOrEqualTo(createdBefore + 1));
|
||||
expect(find.byKey(const Key('player-render-stack')), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('player-back')));
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
|
||||
testWidgets('should_show_one_paused_overlay_when_entering_full_player', (
|
||||
tester,
|
||||
) async {
|
||||
final factory = _RouteVideoFactory();
|
||||
await _pumpApp(tester, playerFactory: factory.create);
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-gesture')));
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
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(find.byType(PlayerPage), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
|
||||
expect(find.byKey(const Key('home-tabs-bar')), findsNothing);
|
||||
expect(find.byKey(const Key('recommend-top-nav')), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-back')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-tabs-bar')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_render_player_loading_indicators_at_compact_size', (
|
||||
|
||||
Reference in new issue
Block a user