fix: fixed tests for priority

pull/83/head
RuiAlonso 4 years ago
parent a2b809effd
commit 784d96c272

@ -188,6 +188,7 @@ class SpaceshipHole extends RampOpening {
outsidePriority: outsidePriority, outsidePriority: outsidePriority,
orientation: RampOrientation.up, orientation: RampOrientation.up,
) { ) {
renderBody = false;
layer = Layer.spaceship; layer = Layer.spaceship;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

@ -129,12 +129,10 @@ void main() {
final callback = TestRampOpeningBallContactCallback(); final callback = TestRampOpeningBallContactCallback();
when(() => ball.body).thenReturn(body); when(() => ball.body).thenReturn(body);
when(() => ball.priority).thenReturn(1);
when(() => body.position).thenReturn(Vector2.zero()); when(() => body.position).thenReturn(Vector2.zero());
when(() => ball.layer).thenReturn(Layer.board); when(() => ball.layer).thenReturn(Layer.board);
await game.ready();
await game.ensureAdd(area);
callback.begin(ball, area, MockContact()); callback.begin(ball, area, MockContact());
verify(() => ball.layer = area.pathwayLayer).called(1); verify(() => ball.layer = area.pathwayLayer).called(1);
}); });
@ -152,12 +150,10 @@ void main() {
final callback = TestRampOpeningBallContactCallback(); final callback = TestRampOpeningBallContactCallback();
when(() => ball.body).thenReturn(body); when(() => ball.body).thenReturn(body);
when(() => ball.priority).thenReturn(1);
when(() => body.position).thenReturn(Vector2.zero()); when(() => body.position).thenReturn(Vector2.zero());
when(() => ball.layer).thenReturn(Layer.board); when(() => ball.layer).thenReturn(Layer.board);
await game.ready();
await game.ensureAdd(area);
callback.begin(ball, area, MockContact()); callback.begin(ball, area, MockContact());
verify(() => ball.layer = area.pathwayLayer).called(1); verify(() => ball.layer = area.pathwayLayer).called(1);
}); });
@ -174,13 +170,11 @@ void main() {
final callback = TestRampOpeningBallContactCallback(); final callback = TestRampOpeningBallContactCallback();
when(() => ball.body).thenReturn(body); when(() => ball.body).thenReturn(body);
when(() => ball.priority).thenReturn(1);
when(() => body.position).thenReturn(Vector2.zero()); 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); when(() => ball.layer).thenReturn(Layer.board);
await game.ready();
await game.ensureAdd(area);
callback.begin(ball, area, MockContact()); callback.begin(ball, area, MockContact());
verify(() => ball.layer = area.pathwayLayer).called(1); verify(() => ball.layer = area.pathwayLayer).called(1);
@ -200,13 +194,11 @@ void main() {
final callback = TestRampOpeningBallContactCallback(); final callback = TestRampOpeningBallContactCallback();
when(() => ball.body).thenReturn(body); when(() => ball.body).thenReturn(body);
when(() => ball.priority).thenReturn(1);
when(() => body.position).thenReturn(Vector2.zero()); 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); when(() => ball.layer).thenReturn(Layer.board);
await game.ready();
await game.ensureAdd(area);
callback.begin(ball, area, MockContact()); callback.begin(ball, area, MockContact());
verify(() => ball.layer = area.pathwayLayer).called(1); verify(() => ball.layer = area.pathwayLayer).called(1);
@ -226,13 +218,11 @@ void main() {
final callback = TestRampOpeningBallContactCallback(); final callback = TestRampOpeningBallContactCallback();
when(() => ball.body).thenReturn(body); when(() => ball.body).thenReturn(body);
when(() => ball.priority).thenReturn(1);
when(() => body.position).thenReturn(Vector2.zero()); 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); when(() => ball.layer).thenReturn(Layer.board);
await game.ready();
await game.ensureAdd(area);
callback.begin(ball, area, MockContact()); callback.begin(ball, area, MockContact());
verify(() => ball.layer = area.pathwayLayer).called(1); verify(() => ball.layer = area.pathwayLayer).called(1);

@ -73,6 +73,7 @@ void main() {
group('SpaceshipHoleBallContactCallback', () { group('SpaceshipHoleBallContactCallback', () {
test('changes the ball priority on contact', () { test('changes the ball priority on contact', () {
when(() => ball.priority).thenReturn(2);
when(() => hole.outsideLayer).thenReturn(Layer.board); when(() => hole.outsideLayer).thenReturn(Layer.board);
when(() => hole.outsidePriority).thenReturn(1); when(() => hole.outsidePriority).thenReturn(1);

Loading…
Cancel
Save