|
|
|
@ -16,6 +16,7 @@ import '../../../../helpers/helpers.dart';
|
|
|
|
|
void main() {
|
|
|
|
|
group('FlutterForestBonusBehavior', () {
|
|
|
|
|
late GameBloc gameBloc;
|
|
|
|
|
final assets = [Assets.images.dash.animatronic.keyName];
|
|
|
|
|
|
|
|
|
|
setUp(() {
|
|
|
|
|
gameBloc = MockGameBloc();
|
|
|
|
@ -31,9 +32,14 @@ void main() {
|
|
|
|
|
blocBuilder: () => gameBloc,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void _contactedBumper(DashNestBumper bumper) =>
|
|
|
|
|
bumper.bloc.onBallContacted();
|
|
|
|
|
|
|
|
|
|
flameBlocTester.testGameWidget(
|
|
|
|
|
'adds GameBonus.dashNest to the game when all bumpers are active',
|
|
|
|
|
'adds GameBonus.dashNest to the game '
|
|
|
|
|
'when bumpers are activated three times',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
await game.images.loadAll(assets);
|
|
|
|
|
final behavior = FlutterForestBonusBehavior();
|
|
|
|
|
final parent = FlutterForest.test();
|
|
|
|
|
final bumpers = [
|
|
|
|
@ -41,12 +47,18 @@ void main() {
|
|
|
|
|
DashNestBumper.test(bloc: DashNestBumperCubit()),
|
|
|
|
|
DashNestBumper.test(bloc: DashNestBumperCubit()),
|
|
|
|
|
];
|
|
|
|
|
final animatronic = DashAnimatronic();
|
|
|
|
|
final signpost = Signpost.test(bloc: SignpostCubit());
|
|
|
|
|
await game.ensureAdd(ZCanvasComponent(children: [parent]));
|
|
|
|
|
await parent.ensureAddAll([...bumpers, behavior]);
|
|
|
|
|
await parent.ensureAddAll([...bumpers, animatronic, signpost]);
|
|
|
|
|
await parent.ensureAdd(behavior);
|
|
|
|
|
|
|
|
|
|
for (final bumper in bumpers) {
|
|
|
|
|
bumper.bloc.onBallContacted();
|
|
|
|
|
}
|
|
|
|
|
expect(game.descendants().whereType<DashNestBumper>(), equals(bumpers));
|
|
|
|
|
bumpers.forEach(_contactedBumper);
|
|
|
|
|
await tester.pump();
|
|
|
|
|
bumpers.forEach(_contactedBumper);
|
|
|
|
|
await tester.pump();
|
|
|
|
|
bumpers.forEach(_contactedBumper);
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
verify(
|
|
|
|
@ -56,8 +68,10 @@ void main() {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
flameBlocTester.testGameWidget(
|
|
|
|
|
'adds a new ball to the game when all bumpers are active',
|
|
|
|
|
'adds a new Ball to the game '
|
|
|
|
|
'when bumpers are activated three times',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
await game.images.loadAll(assets);
|
|
|
|
|
final behavior = FlutterForestBonusBehavior();
|
|
|
|
|
final parent = FlutterForest.test();
|
|
|
|
|
final bumpers = [
|
|
|
|
@ -65,18 +79,68 @@ void main() {
|
|
|
|
|
DashNestBumper.test(bloc: DashNestBumperCubit()),
|
|
|
|
|
DashNestBumper.test(bloc: DashNestBumperCubit()),
|
|
|
|
|
];
|
|
|
|
|
final animatronic = DashAnimatronic();
|
|
|
|
|
final signpost = Signpost.test(bloc: SignpostCubit());
|
|
|
|
|
await game.ensureAdd(ZCanvasComponent(children: [parent]));
|
|
|
|
|
await parent.ensureAddAll([...bumpers, animatronic, signpost]);
|
|
|
|
|
await parent.ensureAdd(behavior);
|
|
|
|
|
|
|
|
|
|
for (final bumper in bumpers) {
|
|
|
|
|
bumper.bloc.onBallContacted();
|
|
|
|
|
}
|
|
|
|
|
expect(game.descendants().whereType<DashNestBumper>(), equals(bumpers));
|
|
|
|
|
bumpers.forEach(_contactedBumper);
|
|
|
|
|
await tester.pump();
|
|
|
|
|
bumpers.forEach(_contactedBumper);
|
|
|
|
|
await tester.pump();
|
|
|
|
|
bumpers.forEach(_contactedBumper);
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
expect(
|
|
|
|
|
game.descendants().whereType<Ball>().length,
|
|
|
|
|
equals(1),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// expect(
|
|
|
|
|
// game.descendants().whereType<Ball>().single,
|
|
|
|
|
// isNotNull,
|
|
|
|
|
// );
|
|
|
|
|
flameBlocTester.testGameWidget(
|
|
|
|
|
'progress the signpost '
|
|
|
|
|
'when bumpers are activated',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
await game.images.loadAll(assets);
|
|
|
|
|
final behavior = FlutterForestBonusBehavior();
|
|
|
|
|
final parent = FlutterForest.test();
|
|
|
|
|
final bumpers = [
|
|
|
|
|
DashNestBumper.test(bloc: DashNestBumperCubit()),
|
|
|
|
|
DashNestBumper.test(bloc: DashNestBumperCubit()),
|
|
|
|
|
DashNestBumper.test(bloc: DashNestBumperCubit()),
|
|
|
|
|
];
|
|
|
|
|
final animatronic = DashAnimatronic();
|
|
|
|
|
final signpost = Signpost.test(bloc: SignpostCubit());
|
|
|
|
|
await game.ensureAdd(ZCanvasComponent(children: [parent]));
|
|
|
|
|
await parent.ensureAddAll([...bumpers, animatronic, signpost]);
|
|
|
|
|
await parent.ensureAdd(behavior);
|
|
|
|
|
|
|
|
|
|
expect(game.descendants().whereType<DashNestBumper>(), equals(bumpers));
|
|
|
|
|
|
|
|
|
|
bumpers.forEach(_contactedBumper);
|
|
|
|
|
await tester.pump();
|
|
|
|
|
expect(
|
|
|
|
|
signpost.bloc.state,
|
|
|
|
|
equals(SignpostState.active1),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
bumpers.forEach(_contactedBumper);
|
|
|
|
|
await tester.pump();
|
|
|
|
|
expect(
|
|
|
|
|
signpost.bloc.state,
|
|
|
|
|
equals(SignpostState.active2),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
bumpers.forEach(_contactedBumper);
|
|
|
|
|
await tester.pump();
|
|
|
|
|
expect(
|
|
|
|
|
signpost.bloc.state,
|
|
|
|
|
equals(SignpostState.inactive),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|