fix(player): 修正缓冲态与首帧时间闪现

This commit is contained in:
Zhou Weidong committed 2026-10-26 21:13:55 +08:00
1 parent 0f27daf664
commit 350d16db75
8 files changed
+262 -22

No files matched your search

+118
View File
@@ -54,6 +54,11 @@ void main() {
expect(find.byKey(const Key('progress-loading')), findsNothing);
expect(find.byKey(const Key('progress-inactive')), findsOneWidget);
expect(find.byType(Slider), findsNothing);
expect(
find.byKey(const Key('player-progress-uninitialized-time')),
findsNothing,
);
expect(find.textContaining('00:00'), findsNothing);
});
testWidgets('should_show_inactive_track_and_disable_seek_when_locked', (
@@ -144,6 +149,119 @@ void main() {
expect(find.byType(Slider), findsOneWidget);
});
testWidgets(
'should_hide_buffering_loading_immediately_when_position_advances',
(tester) async {
final video = ValueNotifier<VideoPlayerValue>(
const VideoPlayerValue(
duration: Duration(seconds: 12),
position: Duration(seconds: 3),
isInitialized: true,
isPlaying: true,
isBuffering: true,
),
);
addTearDown(video.dispose);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: SeekProgressBar(
valueListenable: video,
semanticsLabel: 'Seek video',
onSeek: (_) async {},
),
),
),
);
expect(find.byKey(const Key('progress-loading')), findsNothing);
await tester.pump(const Duration(milliseconds: 200));
video.value = const VideoPlayerValue(
duration: Duration(seconds: 12),
position: Duration(seconds: 4),
isInitialized: true,
isBuffering: true,
);
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
expect(find.byKey(const Key('progress-loading')), findsNothing);
expect(find.byType(Slider), findsOneWidget);
video.value = const VideoPlayerValue(
duration: Duration(seconds: 12),
position: Duration(seconds: 4),
isInitialized: true,
isPlaying: true,
isBuffering: true,
);
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
expect(find.byKey(const Key('progress-loading')), findsOneWidget);
expect(find.byType(Slider), findsNothing);
},
);
testWidgets('should_not_show_loading_for_prewarmed_episode', (tester) async {
final video = ValueNotifier<VideoPlayerValue>(
const VideoPlayerValue(
duration: Duration(seconds: 12),
position: Duration(seconds: 5),
isInitialized: true,
isPlaying: true,
isBuffering: true,
),
);
addTearDown(video.dispose);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: SeekProgressBar(
valueListenable: video,
semanticsLabel: 'Seek video',
onSeek: (_) async {},
),
),
),
);
await tester.pump(const Duration(milliseconds: 400));
expect(find.byKey(const Key('progress-loading')), findsNothing);
expect(find.byType(Slider), findsOneWidget);
});
testWidgets(
'should_suppress_progress_loading_while_entry_loading_is_visible',
(tester) async {
final video = ValueNotifier<VideoPlayerValue>(
const VideoPlayerValue(
duration: Duration(seconds: 12),
position: Duration.zero,
isInitialized: true,
isBuffering: true,
),
);
addTearDown(video.dispose);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: SeekProgressBar(
valueListenable: video,
semanticsLabel: 'Seek video',
suppressBufferLoading: true,
onSeek: (_) async {},
),
),
),
);
await tester.pump(const Duration(milliseconds: 400));
expect(find.byKey(const Key('progress-loading')), findsNothing);
expect(find.byType(Slider), findsOneWidget);
},
);
testWidgets('should_keep_slider_while_scrubbing_during_buffering', (
tester,
) async {