Skip to content

Commit 12a2e6e

Browse files
committed
NAVAND-552: nullify lastDownloadTime in onDetached
1 parent e76aa0a commit 12a2e6e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

libnavui-voice/src/main/java/com/mapbox/navigation/ui/voice/api/VoiceInstructionsPrefetcher.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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()

libnavui-voice/src/test/java/com/mapbox/navigation/ui/voice/api/VoiceInstructionsPrefetcherTest.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)