|
|
@ -43,96 +43,87 @@ void main() {
|
|
|
|
late PinballGame game;
|
|
|
|
late PinballGame game;
|
|
|
|
late Backbox backbox;
|
|
|
|
late Backbox backbox;
|
|
|
|
late CameraController cameraController;
|
|
|
|
late CameraController cameraController;
|
|
|
|
late GameBlocStatusListener gameBlocStatusListener;
|
|
|
|
late GameBlocStatusListener gameFlowController;
|
|
|
|
late PinballAudio pinballAudio;
|
|
|
|
late PinballAudio pinballAudio;
|
|
|
|
late ActiveOverlaysNotifier overlays;
|
|
|
|
late ActiveOverlaysNotifier overlays;
|
|
|
|
|
|
|
|
|
|
|
|
group('onNewState', () {
|
|
|
|
setUp(() {
|
|
|
|
late PinballGame game;
|
|
|
|
game = _MockPinballGame();
|
|
|
|
late Backbox backbox;
|
|
|
|
backbox = _MockBackbox();
|
|
|
|
late CameraController cameraController;
|
|
|
|
cameraController = _MockCameraController();
|
|
|
|
late GameBlocStatusListener gameFlowController;
|
|
|
|
gameFlowController = GameBlocStatusListener();
|
|
|
|
late PinballAudio pinballAudio;
|
|
|
|
overlays = _MockActiveOverlaysNotifier();
|
|
|
|
late ActiveOverlaysNotifier overlays;
|
|
|
|
pinballAudio = _MockPinballAudio();
|
|
|
|
|
|
|
|
|
|
|
|
setUp(() {
|
|
|
|
gameFlowController.mockGameRef(game);
|
|
|
|
game = _MockPinballGame();
|
|
|
|
when(
|
|
|
|
backbox = _MockBackbox();
|
|
|
|
() => backbox.initialsInput(
|
|
|
|
cameraController = _MockCameraController();
|
|
|
|
score: any(named: 'score'),
|
|
|
|
gameFlowController = GameBlocStatusListener();
|
|
|
|
characterIconPath: any(named: 'characterIconPath'),
|
|
|
|
overlays = _MockActiveOverlaysNotifier();
|
|
|
|
onSubmit: any(named: 'onSubmit'),
|
|
|
|
pinballAudio = _MockPinballAudio();
|
|
|
|
),
|
|
|
|
|
|
|
|
).thenAnswer((_) async {});
|
|
|
|
gameFlowController.mockGameRef(game);
|
|
|
|
when(cameraController.focusOnWaitingBackbox).thenAnswer((_) async {});
|
|
|
|
when(
|
|
|
|
when(cameraController.focusOnGame).thenAnswer((_) async {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when(() => overlays.remove(any())).thenAnswer((_) => true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when(() => game.descendants().whereType<Backbox>())
|
|
|
|
|
|
|
|
.thenReturn([backbox]);
|
|
|
|
|
|
|
|
when(game.firstChild<CameraController>).thenReturn(cameraController);
|
|
|
|
|
|
|
|
when(() => game.overlays).thenReturn(overlays);
|
|
|
|
|
|
|
|
when(() => game.characterTheme).thenReturn(DashTheme());
|
|
|
|
|
|
|
|
when(() => game.audio).thenReturn(pinballAudio);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test(
|
|
|
|
|
|
|
|
'changes the backbox display and camera correctly '
|
|
|
|
|
|
|
|
'when the game is over',
|
|
|
|
|
|
|
|
() {
|
|
|
|
|
|
|
|
final state = GameState(
|
|
|
|
|
|
|
|
totalScore: 0,
|
|
|
|
|
|
|
|
roundScore: 10,
|
|
|
|
|
|
|
|
multiplier: 1,
|
|
|
|
|
|
|
|
rounds: 0,
|
|
|
|
|
|
|
|
bonusHistory: const [],
|
|
|
|
|
|
|
|
status: GameStatus.gameOver,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
gameFlowController.onNewState(state);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
verify(
|
|
|
|
() => backbox.initialsInput(
|
|
|
|
() => backbox.initialsInput(
|
|
|
|
score: any(named: 'score'),
|
|
|
|
score: state.displayScore,
|
|
|
|
characterIconPath: any(named: 'characterIconPath'),
|
|
|
|
characterIconPath: any(named: 'characterIconPath'),
|
|
|
|
onSubmit: any(named: 'onSubmit'),
|
|
|
|
onSubmit: any(named: 'onSubmit'),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
).thenAnswer((_) async {});
|
|
|
|
).called(1);
|
|
|
|
when(cameraController.focusOnWaitingBackbox).thenAnswer((_) async {});
|
|
|
|
verify(cameraController.focusOnGameOverBackbox).called(1);
|
|
|
|
when(cameraController.focusOnGame).thenAnswer((_) async {});
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
when(() => overlays.remove(any())).thenAnswer((_) => true);
|
|
|
|
|
|
|
|
|
|
|
|
test(
|
|
|
|
when(() => game.descendants().whereType<Backbox>())
|
|
|
|
'changes the backbox and camera correctly when it is not a game over',
|
|
|
|
.thenReturn([backbox]);
|
|
|
|
() {
|
|
|
|
when(game.firstChild<CameraController>).thenReturn(cameraController);
|
|
|
|
gameFlowController.onNewState(
|
|
|
|
when(() => game.overlays).thenReturn(overlays);
|
|
|
|
GameState.initial().copyWith(status: GameStatus.playing),
|
|
|
|
when(() => game.characterTheme).thenReturn(DashTheme());
|
|
|
|
);
|
|
|
|
when(() => game.audio).thenReturn(pinballAudio);
|
|
|
|
|
|
|
|
});
|
|
|
|
verify(cameraController.focusOnGame).called(1);
|
|
|
|
|
|
|
|
verify(() => overlays.remove(PinballGame.playButtonOverlay))
|
|
|
|
test(
|
|
|
|
.called(1);
|
|
|
|
'changes the backbox display and camera correctly '
|
|
|
|
},
|
|
|
|
'when the game is over',
|
|
|
|
);
|
|
|
|
() {
|
|
|
|
|
|
|
|
final state = GameState(
|
|
|
|
test(
|
|
|
|
totalScore: 0,
|
|
|
|
'plays the background music on start',
|
|
|
|
roundScore: 10,
|
|
|
|
() {
|
|
|
|
multiplier: 1,
|
|
|
|
gameFlowController.onNewState(
|
|
|
|
rounds: 0,
|
|
|
|
GameState.initial().copyWith(status: GameStatus.playing),
|
|
|
|
bonusHistory: const [],
|
|
|
|
);
|
|
|
|
status: GameStatus.gameOver,
|
|
|
|
|
|
|
|
);
|
|
|
|
verify(pinballAudio.backgroundMusic).called(1);
|
|
|
|
gameFlowController.onNewState(state);
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
verify(
|
|
|
|
|
|
|
|
() => backbox.initialsInput(
|
|
|
|
|
|
|
|
score: state.displayScore,
|
|
|
|
|
|
|
|
characterIconPath: any(named: 'characterIconPath'),
|
|
|
|
|
|
|
|
onSubmit: any(named: 'onSubmit'),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
).called(1);
|
|
|
|
|
|
|
|
verify(cameraController.focusOnGameOverBackbox).called(1);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test(
|
|
|
|
|
|
|
|
'changes the backbox and camera correctly when it is not a game over',
|
|
|
|
|
|
|
|
() {
|
|
|
|
|
|
|
|
gameFlowController.onNewState(
|
|
|
|
|
|
|
|
GameState.initial().copyWith(status: GameStatus.playing),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
verify(cameraController.focusOnGame).called(1);
|
|
|
|
|
|
|
|
verify(() => overlays.remove(PinballGame.playButtonOverlay))
|
|
|
|
|
|
|
|
.called(1);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test(
|
|
|
|
|
|
|
|
'plays the background music on start',
|
|
|
|
|
|
|
|
() {
|
|
|
|
|
|
|
|
gameFlowController.onNewState(
|
|
|
|
|
|
|
|
GameState.initial().copyWith(status: GameStatus.playing),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
verify(pinballAudio.backgroundMusic).called(1);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|