fix(player): 修复拖动进度条时加载态闪烁
This commit is contained in:
1 parent
72708630ba
commit
1993ff1102
5 files changed
+350
-13
No files matched your search
@@ -291,6 +291,111 @@ void main() {
|
||||
expect(opened, 1);
|
||||
});
|
||||
|
||||
testWidgets('should_debounce_feed_loading_and_keep_track_while_scrubbing', (
|
||||
tester,
|
||||
) async {
|
||||
final controller = ValueNotifier<VideoPlayerValue>(
|
||||
const VideoPlayerValue(
|
||||
duration: Duration(seconds: 100),
|
||||
position: Duration(seconds: 10),
|
||||
isInitialized: true,
|
||||
),
|
||||
);
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: AppTheme.light(),
|
||||
locale: const Locale('en'),
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
home: Builder(
|
||||
builder: (context) => Scaffold(
|
||||
body: HomeFeedOverlay(
|
||||
l10n: AppLocalizations.of(context)!,
|
||||
drama: const Drama(
|
||||
id: 'debounce-drama',
|
||||
title: 'Debounce Drama',
|
||||
synopsis: 'synopsis',
|
||||
posterUrl: '',
|
||||
totalEpisodes: 8,
|
||||
),
|
||||
episode: const Episode(
|
||||
id: 'debounce-episode',
|
||||
number: 1,
|
||||
title: 'Episode 1',
|
||||
isFree: true,
|
||||
),
|
||||
controller: controller,
|
||||
liked: false,
|
||||
saved: false,
|
||||
visible: true,
|
||||
boosting: false,
|
||||
onTogglePlay: () {},
|
||||
onBoostStart: () {},
|
||||
onBoostEnd: () {},
|
||||
onLike: () {},
|
||||
onSave: () {},
|
||||
onComments: () {},
|
||||
onShare: () {},
|
||||
onDetail: () {},
|
||||
onOpenFullPlayer: () {},
|
||||
onMore: () {},
|
||||
onSeek: (_) {},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
controller.value = const VideoPlayerValue(
|
||||
duration: Duration(seconds: 100),
|
||||
position: Duration(seconds: 10),
|
||||
isInitialized: true,
|
||||
isBuffering: true,
|
||||
);
|
||||
await tester.pump(const Duration(milliseconds: 200));
|
||||
expect(find.byKey(const Key('home-feed-progress-thumb')), findsOneWidget);
|
||||
expect(find.byKey(const Key('progress-loading')), findsNothing);
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 200));
|
||||
expect(find.byKey(const Key('home-feed-progress-thumb')), findsNothing);
|
||||
expect(find.byKey(const Key('progress-loading')), findsOneWidget);
|
||||
|
||||
controller.value = const VideoPlayerValue(
|
||||
duration: Duration(seconds: 100),
|
||||
position: Duration(seconds: 10),
|
||||
isInitialized: true,
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('home-feed-progress-thumb')), findsOneWidget);
|
||||
|
||||
final gesture = await tester.startGesture(
|
||||
tester.getCenter(find.byKey(const Key('home-feed-progress'))),
|
||||
);
|
||||
await gesture.moveBy(const Offset(60, 0));
|
||||
await tester.pump();
|
||||
controller.value = const VideoPlayerValue(
|
||||
duration: Duration(seconds: 100),
|
||||
position: Duration(seconds: 10),
|
||||
isInitialized: true,
|
||||
isBuffering: true,
|
||||
);
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
|
||||
expect(find.byKey(const Key('home-feed-progress-thumb')), findsOneWidget);
|
||||
expect(find.byKey(const Key('progress-loading')), findsNothing);
|
||||
|
||||
controller.value = const VideoPlayerValue(
|
||||
duration: Duration(seconds: 100),
|
||||
position: Duration(seconds: 10),
|
||||
isInitialized: true,
|
||||
);
|
||||
await tester.pump();
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
|
||||
testWidgets('should_show_refresh_spinner_until_refresh_finishes', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -34,7 +34,9 @@ void main() {
|
||||
expect(find.byType(Slider), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_switch_between_loading_track_and_slider', (tester) async {
|
||||
testWidgets('should_debounce_buffering_before_showing_loading_track', (
|
||||
tester,
|
||||
) async {
|
||||
final video = ValueNotifier<VideoPlayerValue>(
|
||||
const VideoPlayerValue(
|
||||
duration: Duration(seconds: 12),
|
||||
@@ -56,9 +58,17 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byKey(const Key('progress-loading')), findsNothing);
|
||||
expect(find.byType(Slider), findsOneWidget);
|
||||
expect(find.textContaining('00:12'), findsNothing);
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 200));
|
||||
expect(find.byKey(const Key('progress-loading')), findsNothing);
|
||||
expect(find.byType(Slider), findsOneWidget);
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 200));
|
||||
expect(find.byKey(const Key('progress-loading')), findsOneWidget);
|
||||
expect(find.byType(Slider), findsNothing);
|
||||
expect(find.textContaining('00:12'), findsNothing);
|
||||
|
||||
video.value = const VideoPlayerValue(
|
||||
duration: Duration(seconds: 12),
|
||||
@@ -71,6 +81,61 @@ void main() {
|
||||
expect(find.byType(Slider), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_slider_while_scrubbing_during_buffering', (
|
||||
tester,
|
||||
) async {
|
||||
final video = ValueNotifier<VideoPlayerValue>(
|
||||
const VideoPlayerValue(
|
||||
duration: Duration(seconds: 12),
|
||||
position: Duration(seconds: 3),
|
||||
isInitialized: true,
|
||||
),
|
||||
);
|
||||
addTearDown(video.dispose);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 300,
|
||||
child: SeekProgressBar(
|
||||
valueListenable: video,
|
||||
semanticsLabel: 'Seek video',
|
||||
onSeek: (_) async {},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final gesture = await tester.startGesture(
|
||||
tester.getCenter(find.byType(Slider)),
|
||||
);
|
||||
await gesture.moveBy(const Offset(60, 0));
|
||||
await tester.pump();
|
||||
|
||||
video.value = const VideoPlayerValue(
|
||||
duration: Duration(seconds: 12),
|
||||
position: Duration(seconds: 5),
|
||||
isInitialized: true,
|
||||
isBuffering: true,
|
||||
);
|
||||
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: 5),
|
||||
isInitialized: true,
|
||||
);
|
||||
await tester.pump();
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'should_preview_while_dragging_and_seek_on_release_when_slider_is_horizontal',
|
||||
(tester) async {
|
||||
|
||||
Reference in new issue
Block a user