53 lines
1.5 KiB
Dart
53 lines
1.5 KiB
Dart
// Author: fruit.com.cn
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.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,
|
|
Colors.white24,
|
|
);
|
|
expect(
|
|
tester
|
|
.widget<ColoredBox>(
|
|
find.byKey(const Key('progress-loading-highlight')),
|
|
)
|
|
.color,
|
|
Colors.white,
|
|
);
|
|
|
|
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);
|
|
});
|
|
}
|