From a26a3abe062c454f01bed498cb9635a1691386f6 Mon Sep 17 00:00:00 2001 From: Allison Ryan Date: Wed, 13 Apr 2022 13:56:23 -0500 Subject: [PATCH] test: update tests related to y directions --- .../test/src/components/baseboard_test.dart | 4 +- .../test/src/components/flipper_test.dart | 6 +-- .../test/src/components/plunger_test.dart | 12 +++--- .../src/components/ramp_opening_test.dart | 6 +-- .../components/controlled_flipper_test.dart | 38 ++----------------- .../components/controlled_plunger_test.dart | 6 +-- 6 files changed, 21 insertions(+), 51 deletions(-) diff --git a/packages/pinball_components/test/src/components/baseboard_test.dart b/packages/pinball_components/test/src/components/baseboard_test.dart index b1ce58e2..7366db7b 100644 --- a/packages/pinball_components/test/src/components/baseboard_test.dart +++ b/packages/pinball_components/test/src/components/baseboard_test.dart @@ -57,8 +57,8 @@ void main() { ); await game.ensureAddAll([leftBaseboard, rightBaseboard]); - expect(leftBaseboard.body.angle, isNegative); - expect(rightBaseboard.body.angle, isPositive); + expect(leftBaseboard.body.angle, isPositive); + expect(rightBaseboard.body.angle, isNegative); }, ); }); diff --git a/packages/pinball_components/test/src/components/flipper_test.dart b/packages/pinball_components/test/src/components/flipper_test.dart index efd4d2b0..80d6c3ed 100644 --- a/packages/pinball_components/test/src/components/flipper_test.dart +++ b/packages/pinball_components/test/src/components/flipper_test.dart @@ -55,7 +55,7 @@ void main() { final flipper = Flipper(side: BoardSide.left); await game.ensureAdd(flipper); - expect(flipper.body.gravityScale, isZero); + expect(flipper.body.gravityScale, equals(Vector2.zero())); }, ); @@ -113,7 +113,7 @@ void main() { expect(flipper.body.linearVelocity, equals(Vector2.zero())); flipper.moveDown(); - expect(flipper.body.linearVelocity.y, lessThan(0)); + expect(flipper.body.linearVelocity.y, isPositive); }, ); @@ -126,7 +126,7 @@ void main() { expect(flipper.body.linearVelocity, equals(Vector2.zero())); flipper.moveUp(); - expect(flipper.body.linearVelocity.y, greaterThan(0)); + expect(flipper.body.linearVelocity.y, isNegative); }, ); }); diff --git a/packages/pinball_components/test/src/components/plunger_test.dart b/packages/pinball_components/test/src/components/plunger_test.dart index 8f8a26db..f6d91984 100644 --- a/packages/pinball_components/test/src/components/plunger_test.dart +++ b/packages/pinball_components/test/src/components/plunger_test.dart @@ -69,7 +69,7 @@ void main() { ); await game.ensureAdd(plunger); - expect(plunger.body.gravityScale, isZero); + expect(plunger.body.gravityScale, equals(Vector2.zero())); }, ); }); @@ -124,7 +124,7 @@ void main() { await game.ensureAdd(plunger); plunger.pull(); - expect(plunger.body.linearVelocity.y, isNegative); + expect(plunger.body.linearVelocity.y, isPositive); expect(plunger.body.linearVelocity.x, isZero); }, ); @@ -143,10 +143,10 @@ void main() { 'moves upwards when release is called ' 'and plunger is below its starting position', (game) async { await game.ensureAdd(plunger); - plunger.body.setTransform(Vector2(0, -1), 0); + plunger.body.setTransform(Vector2(0, 1), 0); plunger.release(); - expect(plunger.body.linearVelocity.y, isPositive); + expect(plunger.body.linearVelocity.y, isNegative); expect(plunger.body.linearVelocity.x, isZero); }); @@ -180,7 +180,7 @@ void main() { expect( plungerAnchor.body.position.y, - equals(plunger.body.position.y - compressionDistance), + equals(plunger.body.position.y + compressionDistance), ); }, ); @@ -297,7 +297,7 @@ void main() { await tester.pump(const Duration(seconds: 1)); }, verify: (game, tester) async { - expect(plunger.body.position.y > anchor.body.position.y, isTrue); + expect(plunger.body.position.y < anchor.body.position.y, isTrue); }, ); diff --git a/packages/pinball_components/test/src/components/ramp_opening_test.dart b/packages/pinball_components/test/src/components/ramp_opening_test.dart index e79842bd..37b8edb0 100644 --- a/packages/pinball_components/test/src/components/ramp_opening_test.dart +++ b/packages/pinball_components/test/src/components/ramp_opening_test.dart @@ -180,7 +180,7 @@ void main() { when(() => ball.body).thenReturn(body); when(() => ball.priority).thenReturn(1); when(() => body.position).thenReturn(Vector2.zero()); - when(() => body.linearVelocity).thenReturn(Vector2(0, -1)); + when(() => body.linearVelocity).thenReturn(Vector2(0, 1)); when(() => ball.layer).thenReturn(Layer.board); callback.begin(ball, area, MockContact()); @@ -205,7 +205,7 @@ void main() { when(() => ball.body).thenReturn(body); when(() => ball.priority).thenReturn(1); when(() => body.position).thenReturn(Vector2.zero()); - when(() => body.linearVelocity).thenReturn(Vector2(0, 1)); + when(() => body.linearVelocity).thenReturn(Vector2(0, -1)); when(() => ball.layer).thenReturn(Layer.board); callback.begin(ball, area, MockContact()); @@ -230,7 +230,7 @@ void main() { when(() => ball.body).thenReturn(body); when(() => ball.priority).thenReturn(1); when(() => body.position).thenReturn(Vector2.zero()); - when(() => body.linearVelocity).thenReturn(Vector2(0, 1)); + when(() => body.linearVelocity).thenReturn(Vector2(0, -1)); when(() => ball.layer).thenReturn(Layer.board); callback.begin(ball, area, MockContact()); diff --git a/test/game/components/controlled_flipper_test.dart b/test/game/components/controlled_flipper_test.dart index 03c51830..5446a672 100644 --- a/test/game/components/controlled_flipper_test.dart +++ b/test/game/components/controlled_flipper_test.dart @@ -42,7 +42,7 @@ void main() { await game.add(flipper); controller.onKeyEvent(event, {}); - expect(flipper.body.linearVelocity.y, isPositive); + expect(flipper.body.linearVelocity.y, isNegative); expect(flipper.body.linearVelocity.x, isZero); }, ); @@ -57,7 +57,7 @@ void main() { await game.add(flipper); controller.onKeyEvent(event, {}); - expect(flipper.body.linearVelocity.y, isNegative); + expect(flipper.body.linearVelocity.y, isPositive); expect(flipper.body.linearVelocity.x, isZero); }, ); @@ -77,21 +77,6 @@ void main() { }, ); }); - - testRawKeyDownEvents(rightKeys, (event) { - flameTester.test( - 'does nothing ' - 'when ${event.logicalKey.keyLabel} is pressed', - (game) async { - await game.ready(); - await game.add(flipper); - controller.onKeyEvent(event, {}); - - expect(flipper.body.linearVelocity.y, isZero); - expect(flipper.body.linearVelocity.x, isZero); - }, - ); - }); }); group('and Flipper is right', () { @@ -113,7 +98,7 @@ void main() { await game.add(flipper); controller.onKeyEvent(event, {}); - expect(flipper.body.linearVelocity.y, isPositive); + expect(flipper.body.linearVelocity.y, isNegative); expect(flipper.body.linearVelocity.x, isZero); }, ); @@ -128,7 +113,7 @@ void main() { await game.add(flipper); controller.onKeyEvent(event, {}); - expect(flipper.body.linearVelocity.y, isNegative); + expect(flipper.body.linearVelocity.y, isPositive); expect(flipper.body.linearVelocity.x, isZero); }, ); @@ -148,21 +133,6 @@ void main() { }, ); }); - - testRawKeyDownEvents(leftKeys, (event) { - flameTester.test( - 'does nothing ' - 'when ${event.logicalKey.keyLabel} is pressed', - (game) async { - await game.ready(); - await game.add(flipper); - controller.onKeyEvent(event, {}); - - expect(flipper.body.linearVelocity.y, isZero); - expect(flipper.body.linearVelocity.x, isZero); - }, - ); - }); }); }); }); diff --git a/test/game/components/controlled_plunger_test.dart b/test/game/components/controlled_plunger_test.dart index bb965fc1..02bf7f24 100644 --- a/test/game/components/controlled_plunger_test.dart +++ b/test/game/components/controlled_plunger_test.dart @@ -38,7 +38,7 @@ void main() { await game.ensureAdd(plunger); controller.onKeyEvent(event, {}); - expect(plunger.body.linearVelocity.y, isNegative); + expect(plunger.body.linearVelocity.y, isPositive); expect(plunger.body.linearVelocity.x, isZero); }, ); @@ -51,10 +51,10 @@ void main() { 'and plunger is below its starting position', (game) async { await game.ensureAdd(plunger); - plunger.body.setTransform(Vector2(0, -1), 0); + plunger.body.setTransform(Vector2(0, 1), 0); controller.onKeyEvent(event, {}); - expect(plunger.body.linearVelocity.y, isPositive); + expect(plunger.body.linearVelocity.y, isNegative); expect(plunger.body.linearVelocity.x, isZero); }, );