test: made overlays test more robust

fix/remove-overlay-flaky-test
alestiago 3 years ago
parent 175c091101
commit 7e0d2c6cac

@ -302,15 +302,16 @@ void main() {
}); });
testWidgets('mobile controls when the overlay is added', (tester) async { testWidgets('mobile controls when the overlay is added', (tester) async {
const targetOverlay = PinballGame.mobileControlsOverlay;
await tester.pumpApp( await tester.pumpApp(
PinballGameView(game), PinballGameView(game),
gameBloc: gameBloc, gameBloc: gameBloc,
startGameBloc: startGameBloc, startGameBloc: startGameBloc,
); );
game.overlays.remove(PinballGame.playButtonOverlay); game.overlays.clear();
game.overlays.add(PinballGame.mobileControlsOverlay); await tester.pump();
game.overlays.add(targetOverlay);
await tester.pump(); await tester.pump();
expect(find.byType(MobileControls), findsOneWidget); expect(find.byType(MobileControls), findsOneWidget);
@ -319,15 +320,16 @@ void main() {
testWidgets( testWidgets(
'ReplayButtonOverlay when the overlay is added', 'ReplayButtonOverlay when the overlay is added',
(tester) async { (tester) async {
const targetOverlay = PinballGame.replayButtonOverlay;
await tester.pumpApp( await tester.pumpApp(
PinballGameView(game), PinballGameView(game),
gameBloc: gameBloc, gameBloc: gameBloc,
startGameBloc: startGameBloc, startGameBloc: startGameBloc,
); );
game.overlays.remove(PinballGame.playButtonOverlay); game.overlays.clear();
game.overlays.add(PinballGame.replayButtonOverlay); await tester.pump();
game.overlays.add(targetOverlay);
await tester.pump(); await tester.pump();
expect(find.byType(ReplayButtonOverlay), findsOneWidget); expect(find.byType(ReplayButtonOverlay), findsOneWidget);

Loading…
Cancel
Save