|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import 'dart:collection';
|
|
|
|
|
|
|
|
|
|
import 'package:bloc_test/bloc_test.dart';
|
|
|
|
|
import 'package:flame_test/flame_test.dart';
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
@ -12,6 +13,22 @@ void main() {
|
|
|
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
final flameTester = FlameTester(EmptyPinballGameTest.new);
|
|
|
|
|
|
|
|
|
|
final gameOverBlocTester = FlameBlocTester<EmptyPinballGameTest, GameBloc>(
|
|
|
|
|
gameBuilder: EmptyPinballGameTest.new,
|
|
|
|
|
blocBuilder: () {
|
|
|
|
|
final bloc = MockGameBloc();
|
|
|
|
|
const state = GameState(
|
|
|
|
|
score: 0,
|
|
|
|
|
balls: 0,
|
|
|
|
|
bonusHistory: [],
|
|
|
|
|
activatedBonusLetters: [],
|
|
|
|
|
activatedDashNests: {},
|
|
|
|
|
);
|
|
|
|
|
whenListen(bloc, Stream.value(state), initialState: state);
|
|
|
|
|
return bloc;
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
group('FlipperController', () {
|
|
|
|
|
group('onKeyEvent', () {
|
|
|
|
|
final leftKeys = UnmodifiableListView([
|
|
|
|
@ -48,6 +65,20 @@ void main() {
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testRawKeyDownEvents(leftKeys, (event) {
|
|
|
|
|
gameOverBlocTester.testGameWidget(
|
|
|
|
|
'does nothing when is game over',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
await game.ensureAdd(flipper);
|
|
|
|
|
controller.onKeyEvent(event, {});
|
|
|
|
|
},
|
|
|
|
|
verify: (game, tester) async {
|
|
|
|
|
expect(flipper.body.linearVelocity.y, isZero);
|
|
|
|
|
expect(flipper.body.linearVelocity.x, isZero);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testRawKeyUpEvents(leftKeys, (event) {
|
|
|
|
|
flameTester.test(
|
|
|
|
|
'moves downwards '
|
|
|
|
@ -119,6 +150,20 @@ void main() {
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testRawKeyDownEvents(rightKeys, (event) {
|
|
|
|
|
gameOverBlocTester.testGameWidget(
|
|
|
|
|
'does nothing when is game over',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
await game.ensureAdd(flipper);
|
|
|
|
|
controller.onKeyEvent(event, {});
|
|
|
|
|
},
|
|
|
|
|
verify: (game, tester) async {
|
|
|
|
|
expect(flipper.body.linearVelocity.y, isZero);
|
|
|
|
|
expect(flipper.body.linearVelocity.x, isZero);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testRawKeyUpEvents(leftKeys, (event) {
|
|
|
|
|
flameTester.test(
|
|
|
|
|
'does nothing '
|
|
|
|
|