|
|
@ -15,102 +15,6 @@ void main() {
|
|
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
final flameTester = FlameTester(PinballGameTest.create);
|
|
|
|
final flameTester = FlameTester(PinballGameTest.create);
|
|
|
|
|
|
|
|
|
|
|
|
group('FlipperGroup', () {
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
|
|
|
'loads correctly',
|
|
|
|
|
|
|
|
(game) async {
|
|
|
|
|
|
|
|
final flipperGroup = FlipperGroup(
|
|
|
|
|
|
|
|
position: Vector2.zero(),
|
|
|
|
|
|
|
|
spacing: 0,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
await game.ensureAdd(flipperGroup);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(game.contains(flipperGroup), isTrue);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
group('constructor', () {
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
|
|
|
'positions correctly',
|
|
|
|
|
|
|
|
(game) async {
|
|
|
|
|
|
|
|
final position = Vector2.all(10);
|
|
|
|
|
|
|
|
final flipperGroup = FlipperGroup(
|
|
|
|
|
|
|
|
position: position,
|
|
|
|
|
|
|
|
spacing: 0,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
await game.ensureAdd(flipperGroup);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(flipperGroup.position, equals(position));
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
group('children', () {
|
|
|
|
|
|
|
|
bool Function(Component) flipperSelector(BoardSide side) =>
|
|
|
|
|
|
|
|
(component) => component is Flipper && component.side == side;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
|
|
|
'has only one left Flipper',
|
|
|
|
|
|
|
|
(game) async {
|
|
|
|
|
|
|
|
final flipperGroup = FlipperGroup(
|
|
|
|
|
|
|
|
position: Vector2.zero(),
|
|
|
|
|
|
|
|
spacing: 0,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
await game.ensureAdd(flipperGroup);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
|
|
|
() => flipperGroup.children.singleWhere(
|
|
|
|
|
|
|
|
flipperSelector(BoardSide.left),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
returnsNormally,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
|
|
|
'has only one right Flipper',
|
|
|
|
|
|
|
|
(game) async {
|
|
|
|
|
|
|
|
final flipperGroup = FlipperGroup(
|
|
|
|
|
|
|
|
position: Vector2.zero(),
|
|
|
|
|
|
|
|
spacing: 0,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
await game.ensureAdd(flipperGroup);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
|
|
|
() => flipperGroup.children.singleWhere(
|
|
|
|
|
|
|
|
flipperSelector(BoardSide.right),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
returnsNormally,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
|
|
|
'spaced correctly',
|
|
|
|
|
|
|
|
(game) async {
|
|
|
|
|
|
|
|
final flipperGroup = FlipperGroup(
|
|
|
|
|
|
|
|
position: Vector2.zero(),
|
|
|
|
|
|
|
|
spacing: 2,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
|
|
|
await game.ensureAdd(flipperGroup);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final leftFlipper = flipperGroup.children.singleWhere(
|
|
|
|
|
|
|
|
flipperSelector(BoardSide.left),
|
|
|
|
|
|
|
|
) as Flipper;
|
|
|
|
|
|
|
|
final rightFlipper = flipperGroup.children.singleWhere(
|
|
|
|
|
|
|
|
flipperSelector(BoardSide.right),
|
|
|
|
|
|
|
|
) as Flipper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
|
|
|
leftFlipper.body.position.x + Flipper.width + flipperGroup.spacing,
|
|
|
|
|
|
|
|
equals(rightFlipper.body.position.x),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
group(
|
|
|
|
group(
|
|
|
|
'Flipper',
|
|
|
|
'Flipper',
|
|
|
|
() {
|
|
|
|
() {
|
|
|
|