@@ -218,3 +218,130 @@ export const testNavigationToSingleDestination = async (
218218 failTest ( 'navigationController.init() exception' ) ;
219219 }
220220} ;
221+
222+ export const testNavigationToMultipleDestination = async (
223+ testTools : TestTools
224+ ) => {
225+ const { navigationController, addListeners, passTest, failTest } = testTools ;
226+ let onArrivalCount = 0 ;
227+ addListeners ( {
228+ onNavigationReady : async ( ) => {
229+ await navigationController . simulator . simulateLocation ( {
230+ lat : 37.4195823 ,
231+ lng : - 122.0799018 ,
232+ } ) ;
233+ await navigationController . setDestinations (
234+ [
235+ {
236+ position : {
237+ lat : 37.4152112 ,
238+ lng : - 122.0813741 ,
239+ } ,
240+ } ,
241+ {
242+ position : {
243+ lat : 37.4155112 ,
244+ lng : - 122.0806959 ,
245+ } ,
246+ } ,
247+ ] ,
248+ {
249+ travelMode : TravelMode . DRIVING ,
250+ avoidFerries : true ,
251+ avoidTolls : false ,
252+ }
253+ ) ;
254+ await navigationController . startGuidance ( ) ;
255+
256+ // Timeout here is used to avoid issues on Android.
257+ setTimeout ( ( ) => {
258+ navigationController . simulator . simulateLocationsAlongExistingRoute ( {
259+ speedMultiplier : Platform . OS === 'ios' ? 5 : 10 ,
260+ } ) ;
261+ } , 3000 ) ;
262+ } ,
263+ onNavigationInitError : ( errorCode : NavigationInitErrorCode ) => {
264+ console . log ( errorCode ) ;
265+ failTest ( 'onNavigatonInitError' ) ;
266+ } ,
267+ onArrival : async ( ) => {
268+ onArrivalCount += 1 ;
269+ if ( onArrivalCount > 1 ) {
270+ return passTest ( ) ;
271+ }
272+ await navigationController . continueToNextDestination ( ) ;
273+ } ,
274+ } ) ;
275+ try {
276+ await navigationController . init ( ) ;
277+ } catch ( error ) {
278+ console . error ( 'Error initializing navigator' , error ) ;
279+ failTest ( 'navigationController.init() exception' ) ;
280+ }
281+ } ;
282+
283+ export const testRouteSegments = async ( testTools : TestTools ) => {
284+ const {
285+ navigationController,
286+ addListeners,
287+ passTest,
288+ failTest,
289+ expectFalseError,
290+ } = testTools ;
291+ let beginTraveledPath ;
292+ addListeners ( {
293+ onNavigationReady : async ( ) => {
294+ await navigationController . simulator . simulateLocation ( {
295+ lat : 37.79136614772824 ,
296+ lng : - 122.41565900473043 ,
297+ } ) ;
298+ await navigationController . setDestination ( {
299+ title : 'Grace Cathedral' ,
300+ position : {
301+ lat : 37.791957 ,
302+ lng : - 122.412529 ,
303+ } ,
304+ } ) ;
305+ await navigationController . startGuidance ( ) ;
306+
307+ // Timeout here is used to avoid issues on Android.
308+ setTimeout ( async ( ) => {
309+ const beginRouteSegments =
310+ await navigationController . getRouteSegments ( ) ;
311+ const beginCurrentRouteSegment =
312+ await navigationController . getCurrentRouteSegment ( ) ;
313+ beginTraveledPath = await navigationController . getTraveledPath ( ) ;
314+
315+ if ( beginRouteSegments . length === 0 ) {
316+ expectFalseError ( 'beginRouteSegments.length === 0' ) ;
317+ return ;
318+ }
319+ if ( ! beginCurrentRouteSegment ) {
320+ return expectFalseError ( '!beginCurrentRouteSegment' ) ;
321+ }
322+ navigationController . simulator . simulateLocationsAlongExistingRoute ( {
323+ speedMultiplier : 5 ,
324+ } ) ;
325+ } , 3000 ) ;
326+ } ,
327+ onNavigationInitError : ( errorCode : NavigationInitErrorCode ) => {
328+ console . log ( errorCode ) ;
329+ failTest ( 'onNavigatonInitError' ) ;
330+ } ,
331+ onArrival : async ( ) => {
332+ const endTraveledPath = await navigationController . getTraveledPath ( ) ;
333+ if ( endTraveledPath . length <= beginTraveledPath . length ) {
334+ return expectFalseError (
335+ 'endTraveledPath.length <= beginTraveledPath.length'
336+ ) ;
337+ }
338+ passTest ( ) ;
339+ } ,
340+ } ) ;
341+ try {
342+ await navigationController . init ( ) ;
343+ } catch ( error ) {
344+ console . error ( 'Error initializing navigator' , error ) ;
345+ failTest ( 'navigationController.init() exception' ) ;
346+ }
347+ } ;
0 commit comments