Skip to content

Commit b8e6a11

Browse files
authored
test: fixes to flaky navigation ui tests (#225)
1 parent e75258a commit b8e6a11

File tree

6 files changed

+26
-12
lines changed

6 files changed

+26
-12
lines changed

android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ internal constructor(
4444
_mapView.onStart()
4545
_mapView.onResume()
4646

47+
viewRegistry.registerMapView(viewId, this)
48+
4749
_mapView.getMapAsync { map ->
4850
setMap(map)
4951
initListeners()
5052
imageRegistry.mapViewInitializationComplete()
5153
mapReady()
5254
invalidateViewAfterMapLoad()
5355
}
54-
55-
viewRegistry.registerMapView(viewId, this)
5656
}
5757

5858
override fun dispose() {

android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoMapView.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ internal constructor(
3737
setMap(map)
3838
initListeners()
3939
imageRegistry.mapViewInitializationComplete()
40+
viewRegistry.registerAndroidAutoView(this)
4041
mapReady()
4142
invalidateViewAfterMapLoad()
42-
43-
viewRegistry.registerAndroidAutoView(this)
4443
}
4544

4645
// Handled by AndroidAutoBaseScreen.

android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsNavigationView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ internal constructor(
6868
}
6969
_navigationView.isNavigationUiEnabled = navigationViewEnabled
7070

71+
viewRegistry.registerNavigationView(viewId, this)
72+
7173
_navigationView.getMapAsync { map ->
7274
setMap(map)
7375
initListeners()
@@ -84,8 +86,6 @@ internal constructor(
8486
mapReady()
8587
invalidateViewAfterMapLoad()
8688
}
87-
88-
viewRegistry.registerNavigationView(viewId, this)
8989
}
9090

9191
override fun dispose() {

example/integration_test/t03_navigation_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void main() {
164164
await GoogleMapsNavigator.setAudioGuidance(settings);
165165

166166
/// Specify tolerance and navigation destination coordinates.
167-
const double tolerance = 0.0005;
167+
const double tolerance = 0.001;
168168
const double midLat = 68.59781164189049,
169169
midLon = 23.520303427087182,
170170
endLat = 68.60079240808535,
@@ -268,7 +268,7 @@ void main() {
268268
await startNavigationWithoutDestination($);
269269

270270
/// Specify tolerance and navigation end coordinates.
271-
const double tolerance = 0.0005;
271+
const double tolerance = 0.001;
272272
const double endLat = 68.59451829688189, endLng = 23.512277951523007;
273273

274274
/// Create a waypoint.

example/integration_test/t04_navigation_ui_test.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,22 @@ void main() {
6363
await viewControllerCompleter.future;
6464

6565
expect(await viewController.isNavigationUIEnabled(), false);
66+
waitForValueMatchingPredicate<bool>(
67+
$,
68+
() async => navigationUIisEnabled,
69+
(bool value) => value == false,
70+
);
6671
expect(navigationUIisEnabled, false);
6772

6873
/// Initialize navigation.
6974
await GoogleMapsNavigator.initializeNavigationSession();
7075

7176
expect(await viewController.isNavigationUIEnabled(), true);
77+
waitForValueMatchingPredicate<bool>(
78+
$,
79+
() async => navigationUIisEnabled,
80+
(bool value) => value == true,
81+
);
7282
expect(navigationUIisEnabled, true);
7383

7484
await $.pumpAndSettle();
@@ -114,6 +124,11 @@ void main() {
114124
expect(isEnabled, result);
115125

116126
/// Test that NavigationUIEnabledChanged event works.
127+
waitForValueMatchingPredicate<bool>(
128+
$,
129+
() async => navigationUIisEnabled,
130+
(bool value) => value == result,
131+
);
117132
expect(navigationUIisEnabled, result);
118133
}
119134

ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ public class GoogleMapsNavigationView: NSObject, FlutterPlatformView, ViewSettle
8989
_mapConfiguration.apply(to: _mapView)
9090

9191
super.init()
92-
93-
_navigationUIEnabledPreference = navigationUIEnabledPreference
94-
applyNavigationUIEnabledPreference()
95-
9692
registerView()
93+
9794
_mapView.delegate = self
9895
_mapView.viewSettledDelegate = self
96+
97+
_navigationUIEnabledPreference = navigationUIEnabledPreference
98+
applyNavigationUIEnabledPreference()
9999
}
100100

101101
deinit {

0 commit comments

Comments
 (0)