diff --git a/packages/pinball_components/test/src/components/golden/spaceship_ramp/active1.png b/packages/pinball_components/test/src/components/golden/spaceship_ramp/active1.png deleted file mode 100644 index e403c805..00000000 Binary files a/packages/pinball_components/test/src/components/golden/spaceship_ramp/active1.png and /dev/null differ diff --git a/packages/pinball_components/test/src/components/golden/spaceship_ramp/active2.png b/packages/pinball_components/test/src/components/golden/spaceship_ramp/active2.png deleted file mode 100644 index e403c805..00000000 Binary files a/packages/pinball_components/test/src/components/golden/spaceship_ramp/active2.png and /dev/null differ diff --git a/packages/pinball_components/test/src/components/golden/spaceship_ramp/active3.png b/packages/pinball_components/test/src/components/golden/spaceship_ramp/active3.png deleted file mode 100644 index e403c805..00000000 Binary files a/packages/pinball_components/test/src/components/golden/spaceship_ramp/active3.png and /dev/null differ diff --git a/packages/pinball_components/test/src/components/golden/spaceship_ramp/active4.png b/packages/pinball_components/test/src/components/golden/spaceship_ramp/active4.png deleted file mode 100644 index e403c805..00000000 Binary files a/packages/pinball_components/test/src/components/golden/spaceship_ramp/active4.png and /dev/null differ diff --git a/packages/pinball_components/test/src/components/golden/spaceship_ramp/active5.png b/packages/pinball_components/test/src/components/golden/spaceship_ramp/active5.png deleted file mode 100644 index e403c805..00000000 Binary files a/packages/pinball_components/test/src/components/golden/spaceship_ramp/active5.png and /dev/null differ diff --git a/packages/pinball_components/test/src/components/golden/spaceship_ramp/inactive.png b/packages/pinball_components/test/src/components/golden/spaceship_ramp/inactive.png index e403c805..edd38070 100644 Binary files a/packages/pinball_components/test/src/components/golden/spaceship_ramp/inactive.png and b/packages/pinball_components/test/src/components/golden/spaceship_ramp/inactive.png differ diff --git a/packages/pinball_components/test/src/components/golden/spaceship_ramp/ramp.png b/packages/pinball_components/test/src/components/golden/spaceship_ramp/ramp.png deleted file mode 100644 index 25f6d1e3..00000000 Binary files a/packages/pinball_components/test/src/components/golden/spaceship_ramp/ramp.png and /dev/null differ diff --git a/packages/pinball_components/test/src/components/spaceship_ramp_test.dart b/packages/pinball_components/test/src/components/spaceship_ramp_test.dart index 8c3c3e6f..e79a83e8 100644 --- a/packages/pinball_components/test/src/components/spaceship_ramp_test.dart +++ b/packages/pinball_components/test/src/components/spaceship_ramp_test.dart @@ -1,5 +1,6 @@ // 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'; @@ -10,7 +11,19 @@ import '../../helpers/helpers.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); - final flameTester = FlameTester(TestGame.new); + final assets = [ + Assets.images.spaceship.ramp.main.keyName, + Assets.images.spaceship.ramp.boardOpening.keyName, + Assets.images.spaceship.ramp.railingBackground.keyName, + Assets.images.spaceship.ramp.railingForeground.keyName, + Assets.images.spaceship.ramp.arrow.inactive.keyName, + Assets.images.spaceship.ramp.arrow.oneActive.keyName, + Assets.images.spaceship.ramp.arrow.twoActive.keyName, + Assets.images.spaceship.ramp.arrow.threeActive.keyName, + Assets.images.spaceship.ramp.arrow.fourActive.keyName, + Assets.images.spaceship.ramp.arrow.fiveActive.keyName, + ]; + final flameTester = FlameTester(() => TestGame(assets)); group('SpaceshipRamp', () { flameTester.test( @@ -25,16 +38,169 @@ void main() { group('renders correctly', () { flameTester.testGameWidget( - 'renders correctly', + 'inactive sprite', setUp: (game, tester) async { - await game.addFromBlueprint(SpaceshipRamp()); - game.camera.followVector2(Vector2(-13, -50)); + await game.images.loadAll(assets); + final spaceshipRamp = SpaceshipRamp(); + await game.addFromBlueprint(spaceshipRamp); await game.ready(); + await tester.pump(); + + expect( + spaceshipRamp.firstChild()!.current, + SpaceshipRampArrowSpriteState.inactive, + ); + + game.camera.followVector2(Vector2(-13, -55)); + }, + verify: (game, tester) async { + await expectLater( + find.byGame(), + matchesGoldenFile('golden/spaceship_ramp/inactive.png'), + ); + }, + ); + + flameTester.testGameWidget( + 'active1 sprite', + setUp: (game, tester) async { + await game.images.loadAll(assets); + final spaceshipRamp = SpaceshipRamp(); + await game.addFromBlueprint(spaceshipRamp); + await game.ready(); + await tester.pump(); + + spaceshipRamp.progress(); + + expect( + spaceshipRamp.firstChild()!.current, + SpaceshipRampArrowSpriteState.active1, + ); + + game.camera.followVector2(Vector2(-13, -55)); + }, + verify: (game, tester) async { + await expectLater( + find.byGame(), + matchesGoldenFile('golden/spaceship_ramp/active1.png'), + ); + }, + ); + + flameTester.testGameWidget( + 'active2 sprite', + setUp: (game, tester) async { + await game.images.loadAll(assets); + final spaceshipRamp = SpaceshipRamp(); + await game.addFromBlueprint(spaceshipRamp); + await game.ready(); + await tester.pump(); + + spaceshipRamp + ..progress() + ..progress(); + + expect( + spaceshipRamp.firstChild()!.current, + SpaceshipRampArrowSpriteState.active2, + ); + + game.camera.followVector2(Vector2(-13, -55)); + }, + verify: (game, tester) async { + await expectLater( + find.byGame(), + matchesGoldenFile('golden/spaceship_ramp/active2.png'), + ); + }, + ); + + flameTester.testGameWidget( + 'active3 sprite', + setUp: (game, tester) async { + await game.images.loadAll(assets); + final spaceshipRamp = SpaceshipRamp(); + await game.addFromBlueprint(spaceshipRamp); + await game.ready(); + await tester.pump(); + + spaceshipRamp + ..progress() + ..progress() + ..progress(); + + expect( + spaceshipRamp.firstChild()!.current, + SpaceshipRampArrowSpriteState.active3, + ); + + game.camera.followVector2(Vector2(-13, -55)); + }, + verify: (game, tester) async { + await expectLater( + find.byGame(), + matchesGoldenFile('golden/spaceship_ramp/active3.png'), + ); + }, + ); + + flameTester.testGameWidget( + 'active4 sprite', + setUp: (game, tester) async { + await game.images.loadAll(assets); + final spaceshipRamp = SpaceshipRamp(); + await game.addFromBlueprint(spaceshipRamp); + await game.ready(); + await tester.pump(); + + spaceshipRamp + ..progress() + ..progress() + ..progress() + ..progress(); + + expect( + spaceshipRamp.firstChild()!.current, + SpaceshipRampArrowSpriteState.active4, + ); + + game.camera.followVector2(Vector2(-13, -55)); + }, + verify: (game, tester) async { + await expectLater( + find.byGame(), + matchesGoldenFile('golden/spaceship_ramp/active4.png'), + ); + }, + ); + + flameTester.testGameWidget( + 'active5 sprite', + setUp: (game, tester) async { + await game.images.loadAll(assets); + final spaceshipRamp = SpaceshipRamp(); + await game.addFromBlueprint(spaceshipRamp); + await game.ready(); + await tester.pump(); + + spaceshipRamp + ..progress() + ..progress() + ..progress() + ..progress() + ..progress(); + + expect( + spaceshipRamp.firstChild()!.current, + SpaceshipRampArrowSpriteState.active5, + ); + + game.camera.followVector2(Vector2(-13, -55)); }, verify: (game, tester) async { await expectLater( find.byGame(), - matchesGoldenFile('golden/spaceship_ramp/ramp.png'), + matchesGoldenFile('golden/spaceship_ramp/active5.png'), ); }, );