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.
67 lines
1.7 KiB
67 lines
1.7 KiB
// ignore_for_file: cascade_invocations
|
|
|
|
import 'package:flame/components.dart';
|
|
import 'package:flame_forge2d/flame_forge2d.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/displays.dart';
|
|
import 'package:pinball/l10n/l10n.dart';
|
|
import 'package:pinball_components/gen/assets.gen.dart';
|
|
import 'package:pinball_flame/pinball_flame.dart';
|
|
|
|
class _TestGame extends Forge2DGame {
|
|
@override
|
|
Future<void> onLoad() async {
|
|
await super.onLoad();
|
|
images.prefix = '';
|
|
await images.loadAll(
|
|
[
|
|
Assets.images.errorBackground.keyName,
|
|
],
|
|
);
|
|
}
|
|
|
|
Future<void> pump(LeaderboardFailureDisplay component) {
|
|
return world.ensureAdd(
|
|
FlameProvider.value(
|
|
_MockAppLocalizations(),
|
|
children: [component],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _MockAppLocalizations extends Mock implements AppLocalizations {
|
|
@override
|
|
String get leaderboardErrorMessage => 'Message';
|
|
}
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
group('LeaderboardFailureDisplay', () {
|
|
final flameTester = FlameTester(_TestGame.new);
|
|
|
|
flameTester.testGameWidget(
|
|
'renders correctly',
|
|
setUp: (game, _) async {
|
|
await game.onLoad();
|
|
await game.pump(LeaderboardFailureDisplay());
|
|
await game.ready();
|
|
},
|
|
verify: (game, _) async {
|
|
expect(
|
|
game
|
|
.descendants()
|
|
.where(
|
|
(component) =>
|
|
component is TextComponent && component.text == 'Message',
|
|
)
|
|
.length,
|
|
equals(1),
|
|
);
|
|
},
|
|
);
|
|
});
|
|
}
|