Fixes launch by touching rocket

pull/505/head
Alvaro Almeida Freire Stivi 1 year ago
parent cf3b00c7d4
commit a35e6687d1
No known key found for this signature in database

@ -159,7 +159,7 @@ class PinballGame extends Forge2DGame
final bounds = rocket.topLeftPosition & rocket.size;
final tappedRocket =
bounds.contains(info.eventPosition.global.toOffset());
bounds.contains(screenToWorld(info.eventPosition.widget).toOffset());
if (tappedRocket) {
descendants()
.whereType<FlameBlocProvider<PlungerCubit, PlungerState>>()

@ -604,7 +604,9 @@ void main() {
gameBloc.emit(gameBloc.state.copyWith(status: GameStatus.playing));
final eventPosition = _MockEventPosition();
when(() => eventPosition.global).thenReturn(Vector2(40, 60));
when(() => eventPosition.widget).thenReturn(
game.worldToScreen(Vector2(40, 60)),
);
final raw = _MockTapDownDetails();
when(() => raw.kind).thenReturn(PointerDeviceKind.touch);

@ -301,25 +301,31 @@ void main() {
expect(game.focusNode.hasFocus, isTrue);
});
testWidgets('mobile controls when the overlay is added', (tester) async {
await tester.pumpApp(
PinballGameView(game),
gameBloc: gameBloc,
startGameBloc: startGameBloc,
);
testWidgets(
'mobile controls when the overlay is added',
(tester) async {
await tester.pumpApp(
Material(child: PinballGameView(game)),
gameBloc: gameBloc,
startGameBloc: startGameBloc,
);
game.overlays.add(PinballGame.mobileControlsOverlay);
game.overlays.add(PinballGame.mobileControlsOverlay);
await tester.pump();
await tester.pump();
expect(find.byType(MobileControls), findsOneWidget);
});
expect(
game.overlays.isActive(PinballGame.mobileControlsOverlay),
isTrue,
);
},
);
testWidgets(
'ReplayButtonOverlay when the overlay is added',
(tester) async {
await tester.pumpApp(
PinballGameView(game),
Material(child: PinballGameView(game)),
gameBloc: gameBloc,
startGameBloc: startGameBloc,
);
@ -328,7 +334,10 @@ void main() {
await tester.pump();
expect(find.byType(ReplayButtonOverlay), findsOneWidget);
expect(
game.overlays.isActive(PinballGame.replayButtonOverlay),
isTrue,
);
},
);

Loading…
Cancel
Save