Files
ReelShort/test/player/player_center_toggle_test.dart
T

61 lines
1.8 KiB
Dart

// Author: fruit.com.cn
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fruitshorts/core/theme/app_colors.dart';
import 'package:fruitshorts/pages/player/widgets/player_center_toggle.dart';
void main() {
testWidgets('should_use_one_shared_68px_translucent_toggle_style', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Row(
children: [
PlayerCenterToggle(
key: const Key('test-center-toggle-a'),
playing: false,
onTap: () {},
),
PlayerCenterToggle(
key: const Key('player-play-toggle'),
playing: true,
onTap: () {},
),
],
),
),
),
);
for (final key in const [
Key('test-center-toggle-a'),
Key('player-play-toggle'),
]) {
expect(tester.getSize(find.byKey(key)), const Size(68, 68));
// 半透明玻璃圆面:压在亮画面上也能看见播放/暂停。
final surface = tester.widget<DecoratedBox>(
find
.descendant(
of: find.byKey(key),
matching: find.byKey(const Key('player-center-toggle-surface')),
)
.first,
);
final decoration = surface.decoration as BoxDecoration;
expect(decoration.gradient, isA<RadialGradient>());
expect(decoration.shape, BoxShape.circle);
expect(decoration.border, isNull);
final icon = tester.widget<Icon>(
find.descendant(of: find.byKey(key), matching: find.byType(Icon)),
);
expect(icon.size, 36);
expect(icon.color, AppColors.onPrimary);
expect(icon.shadows, isNotNull);
expect(icon.shadows, isNotEmpty);
}
});
}