test: update tests related to y directions

pull/185/head
Allison Ryan 3 years ago
parent 6f35fd55b2
commit a26a3abe06

@ -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);
},
);
});

@ -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);
},
);
});

@ -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);
},
);

@ -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());

@ -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);
},
);
});
});
});
});

@ -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);
},
);

Loading…
Cancel
Save