Skip to content

Commit

Permalink
test: padding integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
illuminati1911 committed Dec 16, 2024
1 parent cf2fcf1 commit 5b59f0e
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
66 changes: 66 additions & 0 deletions example/integration_test/t06_map_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<GoogleMapViewController> viewControllerCompleter =
Completer<GoogleMapViewController>();

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,
);
}
2 changes: 1 addition & 1 deletion lib/src/google_maps_auto_view_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class GoogleMapsAutoViewController {
}

// Gets the map padding from the map view.
Future<EdgeInsets> getPadding({required int viewId}) async {
Future<EdgeInsets> getPadding() async {
return GoogleMapsNavigationPlatform.instance.getPaddingForAuto();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/google_maps_map_view_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class GoogleMapViewController {
}

// Gets the map padding from the map view.
Future<EdgeInsets> getPadding({required int viewId}) async {
Future<EdgeInsets> getPadding() async {
return GoogleMapsNavigationPlatform.instance.getPadding(viewId: _viewId);
}
}

0 comments on commit 5b59f0e

Please sign in to comment.