Skip to content

Commit

Permalink
test: fixes to flaky navigation ui tests (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
jokerttu authored Dec 9, 2024
1 parent e75258a commit b8e6a11
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ internal constructor(
_mapView.onStart()
_mapView.onResume()

viewRegistry.registerMapView(viewId, this)

_mapView.getMapAsync { map ->
setMap(map)
initListeners()
imageRegistry.mapViewInitializationComplete()
mapReady()
invalidateViewAfterMapLoad()
}

viewRegistry.registerMapView(viewId, this)
}

override fun dispose() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ internal constructor(
setMap(map)
initListeners()
imageRegistry.mapViewInitializationComplete()
viewRegistry.registerAndroidAutoView(this)
mapReady()
invalidateViewAfterMapLoad()

viewRegistry.registerAndroidAutoView(this)
}

// Handled by AndroidAutoBaseScreen.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ internal constructor(
}
_navigationView.isNavigationUiEnabled = navigationViewEnabled

viewRegistry.registerNavigationView(viewId, this)

_navigationView.getMapAsync { map ->
setMap(map)
initListeners()
Expand All @@ -84,8 +86,6 @@ internal constructor(
mapReady()
invalidateViewAfterMapLoad()
}

viewRegistry.registerNavigationView(viewId, this)
}

override fun dispose() {
Expand Down
4 changes: 2 additions & 2 deletions example/integration_test/t03_navigation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void main() {
await GoogleMapsNavigator.setAudioGuidance(settings);

/// Specify tolerance and navigation destination coordinates.
const double tolerance = 0.0005;
const double tolerance = 0.001;
const double midLat = 68.59781164189049,
midLon = 23.520303427087182,
endLat = 68.60079240808535,
Expand Down Expand Up @@ -268,7 +268,7 @@ void main() {
await startNavigationWithoutDestination($);

/// Specify tolerance and navigation end coordinates.
const double tolerance = 0.0005;
const double tolerance = 0.001;
const double endLat = 68.59451829688189, endLng = 23.512277951523007;

/// Create a waypoint.
Expand Down
15 changes: 15 additions & 0 deletions example/integration_test/t04_navigation_ui_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,22 @@ void main() {
await viewControllerCompleter.future;

expect(await viewController.isNavigationUIEnabled(), false);
waitForValueMatchingPredicate<bool>(
$,
() async => navigationUIisEnabled,
(bool value) => value == false,
);
expect(navigationUIisEnabled, false);

/// Initialize navigation.
await GoogleMapsNavigator.initializeNavigationSession();

expect(await viewController.isNavigationUIEnabled(), true);
waitForValueMatchingPredicate<bool>(
$,
() async => navigationUIisEnabled,
(bool value) => value == true,
);
expect(navigationUIisEnabled, true);

await $.pumpAndSettle();
Expand Down Expand Up @@ -114,6 +124,11 @@ void main() {
expect(isEnabled, result);

/// Test that NavigationUIEnabledChanged event works.
waitForValueMatchingPredicate<bool>(
$,
() async => navigationUIisEnabled,
(bool value) => value == result,
);
expect(navigationUIisEnabled, result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public class GoogleMapsNavigationView: NSObject, FlutterPlatformView, ViewSettle
_mapConfiguration.apply(to: _mapView)

super.init()

_navigationUIEnabledPreference = navigationUIEnabledPreference
applyNavigationUIEnabledPreference()

registerView()

_mapView.delegate = self
_mapView.viewSettledDelegate = self

_navigationUIEnabledPreference = navigationUIEnabledPreference
applyNavigationUIEnabledPreference()
}

deinit {
Expand Down

0 comments on commit b8e6a11

Please sign in to comment.