test(ui): 更新主题导航与布局断言

This commit is contained in:
Zhou Weidong committed 2026-10-26 22:49:23 +08:00
1 parent 2d65cd3006
commit 6512808506
6 files changed
+52 -47

No files matched your search

+2 -3
View File
@@ -14,7 +14,6 @@ import 'package:fruitshorts/core/data/services/auth_session_store.dart';
import 'package:fruitshorts/core/platform/haptics.dart';
import 'package:fruitshorts/core/theme/app_colors.dart';
import 'package:fruitshorts/core/theme/app_dimens.dart';
import 'package:fruitshorts/core/theme/app_theme.dart';
import 'package:fruitshorts/l10n/app_localizations.dart';
import 'package:fruitshorts/pages/auth/auth_view.dart';
@@ -136,7 +135,7 @@ void main() {
cardDecoration.borderRadius,
BorderRadius.circular(AppDimens.authCardRadius),
);
expect(cardDecoration.boxShadow, contains(AppTheme.cardShadow));
expect(cardDecoration.boxShadow, isNull);
expect(card.padding, const EdgeInsets.all(20));
final email = tester.widget<TextField>(
@@ -222,7 +221,7 @@ void main() {
find.descendant(of: back, matching: find.byType(Material)),
)
.color,
AppColors.card,
AppColors.transparent,
);
});
+1 -1
View File
@@ -10,7 +10,7 @@ void main() {
test('should_use_exact_root_navigation_colors', () {
expect(AppColors.navBackground, const Color(0xFF000000));
expect(AppColors.navSelected, const Color(0xFFFFFFFF));
expect(AppColors.navUnselected, const Color(0xFF8E8E93));
expect(AppColors.navUnselected, const Color(0xFFB0B0B0));
});
testWidgets('should_render_four_slots_with_white_selected_state', (
+10 -2
View File
@@ -82,7 +82,13 @@ void main() {
expect(viewsText.style?.fontSize, AppDimens.cardPlayCountFont);
expect(viewsText.style?.fontWeight, FontWeight.w400);
expect(viewsText.style?.color, AppColors.navSelected);
expect(find.descendant(of: cover, matching: views), findsOneWidget);
expect(
find.descendant(
of: find.byKey(const Key('home-feed-cover-clip-anime-card')),
matching: views,
),
findsOneWidget,
);
expect(
tester.getTopRight(cover).dx - tester.getTopRight(views).dx,
AppDimens.cardPlayCountRight,
@@ -201,7 +207,9 @@ Future<void> _pumpCard(
body: Center(
child: SizedBox(
width: 130,
height: 240,
height:
130 / AppDimens.cardCoverAspectRatio +
AppDimens.homeCardBodyExtent,
child: HomeFeedCard(
drama: drama,
onTap: onTap,
+6 -16
View File
@@ -98,22 +98,12 @@ void main() {
tester.getTopRight(walletEntry).dx,
closeTo(390 - AppDimens.feedPageHorizontal, 0.1),
);
final crown = tester.widget<Icon>(
find.descendant(
of: vipEntry,
matching: find.byIcon(Icons.workspace_premium_outlined),
),
);
final gift = tester.widget<Icon>(
find.descendant(
of: walletEntry,
matching: find.byIcon(Icons.card_giftcard_rounded),
),
);
expect(crown.size, AppDimens.homeActionIcon);
expect(crown.color, AppColors.homeCrownGold);
expect(gift.size, AppDimens.homeActionIcon);
expect(gift.color, AppColors.homeGiftPink);
expect(crownImage.width, AppDimens.homeActionIcon);
expect(crownImage.height, AppDimens.homeActionIcon);
expect(crownImage.fit, BoxFit.contain);
expect(giftImage.width, AppDimens.homeActionIcon);
expect(giftImage.height, AppDimens.homeActionIcon);
expect(giftImage.fit, BoxFit.contain);
expect(
tester
.widget<Material>(
+17 -23
View File
@@ -305,7 +305,7 @@ void main() {
find.byKey(const Key('home-feed-episode-progress')),
);
expect(episodeProgress.maxLines, 1);
expect(episodeProgress.softWrap, isFalse);
expect(episodeProgress.overflow, TextOverflow.ellipsis);
expect(episodeProgress.style?.fontSize, 13);
expect(episodeProgress.style?.color, AppColors.overlayLabel);
expect(
@@ -646,13 +646,14 @@ void main() {
.ignoring,
isTrue,
);
expect(find.byKey(const Key('scrub-preview-time-bubble')), findsOneWidget);
final bubbleRect = tester.getRect(
find.byKey(const Key('scrub-preview-time-bubble')),
expect(find.byKey(const Key('scrub-preview-card')), findsOneWidget);
expect(find.byKey(const Key('scrub-preview-time')), findsOneWidget);
final previewRect = tester.getRect(
find.byKey(const Key('scrub-preview-card')),
);
expect(bubbleRect.left, greaterThanOrEqualTo(12));
expect(previewRect.left, greaterThanOrEqualTo(12));
expect(
bubbleRect.right,
previewRect.right,
lessThanOrEqualTo(
tester.getRect(find.byKey(const Key('home-feed-gesture'))).right - 12,
),
@@ -662,33 +663,26 @@ void main() {
.getRect(find.byKey(const Key('home-feed-progress-track')))
.center
.dy -
bubbleRect.bottom,
previewRect.bottom,
closeTo(16, 0.1),
);
final bubbleContainer = tester.widget<Container>(
find.descendant(
of: find.byKey(const Key('scrub-preview-time-bubble')),
matching: find.byType(Container),
),
);
expect(
(bubbleContainer.decoration! as BoxDecoration).color,
AppColors.timeBubbleScrim,
);
expect(
bubbleContainer.padding,
const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
final previewContainer = tester.widget<Container>(
find.byKey(const Key('scrub-preview-card')),
);
final previewDecoration = previewContainer.decoration! as BoxDecoration;
expect(previewDecoration.color, AppColors.card);
expect(previewDecoration.borderRadius, BorderRadius.circular(8));
expect((previewDecoration.border! as Border).top.color, AppColors.onPrimary);
await gesture.moveBy(const Offset(-600, 0));
await tester.pump();
expect(
tester.getRect(find.byKey(const Key('scrub-preview-time-bubble'))).left,
tester.getRect(find.byKey(const Key('scrub-preview-card'))).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,
tester.getRect(find.byKey(const Key('scrub-preview-card'))).right,
closeTo(
tester.getRect(find.byKey(const Key('home-feed-gesture'))).right - 12,
0.1,
@@ -980,7 +974,7 @@ void main() {
await tester.pump();
expect(find.byKey(const Key('scrub-preview-card')), findsOneWidget);
expect(find.byKey(const Key('scrub-preview-poster')), findsOneWidget);
expect(find.byKey(const Key('scrub-preview-background')), findsOneWidget);
expect(find.textContaining('/ 01:40'), findsOneWidget);
await gesture.up();
+16 -2
View File
@@ -8,6 +8,7 @@ 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/core/widgets/app_bottom_nav.dart';
import 'package:fruitshorts/pages/home/widgets/home_feed_grid.dart';
import 'package:fruitshorts/pages/player/player_view.dart';
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
@@ -45,7 +46,7 @@ void main() {
expect(find.byKey(const Key('home-grid')), findsOneWidget);
expect(find.byKey(const Key('home-grid-cards')), findsOneWidget);
expect(find.byType(PageView), findsNothing);
expect(find.byKey(const Key('home-primary-page-view')), findsOneWidget);
expect(find.byKey(const Key('home-page-gradient')), findsNothing);
expect(_hasLightStatusBar(tester), isTrue);
});
@@ -158,7 +159,20 @@ void main() {
testWidgets('should_open_player_from_home_grid_card', (tester) async {
await _pumpApp(tester);
await tester.tap(find.byKey(const Key('home-feed-card-the-signal-demo')));
final grid = tester.widget<HomeFeedGrid>(find.byType(HomeFeedGrid));
expect(grid.feedController.dramas, isNotEmpty);
final card = find.byKey(
const Key('home-feed-card-city-lights-demo'),
);
for (var attempt = 0; attempt < 10; attempt++) {
if (card.evaluate().isNotEmpty) break;
await tester.drag(
find.byKey(const Key('home-grid-scroll')),
const Offset(0, -240),
);
await tester.pump();
}
await tester.tap(card);
await tester.pumpAndSettle();
final player = tester.widget<PlayerPage>(find.byType(PlayerPage).last);