-
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
4ffefdd
commit f2b1759
Showing
4 changed files
with
1,006 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
...ts/src/androidTest/java/com/mapbox/navigation/instrumentation_tests/core/TollCostsTest.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,66 @@ | ||
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 org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertNotNull | ||
import org.junit.Assert.assertNull | ||
import org.junit.Test | ||
|
||
class TollCostsTest : BaseCoreNoCleanUpTest() { | ||
|
||
@Test | ||
fun testNoTollCostsData() { | ||
val route = getRoute(context, R.raw.route_with_no_toll_costs) | ||
assertNull(route.tollCosts()) | ||
} | ||
|
||
@Test | ||
fun testEmptyTollCosts() { | ||
val route = getRoute(context, R.raw.route_with_empty_toll_costs) | ||
val tollCosts = route.tollCosts() | ||
assertNotNull(tollCosts) | ||
|
||
tollCosts!! | ||
assertEquals(1, tollCosts.size) | ||
assertNull(tollCosts[0].currency()) | ||
assertNull(tollCosts[0].paymentMethods()) | ||
} | ||
|
||
@Test | ||
fun testEmptyTollCostsDataPaymentMethods() { | ||
val route = getRoute(context, R.raw.route_with_empty_toll_costs_payment_data) | ||
val tollCosts = route.tollCosts() | ||
assertNotNull(tollCosts) | ||
|
||
tollCosts!! | ||
assertEquals(1, tollCosts.size) | ||
assertEquals("JPY", tollCosts[0].currency()) | ||
|
||
val paymentMethods = tollCosts[0].paymentMethods() | ||
assertNotNull(paymentMethods) | ||
|
||
paymentMethods!! | ||
assertNull(paymentMethods.cash()) | ||
assertNull(paymentMethods.etc()) | ||
} | ||
|
||
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 | ||
} | ||
} | ||
} |
314 changes: 314 additions & 0 deletions
314
instrumentation-tests/src/main/res/raw/route_with_empty_toll_costs.json
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,314 @@ | ||
{ | ||
"routeIndex": "0", | ||
"distance": 80.3, | ||
"duration": 40.9, | ||
"geometry": "etylgAl`guhFpJrBh@kHbC{[nAZ", | ||
"weight": 91.7, | ||
"weight_name": "routability", | ||
"legs": [ | ||
{ | ||
"distance": 80.3, | ||
"duration": 40.9, | ||
"summary": "Laurel Place, Lincoln Avenue", | ||
"steps": [ | ||
{ | ||
"distance": 21.2, | ||
"duration": 18.5, | ||
"geometry": "etylgAl`guhFpJrB", | ||
"name": "", | ||
"mode": "driving", | ||
"maneuver": { | ||
"location": [ | ||
-122.523671, | ||
37.975379 | ||
], | ||
"bearing_before": 0.0, | ||
"bearing_after": 194.0, | ||
"instruction": "Head south", | ||
"type": "depart", | ||
"modifier": "right" | ||
}, | ||
"voiceInstructions": [ | ||
{ | ||
"distanceAlongGeometry": 21.2, | ||
"announcement": "Head south, then turn left onto Laurel Place", | ||
"ssmlAnnouncement": "\u003cspeak\u003e\u003camazon:effect name\u003d\"drc\"\u003e\u003cprosody rate\u003d\"1.08\"\u003eHead south, then turn left onto Laurel Place\u003c/prosody\u003e\u003c/amazon:effect\u003e\u003c/speak\u003e" | ||
}, | ||
{ | ||
"distanceAlongGeometry": 17.2, | ||
"announcement": "Turn left onto Laurel Place, then turn right onto Lincoln Avenue", | ||
"ssmlAnnouncement": "\u003cspeak\u003e\u003camazon:effect name\u003d\"drc\"\u003e\u003cprosody rate\u003d\"1.08\"\u003eTurn left onto Laurel Place, then turn right onto Lincoln Avenue\u003c/prosody\u003e\u003c/amazon:effect\u003e\u003c/speak\u003e" | ||
} | ||
], | ||
"bannerInstructions": [ | ||
{ | ||
"distanceAlongGeometry": 21.2, | ||
"primary": { | ||
"text": "Laurel Place", | ||
"components": [ | ||
{ | ||
"text": "Laurel Place", | ||
"type": "text", | ||
"abbr": "Laurel Pl", | ||
"abbr_priority": 0 | ||
} | ||
], | ||
"type": "turn", | ||
"modifier": "left" | ||
} | ||
}, | ||
{ | ||
"distanceAlongGeometry": 17.2, | ||
"primary": { | ||
"text": "Laurel Place", | ||
"components": [ | ||
{ | ||
"text": "Laurel Place", | ||
"type": "text", | ||
"abbr": "Laurel Pl", | ||
"abbr_priority": 0 | ||
} | ||
], | ||
"type": "turn", | ||
"modifier": "left" | ||
}, | ||
"sub": { | ||
"text": "Lincoln Avenue", | ||
"components": [ | ||
{ | ||
"text": "Lincoln Avenue", | ||
"type": "text", | ||
"abbr": "Lincoln Ave", | ||
"abbr_priority": 0 | ||
} | ||
], | ||
"type": "turn", | ||
"modifier": "right" | ||
} | ||
} | ||
], | ||
"driving_side": "right", | ||
"weight": 53.6, | ||
"intersections": [ | ||
{ | ||
"location": [ | ||
-122.523671, | ||
37.975379 | ||
], | ||
"bearings": [ | ||
194 | ||
], | ||
"entry": [ | ||
true | ||
], | ||
"out": 0 | ||
} | ||
] | ||
}, | ||
{ | ||
"distance": 54.5, | ||
"duration": 20.8, | ||
"geometry": "shylgA`dguhFh@kHbC{[", | ||
"name": "Laurel Place", | ||
"mode": "driving", | ||
"maneuver": { | ||
"location": [ | ||
-122.523729, | ||
37.975194 | ||
], | ||
"bearing_before": 194.0, | ||
"bearing_after": 99.0, | ||
"instruction": "Turn left onto Laurel Place", | ||
"type": "turn", | ||
"modifier": "left" | ||
}, | ||
"voiceInstructions": [ | ||
{ | ||
"distanceAlongGeometry": 39.3, | ||
"announcement": "Turn right onto Lincoln Avenue, then you will arrive at your destination", | ||
"ssmlAnnouncement": "\u003cspeak\u003e\u003camazon:effect name\u003d\"drc\"\u003e\u003cprosody rate\u003d\"1.08\"\u003eTurn right onto Lincoln Avenue, then you will arrive at your destination\u003c/prosody\u003e\u003c/amazon:effect\u003e\u003c/speak\u003e" | ||
} | ||
], | ||
"bannerInstructions": [ | ||
{ | ||
"distanceAlongGeometry": 54.5, | ||
"primary": { | ||
"text": "Lincoln Avenue", | ||
"components": [ | ||
{ | ||
"text": "Lincoln Avenue", | ||
"type": "text", | ||
"abbr": "Lincoln Ave", | ||
"abbr_priority": 0 | ||
} | ||
], | ||
"type": "turn", | ||
"modifier": "right" | ||
} | ||
} | ||
], | ||
"driving_side": "right", | ||
"weight": 36.5, | ||
"intersections": [ | ||
{ | ||
"location": [ | ||
-122.523729, | ||
37.975194 | ||
], | ||
"bearings": [ | ||
15, | ||
105, | ||
285 | ||
], | ||
"entry": [ | ||
false, | ||
true, | ||
true | ||
], | ||
"in": 0, | ||
"out": 1 | ||
} | ||
] | ||
}, | ||
{ | ||
"distance": 4.6, | ||
"duration": 1.6, | ||
"geometry": "ecylgAx}euhFnAZ", | ||
"name": "Lincoln Avenue", | ||
"mode": "driving", | ||
"maneuver": { | ||
"location": [ | ||
-122.523117, | ||
37.975107 | ||
], | ||
"bearing_before": 99.0, | ||
"bearing_after": 194.0, | ||
"instruction": "Turn right onto Lincoln Avenue", | ||
"type": "turn", | ||
"modifier": "right" | ||
}, | ||
"voiceInstructions": [ | ||
{ | ||
"distanceAlongGeometry": 4.6, | ||
"announcement": "You have arrived at your destination", | ||
"ssmlAnnouncement": "\u003cspeak\u003e\u003camazon:effect name\u003d\"drc\"\u003e\u003cprosody rate\u003d\"1.08\"\u003eYou have arrived at your destination\u003c/prosody\u003e\u003c/amazon:effect\u003e\u003c/speak\u003e" | ||
} | ||
], | ||
"bannerInstructions": [ | ||
{ | ||
"distanceAlongGeometry": 4.6, | ||
"primary": { | ||
"text": "You have arrived", | ||
"components": [ | ||
{ | ||
"text": "You have arrived", | ||
"type": "text" | ||
} | ||
], | ||
"type": "arrive", | ||
"modifier": "straight" | ||
} | ||
} | ||
], | ||
"driving_side": "right", | ||
"weight": 1.6, | ||
"intersections": [ | ||
{ | ||
"location": [ | ||
-122.523117, | ||
37.975107 | ||
], | ||
"bearings": [ | ||
15, | ||
105, | ||
195, | ||
285 | ||
], | ||
"entry": [ | ||
true, | ||
true, | ||
true, | ||
false | ||
], | ||
"in": 3, | ||
"out": 2 | ||
} | ||
] | ||
}, | ||
{ | ||
"distance": 0.0, | ||
"duration": 0.0, | ||
"geometry": "u`ylgAt~euhF", | ||
"name": "Lincoln Avenue", | ||
"mode": "driving", | ||
"maneuver": { | ||
"location": [ | ||
-122.523131, | ||
37.975067 | ||
], | ||
"bearing_before": 195.0, | ||
"bearing_after": 0.0, | ||
"instruction": "You have arrived at your destination", | ||
"type": "arrive" | ||
}, | ||
"voiceInstructions": [], | ||
"bannerInstructions": [], | ||
"driving_side": "right", | ||
"weight": 0.0, | ||
"intersections": [ | ||
{ | ||
"location": [ | ||
-122.523131, | ||
37.975067 | ||
], | ||
"bearings": [ | ||
15 | ||
], | ||
"entry": [ | ||
true | ||
], | ||
"in": 0 | ||
} | ||
] | ||
} | ||
], | ||
"annotation": { | ||
"distance": [ | ||
21.195927744585475, | ||
13.357383159214507, | ||
41.16669115760234, | ||
4.6152763527970215 | ||
], | ||
"congestion": [ | ||
"unknown", | ||
"unknown", | ||
"unknown", | ||
"moderate" | ||
] | ||
} | ||
} | ||
], | ||
"routeOptions": { | ||
"baseUrl": "https://api.mapbox.com", | ||
"user": "mapbox", | ||
"profile": "driving-traffic", | ||
"coordinates": "-122.5237429,37.975393;-122.5231413,37.9750695", | ||
"alternatives": true, | ||
"language": "en", | ||
"continue_straight": false, | ||
"roundabout_exits": false, | ||
"geometries": "polyline6", | ||
"overview": "full", | ||
"steps": true, | ||
"annotations": "congestion,distance", | ||
"voice_instructions": true, | ||
"banner_instructions": true, | ||
"voice_units": "imperial" | ||
}, | ||
"toll_costs": [ | ||
{ | ||
} | ||
], | ||
"voiceLocale": "en-US", | ||
"requestUuid": "ckfx63od74hih2ro83w0w4mak" | ||
} |
Oops, something went wrong.