@@ -383,6 +383,53 @@ void main() {
383
383
expect (scrollGesturesEnabled, true );
384
384
});
385
385
386
+ testWidgets ('testInitialCenterLocationAtCenter' , (WidgetTester tester) async {
387
+ final Completer <GoogleMapController > mapControllerCompleter =
388
+ Completer <GoogleMapController >();
389
+ final Key key = GlobalKey ();
390
+ await tester.pumpWidget (
391
+ Directionality (
392
+ textDirection: TextDirection .ltr,
393
+ child: GoogleMap (
394
+ key: key,
395
+ initialCameraPosition: _kInitialCameraPosition,
396
+ onMapCreated: (GoogleMapController controller) {
397
+ mapControllerCompleter.complete (controller);
398
+ },
399
+ ),
400
+ ),
401
+ );
402
+ final GoogleMapController mapController =
403
+ await mapControllerCompleter.future;
404
+
405
+ await tester.pumpAndSettle ();
406
+ // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen
407
+ // in `mapRendered`.
408
+ // https://github.com/flutter/flutter/issues/54758
409
+ await Future .delayed (Duration (seconds: 1 ));
410
+
411
+ ScreenCoordinate coordinate =
412
+ await mapController.getScreenCoordinate (_kInitialCameraPosition.target);
413
+ Rect rect = tester.getRect (find.byKey (key));
414
+ if (Platform .isIOS) {
415
+ // On iOS, the coordinate value from the GoogleMapSdk doesn't include the devicePixelRatio`.
416
+ // So we don't need to do the conversion like we did below for other platforms.
417
+ expect (coordinate.x, (rect.center.dx - rect.topLeft.dx).round ());
418
+ expect (coordinate.y, (rect.center.dy - rect.topLeft.dy).round ());
419
+ } else {
420
+ expect (
421
+ coordinate.x,
422
+ ((rect.center.dx - rect.topLeft.dx) *
423
+ tester.binding.window.devicePixelRatio)
424
+ .round ());
425
+ expect (
426
+ coordinate.y,
427
+ ((rect.center.dy - rect.topLeft.dy) *
428
+ tester.binding.window.devicePixelRatio)
429
+ .round ());
430
+ }
431
+ });
432
+
386
433
testWidgets ('testGetVisibleRegion' , (WidgetTester tester) async {
387
434
final Key key = GlobalKey ();
388
435
final LatLngBounds zeroLatLngBounds = LatLngBounds (
@@ -401,13 +448,8 @@ void main() {
401
448
},
402
449
),
403
450
));
404
- // We suspected a bug in the iOS Google Maps SDK caused the camera is not properly positioned at
405
- // initialization. https://github.com/flutter/flutter/issues/24806
406
- // This temporary workaround fix is provided while the actual fix in the Google Maps SDK is
407
- // still being investigated.
408
- // TODO(cyanglaz): Remove this temporary fix once the Maps SDK issue is resolved.
409
- // https://github.com/flutter/flutter/issues/27550
410
- await tester.pumpAndSettle (const Duration (seconds: 3 ));
451
+ await tester.pumpAndSettle ();
452
+
411
453
final GoogleMapController mapController =
412
454
await mapControllerCompleter.future;
413
455
@@ -707,13 +749,11 @@ void main() {
707
749
708
750
final GoogleMapController controller = await controllerCompleter.future;
709
751
710
- // We suspected a bug in the iOS Google Maps SDK caused the camera is not properly positioned at
711
- // initialization. https://github.com/flutter/flutter/issues/24806
712
- // This temporary workaround fix is provided while the actual fix in the Google Maps SDK is
713
- // still being investigated.
714
- // TODO(cyanglaz): Remove this temporary fix once the Maps SDK issue is resolved.
715
- // https://github.com/flutter/flutter/issues/27550
716
- await tester.pumpAndSettle (const Duration (seconds: 3 ));
752
+ await tester.pumpAndSettle ();
753
+ // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen
754
+ // in `mapRendered`.
755
+ // https://github.com/flutter/flutter/issues/54758
756
+ await Future .delayed (Duration (seconds: 1 ));
717
757
718
758
final LatLngBounds visibleRegion = await controller.getVisibleRegion ();
719
759
final LatLng topLeft =
@@ -744,13 +784,11 @@ void main() {
744
784
745
785
final GoogleMapController controller = await controllerCompleter.future;
746
786
747
- // We suspected a bug in the iOS Google Maps SDK caused the camera is not properly positioned at
748
- // initialization. https://github.com/flutter/flutter/issues/24806
749
- // This temporary workaround fix is provided while the actual fix in the Google Maps SDK is
750
- // still being investigated.
751
- // TODO(cyanglaz): Remove this temporary fix once the Maps SDK issue is resolved.
752
- // https://github.com/flutter/flutter/issues/27550
753
- await tester.pumpAndSettle (const Duration (seconds: 3 ));
787
+ await tester.pumpAndSettle ();
788
+ // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen
789
+ // in `mapRendered`.
790
+ // https://github.com/flutter/flutter/issues/54758
791
+ await Future .delayed (Duration (seconds: 1 ));
754
792
755
793
double zoom = await controller.getZoomLevel ();
756
794
expect (zoom, _kInitialZoomLevel);
@@ -778,13 +816,11 @@ void main() {
778
816
));
779
817
final GoogleMapController controller = await controllerCompleter.future;
780
818
781
- // We suspected a bug in the iOS Google Maps SDK caused the camera is not properly positioned at
782
- // initialization. https://github.com/flutter/flutter/issues/24806
783
- // This temporary workaround fix is provided while the actual fix in the Google Maps SDK is
784
- // still being investigated.
785
- // TODO(cyanglaz): Remove this temporary fix once the Maps SDK issue is resolved.
786
- // https://github.com/flutter/flutter/issues/27550
787
- await tester.pumpAndSettle (const Duration (seconds: 3 ));
819
+ await tester.pumpAndSettle ();
820
+ // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen
821
+ // in `mapRendered`.
822
+ // https://github.com/flutter/flutter/issues/54758
823
+ await Future .delayed (Duration (seconds: 1 ));
788
824
789
825
final LatLngBounds visibleRegion = await controller.getVisibleRegion ();
790
826
final LatLng northWest = LatLng (
@@ -818,13 +854,11 @@ void main() {
818
854
home: Scaffold (
819
855
body: SizedBox (height: 400 , width: 400 , child: map)))));
820
856
821
- // We suspected a bug in the iOS Google Maps SDK caused the camera is not properly positioned at
822
- // initialization. https://github.com/flutter/flutter/issues/24806
823
- // This temporary workaround fix is provided while the actual fix in the Google Maps SDK is
824
- // still being investigated.
825
- // TODO(cyanglaz): Remove this temporary fix once the Maps SDK issue is resolved.
826
- // https://github.com/flutter/flutter/issues/27550
827
- await tester.pumpAndSettle (const Duration (seconds: 3 ));
857
+ await tester.pumpAndSettle ();
858
+ // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen
859
+ // in `mapRendered`.
860
+ // https://github.com/flutter/flutter/issues/54758
861
+ await Future .delayed (Duration (seconds: 1 ));
828
862
829
863
// Simple call to make sure that the app hasn't crashed.
830
864
final LatLngBounds bounds1 = await controller.getVisibleRegion ();
@@ -906,5 +940,5 @@ void main() {
906
940
final GoogleMapInspector inspector = await inspectorCompleter.future;
907
941
final Uint8List bytes = await inspector.takeSnapshot ();
908
942
expect (bytes? .isNotEmpty, true );
909
- });
943
+ }, skip : true );
910
944
}
0 commit comments