fix(flutter): 更多面板增加小窗播放入口

This commit is contained in:
Zhou Weidong committed 2026-10-20 11:47:58 +08:00
1 parent 3b2bdb8e5a
commit 0af5de9641
4 files changed
+115 -1

No files matched your search

+24 -1
View File
@@ -389,7 +389,6 @@ void main() {
Key('player-more-text-size'),
Key('player-more-cast'),
Key('player-more-timer'),
Key('player-more-pip'),
Key('player-more-report'),
]) {
expect(find.byKey(removed), findsNothing);
@@ -506,6 +505,30 @@ void main() {
expect(find.text('720P · Unavailable'), findsOneWidget);
});
testWidgets('should_show_pip_action_when_platform_supported', (tester) async {
await _pumpApp(tester);
await _openSeriesPlayer(tester);
await tester.tap(find.byKey(const Key('player-more')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('player-more-pip')), findsOneWidget);
expect(find.byKey(const Key('player-more-clear')), findsOneWidget);
expect(find.byKey(const Key('player-more-offline')), findsOneWidget);
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgets('should_hide_pip_action_when_platform_unsupported', (
tester,
) async {
await _pumpApp(tester);
await _openSeriesPlayer(tester);
await tester.tap(find.byKey(const Key('player-more')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('player-more-pip')), findsNothing);
expect(find.byKey(const Key('player-more-clear')), findsOneWidget);
expect(find.byKey(const Key('player-more-offline')), findsOneWidget);
}, variant: TargetPlatformVariant.only(TargetPlatform.macOS));
testWidgets('should_enter_clear_screen_from_more_panel', (tester) async {
await _pumpApp(tester);
await _openSeriesPlayer(tester);
+77
View File
@@ -0,0 +1,77 @@
// Author: fruit.com.cn
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fruitshorts/l10n/app_localizations.dart';
import 'package:fruitshorts/pages/player/widgets/player_more_sheet.dart';
void main() {
testWidgets('should_hide_pip_row_when_platform_unsupported', (tester) async {
await _openSheet(tester);
expect(find.byKey(const Key('player-more-sheet')), findsOneWidget);
expect(find.byKey(const Key('player-more-clear')), findsOneWidget);
expect(find.byKey(const Key('player-more-offline')), findsOneWidget);
expect(find.byKey(const Key('player-more-pip')), findsNothing);
});
testWidgets('should_trigger_pip_and_close_sheet_when_tapped', (tester) async {
var pipCalls = 0;
await _openSheet(tester, onPip: () => pipCalls++);
expect(find.byKey(const Key('player-more-pip')), findsOneWidget);
expect(
tester.getTopLeft(find.byKey(const Key('player-more-clear'))).dy <
tester.getTopLeft(find.byKey(const Key('player-more-pip'))).dy,
isTrue,
);
expect(
tester.getTopLeft(find.byKey(const Key('player-more-pip'))).dy <
tester.getTopLeft(find.byKey(const Key('player-more-offline'))).dy,
isTrue,
);
await tester.tap(find.byKey(const Key('player-more-pip')));
await tester.pumpAndSettle();
expect(pipCalls, 1);
expect(find.byKey(const Key('player-more-sheet')), findsNothing);
});
}
Future<void> _openSheet(WidgetTester tester, {VoidCallback? onPip}) async {
await tester.pumpWidget(
MaterialApp(
supportedLocales: AppLocalizations.supportedLocales,
localizationsDelegates: AppLocalizations.localizationsDelegates,
home: Scaffold(
body: Builder(
builder: (context) => Center(
child: TextButton(
key: const Key('open-more-sheet'),
onPressed: () => showModalBottomSheet<void>(
context: context,
backgroundColor: Colors.transparent,
isScrollControlled: true,
builder: (_) => PlayerMoreSheet(
l10n: AppLocalizations.of(context)!,
state: const PlayerMoreState(speed: 1.0, qualities: ['AUTO']),
actions: PlayerMoreActions(
onSpeedChanged: (_) {},
onClear: () {},
onDownload: () {},
onPip: onPip,
),
),
),
child: const Text('open'),
),
),
),
),
),
);
await tester.tap(find.byKey(const Key('open-more-sheet')));
await tester.pumpAndSettle();
}