feat(flutter): 重构四 Tab 与浏览页
This commit is contained in:
1 parent
99c72e2c32
commit
959edc0a32
41 files changed
+2148
-1179
No files matched your search
@@ -7,6 +7,7 @@ import 'package:shared_preferences_platform_interface/shared_preferences_async_p
|
||||
|
||||
import 'package:fruitshorts/app.dart';
|
||||
import 'package:fruitshorts/core/data/models/drama.dart';
|
||||
import 'package:fruitshorts/core/data/models/home_feed.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';
|
||||
@@ -22,7 +23,7 @@ import '../support/fake_notice_repository.dart';
|
||||
import '../support/widget_player.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('should_render_preview_home_card_without_hot_or_follow_avatar', (
|
||||
testWidgets('should_render_browse_home_with_header_channels_and_cards', (
|
||||
tester,
|
||||
) async {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
@@ -32,7 +33,16 @@ void main() {
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
final catalog = FakeCatalogRepository();
|
||||
final catalog = FakeCatalogRepository(
|
||||
banners: const [
|
||||
FeedBanner(
|
||||
id: 'banner-1',
|
||||
imageUrl: '/files/banner.jpg',
|
||||
linkType: 'DRAMA',
|
||||
linkValue: 'the-signal-demo',
|
||||
),
|
||||
],
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
LumaDramaApp(
|
||||
playerFactory: createWidgetPlayer,
|
||||
@@ -51,40 +61,18 @@ void main() {
|
||||
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-episode')), findsOneWidget);
|
||||
final cardRect = tester.getRect(
|
||||
find.byKey(const Key('home-feed-info-card')),
|
||||
);
|
||||
final episodeRect = tester.getRect(
|
||||
find.byKey(const Key('home-feed-episode')),
|
||||
);
|
||||
expect(episodeRect.left, lessThan(cardRect.center.dx));
|
||||
final railCenter = tester.getCenter(find.byKey(const Key('rail-like')));
|
||||
final railBottom = tester.getBottomLeft(find.byKey(const Key('rail-save')));
|
||||
expect(railCenter.dy, greaterThan(844 * 0.4));
|
||||
expect(railBottom.dy, lessThan(cardRect.top));
|
||||
expect(find.byKey(const Key('home-feed-follow-series')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-feed-episodes')), findsOneWidget);
|
||||
for (final key in const [Key('home-feed-search'), Key('home-feed-more')]) {
|
||||
expect(tester.getSize(find.byKey(key)), const Size(36, 36));
|
||||
expect(
|
||||
tester
|
||||
.widget<Icon>(
|
||||
find.descendant(of: find.byKey(key), matching: find.byType(Icon)),
|
||||
)
|
||||
.size,
|
||||
18,
|
||||
);
|
||||
expect(find.byKey(const Key('home-search')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-profile')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-weekday')), findsOneWidget);
|
||||
for (final channel in ['hot', 'free', 'newReleases', 'ranking']) {
|
||||
expect(find.byKey(Key('home-channel-$channel')), findsOneWidget);
|
||||
}
|
||||
expect(find.byKey(const Key('home-hero-banner')), findsOneWidget);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('home-feed-follow-series'))).height,
|
||||
34,
|
||||
find.byKey(const Key('home-drama-card-the-signal-demo')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('HOT'), findsNothing);
|
||||
expect(find.textContaining('Season'), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-follow')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-info-card')), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user