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.
69 lines
2.0 KiB
69 lines
2.0 KiB
// ignore_for_file: cascade_invocations
|
|
|
|
import 'package:flame_forge2d/flame_forge2d.dart';
|
|
import 'package:flame_test/flame_test.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pinball/game/game.dart';
|
|
|
|
import '../../helpers/helpers.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
final flameTester = FlameTester(Forge2DGame.new);
|
|
|
|
group('BottomGroup', () {
|
|
flameTester.test(
|
|
'loads correctly',
|
|
(game) async {
|
|
final bottomGroup = BottomGroup(position: Vector2.zero(), spacing: 0);
|
|
await game.ready();
|
|
await game.ensureAdd(bottomGroup);
|
|
|
|
expect(game.contains(bottomGroup), isTrue);
|
|
},
|
|
);
|
|
|
|
group('children', () {
|
|
flameTester.test(
|
|
'has one left flipper',
|
|
(game) async {
|
|
final bottomGroup = BottomGroup(position: Vector2.zero(), spacing: 0);
|
|
await game.ready();
|
|
await game.ensureAdd(bottomGroup);
|
|
|
|
final leftFlippers = bottomGroup.findNestedChildren<Flipper>(
|
|
condition: (flipper) => flipper.side.isLeft,
|
|
);
|
|
expect(leftFlippers.length, equals(1));
|
|
},
|
|
);
|
|
|
|
flameTester.test(
|
|
'has one right flipper',
|
|
(game) async {
|
|
final bottomGroup = BottomGroup(position: Vector2.zero(), spacing: 0);
|
|
await game.ready();
|
|
await game.ensureAdd(bottomGroup);
|
|
|
|
final leftFlippers = bottomGroup.findNestedChildren<Flipper>(
|
|
condition: (flipper) => flipper.side.isRight,
|
|
);
|
|
expect(leftFlippers.length, equals(1));
|
|
},
|
|
);
|
|
|
|
flameTester.test(
|
|
'has two Baseboards',
|
|
(game) async {
|
|
final bottomGroup = BottomGroup(position: Vector2.zero(), spacing: 0);
|
|
await game.ready();
|
|
await game.ensureAdd(bottomGroup);
|
|
|
|
final leftFlippers = bottomGroup.findNestedChildren<Baseboard>();
|
|
expect(leftFlippers.length, equals(2));
|
|
},
|
|
);
|
|
});
|
|
});
|
|
}
|