Skip to content

Commit 74a3e1a

Browse files
committed
add test
1 parent 4b8df1d commit 74a3e1a

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

examples/src/main/java/com/mapbox/navigation/examples/core/ReplayHistoryActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ import kotlinx.coroutines.CoroutineScope
5151
import kotlinx.coroutines.Dispatchers
5252
import kotlinx.coroutines.Job
5353
import kotlinx.coroutines.launch
54-
import java.util.*
5554

5655
private const val DEFAULT_INITIAL_ZOOM = 15.0
5756

libnavigation-core/src/main/java/com/mapbox/navigation/core/trip/MapboxTripStarter.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ class MapboxTripStarter internal constructor(
206206
}
207207
}
208208

209+
/**
210+
* Internally called when the trip type has been set to replay history.
211+
*
212+
* @param mapboxNavigation
213+
* @param options parameters for the [ReplayHistorySession]
214+
*/
209215
private fun onReplayHistoryEnabled(
210216
mapboxNavigation: MapboxNavigation,
211217
options: ReplayHistorySessionOptions

libnavigation-core/src/test/java/com/mapbox/navigation/core/trip/MapboxTripStarterTest.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,30 @@ class MapboxTripStarterTest {
241241
verify(exactly = 1) { replayHistorySession.onAttached(mapboxNavigation) }
242242
}
243243

244+
@Test
245+
fun `enableReplayHistory will set options before onAttached`() {
246+
every { PermissionsManager.areLocationPermissionsGranted(any()) } returns false
247+
248+
val mapboxNavigation = mockMapboxNavigation()
249+
sut.enableReplayHistory()
250+
sut.onAttached(mapboxNavigation)
251+
val nextOptions = sut.getReplayHistorySessionOptions().toBuilder()
252+
.enableSetRoute(false)
253+
.build()
254+
sut.enableReplayHistory(nextOptions)
255+
256+
verifyOrder {
257+
replayHistorySession.setOptions(any())
258+
replayHistorySession.onAttached(mapboxNavigation)
259+
replayHistorySession.setOptions(nextOptions)
260+
}
261+
verify(exactly = 0) {
262+
mapboxNavigation.stopTripSession()
263+
replayHistorySession.onDetached(mapboxNavigation)
264+
}
265+
}
266+
267+
244268
private fun mockMapboxNavigation(): MapboxNavigation {
245269
val mapboxNavigation = mockk<MapboxNavigation>(relaxed = true)
246270
every { mapboxNavigation.getTripSessionState() } returns TripSessionState.STOPPED

0 commit comments

Comments
 (0)