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.
92 lines
2.4 KiB
92 lines
2.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/dino_desert/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 = [
|
||
|
Assets.images.dino.animatronic.head.keyName,
|
||
|
Assets.images.dino.animatronic.mouth.keyName,
|
||
|
Assets.images.dino.topWall.keyName,
|
||
|
Assets.images.dino.bottomWall.keyName,
|
||
|
Assets.images.slingshot.upper.keyName,
|
||
|
Assets.images.slingshot.lower.keyName,
|
||
|
];
|
||
|
|
||
|
final flameTester = FlameTester(
|
||
|
() => EmptyPinballTestGame(assets: assets),
|
||
|
);
|
||
|
|
||
|
group('DinoDesert', () {
|
||
|
flameTester.test('loads correctly', (game) async {
|
||
|
final component = DinoDesert();
|
||
|
await game.ensureAdd(component);
|
||
|
expect(game.contains(component), isTrue);
|
||
|
});
|
||
|
|
||
|
group('loads', () {
|
||
|
flameTester.test(
|
||
|
'a ChromeDino',
|
||
|
(game) async {
|
||
|
await game.ensureAdd(DinoDesert());
|
||
|
expect(
|
||
|
game.descendants().whereType<ChromeDino>().length,
|
||
|
equals(1),
|
||
|
);
|
||
|
},
|
||
|
);
|
||
|
|
||
|
flameTester.test(
|
||
|
'DinoWalls',
|
||
|
(game) async {
|
||
|
await game.ensureAdd(DinoDesert());
|
||
|
expect(
|
||
|
game.descendants().whereType<DinoWalls>().length,
|
||
|
equals(1),
|
||
|
);
|
||
|
},
|
||
|
);
|
||
|
flameTester.test(
|
||
|
'Slingshots',
|
||
|
(game) async {
|
||
|
await game.ensureAdd(DinoDesert());
|
||
|
expect(
|
||
|
game.descendants().whereType<Slingshots>().length,
|
||
|
equals(1),
|
||
|
);
|
||
|
},
|
||
|
);
|
||
|
});
|
||
|
|
||
3 years ago
|
group('adds', () {
|
||
|
flameTester.test(
|
||
|
'ScoringBehavior to ChromeDino',
|
||
|
(game) async {
|
||
|
await game.ensureAdd(DinoDesert());
|
||
3 years ago
|
|
||
3 years ago
|
final chromeDino = game.descendants().whereType<ChromeDino>().single;
|
||
|
expect(
|
||
|
chromeDino.firstChild<ScoringBehavior>(),
|
||
|
isNotNull,
|
||
|
);
|
||
|
},
|
||
|
);
|
||
|
|
||
|
flameTester.test('a ChromeDinoBonusBehavior', (game) async {
|
||
|
final dinoDesert = DinoDesert();
|
||
|
await game.ensureAdd(dinoDesert);
|
||
3 years ago
|
expect(
|
||
3 years ago
|
dinoDesert.children.whereType<ChromeDinoBonusBehavior>().single,
|
||
3 years ago
|
isNotNull,
|
||
|
);
|
||
3 years ago
|
});
|
||
|
});
|
||
3 years ago
|
});
|
||
|
}
|