@@ -33,6 +33,10 @@ void main() {
3333
3434 final GoogleNavigationInspectorPlatform inspector =
3535 GoogleNavigationInspectorPlatform .instance! ;
36+ final multipleDestinationsVariants = ValueVariant <String >(< String > {
37+ 'continueToNextDestination' ,
38+ 'setDestinations' ,
39+ });
3640
3741 /// Start location coordinates in Finland (Näkkäläntie).
3842 const double startLat = startLocationLat;
@@ -183,6 +187,7 @@ void main() {
183187 (PatrolIntegrationTester $) async {
184188 final Completer <void > navigationFinished = Completer <void >();
185189 int arrivalEventCount = 0 ;
190+ List <NavigationWaypoint > waypoints = < NavigationWaypoint > [];
186191
187192 /// Set up navigation view and controller.
188193 final GoogleNavigationViewController viewController =
@@ -208,7 +213,39 @@ void main() {
208213
209214 Future <void > onArrivalEvent (OnArrivalEvent msg) async {
210215 arrivalEventCount += 1 ;
211- await GoogleMapsNavigator .continueToNextDestination ();
216+
217+ if (multipleDestinationsVariants.currentValue ==
218+ 'continueToNextDestination' ) {
219+ // Note: continueToNextDestination is deprecated.
220+ // This test still uses it to verify the deprecated API works correctly.
221+ // For new implementations, use setDestinations with updated waypoints instead.
222+ await GoogleMapsNavigator .continueToNextDestination ();
223+ } else {
224+ // Find and remove the waypoint that matches the arrived waypoint
225+ int waypointIndex = - 1 ;
226+ for (int i = 0 ; i < waypoints.length; i++ ) {
227+ final NavigationWaypoint waypoint = waypoints[i];
228+ if (waypoint.title == msg.waypoint.title) {
229+ waypointIndex = i;
230+ break ;
231+ }
232+ }
233+
234+ if (waypointIndex >= 0 ) {
235+ waypoints.removeAt (waypointIndex);
236+ }
237+
238+ if (waypoints.isNotEmpty) {
239+ // Update destinations with remaining waypoints
240+ final Destinations updatedDestinations = Destinations (
241+ waypoints: waypoints,
242+ displayOptions: NavigationDisplayOptions (
243+ showDestinationMarkers: false ,
244+ ),
245+ );
246+ await GoogleMapsNavigator .setDestinations (updatedDestinations);
247+ }
248+ }
212249
213250 /// Finish executing the tests once 2 onArrival events come in.
214251 /// Test the guidance stops on last Arrival.
@@ -228,18 +265,21 @@ void main() {
228265 tolerance,
229266 );
230267
268+ /// Set up initial waypoints.
269+ waypoints = < NavigationWaypoint > [
270+ NavigationWaypoint .withLatLngTarget (
271+ title: 'Näkkäläntie 1st stop' ,
272+ target: const LatLng (latitude: midLat, longitude: midLon),
273+ ),
274+ NavigationWaypoint .withLatLngTarget (
275+ title: 'Näkkäläntie 2nd stop' ,
276+ target: const LatLng (latitude: endLat, longitude: endLng),
277+ ),
278+ ];
279+
231280 /// Set Destination.
232281 final Destinations destinations = Destinations (
233- waypoints: < NavigationWaypoint > [
234- NavigationWaypoint .withLatLngTarget (
235- title: 'Näkkäläntie 1st stop' ,
236- target: const LatLng (latitude: midLat, longitude: midLon),
237- ),
238- NavigationWaypoint .withLatLngTarget (
239- title: 'Näkkäläntie 2nd stop' ,
240- target: const LatLng (latitude: endLat, longitude: endLng),
241- ),
242- ],
282+ waypoints: waypoints,
243283 displayOptions: NavigationDisplayOptions (showDestinationMarkers: false ),
244284 );
245285 final NavigationRouteStatus status =
@@ -293,6 +333,7 @@ void main() {
293333
294334 await GoogleMapsNavigator .cleanup ();
295335 },
336+ variant: multipleDestinationsVariants,
296337 // TODO(jokerttu): Skipping Android as this fails on Android emulator on CI.
297338 skip: Platform .isAndroid,
298339 );
0 commit comments