refactor(navigation): 移除全局两侧悬浮元素
This commit is contained in:
1 parent
5cead7ce00
commit
9cf832b318
8 files changed
+103
-217
No files matched your search
@@ -71,6 +71,8 @@ void main() {
|
||||
expect(find.text('Charts'), findsOneWidget);
|
||||
expect(find.text('Costume'), findsOneWidget);
|
||||
expect(find.text('Community'), findsOneWidget);
|
||||
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_hide_unmatched_content_sections', (tester) async {
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/app.dart';
|
||||
import 'package:fruitshorts/core/data/models/wallet.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/commerce_repository.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';
|
||||
@@ -46,6 +48,10 @@ void main() {
|
||||
for (final key in _keys) {
|
||||
expect(find.byKey(key), findsOneWidget);
|
||||
}
|
||||
expect(find.byKey(const Key('home-wallet-entry')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-wallet-badge')), findsOneWidget);
|
||||
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
for (final key in _keys.skip(1)) {
|
||||
expect(tester.getSize(find.byKey(key)).height, greaterThanOrEqualTo(48));
|
||||
}
|
||||
@@ -214,6 +220,7 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('recommend-page')), findsOneWidget);
|
||||
_expectNoFloatingOverlays();
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -226,6 +233,7 @@ void main() {
|
||||
findsNothing,
|
||||
);
|
||||
expect(Navigator.canPop(tester.element(favorites)), isFalse);
|
||||
_expectNoFloatingOverlays();
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-follow')),
|
||||
@@ -241,6 +249,7 @@ void main() {
|
||||
expect(find.byKey(const Key('mine-wallet')), findsOneWidget);
|
||||
expect(find.byKey(const Key('mine-edit')), findsOneWidget);
|
||||
expect(find.byKey(const Key('mine-library-tab-0')), findsNothing);
|
||||
_expectNoFloatingOverlays();
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-follow')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -287,6 +296,7 @@ Future<void> _pumpApp(WidgetTester tester, [FakeHaptics? haptics]) async {
|
||||
playbackRepository: FakePlaybackRepository(),
|
||||
commentRepository: FakeCommentRepository(),
|
||||
interactionRepository: FakeInteractionRepository(),
|
||||
commerceRepository: const _WalletCommerceRepository(),
|
||||
haptics: haptics ?? FakeHaptics(),
|
||||
),
|
||||
);
|
||||
@@ -294,3 +304,34 @@ Future<void> _pumpApp(WidgetTester tester, [FakeHaptics? haptics]) async {
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
class _WalletCommerceRepository implements CommerceRepository {
|
||||
const _WalletCommerceRepository();
|
||||
|
||||
@override
|
||||
Future<WalletSnapshot> fetchWallet() async {
|
||||
return const WalletSnapshot(
|
||||
wallet: CoinWallet(
|
||||
coinBalance: 320,
|
||||
totalRechargedCoin: 500,
|
||||
totalConsumedCoin: 180,
|
||||
totalRefundedCoin: 0,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<UnlockResult> unlock(String episodeId) async {
|
||||
return const UnlockResult(
|
||||
unlocked: true,
|
||||
accessType: 'UNLOCKED',
|
||||
coinCost: 0,
|
||||
coinBalance: 320,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _expectNoFloatingOverlays() {
|
||||
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
}
|
||||
@@ -82,12 +82,14 @@ 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);
|
||||
_expectNoFloatingOverlays();
|
||||
|
||||
await tester.tap(find.byKey(const Key('recommend-tab-playlist')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('recommend-section-hits')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-section-new')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-section-costume')), findsOneWidget);
|
||||
_expectNoFloatingOverlays();
|
||||
});
|
||||
|
||||
testWidgets('should_switch_playlist_and_all_dramas_in_recommend', (
|
||||
@@ -101,6 +103,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('recommend-section-hits')), findsOneWidget);
|
||||
expect(find.byType(AppBottomNav), findsOneWidget);
|
||||
_expectNoFloatingOverlays();
|
||||
|
||||
await tester.tap(find.byKey(const Key('recommend-tab-all')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -108,6 +111,7 @@ void main() {
|
||||
for (var row = 0; row < 4; row++) {
|
||||
expect(find.byKey(Key('all-filter-row-$row')), findsOneWidget);
|
||||
}
|
||||
_expectNoFloatingOverlays();
|
||||
});
|
||||
|
||||
testWidgets('should_open_search_from_home_and_recommend', (tester) async {
|
||||
@@ -159,6 +163,11 @@ const _tabKeys = [
|
||||
Key('tab-mine'),
|
||||
];
|
||||
|
||||
void _expectNoFloatingOverlays() {
|
||||
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
}
|
||||
|
||||
bool _hasLightStatusBar(WidgetTester tester) => tester
|
||||
.widgetList<AnnotatedRegion<SystemUiOverlayStyle>>(
|
||||
find.byType(AnnotatedRegion<SystemUiOverlayStyle>),
|
||||
|
||||
Reference in new issue
Block a user