Files
ReelShort/test/player/loading_progress_track_test.dart
T

54 lines
1.6 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/loading_progress_track.dart';
void main() {
testWidgets('should_move_highlight_while_loading', (tester) async {
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
addTearDown(
() => tester.binding.handleAppLifecycleStateChanged(
AppLifecycleState.paused,
),
);
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: Center(
child: SizedBox(width: 240, child: LoadingProgressTrack(height: 4)),
),
),
),
);
expect(find.byKey(const Key('progress-loading')), findsOneWidget);
expect(
tester
.widget<ColoredBox>(find.byKey(const Key('progress-loading-track')))
.color,
AppColors.inactiveTrack,
);
expect(
tester
.widget<ColoredBox>(
find.byKey(const Key('progress-loading-highlight')),
)
.color,
AppColors.onPrimary,
);
final initialLeft = tester
.getTopLeft(find.byKey(const Key('progress-loading-highlight')))
.dx;
await tester.pump(const Duration(milliseconds: 300));
final movedLeft = tester
.getTopLeft(find.byKey(const Key('progress-loading-highlight')))
.dx;
expect(movedLeft, greaterThan(initialLeft));
expect(tester.getSize(find.byKey(const Key('progress-loading'))).height, 4);
});
}