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

@@ -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')))