@@ -8,6 +8,7 @@ import com.mapbox.navigation.core.directions.session.RoutesObserver
8
8
import com.mapbox.navigation.core.replay.history.ReplayHistorySession
9
9
import com.mapbox.navigation.core.replay.history.ReplayHistorySessionOptions
10
10
import com.mapbox.navigation.core.replay.route.ReplayRouteSession
11
+ import com.mapbox.navigation.core.replay.route.ReplayRouteSessionOptions
11
12
import com.mapbox.navigation.core.trip.session.TripSessionState
12
13
import com.mapbox.navigation.testing.LoggingFrontendTestRule
13
14
import com.mapbox.navigation.testing.MainCoroutineRule
@@ -44,12 +45,19 @@ class MapboxTripStarterTest {
44
45
@get:Rule
45
46
val coroutineRule = MainCoroutineRule ()
46
47
47
- private val replayRouteSession = mockk<ReplayRouteSession >(relaxed = true )
48
- private var historyOptions = MutableStateFlow (ReplayHistorySessionOptions .Builder ().build())
48
+ private var replayRouteOptions = MutableStateFlow (ReplayRouteSessionOptions .Builder ().build())
49
+ private val replayRouteSession = mockk<ReplayRouteSession >(relaxed = true ) {
50
+ every { getOptions() } returns replayRouteOptions
51
+ every { setOptions(any()) } answers {
52
+ replayRouteOptions.value = firstArg()
53
+ this @mockk
54
+ }
55
+ }
56
+ private var replayHistoryOptions = MutableStateFlow (ReplayHistorySessionOptions .Builder ().build())
49
57
private val replayHistorySession = mockk<ReplayHistorySession >(relaxed = true ) {
50
- every { getOptions() } returns historyOptions
58
+ every { getOptions() } returns replayHistoryOptions
51
59
every { setOptions(any()) } answers {
52
- historyOptions .value = firstArg()
60
+ replayHistoryOptions .value = firstArg()
53
61
}
54
62
}
55
63
@@ -192,20 +200,20 @@ class MapboxTripStarterTest {
192
200
193
201
val mapboxNavigation = mockMapboxNavigation()
194
202
sut.enableReplayRoute()
195
- sut.onAttached(mapboxNavigation)
196
- val nextOptions = sut.getReplayRouteSessionOptions().toBuilder()
203
+ val customOptions = sut.getReplayRouteSessionOptions().toBuilder()
197
204
.decodeMinDistance(Double .MAX_VALUE )
198
205
.build()
199
- sut.enableReplayRoute(nextOptions)
206
+ sut.enableReplayRoute(customOptions)
207
+ sut.onAttached(mapboxNavigation)
200
208
201
209
verifyOrder {
202
- replayRouteSession.setOptions(any() )
210
+ replayRouteSession.setOptions(customOptions )
203
211
replayRouteSession.onAttached(mapboxNavigation)
212
+ }
213
+ verify(exactly = 0 ) {
214
+ mapboxNavigation.stopTripSession()
204
215
replayRouteSession.onDetached(mapboxNavigation)
205
- replayRouteSession.setOptions(nextOptions)
206
- replayRouteSession.onAttached(mapboxNavigation)
207
216
}
208
- verify(exactly = 0 ) { mapboxNavigation.stopTripSession() }
209
217
}
210
218
211
219
@Test
@@ -219,7 +227,6 @@ class MapboxTripStarterTest {
219
227
sut.onDetached(mapboxNavigation)
220
228
221
229
verifyOrder {
222
- replayRouteSession.onDetached(mapboxNavigation)
223
230
replayHistorySession.onDetached(mapboxNavigation)
224
231
replayRouteSession.onAttached(mapboxNavigation)
225
232
replayRouteSession.onDetached(mapboxNavigation)
@@ -283,17 +290,15 @@ class MapboxTripStarterTest {
283
290
every { PermissionsManager .areLocationPermissionsGranted(any()) } returns false
284
291
285
292
val mapboxNavigation = mockMapboxNavigation()
286
- sut.enableReplayHistory()
287
- sut.onAttached(mapboxNavigation)
288
293
val nextOptions = sut.getReplayHistorySessionOptions().toBuilder()
289
294
.enableSetRoute(false )
290
295
.build()
291
296
sut.enableReplayHistory(nextOptions)
297
+ sut.onAttached(mapboxNavigation)
292
298
293
299
verifyOrder {
294
- replayHistorySession.setOptions(any())
295
- replayHistorySession.onAttached(mapboxNavigation)
296
300
replayHistorySession.setOptions(nextOptions)
301
+ replayHistorySession.onAttached(mapboxNavigation)
297
302
}
298
303
verify(exactly = 0 ) {
299
304
mapboxNavigation.stopTripSession()
0 commit comments