fix(player): 规范预热回收日志并抓帧过渡

This commit is contained in:
Zhou Weidong committed 2026-10-26 17:13:56 +08:00
1 parent bb2c729a7e
commit 4d3d067f77
6 files changed
+186 -40

No files matched your search

+17
View File
@@ -129,11 +129,15 @@ void main() {
expect(sourceLiveBefore, greaterThan(1));
await tester.tap(find.byKey(const Key('home-feed-full-series')));
await _waitForFullPlayerEntry(tester);
await tester.pumpAndSettle();
final fullPlayer = _fullPlayerFinder();
final fullLogic = _pageLogic(tester, fullPlayer);
expect(fullLogic.session, isNot(same(sourceLogic.session)));
final fullPlayerWidget = tester.widget<PlayerPage>(fullPlayer);
expect(fullPlayerWidget.initialFrameBytes, isNotNull);
expect(fullPlayerWidget.revealAfterFirstFrame, isTrue);
final fullPlayerPort = fullLogic.session.active! as VideoPlayerPort;
expect(fullPlayerPort.controller, isNot(same(feedPlayer.controller)));
expect(feedPlayer.disposed, isFalse);
@@ -221,6 +225,7 @@ void main() {
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
await tester.tap(find.byKey(const Key('home-feed-full-series')));
await _waitForFullPlayerEntry(tester);
await tester.pumpAndSettle();
expect(_fullPlayerFinder(), findsOneWidget);
@@ -263,6 +268,7 @@ void main() {
expect(feedIndex, 1);
await tester.tap(find.byKey(const Key('home-feed-full-series')));
await _waitForFullPlayerEntry(tester);
await tester.pumpAndSettle();
final fullLogic = _pageLogic(tester, _fullPlayerFinder());
@@ -1658,6 +1664,17 @@ Finder _fullPlayerFinder() {
);
}
Future<void> _waitForFullPlayerEntry(WidgetTester tester) async {
for (var attempt = 0; attempt < 120; attempt++) {
await tester.runAsync(
() => Future<void>.delayed(const Duration(milliseconds: 10)),
);
await tester.pump(const Duration(milliseconds: 16));
if (_fullPlayerFinder().evaluate().isNotEmpty) return;
}
fail('full player route was not pushed after frame capture');
}
class _RouteVideoFactory {
final List<_RouteVideoPlayer> created = [];
final List<Episode> episodes = [];
@@ -470,6 +470,7 @@ void main() {
await _pumpRecommend(tester);
await tester.tap(find.byKey(const Key('home-feed-series-name')));
await _waitForFullPlayer(tester);
await tester.pumpAndSettle();
expect(find.byType(PlayerPage).last, findsOneWidget);
expect(
@@ -484,6 +485,7 @@ void main() {
expect(find.byKey(const Key('recommend-tab-recommend')), findsOneWidget);
await tester.tap(find.byKey(const Key('home-feed-full-series')));
await _waitForFullPlayer(tester);
await tester.pumpAndSettle();
expect(find.byType(PlayerPage).last, findsOneWidget);
expect(
@@ -550,6 +552,17 @@ void main() {
});
}
Future<void> _waitForFullPlayer(WidgetTester tester) async {
for (var attempt = 0; attempt < 120; attempt++) {
await tester.runAsync(
() => Future<void>.delayed(const Duration(milliseconds: 10)),
);
await tester.pump(const Duration(milliseconds: 16));
if (find.byType(PlayerPage).evaluate().length > 1) return;
}
fail('full player route was not pushed after frame capture');
}
Future<void> _pumpRecommend(WidgetTester tester) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;