test: golden tests for ball

pull/279/head
RuiAlonso 3 years ago
parent c997ccdfc8
commit 3c2ed1dab7

@ -5,12 +5,22 @@ import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flame_test/flame_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pinball_components/pinball_components.dart';
import 'package:pinball_theme/pinball_theme.dart' as theme;
import '../../helpers/helpers.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(TestGame.new);
final assets = [
Assets.images.ball.ball.keyName,
Assets.images.ball.flameEffect.keyName,
theme.Assets.images.android.ball.keyName,
theme.Assets.images.dash.ball.keyName,
theme.Assets.images.dino.ball.keyName,
theme.Assets.images.sparky.ball.keyName,
];
final flameTester = FlameTester(() => TestGame(assets));
group('Ball', () {
flameTester.test(
@ -24,6 +34,121 @@ void main() {
},
);
group('renders correctly', () {
flameTester.testGameWidget(
'default',
setUp: (game, tester) async {
final ball = Ball()..initialPosition = Vector2.zero();
await game.ready();
await game.ensureAdd(ball);
await tester.pump();
game.camera
..followVector2(Vector2.zero())
..zoom = 8;
},
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/ball/default.png'),
);
},
);
flameTester.testGameWidget(
'android theme',
setUp: (game, tester) async {
final ball = Ball(
spriteAsset: theme.Assets.images.android.ball.keyName,
)..initialPosition = Vector2.zero();
await game.ready();
await game.ensureAdd(ball);
await tester.pump();
game.camera
..followVector2(Vector2.zero())
..zoom = 8;
},
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/ball/android.png'),
);
},
);
flameTester.testGameWidget(
'dash theme',
setUp: (game, tester) async {
final ball = Ball(
spriteAsset: theme.Assets.images.dash.ball.keyName,
)..initialPosition = Vector2.zero();
await game.ready();
await game.ensureAdd(ball);
await tester.pump();
game.camera
..followVector2(Vector2.zero())
..zoom = 8;
},
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/ball/dash.png'),
);
},
);
flameTester.testGameWidget(
'dino theme',
setUp: (game, tester) async {
final ball = Ball(
spriteAsset: theme.Assets.images.dino.ball.keyName,
)..initialPosition = Vector2.zero();
await game.ready();
await game.ensureAdd(ball);
await tester.pump();
game.camera
..followVector2(Vector2.zero())
..zoom = 8;
},
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/ball/dino.png'),
);
},
);
flameTester.testGameWidget(
'sparky theme',
setUp: (game, tester) async {
final ball = Ball(
spriteAsset: theme.Assets.images.sparky.ball.keyName,
)..initialPosition = Vector2.zero();
await game.ready();
await game.ensureAdd(ball);
await tester.pump();
game.camera
..followVector2(Vector2.zero())
..zoom = 8;
},
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/ball/sparky.png'),
);
},
);
});
group('body', () {
flameTester.test(
'is dynamic',

@ -12,7 +12,10 @@ import '../../../../helpers/helpers.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(TestGame.new);
final assets = [
Assets.images.ball.ball.keyName,
];
final flameTester = FlameTester(() => TestGame(assets));
group(
'ChromeDinoChompingBehavior',

@ -14,7 +14,10 @@ import '../../../../helpers/helpers.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(TestGame.new);
final assets = [
Assets.images.ball.ball.keyName,
];
final flameTester = FlameTester(() => TestGame(assets));
group(
'ChromeDinoSpittingBehavior',

@ -12,6 +12,7 @@ void main() {
final assets = [
Assets.images.flipper.left.keyName,
Assets.images.flipper.right.keyName,
Assets.images.ball.ball.keyName,
];
final flameTester = FlameTester(() => TestGame(assets));

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Loading…
Cancel
Save