mirror of https://github.com/flutter/pinball.git
parent
4621f871bb
commit
bafa686a28
@ -0,0 +1,69 @@
|
||||
// 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.add(bottomGroup);
|
||||
|
||||
expect(game.contains(bottomGroup), isTrue);
|
||||
},
|
||||
);
|
||||
|
||||
group('children', () {
|
||||
// TODO(alestiago): Make tests pass.
|
||||
flameTester.test(
|
||||
'has one left flipper',
|
||||
(game) async {
|
||||
final bottomGroup = BottomGroup(position: Vector2.zero(), spacing: 0);
|
||||
await game.ready();
|
||||
await game.add(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.add(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.add(bottomGroup);
|
||||
|
||||
final leftFlippers = bottomGroup.findNestedChildren<Baseboard>();
|
||||
expect(leftFlippers.length, equals(2));
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in new issue