|
|
@ -1,14 +1,12 @@
|
|
|
|
// ignore_for_file: cascade_invocations
|
|
|
|
// ignore_for_file: cascade_invocations
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:bloc_test/bloc_test.dart';
|
|
|
|
import 'package:bloc_test/bloc_test.dart';
|
|
|
|
import 'package:flame_bloc/flame_bloc.dart';
|
|
|
|
|
|
|
|
import 'package:flame_forge2d/flame_forge2d.dart';
|
|
|
|
import 'package:flame_forge2d/flame_forge2d.dart';
|
|
|
|
import 'package:flame_test/flame_test.dart';
|
|
|
|
import 'package:flame_test/flame_test.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:mocktail/mocktail.dart';
|
|
|
|
import 'package:mocktail/mocktail.dart';
|
|
|
|
import 'package:pinball_components/pinball_components.dart';
|
|
|
|
import 'package:pinball_components/pinball_components.dart';
|
|
|
|
import 'package:pinball_components/src/components/spaceship_ramp/behavior/behavior.dart';
|
|
|
|
import 'package:pinball_components/src/components/spaceship_ramp/behavior/behavior.dart';
|
|
|
|
import 'package:pinball_flame/pinball_flame.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _TestGame extends Forge2DGame {
|
|
|
|
class _TestGame extends Forge2DGame {
|
|
|
|
@override
|
|
|
|
@override
|
|
|
@ -27,20 +25,6 @@ class _TestGame extends Forge2DGame {
|
|
|
|
Assets.images.android.ramp.arrow.active5.keyName,
|
|
|
|
Assets.images.android.ramp.arrow.active5.keyName,
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> pump(
|
|
|
|
|
|
|
|
SpaceshipRamp child, {
|
|
|
|
|
|
|
|
required SpaceshipRampCubit spaceshipRampCubit,
|
|
|
|
|
|
|
|
}) async {
|
|
|
|
|
|
|
|
await ensureAdd(
|
|
|
|
|
|
|
|
FlameBlocProvider<SpaceshipRampCubit, SpaceshipRampState>.value(
|
|
|
|
|
|
|
|
value: spaceshipRampCubit,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
ZCanvasComponent(children: [child]),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _MockSpaceshipRampCubit extends Mock implements SpaceshipRampCubit {}
|
|
|
|
class _MockSpaceshipRampCubit extends Mock implements SpaceshipRampCubit {}
|
|
|
@ -88,20 +72,21 @@ void main() {
|
|
|
|
initialState: const SpaceshipRampState.initial(),
|
|
|
|
initialState: const SpaceshipRampState.initial(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
final parent = SpaceshipRampBoardOpening.test();
|
|
|
|
final opening = SpaceshipRampBoardOpening.test();
|
|
|
|
final spaceshipRamp = SpaceshipRamp.test();
|
|
|
|
final spaceshipRamp = SpaceshipRamp.test(
|
|
|
|
|
|
|
|
bloc: bloc,
|
|
|
|
|
|
|
|
children: [opening],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
when(() => body.linearVelocity).thenReturn(Vector2(0, -1));
|
|
|
|
when(() => body.linearVelocity).thenReturn(Vector2(0, -1));
|
|
|
|
|
|
|
|
|
|
|
|
await spaceshipRamp.add(parent);
|
|
|
|
await game.ensureAdd(spaceshipRamp);
|
|
|
|
await game.pump(
|
|
|
|
await opening.add(behavior);
|
|
|
|
spaceshipRamp,
|
|
|
|
|
|
|
|
spaceshipRampCubit: bloc,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
await parent.add(behavior);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
behavior.beginContact(ball, _MockContact());
|
|
|
|
behavior.beginContact(ball, _MockContact());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
|
|
|
|
|
|
|
verify(bloc.onAscendingBallEntered).called(1);
|
|
|
|
verify(bloc.onAscendingBallEntered).called(1);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -117,20 +102,21 @@ void main() {
|
|
|
|
initialState: const SpaceshipRampState.initial(),
|
|
|
|
initialState: const SpaceshipRampState.initial(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
final parent = SpaceshipRampBoardOpening.test();
|
|
|
|
final opening = SpaceshipRampBoardOpening.test();
|
|
|
|
final spaceshipRamp = SpaceshipRamp.test();
|
|
|
|
final spaceshipRamp = SpaceshipRamp.test(
|
|
|
|
|
|
|
|
bloc: bloc,
|
|
|
|
|
|
|
|
children: [opening],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
when(() => body.linearVelocity).thenReturn(Vector2(0, 1));
|
|
|
|
when(() => body.linearVelocity).thenReturn(Vector2(0, 1));
|
|
|
|
|
|
|
|
|
|
|
|
await spaceshipRamp.add(parent);
|
|
|
|
await game.ensureAdd(spaceshipRamp);
|
|
|
|
await game.pump(
|
|
|
|
await opening.add(behavior);
|
|
|
|
spaceshipRamp,
|
|
|
|
|
|
|
|
spaceshipRampCubit: bloc,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
await parent.add(behavior);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
behavior.beginContact(ball, _MockContact());
|
|
|
|
behavior.beginContact(ball, _MockContact());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
|
|
|
|
|
|
|
verifyNever(bloc.onAscendingBallEntered);
|
|
|
|
verifyNever(bloc.onAscendingBallEntered);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|