fix(player): 保持清屏并常驻中心按钮
This commit is contained in:
1 parent
bc5feebf39
commit
0d977da75b
2 files changed
+171
-51
No files matched your search
@@ -69,9 +69,7 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('should_show_play_toggle_only_when_playback_is_paused', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('should_keep_center_toggle_in_both_play_states', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
@@ -82,18 +80,51 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('detail-cta')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-video-tap')));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-controls-bottom')), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('player-play-toggle')),
|
||||
)
|
||||
.playing,
|
||||
isTrue,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-play-toggle')));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('player-play-toggle')),
|
||||
)
|
||||
.playing,
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('player-play-toggle')),
|
||||
matching: find.byIcon(Icons.play_arrow_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-play-toggle')));
|
||||
await tester.pump();
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('player-play-toggle')),
|
||||
)
|
||||
.playing,
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('player-play-toggle')),
|
||||
matching: find.byIcon(Icons.pause_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_controls_visible_until_clear_screen_is_tapped', (
|
||||
@@ -111,11 +142,19 @@ void main() {
|
||||
|
||||
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-controls-bottom')), findsOneWidget);
|
||||
expect(find.byType(PlayerCenterToggle), findsNothing);
|
||||
expect(find.byType(PlayerCenterToggle), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-video-tap')));
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump();
|
||||
expect(find.byType(PlayerCenterToggle), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('player-play-toggle')),
|
||||
)
|
||||
.playing,
|
||||
isFalse,
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 5));
|
||||
await tester.pump();
|
||||
@@ -129,7 +168,15 @@ void main() {
|
||||
|
||||
expect(find.byKey(const Key('player-controls-top')), findsNothing);
|
||||
expect(find.byKey(const Key('player-controls-bottom')), findsNothing);
|
||||
expect(find.byType(PlayerCenterToggle), findsNothing);
|
||||
expect(find.byType(PlayerCenterToggle), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('player-play-toggle')),
|
||||
)
|
||||
.playing,
|
||||
isFalse,
|
||||
);
|
||||
expect(find.byKey(const Key('player-video-tap')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-exit-clear-screen')), findsOneWidget);
|
||||
expect(
|
||||
@@ -137,21 +184,45 @@ void main() {
|
||||
const Size(36, 36),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-video-tap')));
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('player-controls-top')), findsNothing);
|
||||
expect(find.byKey(const Key('player-exit-clear-screen')), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('player-play-toggle')),
|
||||
)
|
||||
.playing,
|
||||
isTrue,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-video-tap')));
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('player-controls-top')), findsNothing);
|
||||
expect(find.byKey(const Key('player-exit-clear-screen')), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('player-play-toggle')),
|
||||
)
|
||||
.playing,
|
||||
isFalse,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-exit-clear-screen')));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-controls-bottom')), findsOneWidget);
|
||||
expect(find.byType(PlayerCenterToggle), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('player-play-toggle')),
|
||||
)
|
||||
.playing,
|
||||
isFalse,
|
||||
);
|
||||
expect(find.byKey(const Key('player-exit-clear-screen')), findsNothing);
|
||||
});
|
||||
|
||||
@@ -181,6 +252,15 @@ void main() {
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-info-card')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-scrim')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('home-feed-center-play')),
|
||||
)
|
||||
.playing,
|
||||
isTrue,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-clear-screen')));
|
||||
await tester.pump();
|
||||
@@ -197,6 +277,7 @@ void main() {
|
||||
tester.getSize(find.byKey(const Key('home-feed-exit-clear-screen'))),
|
||||
const Size(36, 36),
|
||||
);
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
expect(
|
||||
find.ancestor(
|
||||
of: find.byKey(const Key('home-feed-exit-clear-screen')),
|
||||
@@ -211,21 +292,37 @@ void main() {
|
||||
greaterThanOrEqualTo(8),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-video-tap')));
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('home-feed-title')), findsNothing);
|
||||
expect(
|
||||
find.byKey(const Key('home-feed-exit-clear-screen')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('home-feed-center-play')),
|
||||
)
|
||||
.playing,
|
||||
isFalse,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-video-tap')));
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('home-feed-title')), findsNothing);
|
||||
expect(
|
||||
find.byKey(const Key('home-feed-exit-clear-screen')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('home-feed-center-play')),
|
||||
)
|
||||
.playing,
|
||||
isTrue,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-exit-clear-screen')));
|
||||
await tester.pump();
|
||||
@@ -234,25 +331,51 @@ void main() {
|
||||
expect(find.byKey(const Key('home-feed-info-card')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-scrim')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-exit-clear-screen')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_show_home_play_toggle_only_when_paused', (tester) async {
|
||||
testWidgets('should_keep_home_center_toggle_in_both_play_states', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
|
||||
await tester.tap(find.byKey(const Key('home-feed-video-toggle')));
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('home-feed-center-play')),
|
||||
)
|
||||
.playing,
|
||||
isTrue,
|
||||
);
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('home-feed-center-play')),
|
||||
)
|
||||
.playing,
|
||||
isFalse,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-center-play')));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('home-feed-center-play')),
|
||||
)
|
||||
.playing,
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_reset_home_chrome_when_swiping_to_next_page', (
|
||||
testWidgets('should_keep_home_clear_state_when_swiping_to_next_page', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
@@ -265,9 +388,13 @@ void main() {
|
||||
await tester.drag(find.byType(PageView), const Offset(0, -550));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-info-card')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-exit-clear-screen')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-info-card')), findsNothing);
|
||||
expect(
|
||||
find.byKey(const Key('home-feed-exit-clear-screen')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -278,7 +405,7 @@ void _expectFullscreenOverlay(WidgetTester tester) {
|
||||
for (final key in const [Key('player-back'), Key('player-more')]) {
|
||||
expect(tester.getSize(find.byKey(key)), const Size(36, 36));
|
||||
}
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-episodes')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-comments')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-next')), findsOneWidget);
|
||||
|
||||
Reference in new issue
Block a user