From 446f782abb407fba2b26973c6482406d2ac60bbe Mon Sep 17 00:00:00 2001 From: arturplaczek Date: Fri, 15 Apr 2022 14:01:56 +0200 Subject: [PATCH] feat: CharacterSelectionPage opens how to play dialog --- lib/theme/view/character_selection_page.dart | 14 ++++++++------ test/theme/view/character_selection_page_test.dart | 10 ++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/theme/view/character_selection_page.dart b/lib/theme/view/character_selection_page.dart index 119a897e..8aa5368c 100644 --- a/lib/theme/view/character_selection_page.dart +++ b/lib/theme/view/character_selection_page.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:pinball/game/game.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/pinball_theme.dart'; @@ -46,11 +46,13 @@ class CharacterSelectionView extends StatelessWidget { const _CharacterSelectionGridView(), const SizedBox(height: 20), TextButton( - onPressed: () => Navigator.of(context).push( - PinballGamePage.route( - theme: context.read().state.theme, - ), - ), + onPressed: () { + Navigator.of(context).pop(); + showDialog( + context: context, + builder: (_) => const HowToPlayDialog(), + ); + }, child: Text(l10n.start), ), ], diff --git a/test/theme/view/character_selection_page_test.dart b/test/theme/view/character_selection_page_test.dart index eeac690f..e3543c4b 100644 --- a/test/theme/view/character_selection_page_test.dart +++ b/test/theme/view/character_selection_page_test.dart @@ -4,6 +4,7 @@ import 'package:bloc_test/bloc_test.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockingjay/mockingjay.dart'; +import 'package:pinball/start_game/start_game.dart'; import 'package:pinball/theme/theme.dart'; import 'package:pinball_theme/pinball_theme.dart'; @@ -82,20 +83,17 @@ void main() { 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 { - final navigator = MockNavigator(); - when(() => navigator.push(any())).thenAnswer((_) async {}); - await tester.pumpApp( CharacterSelectionView(), themeCubit: themeCubit, - navigator: navigator, ); await tester.ensureVisible(find.byType(TextButton)); await tester.tap(find.byType(TextButton)); + await tester.pumpAndSettle(); - verify(() => navigator.push(any())).called(1); + expect(find.byType(HowToPlayDialog), findsOneWidget); }); });