|
|
@ -5,40 +5,46 @@ import 'package:flame/game.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
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_theme/pinball_theme.dart';
|
|
|
|
import 'package:pinball/theme/theme.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../../helpers/helpers.dart';
|
|
|
|
import '../../helpers/helpers.dart';
|
|
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
void main() {
|
|
|
|
const theme = PinballTheme(characterTheme: DashTheme());
|
|
|
|
|
|
|
|
final game = PinballTestGame();
|
|
|
|
final game = PinballTestGame();
|
|
|
|
|
|
|
|
|
|
|
|
group('PinballGamePage', () {
|
|
|
|
group('PinballGamePage', () {
|
|
|
|
testWidgets('renders PinballGameView', (tester) async {
|
|
|
|
late ThemeCubit themeCubit;
|
|
|
|
final gameBloc = MockGameBloc();
|
|
|
|
late GameBloc gameBloc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setUp(() {
|
|
|
|
|
|
|
|
themeCubit = MockThemeCubit();
|
|
|
|
|
|
|
|
gameBloc = MockGameBloc();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
whenListen(
|
|
|
|
|
|
|
|
themeCubit,
|
|
|
|
|
|
|
|
const Stream<ThemeState>.empty(),
|
|
|
|
|
|
|
|
initialState: const ThemeState.initial(),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
whenListen(
|
|
|
|
whenListen(
|
|
|
|
gameBloc,
|
|
|
|
gameBloc,
|
|
|
|
Stream.value(const GameState.initial()),
|
|
|
|
Stream.value(const GameState.initial()),
|
|
|
|
initialState: const GameState.initial(),
|
|
|
|
initialState: const GameState.initial(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testWidgets('renders PinballGameView', (tester) async {
|
|
|
|
await tester.pumpApp(
|
|
|
|
await tester.pumpApp(
|
|
|
|
PinballGamePage(theme: theme, game: game),
|
|
|
|
PinballGamePage(),
|
|
|
|
gameBloc: gameBloc,
|
|
|
|
themeCubit: themeCubit,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
expect(find.byType(PinballGameView), findsOneWidget);
|
|
|
|
expect(find.byType(PinballGameView), findsOneWidget);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
testWidgets(
|
|
|
|
testWidgets(
|
|
|
|
'renders the loading indicator while the assets load',
|
|
|
|
'renders the loading indicator while the assets load',
|
|
|
|
(tester) async {
|
|
|
|
(tester) async {
|
|
|
|
final gameBloc = MockGameBloc();
|
|
|
|
|
|
|
|
whenListen(
|
|
|
|
|
|
|
|
gameBloc,
|
|
|
|
|
|
|
|
Stream.value(const GameState.initial()),
|
|
|
|
|
|
|
|
initialState: const GameState.initial(),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final assetsManagerCubit = MockAssetsManagerCubit();
|
|
|
|
final assetsManagerCubit = MockAssetsManagerCubit();
|
|
|
|
final initialAssetsState = AssetsManagerState(
|
|
|
|
final initialAssetsState = AssetsManagerState(
|
|
|
|
loadables: [Future<void>.value()],
|
|
|
|
loadables: [Future<void>.value()],
|
|
|
@ -51,11 +57,21 @@ void main() {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
await tester.pumpApp(
|
|
|
|
await tester.pumpApp(
|
|
|
|
PinballGamePage(theme: theme, game: game),
|
|
|
|
PinballGameView(
|
|
|
|
gameBloc: gameBloc,
|
|
|
|
game: game,
|
|
|
|
|
|
|
|
),
|
|
|
|
assetsManagerCubit: assetsManagerCubit,
|
|
|
|
assetsManagerCubit: assetsManagerCubit,
|
|
|
|
|
|
|
|
themeCubit: themeCubit,
|
|
|
|
|
|
|
|
gameBloc: gameBloc,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
|
|
|
find.byWidgetPredicate(
|
|
|
|
|
|
|
|
(widget) =>
|
|
|
|
|
|
|
|
widget is LinearProgressIndicator && widget.value == 0.0,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
findsOneWidget,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
expect(find.text('0.0'), findsOneWidget);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final loadedAssetsState = AssetsManagerState(
|
|
|
|
final loadedAssetsState = AssetsManagerState(
|
|
|
|
loadables: [Future<void>.value()],
|
|
|
|
loadables: [Future<void>.value()],
|
|
|
@ -68,7 +84,8 @@ void main() {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
await tester.pump();
|
|
|
|
await tester.pump();
|
|
|
|
expect(find.byType(PinballGameView), findsOneWidget);
|
|
|
|
|
|
|
|
|
|
|
|
expect(find.byType(PinballGameBody), findsOneWidget);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
@ -85,7 +102,6 @@ void main() {
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).push<void>(
|
|
|
|
Navigator.of(context).push<void>(
|
|
|
|
PinballGamePage.route(
|
|
|
|
PinballGamePage.route(
|
|
|
|
theme: theme,
|
|
|
|
|
|
|
|
isDebugMode: isDebugMode,
|
|
|
|
isDebugMode: isDebugMode,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -95,6 +111,7 @@ void main() {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
themeCubit: themeCubit,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
await tester.tap(find.text('Tap me'));
|
|
|
|
await tester.tap(find.text('Tap me'));
|
|
|
|