File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
main/java/com/mapbox/navigation/ui/voice/api
test/java/com/mapbox/navigation/ui/voice/api Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ class VoiceInstructionsPrefetcher internal constructor(
6363 * See [MapboxNavigationObserver.onDetached].
6464 */
6565 override fun onDetached (mapboxNavigation : MapboxNavigation ) {
66+ lastDownloadTime = 0
6667 mapboxNavigation.unregisterRoutesObserver(routesObserver)
6768 mapboxNavigation.unregisterRouteProgressObserver(routeProgressObserver)
6869 speechApi.destroy()
Original file line number Diff line number Diff line change @@ -336,6 +336,22 @@ class VoiceInstructionsPrefetcherTest {
336336 verify(exactly = 0 ) { speechAPI.predownload(any()) }
337337 }
338338
339+ @Test
340+ fun `onDetached should nullify lastDownloadTime` () {
341+ val mapboxNavigation = mockk<MapboxNavigation >(relaxed = true )
342+ val route = validRoute()
343+ onRoutesChanged(
344+ routesUpdatedResult(listOf (route), RoutesExtra .ROUTES_UPDATE_REASON_NEW )
345+ )
346+ sut.onDetached(mapboxNavigation)
347+ clearMocks(speechAPI, answers = false )
348+ every { timeProvider.seconds() } returns currentTimeSeconds + 49
349+
350+ onRouteProgressChanged(validRouteProgress())
351+
352+ verify(exactly = 1 ) { speechAPI.predownload(any()) }
353+ }
354+
339355 private fun routesUpdatedResult (
340356 routes : List <NavigationRoute >,
341357 @RoutesExtra.RoutesUpdateReason mockReason : String
You can’t perform that action at this time.
0 commit comments