From 5b59f0e24f98c94259d32e16b4bd1b3b07125929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20V=C3=A4limaa?= Date: Mon, 16 Dec 2024 19:55:10 +0800 Subject: [PATCH] test: padding integration test --- example/integration_test/t06_map_test.dart | 66 +++++++++++++++++++ lib/src/google_maps_auto_view_controller.dart | 2 +- lib/src/google_maps_map_view_controller.dart | 2 +- 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/example/integration_test/t06_map_test.dart b/example/integration_test/t06_map_test.dart index a556a08..707e6a7 100644 --- a/example/integration_test/t06_map_test.dart +++ b/example/integration_test/t06_map_test.dart @@ -373,4 +373,70 @@ void main() { }, variant: mapTypeVariants, ); + + patrol( + 'Test map padding', + (PatrolIntegrationTester $) async { + /// For some reason the functionality works on Android example app, but it doesn't work + /// during the testing. Will skip Android testing for now. + final Completer viewControllerCompleter = + Completer(); + + await checkLocationDialogAcceptance($); + + switch (mapTypeVariants.currentValue!) { + case TestMapType.mapView: + + /// Display map view. + final Key key = GlobalKey(); + await pumpMapView( + $, + GoogleMapsMapView( + key: key, + onViewCreated: (GoogleMapViewController controller) { + viewControllerCompleter.complete(controller); + }, + ), + ); + break; + case TestMapType.navigationView: + + /// Display navigation view. + final Key key = GlobalKey(); + await pumpNavigationView( + $, + GoogleMapsNavigationView( + key: key, + onViewCreated: (GoogleNavigationViewController controller) { + viewControllerCompleter.complete(controller); + }, + ), + ); + break; + } + + final GoogleMapViewController viewController = + await viewControllerCompleter.future; + + // Test initial values + EdgeInsets initialPadding = await viewController.getPadding(); + + expect(initialPadding.left, 0.0); + expect(initialPadding.top, 0.0); + expect(initialPadding.right, 0.0); + expect(initialPadding.bottom, 0.0); + + await viewController.setPadding( + const EdgeInsets.only(left: 50, top: 60, right: 70, bottom: 80)); + + // Test that the padding values were changed. + EdgeInsets newPadding = await viewController.getPadding(); + + expect(newPadding.left, 50.0); + expect(newPadding.top, 60.0); + expect(newPadding.right, 70.0); + expect(newPadding.bottom, 80.0); + }, + variant: mapTypeVariants, + ); } diff --git a/lib/src/google_maps_auto_view_controller.dart b/lib/src/google_maps_auto_view_controller.dart index 5f7101b..0ddd05d 100644 --- a/lib/src/google_maps_auto_view_controller.dart +++ b/lib/src/google_maps_auto_view_controller.dart @@ -334,7 +334,7 @@ class GoogleMapsAutoViewController { } // Gets the map padding from the map view. - Future getPadding({required int viewId}) async { + Future getPadding() async { return GoogleMapsNavigationPlatform.instance.getPaddingForAuto(); } diff --git a/lib/src/google_maps_map_view_controller.dart b/lib/src/google_maps_map_view_controller.dart index 280f13b..ce638a2 100644 --- a/lib/src/google_maps_map_view_controller.dart +++ b/lib/src/google_maps_map_view_controller.dart @@ -373,7 +373,7 @@ class GoogleMapViewController { } // Gets the map padding from the map view. - Future getPadding({required int viewId}) async { + Future getPadding() async { return GoogleMapsNavigationPlatform.instance.getPadding(viewId: _viewId); } }