diff --git a/lib/select_character/view/character_selection_page.dart b/lib/select_character/view/character_selection_page.dart index 8f26815b..8f02557c 100644 --- a/lib/select_character/view/character_selection_page.dart +++ b/lib/select_character/view/character_selection_page.dart @@ -1,5 +1,7 @@ // ignore_for_file: public_member_api_docs +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:pinball/l10n/l10n.dart'; @@ -47,10 +49,20 @@ class CharacterSelectionView extends StatelessWidget { TextButton( onPressed: () { Navigator.of(context).pop(); + late Timer timer; showDialog( context: context, - builder: (_) => const HowToPlayDialog(), - ); + builder: (context) { + timer = Timer(const Duration(seconds: 3), () { + Navigator.of(context).pop(); + }); + return const HowToPlayDialog(); + }, + ).then((_) { + if (timer.isActive) { + timer.cancel(); + } + }); }, child: Text(l10n.start), ), diff --git a/test/select_character/view/character_selection_page_test.dart b/test/select_character/view/character_selection_page_test.dart index 0dda92d7..48179f34 100644 --- a/test/select_character/view/character_selection_page_test.dart +++ b/test/select_character/view/character_selection_page_test.dart @@ -1,5 +1,7 @@ // ignore_for_file: prefer_const_constructors +import 'dart:async'; + import 'package:bloc_test/bloc_test.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -84,18 +86,22 @@ void main() { .called(1); }); - testWidgets('displays how to play dialog when start is tapped', - (tester) async { - await tester.pumpApp( - CharacterSelectionView(), - characterThemeCubit: characterThemeCubit, - ); - await tester.ensureVisible(find.byType(TextButton)); - await tester.tap(find.byType(TextButton)); - await tester.pumpAndSettle(); - - expect(find.byType(HowToPlayDialog), findsOneWidget); - }); + testWidgets( + 'displays how to play dialog for 3 seconds when start is tapped', + (tester) async { + await tester.pumpApp( + CharacterSelectionView(), + characterThemeCubit: characterThemeCubit, + ); + await tester.ensureVisible(find.byType(TextButton)); + await tester.tap(find.byType(TextButton)); + await tester.pumpAndSettle(); + expect(find.byType(HowToPlayDialog), findsOneWidget); + await tester.pump(Duration(seconds: 3)); + await tester.pumpAndSettle(); + expect(find.byType(HowToPlayDialog), findsNothing); + }, + ); }); testWidgets('CharacterImageButton renders correctly', (tester) async {