feat(flutter): 播放页长按手势与加速态
This commit is contained in:
1 parent
7bb2714941
commit
96074bc5e8
11 files changed
+231
-4
No files matched your search
@@ -152,6 +152,102 @@ void main() {
|
||||
expect(find.byTooltip('Clear screen'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_open_more_sheet_on_center_long_press', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await _openSeriesPlayer(tester);
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||
|
||||
final gesture = await tester.startGesture(const Offset(195, 300));
|
||||
await tester.pump(const Duration(milliseconds: 700));
|
||||
await tester.pump();
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('player-more-sheet')), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('player-more-close')));
|
||||
await tester.pumpAndSettle();
|
||||
// 长按弹更多不改播放状态,仍处于播放中。
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('should_boost_speed_on_side_long_press_and_restore', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
await _openSeriesPlayer(tester);
|
||||
expect(find.byKey(const Key('player-interaction-rail')), findsOneWidget);
|
||||
|
||||
final gesture = await tester.startGesture(const Offset(60, 300));
|
||||
await tester.pump(const Duration(milliseconds: 700));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byKey(const Key('player-speed-boost-hint')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-progress')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-interaction-rail')), findsNothing);
|
||||
expect(find.byKey(const Key('player-controls-bottom')), findsNothing);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('player-speed-entry')),
|
||||
matching: find.text('2.0x'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
// 加速与清屏都不改变播放状态。
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('player-speed-boost-hint')), findsNothing);
|
||||
expect(find.byKey(const Key('player-interaction-rail')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-controls-bottom')), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('player-speed-entry')),
|
||||
matching: find.text('1.0x'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||
|
||||
// 右侧 1/3 同样触发加速。
|
||||
final rightSide = await tester.startGesture(const Offset(330, 300));
|
||||
await tester.pump(const Duration(milliseconds: 700));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('player-speed-boost-hint')), findsOneWidget);
|
||||
await rightSide.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('player-speed-boost-hint')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_previous_clear_state_after_boost', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await _openSeriesPlayer(tester);
|
||||
await tester.tap(find.byKey(const Key('player-bottom-clear-screen')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('player-interaction-rail')), findsNothing);
|
||||
|
||||
final gesture = await tester.startGesture(const Offset(60, 300));
|
||||
await tester.pump(const Duration(milliseconds: 700));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('player-speed-boost-hint')), findsOneWidget);
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// 本来已清屏,松手后仍保持清屏,只恢复倍速与提示。
|
||||
expect(find.byKey(const Key('player-speed-boost-hint')), findsNothing);
|
||||
expect(find.byKey(const Key('player-interaction-rail')), findsNothing);
|
||||
expect(find.byTooltip('Exit clear screen'), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('player-speed-entry')),
|
||||
matching: find.text('1.0x'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_fit_player_header_on_320_width', (tester) async {
|
||||
await _pumpApp(tester, size: const Size(320, 568));
|
||||
await _openSeriesPlayer(tester);
|
||||
|
||||
Reference in new issue
Block a user