feat: CharacterSelectionPage opens how to play dialog

pull/195/head
arturplaczek 3 years ago
parent d3e9519b02
commit 446f782abb

@ -2,8 +2,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pinball/game/game.dart';
import 'package:pinball/l10n/l10n.dart'; import 'package:pinball/l10n/l10n.dart';
import 'package:pinball/start_game/start_game.dart';
import 'package:pinball/theme/theme.dart'; import 'package:pinball/theme/theme.dart';
import 'package:pinball_theme/pinball_theme.dart'; import 'package:pinball_theme/pinball_theme.dart';
@ -46,11 +46,13 @@ class CharacterSelectionView extends StatelessWidget {
const _CharacterSelectionGridView(), const _CharacterSelectionGridView(),
const SizedBox(height: 20), const SizedBox(height: 20),
TextButton( TextButton(
onPressed: () => Navigator.of(context).push<void>( onPressed: () {
PinballGamePage.route( Navigator.of(context).pop();
theme: context.read<ThemeCubit>().state.theme, showDialog<void>(
), context: context,
), builder: (_) => const HowToPlayDialog(),
);
},
child: Text(l10n.start), child: Text(l10n.start),
), ),
], ],

@ -4,6 +4,7 @@ import 'package:bloc_test/bloc_test.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:mockingjay/mockingjay.dart'; import 'package:mockingjay/mockingjay.dart';
import 'package:pinball/start_game/start_game.dart';
import 'package:pinball/theme/theme.dart'; import 'package:pinball/theme/theme.dart';
import 'package:pinball_theme/pinball_theme.dart'; import 'package:pinball_theme/pinball_theme.dart';
@ -82,20 +83,17 @@ void main() {
verify(() => themeCubit.characterSelected(SparkyTheme())).called(1); verify(() => themeCubit.characterSelected(SparkyTheme())).called(1);
}); });
testWidgets('navigates to PinballGamePage when start is tapped', testWidgets('is showing how to play dialog when start is tapped',
(tester) async { (tester) async {
final navigator = MockNavigator();
when(() => navigator.push<void>(any())).thenAnswer((_) async {});
await tester.pumpApp( await tester.pumpApp(
CharacterSelectionView(), CharacterSelectionView(),
themeCubit: themeCubit, themeCubit: themeCubit,
navigator: navigator,
); );
await tester.ensureVisible(find.byType(TextButton)); await tester.ensureVisible(find.byType(TextButton));
await tester.tap(find.byType(TextButton)); await tester.tap(find.byType(TextButton));
await tester.pumpAndSettle();
verify(() => navigator.push<void>(any())).called(1); expect(find.byType(HowToPlayDialog), findsOneWidget);
}); });
}); });

Loading…
Cancel
Save