chore: enable and add golden tests (#186)

* chore: enable/add golden tests

* chore: remove failures

* chore: find by test game
pull/192/head
Allison Ryan 3 years ago committed by GitHub
parent 333f91fc1e
commit f00d090e8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,11 +9,30 @@ import '../../helpers/helpers.dart';
void main() {
group('Baseboard', () {
// TODO(allisonryan0002): Add golden tests.
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(TestGame.new);
flameTester.testGameWidget(
'renders correctly',
setUp: (game, tester) async {
final leftBaseboard = Baseboard(
side: BoardSide.left,
)..initialPosition = Vector2(-20, 0);
final rightBaseboard = Baseboard(
side: BoardSide.right,
)..initialPosition = Vector2(20, 0);
await game.ensureAddAll([leftBaseboard, rightBaseboard]);
game.camera.followVector2(Vector2.zero());
},
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/baseboard.png'),
);
},
);
flameTester.test(
'loads correctly',
(game) async {

@ -15,17 +15,15 @@ void main() {
'render correctly',
setUp: (game, tester) async {
await game.addFromBlueprint(Boundaries());
await game.ready();
game.camera.followVector2(Vector2.zero());
game.camera.zoom = 3.9;
},
// TODO(allisonryan0002): enable test when workflows are fixed.
// verify: (game, tester) async {
// await expectLater(
// find.byGame<Forge2DGame>(),
// matchesGoldenFile('golden/boundaries.png'),
// );
// },
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/boundaries.png'),
);
},
);
});
}

@ -1,5 +1,6 @@
// ignore_for_file: cascade_invocations
import 'package:flame/extensions.dart';
import 'package:flame_test/flame_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pinball_components/pinball_components.dart';
@ -11,6 +12,33 @@ void main() {
final flameTester = FlameTester(TestGame.new);
group('DashAnimatronic', () {
flameTester.testGameWidget(
'renders correctly',
setUp: (game, tester) async {
await game.ensureAdd(DashAnimatronic()..playing = true);
game.camera.followVector2(Vector2.zero());
},
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/dash_animatronic/start.png'),
);
game.update(1);
await tester.pump();
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/dash_animatronic/middle.png'),
);
game.update(4);
await tester.pump();
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/dash_animatronic/end.png'),
);
},
);
flameTester.test(
'loads correctly',
(game) async {

@ -1,5 +1,6 @@
// 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:pinball_components/pinball_components.dart';
@ -11,6 +12,21 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(TestGame.new);
flameTester.testGameWidget(
'renders correctly',
setUp: (game, tester) async {
await game.addFromBlueprint(DinoWalls());
game.camera.followVector2(Vector2.zero());
game.camera.zoom = 6.5;
},
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/dino-walls.png'),
);
},
);
flameTester.test(
'loads correctly',
(game) async {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 913 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 894 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 KiB

@ -13,9 +13,29 @@ void main() {
final flameTester = FlameTester(TestGame.new);
group('Flipper', () {
// TODO(alestiago): Add golden tests.
// TODO(alestiago): Consider testing always both left and right Flipper.
flameTester.testGameWidget(
'renders correctly',
setUp: (game, tester) async {
final leftFlipper = Flipper(
side: BoardSide.left,
)..initialPosition = Vector2(-10, 0);
final rightFlipper = Flipper(
side: BoardSide.right,
)..initialPosition = Vector2(10, 0);
await game.ensureAddAll([leftFlipper, rightFlipper]);
game.camera.followVector2(Vector2.zero());
},
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/flipper.png'),
);
},
);
flameTester.test(
'loads correctly',
(game) async {

@ -1,5 +1,6 @@
// 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:pinball_components/pinball_components.dart';
@ -11,6 +12,20 @@ void main() {
final flameTester = FlameTester(TestGame.new);
group('FlutterSignPost', () {
flameTester.testGameWidget(
'renders correctly',
setUp: (game, tester) async {
await game.ensureAdd(FlutterSignPost());
game.camera.followVector2(Vector2.zero());
},
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/flutter-sign-post.png'),
);
},
);
flameTester.test(
'loads correctly',
(game) async {

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

@ -21,17 +21,15 @@ void main() {
side: BoardSide.right,
)..initialPosition = Vector2(20, 0);
await game.addAll([leftKicker, rightKicker]);
await game.ready();
await game.ensureAddAll([leftKicker, rightKicker]);
game.camera.followVector2(Vector2.zero());
},
// TODO(ruimiguel): enable test when workflows are fixed.
//verify: (game, tester) async {
// await expectLater(
// find.byGame<Forge2DGame>(),
// matchesGoldenFile('golden/kickers.png'),
// );
//},
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/kickers.png'),
);
},
);
flameTester.test(

@ -15,17 +15,15 @@ void main() {
'renders correctly',
setUp: (game, tester) async {
await game.addFromBlueprint(LaunchRamp());
await game.ready();
game.camera.followVector2(Vector2.zero());
game.camera.zoom = 4.1;
},
// TODO(allisonryan0002): enable test when workflows are fixed.
// verify: (game, tester) async {
// await expectLater(
// find.byGame<Forge2DGame>(),
// matchesGoldenFile('golden/launch-ramp.png'),
// );
// },
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/launch-ramp.png'),
);
},
);
});
}

@ -17,19 +17,15 @@ void main() {
flameTester.testGameWidget(
'renders correctly',
setUp: (game, tester) async {
await game.add(
Plunger(
compressionDistance: compressionDistance,
),
);
await game.ready();
await game.ensureAdd(Plunger(compressionDistance: compressionDistance));
game.camera.followVector2(Vector2.zero());
game.camera.zoom = 4.1;
},
verify: (game, tester) async {
await expectLater(
find.byGame<Forge2DGame>(),
matchesGoldenFile('golden/plunger/plunger.png'),
find.byGame<TestGame>(),
matchesGoldenFile('golden/plunger.png'),
);
},
);

@ -20,7 +20,7 @@ void main() {
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/plunger/rocket.png'),
matchesGoldenFile('golden/rocket.png'),
);
},
);

@ -18,16 +18,14 @@ void main() {
'renders correctly',
setUp: (game, tester) async {
await game.addFromBlueprint(Slingshots());
await game.ready();
game.camera.followVector2(Vector2.zero());
},
// TODO(allisonryan0002): enable test when workflows are fixed.
// verify: (game, tester) async {
// await expectLater(
// find.byGame<Forge2DGame>(),
// matchesGoldenFile('golden/slingshots.png'),
// );
// },
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/slingshots.png'),
);
},
);
flameTester.test(

@ -13,6 +13,21 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(TestGame.new);
flameTester.testGameWidget(
'renders correctly',
setUp: (game, tester) async {
await game.addFromBlueprint(SpaceshipRail());
game.camera.followVector2(Vector2.zero());
game.camera.zoom = 8;
},
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/spaceship-rail.png'),
);
},
);
flameTester.test(
'loads correctly',
(game) async {

@ -15,16 +15,14 @@ void main() {
'renders correctly',
setUp: (game, tester) async {
await game.addFromBlueprint(SpaceshipRamp());
await game.ready();
game.camera.followVector2(Vector2(-13, -50));
},
// TODO(allisonryan0002): enable test when workflows are fixed.
// verify: (game, tester) async {
// await expectLater(
// find.byGame<Forge2DGame>(),
// matchesGoldenFile('golden/spaceship-ramp.png'),
// );
// },
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/spaceship-ramp.png'),
);
},
);
});
}

@ -44,15 +44,12 @@ void main() {
'renders correctly',
setUp: (game, tester) async {
await game.addFromBlueprint(Spaceship(position: Vector2(30, -30)));
await game.ready();
await tester.pump();
},
verify: (game, tester) async {
// FIXME(erickzanardo): Failing pipeline.
// await expectLater(
// find.byGame<Forge2DGame>(),
// matchesGoldenFile('golden/spaceship.png'),
// );
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/spaceship.png'),
);
},
);
});

@ -15,16 +15,14 @@ void main() {
'renders correctly',
setUp: (game, tester) async {
await game.addFromBlueprint(SparkyComputer());
await game.ready();
game.camera.followVector2(Vector2(-15, -50));
},
// TODO(allisonryan0002): enable test when workflows are fixed.
// verify: (game, tester) async {
// await expectLater(
// find.byGame<Forge2DGame>(),
// matchesGoldenFile('golden/sparky-computer.png'),
// );
// },
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/sparky-computer.png'),
);
},
);
});
}

Loading…
Cancel
Save