Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ class MapboxHybridRouterTest {
} catch (ex: Exception) {
}

every { context.unregisterReceiver(any()) } answers {}

verify { context.unregisterReceiver(any()) }
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mapbox.navigation.utils.internal

import com.mapbox.navigation.testing.MainCoroutineRule
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedReceiveChannelException
import kotlinx.coroutines.delay
Expand All @@ -10,16 +9,12 @@ import org.hamcrest.CoreMatchers.`is`
import org.junit.Assert.assertFalse
import org.junit.Assert.assertThat
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test

class ThreadControllerTest {

@get:Rule
val coroutineRule = MainCoroutineRule()

@Test
fun jobCountValidationNonUIScope() = coroutineRule.runBlockingTest {
fun jobCountValidationNonUIScope() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this test should actually use coroutineRule.runBlockingTest

since it delays inside

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah that's what I was saying here #2839 (comment) It actually makes the test execution slower so I reverted 😉

val maxCoroutines = 10
val maxDelay = 100L
val jobControl = ThreadController.getIOScopeAndRootJob()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import java.util.Date
interface MapboxNativeNavigator {

companion object {
private const val INDEX_FIRST_ROUTE = 0
private const val INDEX_FIRST_LEG = 0
private const val GRID_SIZE = 0.0025f
private const val BUFFER_DILATION: Short = 1
Expand Down Expand Up @@ -69,15 +68,13 @@ interface MapboxNativeNavigator {
* Otherwise, it returns a invalid route state.
*
* @param route [DirectionsRoute] to follow.
* @param routeIndex Which route to follow
* @param legIndex Which leg to follow
*
* @return a [NavigationStatus] route state if no errors occurred.
* Otherwise, it returns a invalid route state.
*/
suspend fun setRoute(
route: DirectionsRoute?,
routeIndex: Int = INDEX_FIRST_ROUTE,
legIndex: Int = INDEX_FIRST_LEG
): NavigationStatus

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,18 @@ object MapboxNativeNavigatorImpl : MapboxNativeNavigator {
* Otherwise, it returns a invalid route state.
*
* @param route [DirectionsRoute] to follow.
* @param routeIndex Which route to follow
* @param legIndex Which leg to follow
*
* @return a [NavigationStatus] route state if no errors occurred.
* Otherwise, it returns a invalid route state.
*/
override suspend fun setRoute(
route: DirectionsRoute?,
routeIndex: Int,
legIndex: Int
): NavigationStatus {
mutex.withLock {
MapboxNativeNavigatorImpl.route = route
val result = navigator.setRoute(route?.toJson() ?: "{}", routeIndex, legIndex)
val result = navigator.setRoute(route?.toJson() ?: "{}", PRIMARY_ROUTE_INDEX, legIndex)
navigator.getRouteBufferGeoJson(GRID_SIZE, BUFFER_DILATION)?.also {
routeBufferGeoJson = GeometryGeoJson.fromJson(it)
}
Expand Down