fix(player): 恢复独立播放页双击点赞
This commit is contained in:
1 parent
b291044acc
commit
63296d2a92
8 files changed
+348
-145
No files matched your search
@@ -12,8 +12,8 @@ import '../support/fake_haptics.dart';
|
||||
import '../support/fake_interaction_repositories.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('double tap within 400ms never pauses', (tester) async {
|
||||
for (final delay in [120, 250, 300, 380]) {
|
||||
testWidgets('double tap within 320ms never pauses', (tester) async {
|
||||
for (final delay in [120, 250, 300]) {
|
||||
final repository = FakeInteractionRepository();
|
||||
final haptics = FakeHaptics();
|
||||
final key = GlobalKey<_HarnessState>();
|
||||
@@ -74,6 +74,39 @@ void main() {
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
expect(key.currentState!.pauseToggles, 2);
|
||||
});
|
||||
|
||||
testWidgets('liked episode keeps heart feedback without liking again', (
|
||||
tester,
|
||||
) async {
|
||||
final repository = FakeInteractionRepository();
|
||||
final haptics = FakeHaptics();
|
||||
final key = GlobalKey<_HarnessState>();
|
||||
final clock = _TestClock();
|
||||
await _pumpHarness(tester, repository, haptics, key, clock);
|
||||
final center = tester.getCenter(find.byKey(const Key('home-feed-gesture')));
|
||||
|
||||
await tester.tapAt(center);
|
||||
clock.advance(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.tapAt(center);
|
||||
await tester.pump();
|
||||
expect(repository.likeTargets, hasLength(1));
|
||||
await tester.pump(const Duration(milliseconds: 800));
|
||||
|
||||
clock.advance(const Duration(milliseconds: 500));
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
await tester.tapAt(center);
|
||||
clock.advance(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.tapAt(center);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
expect(repository.likeTargets, hasLength(1));
|
||||
expect(haptics.lightImpacts, 2);
|
||||
expect(key.currentState!.pauseToggles, 0);
|
||||
expect(find.byKey(const Key('double-tap-heart-0')), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _pumpHarness(
|
||||
|
||||
@@ -364,7 +364,7 @@ void main() {
|
||||
// IgnorePointer 让加载中的播放暂停与上下滑穿透,滑动会关闭入口 loading。
|
||||
expect(fullLogic.session.userWantsPlay, isTrue);
|
||||
await tester.tap(find.byKey(const Key('player-video-tap')).hitTestable());
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 350));
|
||||
expect(fullLogic.session.userWantsPlay, isFalse);
|
||||
final indexBeforeSwipe = fullLogic.session.currentIndex;
|
||||
await tester.drag(fullPlayerPage, const Offset(0, -560));
|
||||
@@ -632,7 +632,7 @@ void main() {
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 350));
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
@@ -655,6 +655,82 @@ void main() {
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_double_tap_like_once_without_pausing_full_player', (
|
||||
tester,
|
||||
) async {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.withData({
|
||||
'auth.accessToken': 'test-access',
|
||||
'auth.refreshToken': 'test-refresh',
|
||||
'auth.user': '{"uid":"9","nickname":"Me","avatarUrl":""}',
|
||||
});
|
||||
final interactions = FakeInteractionRepository(
|
||||
nextLikeResult: const LikeToggleResult(liked: true, count: 23000),
|
||||
);
|
||||
await _pumpApp(tester, interactions: interactions);
|
||||
await _openSeriesPlayer(tester);
|
||||
|
||||
final logic = _pageLogic(tester, find.byType(PlayerPage).last);
|
||||
final gesture = find.byKey(const Key('player-video-tap')).hitTestable();
|
||||
final position = tester.getCenter(gesture);
|
||||
expect(logic.session.userWantsPlay, isTrue);
|
||||
|
||||
for (var index = 0; index < 4; index++) {
|
||||
await tester.tapAt(position);
|
||||
}
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
expect(logic.session.userWantsPlay, isTrue);
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||
expect(interactions.likeTargets, ['EPISODE:city-lights-demo-1']);
|
||||
for (var index = 0; index < 3; index++) {
|
||||
expect(find.byKey(Key('double-tap-heart-$index')), findsOneWidget);
|
||||
}
|
||||
expect(
|
||||
tester
|
||||
.widget<Image>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('player-rail-like')),
|
||||
matching: find.byType(Image),
|
||||
),
|
||||
)
|
||||
.color,
|
||||
AppColors.doubleTapHeartRed,
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 800));
|
||||
expect(find.byKey(const Key('double-tap-heart-0')), findsNothing);
|
||||
expect(logic.session.userWantsPlay, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('should_double_tap_like_in_clear_screen', (tester) async {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.withData({
|
||||
'auth.accessToken': 'test-access',
|
||||
'auth.refreshToken': 'test-refresh',
|
||||
'auth.user': '{"uid":"9","nickname":"Me","avatarUrl":""}',
|
||||
});
|
||||
final interactions = FakeInteractionRepository();
|
||||
await _pumpApp(tester, interactions: interactions);
|
||||
await _openSeriesPlayer(tester);
|
||||
final logic = _pageLogic(tester, find.byType(PlayerPage).last);
|
||||
|
||||
await _clearFromMore(tester);
|
||||
expect(find.byKey(const Key('player-controls-bottom')), findsNothing);
|
||||
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
expect(logic.session.userWantsPlay, isTrue);
|
||||
expect(interactions.likeTargets, hasLength(1));
|
||||
expect(find.byKey(const Key('double-tap-heart-0')), findsOneWidget);
|
||||
expect(find.byKey(const Key('double-tap-heart-1')), findsOneWidget);
|
||||
expect(find.byKey(const Key('double-tap-heart-2')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_controls_visible_until_clear_screen_is_tapped', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -666,7 +742,7 @@ void main() {
|
||||
expect(find.byType(PlayerCenterToggle), findsNothing);
|
||||
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 350));
|
||||
expect(find.byType(PlayerCenterToggle), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
@@ -710,13 +786,13 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 350));
|
||||
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-bottom-actions')), findsOneWidget);
|
||||
expect(find.byType(PlayerCenterToggle), findsNothing);
|
||||
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 350));
|
||||
expect(find.byType(PlayerCenterToggle), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-bottom-clear-screen')));
|
||||
@@ -1649,8 +1725,10 @@ void main() {
|
||||
testWidgets('should_open_unlock_panel_with_honest_method_states', (
|
||||
tester,
|
||||
) async {
|
||||
final interactions = FakeInteractionRepository();
|
||||
await _pumpApp(
|
||||
tester,
|
||||
interactions: interactions,
|
||||
playback: FakePlaybackRepository(
|
||||
ticket: const PlayTicket(
|
||||
episodeId: 'city-lights-demo-1',
|
||||
@@ -1663,6 +1741,12 @@ void main() {
|
||||
await _openSeriesPlayer(tester);
|
||||
|
||||
expect(find.byKey(const Key('player-unlock-notice')), findsOneWidget);
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump(const Duration(milliseconds: 350));
|
||||
expect(find.byKey(const Key('double-tap-heart-0')), findsNothing);
|
||||
expect(interactions.likeTargets, isEmpty);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-open-unlock')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
|
||||
Reference in new issue
Block a user