fix(player): 观看全集进入后自动播放

This commit is contained in:
Zhou Weidong committed 2026-10-26 21:25:38 +08:00
1 parent 350d16db75
commit 37353dac15
5 files changed
+126 -6

No files matched your search

+37 -2
View File
@@ -229,7 +229,7 @@ void main() {
expect(find.byKey(const Key('recommend-top-nav')), findsOneWidget);
});
testWidgets('should_show_one_paused_overlay_when_entering_full_player', (
testWidgets('should_autoplay_full_player_and_restore_paused_feed', (
tester,
) async {
final factory = _RouteVideoFactory();
@@ -245,7 +245,9 @@ void main() {
await tester.pumpAndSettle();
expect(_fullPlayerFinder(), findsOneWidget);
expect(find.byKey(const Key('player-play-toggle')), findsOneWidget);
final fullLogic = _pageLogic(tester, _fullPlayerFinder());
expect(fullLogic.session.userWantsPlay, isTrue);
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
expect(
find.byKey(const Key('home-feed-center-play')).hitTestable(),
findsNothing,
@@ -519,6 +521,37 @@ void main() {
expect(find.byKey(const Key('progress-inactive')), findsOneWidget);
});
testWidgets('should_auto_play_full_player_when_feed_is_paused', (
tester,
) async {
await _pumpApp(tester, playerFactory: (_) => _RecordingPlayer());
await tester.tap(find.byKey(const Key('tab-recommend')));
await tester.pumpAndSettle();
final feedPage = find.byKey(const Key('recommend-feed-player'));
final feedLogic = _pageLogic(tester, feedPage);
await feedLogic.session.preloadSettled;
feedLogic.session.setUserWantsPlay(false);
await feedLogic.session.playbackSettled;
await tester.pump();
expect(feedLogic.session.userWantsPlay, isFalse);
await tester.tap(find.byKey(const Key('home-feed-full-series')));
await tester.pumpAndSettle();
final fullLogic = _pageLogic(tester, _fullPlayerFinder());
final fullPlayer = fullLogic.session.active! as _RecordingPlayer;
expect(fullLogic.session, isNot(same(feedLogic.session)));
expect(fullLogic.session.userWantsPlay, isTrue);
expect(fullPlayer.playCalls, greaterThan(0));
expect(fullPlayer.playing, isTrue);
await tester.tap(find.byKey(const Key('player-back')).hitTestable());
await tester.pumpAndSettle();
expect(feedLogic.session.userWantsPlay, isFalse);
expect(feedLogic.session.activeSlotPlaying, isFalse);
});
testWidgets('should_only_show_progress_buffer_after_video_first_frame', (
tester,
) async {
@@ -2103,12 +2136,14 @@ class _RouteVideoPlayer extends VideoPlayerPort {
class _RecordingPlayer implements PlayerPort {
bool playing = false;
int playCalls = 0;
@override
Future<void> initialize() async {}
@override
Future<void> play() async {
playCalls++;
playing = true;
}