Skip to content

Commit 7fb60f8

Browse files
committed
fixing issues
1 parent 959b5ea commit 7fb60f8

File tree

3 files changed

+32
-56
lines changed

3 files changed

+32
-56
lines changed

android-auto-app/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ dependencies {
7272
// This example is used for development so it may depend on unstable versions.
7373
// Examples based on final versions can be found in the examples repository.
7474
// https://github.com/mapbox/mapbox-navigation-android-examples
75-
implementation project(':libnavui-dropin')
76-
// implementation("com.mapbox.navigation:ui-dropin:2.10.0")
75+
implementation("com.mapbox.navigation:ui-dropin:2.10.0")
7776
implementation("com.mapbox.search:mapbox-search-android:1.0.0-beta.43")
7877

7978
// Dependencies needed for this example.

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

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,16 @@ class MapboxTripStarter internal constructor(
152152
isLocationPermissionGranted.onEach { granted ->
153153
onMapMatchingEnabled(mapboxNavigation, granted)
154154
}
155-
MapboxTripStarterType.ReplayRoute ->
156-
replayRouteSession.getOptions().onEach { options ->
157-
onReplayRouteEnabled(mapboxNavigation, options)
158-
}
159-
MapboxTripStarterType.ReplayHistory ->
160-
replayHistorySession.getOptions().onEach { options ->
161-
onReplayHistoryEnabled(mapboxNavigation, options)
162-
}
155+
MapboxTripStarterType.ReplayRoute -> {
156+
replayHistorySession.onDetached(mapboxNavigation)
157+
replayRouteSession.onAttached(mapboxNavigation)
158+
replayRouteSession.getOptions()
159+
}
160+
MapboxTripStarterType.ReplayHistory -> {
161+
replayRouteSession.onDetached(mapboxNavigation)
162+
replayHistorySession.onAttached(mapboxNavigation)
163+
replayHistorySession.getOptions()
164+
}
163165
}
164166
}
165167
}
@@ -186,36 +188,6 @@ class MapboxTripStarter internal constructor(
186188
}
187189
}
188190

189-
/**
190-
* Internally called when the trip type has been set to replay route.
191-
*
192-
* @param mapboxNavigation
193-
* @param options parameters for the [ReplayRouteSession]
194-
*/
195-
private fun onReplayRouteEnabled(
196-
mapboxNavigation: MapboxNavigation,
197-
options: ReplayRouteSessionOptions
198-
) {
199-
replayHistorySession.onDetached(mapboxNavigation)
200-
replayRouteSession.setOptions(options)
201-
replayRouteSession.onAttached(mapboxNavigation)
202-
}
203-
204-
/**
205-
* Internally called when the trip type has been set to replay history.
206-
*
207-
* @param mapboxNavigation
208-
* @param options parameters for the [ReplayHistorySession]
209-
*/
210-
private fun onReplayHistoryEnabled(
211-
mapboxNavigation: MapboxNavigation,
212-
options: ReplayHistorySessionOptions
213-
) {
214-
replayRouteSession.onDetached(mapboxNavigation)
215-
replayHistorySession.setOptions(options)
216-
replayHistorySession.onAttached(mapboxNavigation)
217-
}
218-
219191
/**
220192
* Internally called when the trip session needs to be stopped.
221193
*

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

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.mapbox.navigation.core.directions.session.RoutesObserver
88
import com.mapbox.navigation.core.replay.history.ReplayHistorySession
99
import com.mapbox.navigation.core.replay.history.ReplayHistorySessionOptions
1010
import com.mapbox.navigation.core.replay.route.ReplayRouteSession
11+
import com.mapbox.navigation.core.replay.route.ReplayRouteSessionOptions
1112
import com.mapbox.navigation.core.trip.session.TripSessionState
1213
import com.mapbox.navigation.testing.LoggingFrontendTestRule
1314
import com.mapbox.navigation.testing.MainCoroutineRule
@@ -44,12 +45,19 @@ class MapboxTripStarterTest {
4445
@get:Rule
4546
val coroutineRule = MainCoroutineRule()
4647

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())
4957
private val replayHistorySession = mockk<ReplayHistorySession>(relaxed = true) {
50-
every { getOptions() } returns historyOptions
58+
every { getOptions() } returns replayHistoryOptions
5159
every { setOptions(any()) } answers {
52-
historyOptions.value = firstArg()
60+
replayHistoryOptions.value = firstArg()
5361
}
5462
}
5563

@@ -192,20 +200,20 @@ class MapboxTripStarterTest {
192200

193201
val mapboxNavigation = mockMapboxNavigation()
194202
sut.enableReplayRoute()
195-
sut.onAttached(mapboxNavigation)
196-
val nextOptions = sut.getReplayRouteSessionOptions().toBuilder()
203+
val customOptions = sut.getReplayRouteSessionOptions().toBuilder()
197204
.decodeMinDistance(Double.MAX_VALUE)
198205
.build()
199-
sut.enableReplayRoute(nextOptions)
206+
sut.enableReplayRoute(customOptions)
207+
sut.onAttached(mapboxNavigation)
200208

201209
verifyOrder {
202-
replayRouteSession.setOptions(any())
210+
replayRouteSession.setOptions(customOptions)
203211
replayRouteSession.onAttached(mapboxNavigation)
212+
}
213+
verify(exactly = 0) {
214+
mapboxNavigation.stopTripSession()
204215
replayRouteSession.onDetached(mapboxNavigation)
205-
replayRouteSession.setOptions(nextOptions)
206-
replayRouteSession.onAttached(mapboxNavigation)
207216
}
208-
verify(exactly = 0) { mapboxNavigation.stopTripSession() }
209217
}
210218

211219
@Test
@@ -219,7 +227,6 @@ class MapboxTripStarterTest {
219227
sut.onDetached(mapboxNavigation)
220228

221229
verifyOrder {
222-
replayRouteSession.onDetached(mapboxNavigation)
223230
replayHistorySession.onDetached(mapboxNavigation)
224231
replayRouteSession.onAttached(mapboxNavigation)
225232
replayRouteSession.onDetached(mapboxNavigation)
@@ -283,17 +290,15 @@ class MapboxTripStarterTest {
283290
every { PermissionsManager.areLocationPermissionsGranted(any()) } returns false
284291

285292
val mapboxNavigation = mockMapboxNavigation()
286-
sut.enableReplayHistory()
287-
sut.onAttached(mapboxNavigation)
288293
val nextOptions = sut.getReplayHistorySessionOptions().toBuilder()
289294
.enableSetRoute(false)
290295
.build()
291296
sut.enableReplayHistory(nextOptions)
297+
sut.onAttached(mapboxNavigation)
292298

293299
verifyOrder {
294-
replayHistorySession.setOptions(any())
295-
replayHistorySession.onAttached(mapboxNavigation)
296300
replayHistorySession.setOptions(nextOptions)
301+
replayHistorySession.onAttached(mapboxNavigation)
297302
}
298303
verify(exactly = 0) {
299304
mapboxNavigation.stopTripSession()

0 commit comments

Comments
 (0)