fix(player): 收敛播放页入口加载态

This commit is contained in:
Zhou Weidong committed 2026-10-26 17:56:40 +08:00
1 parent ee4e573f4f
commit b291044acc
7 files changed
+164 -90

No files matched your search

+58 -23
View File
@@ -139,6 +139,15 @@ void main() {
expect(feedPlayer.disposed, isFalse);
expect(feedPlayer.playing, isFalse);
final fullCurrentSurface = find.descendant(
of: fullPlayer,
matching: find.byKey(const ValueKey('player-render-slot-current')),
);
final fullCurrentSurfaceState = tester.state(fullCurrentSurface);
final loadingOverlay = find.byKey(
const Key('player-entry-loading-overlay'),
);
expect(loadingOverlay, findsNothing);
final fullPlayerPage = find
.descendant(
of: _fullPlayerFinder(),
@@ -149,15 +158,14 @@ void main() {
)
.first;
for (var index = 0; index < 4; index++) {
await tester.drag(
fullPlayerPage,
const Offset(0, -560),
);
await tester.drag(fullPlayerPage, const Offset(0, -560));
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
expect(loadingOverlay, findsNothing);
}
expect(fullLogic.session.currentEpisode.number, 5);
expect(tester.state(fullCurrentSurface), same(fullCurrentSurfaceState));
expect(
fullLogic.queue.entryAt(fullLogic.session.currentIndex).drama.id,
sourceDramaId,
@@ -260,7 +268,7 @@ void main() {
await _pumpApp(
tester,
playerFactory: (episode) => episode.id == 'the-signal-demo-2'
? _GatedPlayer(initialization.future)
? _GatedVideoPlayer(episode, initialization.future)
: routeFactory.create(episode),
);
await tester.tap(find.byKey(const Key('tab-recommend')));
@@ -270,13 +278,18 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('player-episode-2')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 16));
await tester.pump(const Duration(milliseconds: 300));
final loadingOverlay = find.byKey(
const Key('player-entry-loading-overlay'),
);
final fullPlayer = find.byType(PlayerPage).last;
final fullLogic = _pageLogic(tester, fullPlayer);
final fullCurrentSurface = find.descendant(
of: fullPlayer,
matching: find.byKey(const ValueKey('player-render-slot-current')),
);
final fullCurrentSurfaceState = tester.state(fullCurrentSurface);
final fullPlayerPage = find
.descendant(
of: fullPlayer,
@@ -288,6 +301,7 @@ void main() {
.first;
expect(loadingOverlay, findsOneWidget);
expect(tester.widget<IgnorePointer>(loadingOverlay).ignoring, isTrue);
expect(tester.getSize(loadingOverlay), const Size(40, 40));
expect(
tester
.widget<AnimatedOpacity>(
@@ -315,39 +329,51 @@ void main() {
.color,
Colors.white,
);
expect(
tester
.widget<ColoredBox>(
find.descendant(
of: loadingOverlay,
matching: find.byType(ColoredBox),
),
)
.color,
AppColors.mediaBlack,
);
final loadingSurface = tester.widget<Container>(
find.byKey(const Key('player-loading-surface')),
);
final decoration = loadingSurface.decoration! as BoxDecoration;
expect(decoration.color, AppColors.refreshIndicatorSurface);
expect(decoration.borderRadius, BorderRadius.circular(20));
expect(
find.descendant(of: loadingOverlay, matching: find.byType(ColoredBox)),
findsNothing,
);
// IgnorePointer 让加载中的播放暂停与上下滑仍能透传。
expect(find.byKey(const Key('player-back')).hitTestable(), findsOneWidget);
expect(
find.byKey(const Key('player-episode-heading')).hitTestable(),
findsOneWidget,
);
expect(
find.byKey(const Key('player-drama-title')).hitTestable(),
findsOneWidget,
);
expect(
find
.descendant(
of: find.byKey(const Key('player-rail-like')),
matching: find.byType(IconButton),
)
.hitTestable(),
findsOneWidget,
);
expect(find.byKey(const Key('player-progress')), findsOneWidget);
expect(find.text('00:00 / 01:00'), findsOneWidget);
// IgnorePointer 让加载中的播放暂停与上下滑穿透,滑动会关闭入口 loading。
expect(fullLogic.session.userWantsPlay, isTrue);
await tester.tap(find.byKey(const Key('player-video-tap')).hitTestable());
await tester.pump();
expect(fullLogic.session.userWantsPlay, isFalse);
final indexBeforeSwipe = fullLogic.session.currentIndex;
await tester.drag(
fullPlayerPage,
const Offset(0, -560),
);
await tester.drag(fullPlayerPage, const Offset(0, -560));
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
expect(fullLogic.session.currentIndex, isNot(indexBeforeSwipe));
expect(tester.state(fullCurrentSurface), same(fullCurrentSurfaceState));
// IgnorePointer 让加载中的返回按钮仍可点击。
// 切集完成后返回按钮仍可正常点击。
await tester.pumpAndSettle();
expect(loadingOverlay, findsNothing);
await tester.tap(find.byKey(const Key('player-back')).hitTestable());
@@ -1900,6 +1926,15 @@ class _GatedPlayer implements PlayerPort {
Future<void> dispose() async {}
}
class _GatedVideoPlayer extends VideoPlayerPort {
_GatedVideoPlayer(super.episode, this.initialization);
final Future<void> initialization;
@override
Future<void> initialize() => initialization;
}
const _lockedDrama = Drama(
id: 'locked-demo',
title: 'Locked Demo',