mirror of https://github.com/flutter/pinball.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
55 lines
1.5 KiB
// ignore_for_file: cascade_invocations
|
|
|
|
import 'package:flame/components.dart';
|
|
import 'package:flame_test/flame_test.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:mocktail/mocktail.dart';
|
|
import 'package:pinball/game/components/backbox/displays/loading_display.dart';
|
|
import 'package:pinball/l10n/l10n.dart';
|
|
|
|
import '../../../../helpers/helpers.dart';
|
|
|
|
class _MockAppLocalizations extends Mock implements AppLocalizations {
|
|
@override
|
|
String get loading => 'Loading';
|
|
}
|
|
|
|
void main() {
|
|
group('LoadingDisplay', () {
|
|
final flameTester = FlameTester(
|
|
() => EmptyPinballTestGame(
|
|
l10n: _MockAppLocalizations(),
|
|
),
|
|
);
|
|
|
|
flameTester.test('renders correctly', (game) async {
|
|
await game.ensureAdd(LoadingDisplay());
|
|
|
|
final component = game.firstChild<TextComponent>();
|
|
expect(component, isNotNull);
|
|
expect(component?.text, equals('Loading'));
|
|
});
|
|
|
|
flameTester.test('use ellipses as animation', (game) async {
|
|
await game.ensureAdd(LoadingDisplay());
|
|
|
|
final component = game.firstChild<TextComponent>();
|
|
expect(component?.text, equals('Loading'));
|
|
|
|
final timer = component?.firstChild<TimerComponent>();
|
|
|
|
timer?.update(1.1);
|
|
expect(component?.text, equals('Loading.'));
|
|
|
|
timer?.update(1.1);
|
|
expect(component?.text, equals('Loading..'));
|
|
|
|
timer?.update(1.1);
|
|
expect(component?.text, equals('Loading...'));
|
|
|
|
timer?.update(1.1);
|
|
expect(component?.text, equals('Loading'));
|
|
});
|
|
});
|
|
}
|