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(
63
63
* See [MapboxNavigationObserver.onDetached].
64
64
*/
65
65
override fun onDetached (mapboxNavigation : MapboxNavigation ) {
66
+ lastDownloadTime = 0
66
67
mapboxNavigation.unregisterRoutesObserver(routesObserver)
67
68
mapboxNavigation.unregisterRouteProgressObserver(routeProgressObserver)
68
69
speechApi.destroy()
Original file line number Diff line number Diff line change @@ -336,6 +336,22 @@ class VoiceInstructionsPrefetcherTest {
336
336
verify(exactly = 0 ) { speechAPI.predownload(any()) }
337
337
}
338
338
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
+
339
355
private fun routesUpdatedResult (
340
356
routes : List <NavigationRoute >,
341
357
@RoutesExtra.RoutesUpdateReason mockReason : String
You can’t perform that action at this time.
0 commit comments