|
|
@ -116,13 +116,6 @@ void main() {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
group('RampOpeningBallContactCallback', () {
|
|
|
|
group('RampOpeningBallContactCallback', () {
|
|
|
|
test('ballsInside is empty when initialized', () {
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
|
|
|
RampOpeningBallContactCallback<TestRampOpening>().ballsInside,
|
|
|
|
|
|
|
|
isEmpty,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
flameTester.test(
|
|
|
|
'changes ball layer '
|
|
|
|
'changes ball layer '
|
|
|
|
'when a ball enters upwards into a downward ramp opening',
|
|
|
|
'when a ball enters upwards into a downward ramp opening',
|
|
|
@ -146,30 +139,6 @@ void main() {
|
|
|
|
verify(() => ball.layer = area.pathwayLayer).called(1);
|
|
|
|
verify(() => ball.layer = area.pathwayLayer).called(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
|
|
|
'adds ball to ballsInside '
|
|
|
|
|
|
|
|
'when a ball enters upwards into a downward oriented ramp',
|
|
|
|
|
|
|
|
(game) async {
|
|
|
|
|
|
|
|
final ball = MockBall();
|
|
|
|
|
|
|
|
final body = MockBody();
|
|
|
|
|
|
|
|
final area = TestRampOpening(
|
|
|
|
|
|
|
|
orientation: RampOrientation.down,
|
|
|
|
|
|
|
|
pathwayLayer: Layer.jetpack,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
final callback = TestRampOpeningBallContactCallback();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when(() => ball.body).thenReturn(body);
|
|
|
|
|
|
|
|
when(() => body.position).thenReturn(Vector2.zero());
|
|
|
|
|
|
|
|
when(() => ball.layer).thenReturn(Layer.board);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
|
|
|
await game.ensureAdd(area);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.begin(ball, area, MockContact());
|
|
|
|
|
|
|
|
expect(callback.ballsInside.length, equals(1));
|
|
|
|
|
|
|
|
expect(callback.ballsInside.first, ball);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
flameTester.test(
|
|
|
|
'changes ball layer '
|
|
|
|
'changes ball layer '
|
|
|
|
'when a ball enters downwards into a upward ramp opening',
|
|
|
|
'when a ball enters downwards into a upward ramp opening',
|
|
|
@ -193,59 +162,6 @@ void main() {
|
|
|
|
verify(() => ball.layer = area.pathwayLayer).called(1);
|
|
|
|
verify(() => ball.layer = area.pathwayLayer).called(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
|
|
|
'adds ball to ballsInside '
|
|
|
|
|
|
|
|
'when a ball enters downwards into an upward oriented ramp',
|
|
|
|
|
|
|
|
(game) async {
|
|
|
|
|
|
|
|
final ball = MockBall();
|
|
|
|
|
|
|
|
final body = MockBody();
|
|
|
|
|
|
|
|
final area = TestRampOpening(
|
|
|
|
|
|
|
|
orientation: RampOrientation.up,
|
|
|
|
|
|
|
|
pathwayLayer: Layer.jetpack,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
final callback = TestRampOpeningBallContactCallback();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when(() => ball.body).thenReturn(body);
|
|
|
|
|
|
|
|
when(() => body.position).thenReturn(Vector2.zero());
|
|
|
|
|
|
|
|
when(() => ball.layer).thenReturn(Layer.board);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
|
|
|
await game.ensureAdd(area);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.begin(ball, area, MockContact());
|
|
|
|
|
|
|
|
expect(callback.ballsInside.contains(ball), isTrue);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
|
|
|
'removes ball from ballsInside '
|
|
|
|
|
|
|
|
'when a ball exits from a downward oriented ramp', (game) async {
|
|
|
|
|
|
|
|
final ball = MockBall();
|
|
|
|
|
|
|
|
final body = MockBody();
|
|
|
|
|
|
|
|
final area = TestRampOpening(
|
|
|
|
|
|
|
|
orientation: RampOrientation.down,
|
|
|
|
|
|
|
|
pathwayLayer: Layer.jetpack,
|
|
|
|
|
|
|
|
)..initialPosition = Vector2(0, 10);
|
|
|
|
|
|
|
|
final callback = TestRampOpeningBallContactCallback();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when(() => ball.body).thenReturn(body);
|
|
|
|
|
|
|
|
when(() => body.position).thenReturn(Vector2.zero());
|
|
|
|
|
|
|
|
when(() => body.linearVelocity).thenReturn(Vector2(0, -1));
|
|
|
|
|
|
|
|
when(() => ball.layer).thenReturn(Layer.board);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
|
|
|
await game.ensureAdd(area);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(callback.ballsInside.isEmpty, isTrue);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.begin(ball, area, MockContact());
|
|
|
|
|
|
|
|
expect(callback.ballsInside.length, equals(1));
|
|
|
|
|
|
|
|
expect(callback.ballsInside.first, ball);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.end(ball, area, MockContact());
|
|
|
|
|
|
|
|
expect(callback.ballsInside.isEmpty, true);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
flameTester.test(
|
|
|
|
'changes ball layer '
|
|
|
|
'changes ball layer '
|
|
|
|
'when a ball exits from a downward oriented ramp', (game) async {
|
|
|
|
'when a ball exits from a downward oriented ramp', (game) async {
|
|
|
@ -272,35 +188,6 @@ void main() {
|
|
|
|
verify(() => ball.layer = Layer.board);
|
|
|
|
verify(() => ball.layer = Layer.board);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
|
|
|
'removes ball from ballsInside '
|
|
|
|
|
|
|
|
'when a ball exits from a upward oriented ramp', (game) async {
|
|
|
|
|
|
|
|
final ball = MockBall();
|
|
|
|
|
|
|
|
final body = MockBody();
|
|
|
|
|
|
|
|
final area = TestRampOpening(
|
|
|
|
|
|
|
|
orientation: RampOrientation.up,
|
|
|
|
|
|
|
|
pathwayLayer: Layer.jetpack,
|
|
|
|
|
|
|
|
)..initialPosition = Vector2(0, 10);
|
|
|
|
|
|
|
|
final callback = TestRampOpeningBallContactCallback();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when(() => ball.body).thenReturn(body);
|
|
|
|
|
|
|
|
when(() => body.position).thenReturn(Vector2.zero());
|
|
|
|
|
|
|
|
when(() => body.linearVelocity).thenReturn(Vector2(0, 1));
|
|
|
|
|
|
|
|
when(() => ball.layer).thenReturn(Layer.board);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
|
|
|
await game.ensureAdd(area);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(callback.ballsInside.isEmpty, isTrue);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.begin(ball, area, MockContact());
|
|
|
|
|
|
|
|
expect(callback.ballsInside.length, equals(1));
|
|
|
|
|
|
|
|
expect(callback.ballsInside.first, ball);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.end(ball, area, MockContact());
|
|
|
|
|
|
|
|
expect(callback.ballsInside.isEmpty, true);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
flameTester.test(
|
|
|
|
'changes ball layer '
|
|
|
|
'changes ball layer '
|
|
|
|
'when a ball exits from a upward oriented ramp', (game) async {
|
|
|
|
'when a ball exits from a upward oriented ramp', (game) async {
|
|
|
@ -327,39 +214,6 @@ void main() {
|
|
|
|
verify(() => ball.layer = Layer.board);
|
|
|
|
verify(() => ball.layer = Layer.board);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
|
|
|
'removes added ball from ballsInside '
|
|
|
|
|
|
|
|
'when a ball enters and exits from ramp', (game) async {
|
|
|
|
|
|
|
|
final ball = MockBall();
|
|
|
|
|
|
|
|
final body = MockBody();
|
|
|
|
|
|
|
|
final area = TestRampOpening(
|
|
|
|
|
|
|
|
orientation: RampOrientation.down,
|
|
|
|
|
|
|
|
pathwayLayer: Layer.jetpack,
|
|
|
|
|
|
|
|
)..initialPosition = Vector2(0, 10);
|
|
|
|
|
|
|
|
final callback = TestRampOpeningBallContactCallback();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when(() => ball.body).thenReturn(body);
|
|
|
|
|
|
|
|
when(() => body.position).thenReturn(Vector2.zero());
|
|
|
|
|
|
|
|
when(() => body.linearVelocity).thenReturn(Vector2(0, 1));
|
|
|
|
|
|
|
|
when(() => ball.layer).thenReturn(Layer.board);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
|
|
|
await game.ensureAdd(area);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(callback.ballsInside.isEmpty, isTrue);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.begin(ball, area, MockContact());
|
|
|
|
|
|
|
|
expect(callback.ballsInside.length, equals(1));
|
|
|
|
|
|
|
|
expect(callback.ballsInside.first, ball);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.end(ball, area, MockContact());
|
|
|
|
|
|
|
|
expect(callback.ballsInside.length, equals(1));
|
|
|
|
|
|
|
|
expect(callback.ballsInside.first, ball);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback.begin(ball, area, MockContact());
|
|
|
|
|
|
|
|
expect(callback.ballsInside.isEmpty, isTrue);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
flameTester.test(
|
|
|
|
'change ball layer between pathwayLayer and again to Layer.board '
|
|
|
|
'change ball layer between pathwayLayer and again to Layer.board '
|
|
|
|
'when a ball enters and exits from ramp', (game) async {
|
|
|
|
'when a ball enters and exits from ramp', (game) async {
|
|
|
|