test: updated golden animatronic tests

pull/194/head
alestiago 3 years ago
parent 991396805b
commit d631875fce

@ -22,7 +22,9 @@ void main() {
await tester.pump(); await tester.pump();
}, },
verify: (game, tester) async { verify: (game, tester) async {
const animationDuration = 3.25; final animationDuration =
game.firstChild<DashAnimatronic>()!.animation!.totalDuration();
await expectLater( await expectLater(
find.byGame<TestGame>(), find.byGame<TestGame>(),
matchesGoldenFile('golden/dash_animatronic/start.png'), matchesGoldenFile('golden/dash_animatronic/start.png'),

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 34 KiB

@ -9,29 +9,37 @@ import '../../helpers/helpers.dart';
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(TestGame.new);
group('SparkyAnimatronic', () { group('SparkyAnimatronic', () {
final asset = Assets.images.sparky.animatronic.keyName;
final flameTester = FlameTester(() => TestGame([asset]));
flameTester.testGameWidget( flameTester.testGameWidget(
'renders correctly', 'renders correctly',
setUp: (game, tester) async { setUp: (game, tester) async {
await game.images.load(asset);
await game.ensureAdd(SparkyAnimatronic()..playing = true); await game.ensureAdd(SparkyAnimatronic()..playing = true);
await tester.pump();
game.camera.followVector2(Vector2.zero()); game.camera.followVector2(Vector2.zero());
}, },
verify: (game, tester) async { verify: (game, tester) async {
final animationDuration =
game.firstChild<SparkyAnimatronic>()!.animation!.totalDuration();
await expectLater( await expectLater(
find.byGame<TestGame>(), find.byGame<TestGame>(),
matchesGoldenFile('golden/sparky_animatronic/start.png'), matchesGoldenFile('golden/sparky_animatronic/start.png'),
); );
game.update(1); game.update(animationDuration * 0.25);
await tester.pump(); await tester.pump();
await expectLater( await expectLater(
find.byGame<TestGame>(), find.byGame<TestGame>(),
matchesGoldenFile('golden/sparky_animatronic/middle.png'), matchesGoldenFile('golden/sparky_animatronic/middle.png'),
); );
game.update(1); game.update(animationDuration * 0.75);
await tester.pump(); await tester.pump();
await expectLater( await expectLater(
find.byGame<TestGame>(), find.byGame<TestGame>(),
@ -39,6 +47,7 @@ void main() {
); );
}, },
); );
flameTester.test( flameTester.test(
'loads correctly', 'loads correctly',
(game) async { (game) async {
@ -56,7 +65,9 @@ void main() {
await game.ensureAdd(sparkyAnimatronic); await game.ensureAdd(sparkyAnimatronic);
sparkyAnimatronic.playing = true; sparkyAnimatronic.playing = true;
game.update(3); final animationDuration =
game.firstChild<SparkyAnimatronic>()!.animation!.totalDuration();
game.update(animationDuration);
expect(sparkyAnimatronic.playing, isFalse); expect(sparkyAnimatronic.playing, isFalse);
}, },

Loading…
Cancel
Save