|
|
|
@ -28,31 +28,47 @@ void main() {
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('on the next time the mouth opens and status is chomping', () {
|
|
|
|
|
flameTester.test(
|
|
|
|
|
'creates a RevoluteJoint',
|
|
|
|
|
'sets ball sprite to visible and sets a linear velocity',
|
|
|
|
|
(game) async {
|
|
|
|
|
final ball = Ball(baseColor: Colors.red);
|
|
|
|
|
final behavior = ChromeDinoSpittingBehavior();
|
|
|
|
|
final bloc = MockChromeDinoCubit();
|
|
|
|
|
final streamController = StreamController<ChromeDinoState>();
|
|
|
|
|
final chompingState = ChromeDinoState(
|
|
|
|
|
status: ChromeDinoStatus.chomping,
|
|
|
|
|
isMouthOpen: true,
|
|
|
|
|
ball: ball,
|
|
|
|
|
);
|
|
|
|
|
whenListen(
|
|
|
|
|
bloc,
|
|
|
|
|
const Stream<ChromeDinoState>.empty(),
|
|
|
|
|
initialState: const ChromeDinoState.inital(),
|
|
|
|
|
streamController.stream,
|
|
|
|
|
initialState: chompingState,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final chromeDino = ChromeDino.test(bloc: bloc);
|
|
|
|
|
await chromeDino.add(behavior);
|
|
|
|
|
await game.ensureAdd(chromeDino);
|
|
|
|
|
await game.ensureAddAll([chromeDino, ball]);
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
game.world.joints.whereType<RevoluteJoint>().single,
|
|
|
|
|
isNotNull,
|
|
|
|
|
);
|
|
|
|
|
streamController.add(chompingState.copyWith(isMouthOpen: false));
|
|
|
|
|
streamController.add(chompingState.copyWith(isMouthOpen: true));
|
|
|
|
|
await game.ready();
|
|
|
|
|
|
|
|
|
|
game
|
|
|
|
|
.descendants()
|
|
|
|
|
.whereType<TimerComponent>()
|
|
|
|
|
.single
|
|
|
|
|
.timer
|
|
|
|
|
.onTick!();
|
|
|
|
|
|
|
|
|
|
expect(ball.firstChild<SpriteComponent>()!.getOpacity(), equals(1));
|
|
|
|
|
expect(ball.body.linearVelocity, equals(Vector2(-50, 0)));
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
group('calls', () {
|
|
|
|
|
flameTester.test(
|
|
|
|
|
'onSpit the next time the mouth opens and status is chomping',
|
|
|
|
|
'calls onSpit',
|
|
|
|
|
(game) async {
|
|
|
|
|
final ball = Ball(baseColor: Colors.red);
|
|
|
|
|
final behavior = ChromeDinoSpittingBehavior();
|
|
|
|
|