mirror of https://github.com/flutter/pinball.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.9 KiB
82 lines
1.9 KiB
import 'package:flame_forge2d/flame_forge2d.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:mocktail/mocktail.dart';
|
|
import 'package:pinball/game/game.dart';
|
|
|
|
import '../../helpers/helpers.dart';
|
|
|
|
void main() {
|
|
group('Spaceship', () {
|
|
late Filter filterData;
|
|
late Fixture fixture;
|
|
late Body body;
|
|
late PinballGame game;
|
|
late Ball ball;
|
|
late SpaceshipEntrance entrance;
|
|
late SpaceshipHole hole;
|
|
|
|
setUp(() {
|
|
filterData = MockFilter();
|
|
|
|
fixture = MockFixture();
|
|
when(() => fixture.filterData).thenReturn(filterData);
|
|
|
|
body = MockBody();
|
|
when(() => body.fixtures).thenReturn([fixture]);
|
|
|
|
game = MockPinballGame();
|
|
|
|
ball = MockBall();
|
|
when(() => ball.gameRef).thenReturn(game);
|
|
when(() => ball.body).thenReturn(body);
|
|
|
|
entrance = MockSpaceshipEntrance();
|
|
hole = MockSpaceshipHole();
|
|
});
|
|
|
|
group('SpaceshipEntranceBallContactCallback', () {
|
|
test('changes the ball priority on contact', () {
|
|
SpaceshipEntranceBallContactCallback().begin(
|
|
entrance,
|
|
ball,
|
|
MockContact(),
|
|
);
|
|
|
|
verify(() => ball.priority = 3).called(1);
|
|
});
|
|
|
|
test('re order the game children', () {
|
|
SpaceshipEntranceBallContactCallback().begin(
|
|
entrance,
|
|
ball,
|
|
MockContact(),
|
|
);
|
|
|
|
verify(game.reorderChildren).called(1);
|
|
});
|
|
});
|
|
|
|
group('SpaceshipHoleBallContactCallback', () {
|
|
test('changes the ball priority on contact', () {
|
|
SpaceshipHoleBallContactCallback().begin(
|
|
hole,
|
|
ball,
|
|
MockContact(),
|
|
);
|
|
|
|
verify(() => ball.priority = 1).called(1);
|
|
});
|
|
|
|
test('re order the game children', () {
|
|
SpaceshipHoleBallContactCallback().begin(
|
|
hole,
|
|
ball,
|
|
MockContact(),
|
|
);
|
|
|
|
verify(game.reorderChildren).called(1);
|
|
});
|
|
});
|
|
});
|
|
}
|