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_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<void>(
PinballGamePage.route(
theme: context.read<ThemeCubit>().state.theme,
),
),
onPressed: () {
Navigator.of(context).pop();
showDialog<void>(
context: context,
builder: (_) => const HowToPlayDialog(),
);
},
child: Text(l10n.start),
),
],

@ -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<void>(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<void>(any())).called(1);
expect(find.byType(HowToPlayDialog), findsOneWidget);
});
});

Loading…
Cancel
Save