mirror of https://github.com/flutter/pinball.git
parent
1d4e633a21
commit
749013e6bc
@ -0,0 +1,67 @@
|
|||||||
|
// ignore_for_file: cascade_invocations
|
||||||
|
|
||||||
|
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_components/pinball_components.dart';
|
||||||
|
|
||||||
|
import '../../helpers/helpers.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('DinoWalls', () {
|
||||||
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
final flameTester = FlameTester(TestGame.new);
|
||||||
|
|
||||||
|
flameTester.test(
|
||||||
|
'loads correctly',
|
||||||
|
(game) async {
|
||||||
|
final dinoWalls = DinoWalls(position: Vector2.zero());
|
||||||
|
await game.addFromBlueprint(dinoWalls);
|
||||||
|
await game.ready();
|
||||||
|
|
||||||
|
for (final wall in dinoWalls.components) {
|
||||||
|
expect(game.contains(wall), isTrue);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
group('DinoTopWall', () {
|
||||||
|
flameTester.testGameWidget(
|
||||||
|
'renders correctly',
|
||||||
|
setUp: (game, tester) async {
|
||||||
|
await game.add(
|
||||||
|
DinoTopWall()..initialPosition = Vector2(0, -50),
|
||||||
|
);
|
||||||
|
await game.ready();
|
||||||
|
await tester.pump();
|
||||||
|
},
|
||||||
|
verify: (game, tester) async {
|
||||||
|
await expectLater(
|
||||||
|
find.byGame<Forge2DGame>(),
|
||||||
|
matchesGoldenFile('golden/dino-top-wall.png'),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
group('DinoBottomWall', () {
|
||||||
|
flameTester.testGameWidget(
|
||||||
|
'renders correctly',
|
||||||
|
setUp: (game, tester) async {
|
||||||
|
await game.add(
|
||||||
|
DinoBottomWall()..initialPosition = Vector2(0, -12),
|
||||||
|
);
|
||||||
|
await game.ready();
|
||||||
|
await tester.pump();
|
||||||
|
},
|
||||||
|
verify: (game, tester) async {
|
||||||
|
await expectLater(
|
||||||
|
find.byGame<Forge2DGame>(),
|
||||||
|
matchesGoldenFile('golden/dino-bottom-wall.png'),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 44 KiB |
Loading…
Reference in new issue