74 lines
2.5 KiB
Dart
74 lines
2.5 KiB
Dart
// Author: fruit.com.cn
|
|
// 职责:验证剧集播放页 YMB 入场 loading 的品牌视觉、运动和减少动画行为。
|
|
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_loading_overlay.dart';
|
|
|
|
const _surface = Key('player-loading-surface');
|
|
const _logo = Key('player-entry-loading');
|
|
const _motion = Key('player-entry-loading-motion');
|
|
|
|
void main() {
|
|
testWidgets('should_show_ymb_motion_without_circular_spinner', (
|
|
tester,
|
|
) async {
|
|
await _pump(tester);
|
|
|
|
expect(find.byType(CircularProgressIndicator), findsNothing);
|
|
expect(find.byKey(_surface), findsOneWidget);
|
|
expect(find.byKey(_logo), findsOneWidget);
|
|
expect(find.text('Loading'), findsNothing);
|
|
expect(find.byKey(const Key('player-entry-loading-track')), findsNothing);
|
|
expect(
|
|
find.byKey(const Key('player-entry-loading-highlight')),
|
|
findsNothing,
|
|
);
|
|
expect(find.byType(ShaderMask), findsOneWidget);
|
|
expect(tester.getSize(find.byKey(_surface)), const Size(56, 36));
|
|
expect(tester.getSize(find.byKey(_logo)), const Size(48, 29));
|
|
expect(tester.widget<Container>(find.byKey(_surface)).decoration, isNull);
|
|
|
|
final initialScale = _scaleOf(tester);
|
|
await tester.pump(const Duration(milliseconds: 300));
|
|
expect(_scaleOf(tester), isNot(initialScale));
|
|
});
|
|
|
|
testWidgets('should_keep_loading_static_when_motion_is_disabled', (
|
|
tester,
|
|
) async {
|
|
await _pump(tester, disableAnimations: true);
|
|
|
|
final initialScale = _scaleOf(tester);
|
|
await tester.pump(const Duration(milliseconds: 300));
|
|
expect(_scaleOf(tester), initialScale);
|
|
expect(find.byKey(_logo), findsOneWidget);
|
|
expect(find.text('Loading'), findsNothing);
|
|
});
|
|
}
|
|
|
|
double _scaleOf(WidgetTester tester) {
|
|
return tester.widget<Transform>(find.byKey(_motion)).transform.storage.first;
|
|
}
|
|
|
|
Future<void> _pump(
|
|
WidgetTester tester, {
|
|
bool disableAnimations = false,
|
|
}) async {
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
locale: const Locale('en'),
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
home: MediaQuery(
|
|
data: MediaQueryData(disableAnimations: disableAnimations),
|
|
child: Scaffold(
|
|
body: Center(
|
|
child: PlayerLoadingOverlay(opacity: 1, onFadeEnd: () {}),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|