test: added test for barrier dismiss on tap

pull/251/head
Jonathan Daniels 3 years ago
parent 026e044634
commit 1e93d91bfc

@ -86,22 +86,55 @@ void main() {
.called(1); .called(1);
}); });
testWidgets( group('HowToPlayDialog', () {
'displays how to play dialog for 3 seconds when start is tapped', testWidgets(
(tester) async { 'is displayed for 3 seconds when start is tapped',
await tester.pumpApp( (tester) async {
CharacterSelectionView(), await tester.pumpApp(
characterThemeCubit: characterThemeCubit, CharacterSelectionView(),
); characterThemeCubit: characterThemeCubit,
await tester.ensureVisible(find.byType(TextButton)); );
await tester.tap(find.byType(TextButton)); await tester.ensureVisible(find.byType(TextButton));
await tester.pumpAndSettle(); await tester.tap(find.byType(TextButton));
expect(find.byType(HowToPlayDialog), findsOneWidget); await tester.pumpAndSettle();
await tester.pump(Duration(seconds: 3)); expect(find.byType(HowToPlayDialog), findsOneWidget);
await tester.pumpAndSettle(); await tester.pump(Duration(seconds: 3));
expect(find.byType(HowToPlayDialog), findsNothing); await tester.pumpAndSettle();
}, expect(find.byType(HowToPlayDialog), findsNothing);
); },
);
testWidgets(
'can be dismissed manually before 3 seconds have passed',
(tester) async {
await tester.pumpApp(
Scaffold(
body: Builder(
builder: (context) {
return ElevatedButton(
onPressed: () {
Navigator.of(context)
.push<void>(CharacterSelectionDialog.route());
},
child: Text('Tap me'),
);
},
),
),
characterThemeCubit: characterThemeCubit,
);
await tester.tap(find.text('Tap me'));
await tester.pumpAndSettle();
await tester.ensureVisible(find.byType(TextButton));
await tester.tap(find.byType(TextButton));
await tester.pumpAndSettle();
expect(find.byType(HowToPlayDialog), findsOneWidget);
await tester.tapAt(Offset(1, 1));
await tester.pumpAndSettle();
expect(find.byType(HowToPlayDialog), findsNothing);
},
);
});
}); });
testWidgets('CharacterImageButton renders correctly', (tester) async { testWidgets('CharacterImageButton renders correctly', (tester) async {

Loading…
Cancel
Save