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.
114 lines
3.4 KiB
114 lines
3.4 KiB
3 years ago
|
// ignore_for_file: cascade_invocations
|
||
|
|
||
|
import 'package:flame_test/flame_test.dart';
|
||
|
import 'package:flutter_test/flutter_test.dart';
|
||
3 years ago
|
import 'package:pinball/game/components/android_acres/behaviors/behaviors.dart';
|
||
3 years ago
|
import 'package:pinball/game/game.dart';
|
||
|
import 'package:pinball_components/pinball_components.dart';
|
||
|
|
||
3 years ago
|
import '../../../helpers/helpers.dart';
|
||
3 years ago
|
|
||
|
void main() {
|
||
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||
|
final assets = [
|
||
3 years ago
|
Assets.images.android.spaceship.saucer.keyName,
|
||
|
Assets.images.android.spaceship.animatronic.keyName,
|
||
|
Assets.images.android.spaceship.lightBeam.keyName,
|
||
|
Assets.images.android.ramp.boardOpening.keyName,
|
||
|
Assets.images.android.ramp.railingForeground.keyName,
|
||
|
Assets.images.android.ramp.railingBackground.keyName,
|
||
|
Assets.images.android.ramp.main.keyName,
|
||
|
Assets.images.android.ramp.arrow.inactive.keyName,
|
||
|
Assets.images.android.ramp.arrow.active1.keyName,
|
||
|
Assets.images.android.ramp.arrow.active2.keyName,
|
||
|
Assets.images.android.ramp.arrow.active3.keyName,
|
||
|
Assets.images.android.ramp.arrow.active4.keyName,
|
||
|
Assets.images.android.ramp.arrow.active5.keyName,
|
||
|
Assets.images.android.rail.main.keyName,
|
||
|
Assets.images.android.rail.exit.keyName,
|
||
|
Assets.images.android.bumper.a.lit.keyName,
|
||
|
Assets.images.android.bumper.a.dimmed.keyName,
|
||
|
Assets.images.android.bumper.b.lit.keyName,
|
||
|
Assets.images.android.bumper.b.dimmed.keyName,
|
||
|
Assets.images.android.bumper.cow.lit.keyName,
|
||
|
Assets.images.android.bumper.cow.dimmed.keyName,
|
||
3 years ago
|
];
|
||
|
final flameTester = FlameTester(
|
||
|
() => EmptyPinballTestGame(assets: assets),
|
||
|
);
|
||
|
|
||
|
group('AndroidAcres', () {
|
||
3 years ago
|
flameTester.test('loads correctly', (game) async {
|
||
|
final component = AndroidAcres();
|
||
|
await game.ensureAdd(component);
|
||
|
expect(game.contains(component), isTrue);
|
||
|
});
|
||
3 years ago
|
|
||
|
group('loads', () {
|
||
|
flameTester.test(
|
||
3 years ago
|
'an AndroidSpaceship',
|
||
3 years ago
|
(game) async {
|
||
3 years ago
|
await game.ensureAdd(AndroidAcres());
|
||
3 years ago
|
expect(
|
||
3 years ago
|
game.descendants().whereType<AndroidSpaceship>().length,
|
||
|
equals(1),
|
||
3 years ago
|
);
|
||
|
},
|
||
|
);
|
||
|
|
||
3 years ago
|
flameTester.test(
|
||
|
'an AndroidAnimatronic',
|
||
|
(game) async {
|
||
|
await game.ensureAdd(AndroidAcres());
|
||
|
expect(
|
||
|
game.descendants().whereType<AndroidAnimatronic>().length,
|
||
|
equals(1),
|
||
|
);
|
||
|
},
|
||
|
);
|
||
|
|
||
3 years ago
|
flameTester.test(
|
||
|
'a SpaceshipRamp',
|
||
|
(game) async {
|
||
3 years ago
|
await game.ensureAdd(AndroidAcres());
|
||
3 years ago
|
expect(
|
||
3 years ago
|
game.descendants().whereType<SpaceshipRamp>().length,
|
||
|
equals(1),
|
||
3 years ago
|
);
|
||
|
},
|
||
|
);
|
||
|
|
||
|
flameTester.test(
|
||
|
'a SpaceshipRail',
|
||
|
(game) async {
|
||
3 years ago
|
await game.ensureAdd(AndroidAcres());
|
||
3 years ago
|
expect(
|
||
3 years ago
|
game.descendants().whereType<SpaceshipRail>().length,
|
||
|
equals(1),
|
||
3 years ago
|
);
|
||
|
},
|
||
|
);
|
||
|
|
||
|
flameTester.test(
|
||
3 years ago
|
'three AndroidBumper',
|
||
3 years ago
|
(game) async {
|
||
3 years ago
|
await game.ensureAdd(AndroidAcres());
|
||
3 years ago
|
expect(
|
||
|
game.descendants().whereType<AndroidBumper>().length,
|
||
3 years ago
|
equals(3),
|
||
3 years ago
|
);
|
||
|
},
|
||
|
);
|
||
|
});
|
||
3 years ago
|
|
||
|
flameTester.test('adds an AndroidSpaceshipBonusBehavior', (game) async {
|
||
|
final androidAcres = AndroidAcres();
|
||
|
await game.ensureAdd(androidAcres);
|
||
|
expect(
|
||
|
androidAcres.children.whereType<AndroidSpaceshipBonusBehavior>().single,
|
||
|
isNotNull,
|
||
|
);
|
||
|
});
|
||
3 years ago
|
});
|
||
|
}
|