-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7054ed8
commit 4ffefdd
Showing
2 changed files
with
412 additions
and
0 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
...-tests/src/androidTest/java/com/mapbox/navigation/instrumentation_tests/core/LanesTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.mapbox.navigation.instrumentation_tests.core | ||
|
||
import android.content.Context | ||
import android.location.Location | ||
import androidx.annotation.IntegerRes | ||
import com.mapbox.api.directions.v5.models.DirectionsRoute | ||
import com.mapbox.navigation.instrumentation_tests.R | ||
import com.mapbox.navigation.instrumentation_tests.utils.readRawFileText | ||
import com.mapbox.navigation.testing.ui.BaseCoreNoCleanUpTest | ||
import com.mapbox.navigation.ui.maneuver.api.MapboxLaneIconsApi | ||
import com.mapbox.navigation.ui.maneuver.model.LaneIconResources | ||
import com.mapbox.navigation.ui.maneuver.model.LaneIndicator | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertNotNull | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
|
||
class LanesTest : BaseCoreNoCleanUpTest() { | ||
|
||
@Test | ||
fun testUnknownIndicationTypes() { | ||
val route = getRoute(context, R.raw.route_with_unknown_lane_types) | ||
val lanes = route.legs()?.first()?.steps()?.first()?.intersections()?.first()?.lanes() | ||
|
||
assertNotNull(lanes) | ||
requireNotNull(lanes) | ||
|
||
assertTrue(lanes.isNotEmpty()) | ||
assertEquals(listOf("left", "straight", "unknown"), lanes.first().indications()) | ||
assertEquals(listOf("right", "unknown"), lanes.last().indications()) | ||
assertEquals("unknown", lanes.last().validIndication()) | ||
} | ||
|
||
@Test | ||
fun testUnknownLaneTypesRendering() { | ||
val laneIconRes = LaneIconResources.Builder().build() | ||
val laneApi = MapboxLaneIconsApi(laneIconRes) | ||
|
||
val inactiveIndicator = LaneIndicator | ||
.Builder() | ||
.drivingSide("right") | ||
.isActive(false) | ||
.directions(listOf("unknown")) | ||
.activeDirection(null) | ||
.build() | ||
|
||
val inactiveTurnLane = laneApi.getTurnLane(inactiveIndicator) | ||
assertEquals(laneIconRes.laneStraight, inactiveTurnLane.drawableResId) | ||
|
||
val activeIndicator = LaneIndicator | ||
.Builder() | ||
.drivingSide("right") | ||
.isActive(true) | ||
.directions(listOf("unknown", "right")) | ||
.activeDirection("unknown") | ||
.build() | ||
|
||
val activeTurnLane = laneApi.getTurnLane(activeIndicator) | ||
assertEquals(laneIconRes.laneStraight, activeTurnLane.drawableResId) | ||
} | ||
|
||
private fun getRoute( | ||
context: Context, | ||
@IntegerRes routeFileResource: Int | ||
): DirectionsRoute { | ||
val routeAsString = readRawFileText(context, routeFileResource) | ||
return DirectionsRoute.fromJson(routeAsString) | ||
} | ||
|
||
override fun setupMockLocation(): Location { | ||
return mockLocationUpdatesRule.generateLocationUpdate { | ||
// no op | ||
} | ||
} | ||
} |
Oops, something went wrong.