From 246fdb7a2713f52d702888513f676f363c0b539a Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Thu, 28 Nov 2024 22:57:55 +0200 Subject: [PATCH 1/4] test: fix flaky navigation ui test --- .../integration_test/t04_navigation_ui_test.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/example/integration_test/t04_navigation_ui_test.dart b/example/integration_test/t04_navigation_ui_test.dart index 99d74a4..1a64d05 100644 --- a/example/integration_test/t04_navigation_ui_test.dart +++ b/example/integration_test/t04_navigation_ui_test.dart @@ -63,12 +63,22 @@ void main() { await viewControllerCompleter.future; expect(await viewController.isNavigationUIEnabled(), false); + waitForValueMatchingPredicate( + $, + () async => navigationUIisEnabled, + (bool value) => value == false, + ); expect(navigationUIisEnabled, false); /// Initialize navigation. await GoogleMapsNavigator.initializeNavigationSession(); expect(await viewController.isNavigationUIEnabled(), true); + waitForValueMatchingPredicate( + $, + () async => navigationUIisEnabled, + (bool value) => value == true, + ); expect(navigationUIisEnabled, true); await $.pumpAndSettle(); @@ -114,6 +124,11 @@ void main() { expect(isEnabled, result); /// Test that NavigationUIEnabledChanged event works. + waitForValueMatchingPredicate( + $, + () async => navigationUIisEnabled, + (bool value) => value == result, + ); expect(navigationUIisEnabled, result); } From 3a7488c8a1ec42f0b8d40e9f8b16523c34c7e0c9 Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Thu, 28 Nov 2024 23:21:41 +0200 Subject: [PATCH 2/4] test: increase navigation test tolerances --- example/integration_test/t03_navigation_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/integration_test/t03_navigation_test.dart b/example/integration_test/t03_navigation_test.dart index 71551c6..cdc3b54 100644 --- a/example/integration_test/t03_navigation_test.dart +++ b/example/integration_test/t03_navigation_test.dart @@ -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, @@ -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. From 6572471807e2e21292cb27d02c5954209c6393a3 Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Fri, 29 Nov 2024 13:31:36 +0200 Subject: [PATCH 3/4] Move view registration for navigation view as early as possible --- .../GoogleMapsNavigationView.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationView.swift b/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationView.swift index fa2d789..6c0afa9 100644 --- a/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationView.swift +++ b/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationView.swift @@ -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 { From c730cadef47fa7e6a9f9019df6b000850d2ec326 Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Fri, 29 Nov 2024 13:44:56 +0200 Subject: [PATCH 4/4] Make sure view is registered before calling map ready --- .../com/google/maps/flutter/navigation/GoogleMapView.kt | 4 ++-- .../google/maps/flutter/navigation/GoogleMapsAutoMapView.kt | 3 +-- .../maps/flutter/navigation/GoogleMapsNavigationView.kt | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapView.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapView.kt index 6d6febc..b11a2c9 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapView.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapView.kt @@ -44,6 +44,8 @@ internal constructor( _mapView.onStart() _mapView.onResume() + viewRegistry.registerMapView(viewId, this) + _mapView.getMapAsync { map -> setMap(map) initListeners() @@ -51,8 +53,6 @@ internal constructor( mapReady() invalidateViewAfterMapLoad() } - - viewRegistry.registerMapView(viewId, this) } override fun dispose() { diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoMapView.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoMapView.kt index 7ca8e9c..4402072 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoMapView.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoMapView.kt @@ -37,10 +37,9 @@ internal constructor( setMap(map) initListeners() imageRegistry.mapViewInitializationComplete() + viewRegistry.registerAndroidAutoView(this) mapReady() invalidateViewAfterMapLoad() - - viewRegistry.registerAndroidAutoView(this) } // Handled by AndroidAutoBaseScreen. diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsNavigationView.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsNavigationView.kt index 55a5d5a..d6237e3 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsNavigationView.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsNavigationView.kt @@ -68,6 +68,8 @@ internal constructor( } _navigationView.isNavigationUiEnabled = navigationViewEnabled + viewRegistry.registerNavigationView(viewId, this) + _navigationView.getMapAsync { map -> setMap(map) initListeners() @@ -84,8 +86,6 @@ internal constructor( mapReady() invalidateViewAfterMapLoad() } - - viewRegistry.registerNavigationView(viewId, this) } override fun dispose() {