fix(recommend): 稳定进度拖动与清屏状态
This commit is contained in:
1 parent
76c4f1d411
commit
30b55afdd4
9 files changed
+339
-96
No files matched your search
@@ -23,7 +23,6 @@ import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||
import 'package:fruitshorts/pages/home/home_feed_channel.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/home_feed_header.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/home_feed_overlay.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/scrub_preview_card.dart';
|
||||
import 'package:fruitshorts/pages/player/player_view.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
|
||||
@@ -681,8 +680,12 @@ void main() {
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('home-feed-progress'))).height,
|
||||
greaterThanOrEqualTo(24),
|
||||
greaterThanOrEqualTo(28),
|
||||
);
|
||||
final idleTrackCenter = tester
|
||||
.getRect(find.byKey(const Key('home-feed-progress-track')))
|
||||
.center
|
||||
.dy;
|
||||
expect(
|
||||
tester
|
||||
.getRect(find.byKey(const Key('home-feed-progress-thumb')))
|
||||
@@ -705,7 +708,33 @@ void main() {
|
||||
expect(scrubVisibility.last, isTrue);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsNothing);
|
||||
expect(find.byKey(const Key('rail-save')), findsNothing);
|
||||
expect(find.byType(ScrubPreviewCard), findsOneWidget);
|
||||
expect(find.byKey(const Key('scrub-preview-time-bubble')), findsOneWidget);
|
||||
final bubbleRect = tester.getRect(
|
||||
find.byKey(const Key('scrub-preview-time-bubble')),
|
||||
);
|
||||
expect(bubbleRect.left, greaterThanOrEqualTo(12));
|
||||
expect(
|
||||
bubbleRect.right,
|
||||
lessThanOrEqualTo(
|
||||
tester.getRect(find.byKey(const Key('home-feed-gesture'))).right - 12,
|
||||
),
|
||||
);
|
||||
await gesture.moveBy(const Offset(-600, 0));
|
||||
await tester.pump();
|
||||
expect(
|
||||
tester.getRect(find.byKey(const Key('scrub-preview-time-bubble'))).left,
|
||||
closeTo(12, 0.1),
|
||||
);
|
||||
await gesture.moveBy(const Offset(1200, 0));
|
||||
await tester.pump();
|
||||
expect(
|
||||
tester.getRect(find.byKey(const Key('scrub-preview-time-bubble'))).right,
|
||||
closeTo(
|
||||
tester.getRect(find.byKey(const Key('home-feed-gesture'))).right - 12,
|
||||
0.1,
|
||||
),
|
||||
);
|
||||
await tester.pump(const Duration(milliseconds: 130));
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('home-feed-progress-thumb'))),
|
||||
const Size(14, 14),
|
||||
@@ -714,6 +743,13 @@ void main() {
|
||||
tester.getSize(find.byKey(const Key('home-feed-progress-track'))).height,
|
||||
6,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.getRect(find.byKey(const Key('home-feed-progress-track')))
|
||||
.center
|
||||
.dy,
|
||||
closeTo(idleTrackCenter, 0.1),
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.getRect(find.byKey(const Key('home-feed-progress-thumb')))
|
||||
@@ -729,8 +765,8 @@ void main() {
|
||||
);
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(scrubVisibility.last, isFalse);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
expect(scrubVisibility.last, isTrue);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsNothing);
|
||||
expect(seeked, isNotNull);
|
||||
expect(seeked!.inSeconds, greaterThan(0));
|
||||
expect(
|
||||
@@ -742,6 +778,11 @@ void main() {
|
||||
2,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-gesture')));
|
||||
await tester.pump();
|
||||
expect(scrubVisibility.last, isFalse);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-full-series')));
|
||||
await tester.pump();
|
||||
expect(opened, 1);
|
||||
|
||||
@@ -35,6 +35,7 @@ void main() {
|
||||
expect(find.byKey(const Key('recommend-tab-playlist')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-tab-all')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-feed-player')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-top-gradient')), findsOneWidget);
|
||||
final recommendText = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('recommend-tab-recommend')),
|
||||
@@ -93,6 +94,21 @@ void main() {
|
||||
expect(find.byType(PageView), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-section-hits')), findsNothing);
|
||||
expect(find.byType(AppBottomNav), findsOneWidget);
|
||||
|
||||
final progress = find.byKey(const Key('home-feed-progress'));
|
||||
final progressCenterY = tester.getCenter(progress).dy;
|
||||
final scrub = await tester.startGesture(tester.getCenter(progress));
|
||||
await scrub.moveBy(const Offset(40, 0));
|
||||
await tester.pump(const Duration(milliseconds: 130));
|
||||
expect(find.byKey(const Key('recommend-top-nav')), findsOneWidget);
|
||||
expect(tester.getCenter(progress).dy, closeTo(progressCenterY, 0.1));
|
||||
await scrub.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('recommend-top-nav')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('recommend-tab-playlist')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('recommend-section-hits')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_render_playlist_sections_and_horizontal_cards', (
|
||||
|
||||
Reference in new issue
Block a user