fix(home): 频道切换用封面过渡

This commit is contained in:
Zhou Weidong committed 2026-10-21 18:06:09 +08:00
1 parent 838ca2ce2a
commit c9adf8b399
5 files changed
+111 -19

No files matched your search

+5 -12
View File
@@ -131,18 +131,12 @@ void main() {
expect(player.playing, isTrue);
});
testWidgets('should_keep_video_surface_background_black', (tester) async {
testWidgets('should_show_poster_before_video_first_frame', (tester) async {
await _pumpApp(tester);
await _openSeriesPlayer(tester);
expect(
tester
.widget<ColoredBox>(
find.byKey(const Key('player-fallback-background')),
)
.color,
Colors.black,
);
expect(find.byKey(const Key('player-video-poster')), findsOneWidget);
expect(find.byKey(const Key('player-fallback-background')), findsNothing);
expect(find.byKey(const Key('player-fallback-cover')), findsNothing);
expect(find.byKey(const Key('player-fallback-scrim')), findsNothing);
});
@@ -471,9 +465,8 @@ void main() {
find.byKey(const Key('player-interaction-rail')),
);
expect(find.byKey(const Key('player-background')), findsNothing);
final fallback = find.byKey(const Key('player-fallback-background'));
expect(fallback, findsOneWidget);
expect(tester.widget<ColoredBox>(fallback).color, Colors.black);
expect(find.byKey(const Key('player-video-poster')), findsOneWidget);
expect(find.byKey(const Key('player-fallback-background')), findsNothing);
expect(find.byKey(const Key('player-fallback-cover')), findsNothing);
expect(find.byKey(const Key('player-fallback-scrim')), findsNothing);
expect(
@@ -7,6 +7,24 @@ import 'package:video_player/video_player.dart';
import 'package:fruitshorts/pages/player/widgets/player_video_surface.dart';
void main() {
testWidgets('should_show_poster_when_controller_is_missing', (tester) async {
await _pumpBareSurface(tester, posterUrl: '/files/poster.png');
expect(find.byKey(const Key('player-video-poster')), findsOneWidget);
expect(find.byKey(const Key('player-fallback-background')), findsNothing);
expect(_opacity(tester), 0);
});
testWidgets('should_keep_black_fallback_when_poster_is_empty', (
tester,
) async {
await _pumpBareSurface(tester);
expect(find.byKey(const Key('player-video-poster')), findsNothing);
expect(_fallbackColor(tester), Colors.black);
expect(_opacity(tester), 0);
});
testWidgets('should_keep_fallback_visible_before_video_is_ready', (
tester,
) async {
@@ -96,6 +114,25 @@ Future<VideoPlayerController> _pumpSurface(
return controller;
}
Future<void> _pumpBareSurface(
WidgetTester tester, {
String posterUrl = '',
}) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: PlayerVideoSurface(
controller: null,
videoUrl: '',
posterUrl: posterUrl,
theater: false,
onTap: () {},
),
),
),
);
}
Color _fallbackColor(WidgetTester tester) {
return tester
.widget<ColoredBox>(find.byKey(const Key('player-fallback-background')))