feat(player): 更多面板按参考图重做
This commit is contained in:
1 parent
c06a67c4b0
commit
7fccd16750
3 files changed
+260
-131
No files matched your search
@@ -50,7 +50,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('player-more-quality-AUTO')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-more-offline')), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('player-more-close')));
|
||||
await tester.tapAt(const Offset(10, 10));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
@@ -290,7 +290,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('player-more-sheet')), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('player-more-close')));
|
||||
await tester.tapAt(const Offset(10, 10));
|
||||
await tester.pumpAndSettle();
|
||||
// 长按弹更多不改播放状态,仍处于播放中。
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||
@@ -832,6 +832,7 @@ void main() {
|
||||
expect(find.byKey(const Key('player-more-offline')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-more-clear')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-more-drag-handle')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-more-close')), findsNothing);
|
||||
for (final removed in const [
|
||||
Key('player-more-not-interested'),
|
||||
Key('player-more-danmaku'),
|
||||
@@ -845,15 +846,27 @@ void main() {
|
||||
}
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('player-more-speed-1.0'))).height,
|
||||
28,
|
||||
26,
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('player-more-speed-track'))).height,
|
||||
34,
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('player-more-speed-row'))).height,
|
||||
44,
|
||||
56,
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('player-more-quality-row'))).height,
|
||||
44,
|
||||
56,
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('player-more-clear'))).height,
|
||||
56,
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('player-more-offline'))).height,
|
||||
56,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
@@ -881,7 +894,7 @@ void main() {
|
||||
)
|
||||
.style
|
||||
?.fontSize,
|
||||
12,
|
||||
14,
|
||||
);
|
||||
await tester.ensureVisible(find.byKey(const Key('player-more-speed-1.5')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:fruitshorts/core/theme/app_colors.dart';
|
||||
import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/player_more_sheet.dart';
|
||||
|
||||
@@ -14,6 +15,105 @@ void main() {
|
||||
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);
|
||||
expect(find.byKey(const Key('player-more-close')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_render_reference_layout_metrics', (tester) async {
|
||||
await _openSheet(tester);
|
||||
|
||||
expect(
|
||||
tester.widget<Material>(find.byKey(const Key('player-more-sheet'))).color,
|
||||
AppColors.ink,
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('player-more-drag-handle'))),
|
||||
const Size(36, 4),
|
||||
);
|
||||
for (final key in const [
|
||||
Key('player-more-speed-row'),
|
||||
Key('player-more-quality-row'),
|
||||
Key('player-more-clear'),
|
||||
Key('player-more-offline'),
|
||||
]) {
|
||||
expect(tester.getSize(find.byKey(key)).height, 56);
|
||||
}
|
||||
for (final key in const [
|
||||
Key('player-more-speed-track'),
|
||||
Key('player-more-quality-track'),
|
||||
]) {
|
||||
expect(tester.getSize(find.byKey(key)).height, 34);
|
||||
final trackDecoration =
|
||||
tester.widget<Container>(find.byKey(key)).decoration!
|
||||
as BoxDecoration;
|
||||
expect(trackDecoration.color, AppColors.raised);
|
||||
}
|
||||
for (final key in const [
|
||||
Key('player-more-speed-0.75'),
|
||||
Key('player-more-speed-1.0'),
|
||||
Key('player-more-speed-1.25'),
|
||||
]) {
|
||||
expect(tester.getSize(find.byKey(key)).height, 26);
|
||||
}
|
||||
|
||||
final speedLabel = tester.widget<Text>(
|
||||
find
|
||||
.descendant(
|
||||
of: find.byKey(const Key('player-more-speed-row')),
|
||||
matching: find.byType(Text),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
expect(speedLabel.style?.fontSize, 16);
|
||||
expect(speedLabel.style?.fontWeight, FontWeight.w600);
|
||||
expect(tester.widget<Icon>(find.byIcon(Icons.speed_outlined)).size, 22);
|
||||
expect(tester.widget<Icon>(find.byIcon(Icons.fullscreen)).size, 22);
|
||||
|
||||
final selected = tester.widget<Container>(
|
||||
find
|
||||
.descendant(
|
||||
of: find.byKey(const Key('player-more-speed-1.0')),
|
||||
matching: find.byType(Container),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
final selectedDecoration = selected.decoration! as BoxDecoration;
|
||||
expect(selectedDecoration.color, AppColors.card);
|
||||
expect(selectedDecoration.boxShadow, isNotEmpty);
|
||||
final selectedText = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('player-more-speed-1.0')),
|
||||
matching: find.text('1.0x'),
|
||||
),
|
||||
);
|
||||
expect(selectedText.style?.color, AppColors.onSurface);
|
||||
expect(selectedText.style?.fontWeight, FontWeight.w700);
|
||||
|
||||
final unselected = tester.widget<Container>(
|
||||
find
|
||||
.descendant(
|
||||
of: find.byKey(const Key('player-more-speed-1.25')),
|
||||
matching: find.byType(Container),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
final unselectedDecoration = unselected.decoration! as BoxDecoration;
|
||||
expect(unselectedDecoration.color, Colors.transparent);
|
||||
final unselectedText = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('player-more-speed-1.25')),
|
||||
matching: find.text('1.25x'),
|
||||
),
|
||||
);
|
||||
expect(unselectedText.style?.color, AppColors.muted);
|
||||
expect(unselectedText.style?.fontWeight, FontWeight.w500);
|
||||
|
||||
final disabledText = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('player-more-quality-720P')),
|
||||
matching: find.byType(Text),
|
||||
),
|
||||
);
|
||||
expect(disabledText.style?.color, AppColors.subtle);
|
||||
});
|
||||
|
||||
testWidgets('should_trigger_pip_and_close_sheet_when_tapped', (tester) async {
|
||||
|
||||
Reference in new issue
Block a user