mirror of https://github.com/flutter/pinball.git
feat: change screens flow (#195)
parent
12d20b8dbc
commit
35c23140b5
Before Width: | Height: | Size: 3.2 MiB After Width: | Height: | Size: 2.2 MiB |
@ -1 +0,0 @@
|
||||
export 'view/landing_page.dart';
|
@ -1 +1,2 @@
|
||||
export 'bloc/start_game_bloc.dart';
|
||||
export 'widgets/widgets.dart';
|
||||
|
@ -0,0 +1 @@
|
||||
export 'how_to_play_dialog.dart';
|
@ -1,71 +0,0 @@
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockingjay/mockingjay.dart';
|
||||
import 'package:pinball/l10n/l10n.dart';
|
||||
import 'package:pinball/landing/landing.dart';
|
||||
|
||||
import '../../helpers/helpers.dart';
|
||||
|
||||
void main() {
|
||||
group('LandingPage', () {
|
||||
testWidgets('renders correctly', (tester) async {
|
||||
final l10n = await AppLocalizations.delegate.load(Locale('en'));
|
||||
await tester.pumpApp(LandingPage());
|
||||
|
||||
expect(find.byType(TextButton), findsNWidgets(2));
|
||||
expect(find.text(l10n.play), findsOneWidget);
|
||||
expect(find.text(l10n.howToPlay), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('tapping on play button navigates to CharacterSelectionPage',
|
||||
(tester) async {
|
||||
final l10n = await AppLocalizations.delegate.load(Locale('en'));
|
||||
final navigator = MockNavigator();
|
||||
when(() => navigator.push<void>(any())).thenAnswer((_) async {});
|
||||
|
||||
await tester.pumpApp(
|
||||
LandingPage(),
|
||||
navigator: navigator,
|
||||
);
|
||||
|
||||
await tester.tap(find.widgetWithText(TextButton, l10n.play));
|
||||
|
||||
verify(() => navigator.push<void>(any())).called(1);
|
||||
});
|
||||
|
||||
testWidgets('tapping on how to play button displays dialog with controls',
|
||||
(tester) async {
|
||||
final l10n = await AppLocalizations.delegate.load(Locale('en'));
|
||||
await tester.pumpApp(LandingPage());
|
||||
|
||||
await tester.tap(find.widgetWithText(TextButton, l10n.howToPlay));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(Dialog), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
group('KeyIndicator', () {
|
||||
testWidgets('fromKeyName renders correctly', (tester) async {
|
||||
const keyName = 'A';
|
||||
|
||||
await tester.pumpApp(
|
||||
KeyIndicator.fromKeyName(keyName: keyName),
|
||||
);
|
||||
|
||||
expect(find.text(keyName), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('fromIcon renders correctly', (tester) async {
|
||||
const keyIcon = Icons.keyboard_arrow_down;
|
||||
|
||||
await tester.pumpApp(
|
||||
KeyIndicator.fromIcon(keyIcon: keyIcon),
|
||||
);
|
||||
|
||||
expect(find.byIcon(keyIcon), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pinball/start_game/start_game.dart';
|
||||
|
||||
import '../../helpers/helpers.dart';
|
||||
|
||||
void main() {
|
||||
group('HowToPlayDialog', () {
|
||||
testWidgets('displays dialog', (tester) async {
|
||||
await tester.pumpApp(HowToPlayDialog());
|
||||
|
||||
expect(find.byType(Dialog), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
group('KeyIndicator', () {
|
||||
testWidgets('fromKeyName renders correctly', (tester) async {
|
||||
const keyName = 'A';
|
||||
|
||||
await tester.pumpApp(
|
||||
KeyIndicator.fromKeyName(keyName: keyName),
|
||||
);
|
||||
|
||||
expect(find.text(keyName), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('fromIcon renders correctly', (tester) async {
|
||||
const keyIcon = Icons.keyboard_arrow_down;
|
||||
|
||||
await tester.pumpApp(
|
||||
KeyIndicator.fromIcon(keyIcon: keyIcon),
|
||||
);
|
||||
|
||||
expect(find.byIcon(keyIcon), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in new issue