WidgetTester tap is recognized as longPress by GoogleMap
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.1k
- PR merge metrics
- PR metrics pending
Description
### Steps to reproduce
1. Create integration test in google_maps_flutter_android/example
2. Add onTap callback on the ExampleGoogleMap
3. Use the WidgetTester instance to call tap i.e. tester.tap(find.byKey(myGoogleMapKey))
4. See that this tap was not recognized
### Expected results
I expect that when I use .tap from WidgetTester on my GoogleMap widget that the onTap callback is called.
### Actual results
What I see is that the onLongPress callback is called.
### Code sample
Code sample
```dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:google_maps_flutter_example/example_google_map.dart';
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
void main() {
testWidgets('onTap', (WidgetTester tester) async {
final Key key = GlobalKey();
final Completer mapIdCompleter = Completer();
bool hasTapped = false;
await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr,
child: ExampleGoogleMap(
key: key,
onTap: (LatLng position) {
print('Tapped at: $position');
hasTapped = true;
},
onLongPress: (LatLng position) => print('Long pressed at: $position'),
initialCameraPosition: const CameraPosition(
target: LatLng(0, 0),
zoom: 5,
),
onMapCreated: (ExampleGoogleMapController controller) {
mapIdCompleter.complete(controller.mapId);
},
),
));
final int mapsId = await mapIdCompleter.future;
await tester.tap(find.byKey(key));
expect(mapsId, 0);
expect(hasTapped, isTrue, reason: 'onTap callback should be called when the map is tapped.');
});
}
```
### Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
### Logs
Logs
```console
[Paste your logs here]
```
### Flutter Doctor output
Doctor output
```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.0, on Linux Mint 22.1 6.8.0-51-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (not installed)
[✓] VS Code (version 1.99.3)
[✓] Connected device (3 available)
[✓] Network resources
! Doctor found issues in 1 category.
```
This was tested with a Galaxy Tab Active5
Contributor guide
Research direction
Reproduce the issue using an integration test in google_maps_flutter_android/example and the WidgetTester tap shown in the report. Trace the GoogleMap gesture handling to determine why a tester tap reaches onLongPress instead of onTap. Done means the provided test invokes onTap and no longer invokes onLongPress for a tap.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, dart, flutter
- Domain
- mobile, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100