fix(player): 改为显式清屏交互
This commit is contained in:
1 parent
f4e1a5424e
commit
f613033088
12 files changed
+158
-166
No files matched your search
@@ -101,6 +101,7 @@ void main() {
|
||||
onShare: () {},
|
||||
onEpisodes: () {},
|
||||
onDownload: () {},
|
||||
onClear: () {},
|
||||
onSearch: () {},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -5,16 +5,14 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/player_center_toggle.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('should_use_one_shared_52px_style_for_home_and_player', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('should_use_one_shared_52px_center_toggle_style', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Row(
|
||||
children: [
|
||||
PlayerCenterToggle(
|
||||
key: const Key('home-feed-center-play'),
|
||||
key: const Key('test-center-toggle-a'),
|
||||
playing: false,
|
||||
onTap: () {},
|
||||
),
|
||||
@@ -30,7 +28,7 @@ void main() {
|
||||
);
|
||||
|
||||
for (final key in const [
|
||||
Key('home-feed-center-play'),
|
||||
Key('test-center-toggle-a'),
|
||||
Key('player-play-toggle'),
|
||||
]) {
|
||||
expect(tester.getSize(find.byKey(key)), const Size(52, 52));
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:fruitshorts/app.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/favorite_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/playback_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart';
|
||||
import 'package:fruitshorts/pages/player/player_view.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/player_center_toggle.dart';
|
||||
|
||||
import '../support/fake_catalog.dart';
|
||||
@@ -70,7 +69,7 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_single_pause_toggle_when_detail_player_is_paused', (
|
||||
testWidgets('should_hide_pause_toggle_when_playback_is_paused', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
@@ -86,12 +85,16 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('player-play-toggle')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-controls-bottom')), findsOneWidget);
|
||||
|
||||
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('home-feed-center-play')), findsNothing);
|
||||
expect(find.byIcon(Icons.play_arrow_rounded), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_hide_controls_after_2_5s_and_reveal_on_video_tap', (
|
||||
testWidgets('should_keep_controls_visible_until_clear_screen_is_tapped', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
@@ -108,7 +111,14 @@ void main() {
|
||||
expect(find.byKey(const Key('player-controls-bottom')), findsOneWidget);
|
||||
expect(find.byType(PlayerCenterToggle), findsOneWidget);
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 2600));
|
||||
await tester.pump(const Duration(seconds: 5));
|
||||
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);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-clear-screen')));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byKey(const Key('player-controls-top')), findsNothing);
|
||||
@@ -124,39 +134,6 @@ void main() {
|
||||
expect(find.byType(PlayerCenterToggle), findsOneWidget);
|
||||
});
|
||||
|
||||
test('should_only_show_feed_pause_indicator_in_home_mode', () {
|
||||
expect(
|
||||
shouldShowFeedPauseIndicator(
|
||||
homeMode: true,
|
||||
selected: true,
|
||||
ready: true,
|
||||
playing: false,
|
||||
pip: false,
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
shouldShowFeedPauseIndicator(
|
||||
homeMode: false,
|
||||
selected: true,
|
||||
ready: true,
|
||||
playing: false,
|
||||
pip: false,
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
shouldShowFeedPauseIndicator(
|
||||
homeMode: true,
|
||||
selected: true,
|
||||
ready: true,
|
||||
playing: true,
|
||||
pip: false,
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_fit_player_header_on_320_width', (tester) async {
|
||||
await _pumpApp(tester, size: const Size(320, 568));
|
||||
await tester.binding.handlePopRoute();
|
||||
@@ -174,6 +151,31 @@ void main() {
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('should_clear_and_restore_home_feed_chrome', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
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-scrim')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-clear-screen')));
|
||||
await tester.pump();
|
||||
|
||||
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-scrim')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-video-tap')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-video-tap')));
|
||||
await tester.pump();
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
void _expectFullscreenOverlay(WidgetTester tester) {
|
||||
|
||||
Reference in new issue
Block a user