Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fixes to flaky navigation ui tests #225

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading