|
|
|
@ -22,25 +22,19 @@ void main() {
|
|
|
|
|
() => EmptyPinballTestGame(assets: assets),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
group('FlipperController', () {
|
|
|
|
|
late GameBloc gameBloc;
|
|
|
|
|
|
|
|
|
|
setUp(() {
|
|
|
|
|
gameBloc = _MockGameBloc();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
final flameBlocTester = FlameBlocTester<EmptyPinballTestGame, GameBloc>(
|
|
|
|
|
gameBuilder: EmptyPinballTestGame.new,
|
|
|
|
|
blocBuilder: () {
|
|
|
|
|
final bloc = _MockGameBloc();
|
|
|
|
|
const state = GameState(
|
|
|
|
|
totalScore: 0,
|
|
|
|
|
roundScore: 0,
|
|
|
|
|
multiplier: 1,
|
|
|
|
|
rounds: 0,
|
|
|
|
|
bonusHistory: [],
|
|
|
|
|
status: GameStatus.playing,
|
|
|
|
|
);
|
|
|
|
|
whenListen(bloc, Stream.value(state), initialState: state);
|
|
|
|
|
return bloc;
|
|
|
|
|
},
|
|
|
|
|
blocBuilder: () => gameBloc,
|
|
|
|
|
assets: assets,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
group('FlipperController', () {
|
|
|
|
|
group('onKeyEvent', () {
|
|
|
|
|
final leftKeys = UnmodifiableListView([
|
|
|
|
|
LogicalKeyboardKey.arrowLeft,
|
|
|
|
@ -66,6 +60,12 @@ void main() {
|
|
|
|
|
'moves upwards '
|
|
|
|
|
'when ${event.logicalKey.keyLabel} is pressed',
|
|
|
|
|
(game) async {
|
|
|
|
|
whenListen(
|
|
|
|
|
gameBloc,
|
|
|
|
|
const Stream<GameState>.empty(),
|
|
|
|
|
initialState: const GameState.initial(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
await game.add(flipper);
|
|
|
|
|
controller.onKeyEvent(event, {});
|
|
|
|
@ -80,6 +80,14 @@ void main() {
|
|
|
|
|
flameBlocTester.testGameWidget(
|
|
|
|
|
'does nothing when is game over',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
whenListen(
|
|
|
|
|
gameBloc,
|
|
|
|
|
const Stream<GameState>.empty(),
|
|
|
|
|
initialState: const GameState.initial().copyWith(
|
|
|
|
|
status: GameStatus.gameOver,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await game.ensureAdd(flipper);
|
|
|
|
|
controller.onKeyEvent(event, {});
|
|
|
|
|
},
|
|
|
|
@ -95,6 +103,12 @@ void main() {
|
|
|
|
|
'moves downwards '
|
|
|
|
|
'when ${event.logicalKey.keyLabel} is released',
|
|
|
|
|
(game) async {
|
|
|
|
|
whenListen(
|
|
|
|
|
gameBloc,
|
|
|
|
|
const Stream<GameState>.empty(),
|
|
|
|
|
initialState: const GameState.initial(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
await game.add(flipper);
|
|
|
|
|
controller.onKeyEvent(event, {});
|
|
|
|
@ -110,6 +124,12 @@ void main() {
|
|
|
|
|
'does nothing '
|
|
|
|
|
'when ${event.logicalKey.keyLabel} is released',
|
|
|
|
|
(game) async {
|
|
|
|
|
whenListen(
|
|
|
|
|
gameBloc,
|
|
|
|
|
const Stream<GameState>.empty(),
|
|
|
|
|
initialState: const GameState.initial(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
await game.add(flipper);
|
|
|
|
|
controller.onKeyEvent(event, {});
|
|
|
|
@ -136,6 +156,12 @@ void main() {
|
|
|
|
|
'moves upwards '
|
|
|
|
|
'when ${event.logicalKey.keyLabel} is pressed',
|
|
|
|
|
(game) async {
|
|
|
|
|
whenListen(
|
|
|
|
|
gameBloc,
|
|
|
|
|
const Stream<GameState>.empty(),
|
|
|
|
|
initialState: const GameState.initial(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
await game.add(flipper);
|
|
|
|
|
controller.onKeyEvent(event, {});
|
|
|
|
@ -151,6 +177,12 @@ void main() {
|
|
|
|
|
'moves downwards '
|
|
|
|
|
'when ${event.logicalKey.keyLabel} is released',
|
|
|
|
|
(game) async {
|
|
|
|
|
whenListen(
|
|
|
|
|
gameBloc,
|
|
|
|
|
const Stream<GameState>.empty(),
|
|
|
|
|
initialState: const GameState.initial(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await game.ready();
|
|
|
|
|
await game.add(flipper);
|
|
|
|
|
controller.onKeyEvent(event, {});
|
|
|
|
@ -165,6 +197,14 @@ void main() {
|
|
|
|
|
flameBlocTester.testGameWidget(
|
|
|
|
|
'does nothing when is game over',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
whenListen(
|
|
|
|
|
gameBloc,
|
|
|
|
|
const Stream<GameState>.empty(),
|
|
|
|
|
initialState: const GameState.initial().copyWith(
|
|
|
|
|
status: GameStatus.gameOver,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await game.ensureAdd(flipper);
|
|
|
|
|
controller.onKeyEvent(event, {});
|
|
|
|
|
},
|
|
|
|
|