|
|
@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:pinball/game/game.dart';
|
|
|
|
import 'package:pinball/game/game.dart';
|
|
|
|
import 'package:pinball/select_character/select_character.dart';
|
|
|
|
import 'package:pinball/select_character/select_character.dart';
|
|
|
|
|
|
|
|
import 'package:pinball/start_game/start_game.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../../helpers/helpers.dart';
|
|
|
|
import '../../helpers/helpers.dart';
|
|
|
|
|
|
|
|
|
|
|
@ -79,6 +80,7 @@ void main() {
|
|
|
|
'renders PinballGameLoadedView after resources have been loaded',
|
|
|
|
'renders PinballGameLoadedView after resources have been loaded',
|
|
|
|
(tester) async {
|
|
|
|
(tester) async {
|
|
|
|
final assetsManagerCubit = MockAssetsManagerCubit();
|
|
|
|
final assetsManagerCubit = MockAssetsManagerCubit();
|
|
|
|
|
|
|
|
final startGameBloc = MockStartGameBloc();
|
|
|
|
|
|
|
|
|
|
|
|
final loadedAssetsState = AssetsManagerState(
|
|
|
|
final loadedAssetsState = AssetsManagerState(
|
|
|
|
loadables: [Future<void>.value()],
|
|
|
|
loadables: [Future<void>.value()],
|
|
|
@ -89,6 +91,11 @@ void main() {
|
|
|
|
Stream.value(loadedAssetsState),
|
|
|
|
Stream.value(loadedAssetsState),
|
|
|
|
initialState: loadedAssetsState,
|
|
|
|
initialState: loadedAssetsState,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
whenListen(
|
|
|
|
|
|
|
|
startGameBloc,
|
|
|
|
|
|
|
|
Stream.value(StartGameState.initial()),
|
|
|
|
|
|
|
|
initialState: StartGameState.initial(),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
await tester.pumpApp(
|
|
|
|
await tester.pumpApp(
|
|
|
|
PinballGameView(
|
|
|
|
PinballGameView(
|
|
|
@ -97,6 +104,7 @@ void main() {
|
|
|
|
assetsManagerCubit: assetsManagerCubit,
|
|
|
|
assetsManagerCubit: assetsManagerCubit,
|
|
|
|
characterThemeCubit: characterThemeCubit,
|
|
|
|
characterThemeCubit: characterThemeCubit,
|
|
|
|
gameBloc: gameBloc,
|
|
|
|
gameBloc: gameBloc,
|
|
|
|
|
|
|
|
startGameBloc: startGameBloc,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
await tester.pump();
|
|
|
|
await tester.pump();
|
|
|
@ -160,27 +168,59 @@ void main() {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
group('PinballGameView', () {
|
|
|
|
group('PinballGameView', () {
|
|
|
|
|
|
|
|
final gameBloc = MockGameBloc();
|
|
|
|
|
|
|
|
final startGameBloc = MockStartGameBloc();
|
|
|
|
|
|
|
|
|
|
|
|
setUp(() async {
|
|
|
|
setUp(() async {
|
|
|
|
await Future.wait<void>(game.preLoadAssets());
|
|
|
|
await Future.wait<void>(game.preLoadAssets());
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testWidgets('renders game and a hud', (tester) async {
|
|
|
|
|
|
|
|
final gameBloc = MockGameBloc();
|
|
|
|
|
|
|
|
whenListen(
|
|
|
|
whenListen(
|
|
|
|
gameBloc,
|
|
|
|
gameBloc,
|
|
|
|
Stream.value(const GameState.initial()),
|
|
|
|
Stream.value(const GameState.initial()),
|
|
|
|
initialState: const GameState.initial(),
|
|
|
|
initialState: const GameState.initial(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
whenListen(
|
|
|
|
|
|
|
|
startGameBloc,
|
|
|
|
|
|
|
|
Stream.value(StartGameState.initial()),
|
|
|
|
|
|
|
|
initialState: StartGameState.initial(),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testWidgets('renders game', (tester) async {
|
|
|
|
await tester.pumpApp(
|
|
|
|
await tester.pumpApp(
|
|
|
|
PinballGameView(game: game),
|
|
|
|
PinballGameView(game: game),
|
|
|
|
gameBloc: gameBloc,
|
|
|
|
gameBloc: gameBloc,
|
|
|
|
|
|
|
|
startGameBloc: startGameBloc,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
expect(
|
|
|
|
find.byWidgetPredicate((w) => w is GameWidget<PinballGame>),
|
|
|
|
find.byWidgetPredicate((w) => w is GameWidget<PinballGame>),
|
|
|
|
findsOneWidget,
|
|
|
|
findsOneWidget,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
|
|
|
find.byType(GameHud),
|
|
|
|
|
|
|
|
findsNothing,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testWidgets('renders a hud on play state', (tester) async {
|
|
|
|
|
|
|
|
final startGameState = StartGameState.initial().copyWith(
|
|
|
|
|
|
|
|
status: StartGameStatus.play,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
whenListen(
|
|
|
|
|
|
|
|
startGameBloc,
|
|
|
|
|
|
|
|
Stream.value(startGameState),
|
|
|
|
|
|
|
|
initialState: startGameState,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await tester.pumpApp(
|
|
|
|
|
|
|
|
PinballGameView(game: game),
|
|
|
|
|
|
|
|
gameBloc: gameBloc,
|
|
|
|
|
|
|
|
startGameBloc: startGameBloc,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
expect(
|
|
|
|
find.byType(GameHud),
|
|
|
|
find.byType(GameHud),
|
|
|
|
findsOneWidget,
|
|
|
|
findsOneWidget,
|
|
|
|