summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt114
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt31
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt14
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt45
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java13
5 files changed, 140 insertions, 77 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
index 9f756239e1..8362095042 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
@@ -75,7 +75,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context)
+ component.activateLocationComponent(context, mapboxMap.style!!)
component.isLocationComponentEnabled = true
val locationEngine = component.locationEngine
@@ -96,6 +96,7 @@ class LocationComponentTest : BaseActivityTest() {
uiController: UiController, context: Context) {
component.activateLocationComponent(
context,
+ mapboxMap.style!!,
LocationComponentOptions.builder(context)
.staleStateTimeout(200)
.enableStaleState(false)
@@ -127,6 +128,7 @@ class LocationComponentTest : BaseActivityTest() {
uiController: UiController, context: Context) {
component.activateLocationComponent(
context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.staleStateTimeout(200)
@@ -158,8 +160,9 @@ class LocationComponentTest : BaseActivityTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
+ val style = mapboxMap.style!!
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, style,false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
@@ -181,7 +184,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
// Source should be present but empty
@@ -212,6 +215,7 @@ class LocationComponentTest : BaseActivityTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.staleStateTimeout(200)
@@ -223,6 +227,7 @@ class LocationComponentTest : BaseActivityTest() {
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
uiController.loopMainThreadForAtLeast(500)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
mapboxMap.querySourceFeatures(LOCATION_SOURCE).also {
it.forEach {
assertThat(it.getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(false))
@@ -241,6 +246,7 @@ class LocationComponentTest : BaseActivityTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.foregroundName("custom-foreground-bitmap")
@@ -264,6 +270,7 @@ class LocationComponentTest : BaseActivityTest() {
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(false))
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
val feature = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0]
assertThat(feature.getStringProperty(PROPERTY_FOREGROUND_ICON), `is`(equalTo("custom-foreground-bitmap")))
assertThat(feature.getStringProperty(PROPERTY_BACKGROUND_ICON), `is`(equalTo("custom-background-bitmap")))
@@ -283,6 +290,7 @@ class LocationComponentTest : BaseActivityTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.foregroundName("custom-foreground-bitmap")
@@ -298,7 +306,7 @@ class LocationComponentTest : BaseActivityTest() {
mapboxMap.addImageFromDrawable("custom-foreground-bitmap", it)
mapboxMap.addImageFromDrawable("custom-gps-bitmap", it)
}
-
+ mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
val foregroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON)
assertThat(foregroundId, `is`(equalTo("custom-gps-bitmap")))
}
@@ -314,6 +322,7 @@ class LocationComponentTest : BaseActivityTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.foregroundName("custom-foreground-bitmap")
@@ -325,12 +334,14 @@ class LocationComponentTest : BaseActivityTest() {
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
val foregroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON)
assertThat(foregroundId, `is`(equalTo("custom-gps-bitmap")))
component.applyStyle(LocationComponentOptions.builder(context).build())
val renderCheck = {
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON) == FOREGROUND_ICON
}
waitForRenderResult(uiController, renderCheck, true)
@@ -349,6 +360,7 @@ class LocationComponentTest : BaseActivityTest() {
uiController: UiController, context: Context) {
component.activateLocationComponent(context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.gpsName("custom-gps-bitmap")
@@ -359,12 +371,14 @@ class LocationComponentTest : BaseActivityTest() {
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
val foregroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON)
assertThat(foregroundId, `is`(equalTo("custom-gps-bitmap")))
component.renderMode = RenderMode.NORMAL
val renderCheck = {
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON) == FOREGROUND_ICON
}
waitForRenderResult(uiController, renderCheck, true)
@@ -382,6 +396,7 @@ class LocationComponentTest : BaseActivityTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.staleStateTimeout(200)
@@ -393,6 +408,7 @@ class LocationComponentTest : BaseActivityTest() {
uiController.loopMainThreadForAtLeast(250) // engaging stale state
val renderCheck = {
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE)
}
waitForRenderResult(uiController, renderCheck, true)
@@ -402,6 +418,7 @@ class LocationComponentTest : BaseActivityTest() {
component.onStart()
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true))
assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(false))
}
@@ -416,16 +433,19 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(false))
component.onStop()
component.onStart()
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(false))
assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(true))
}
@@ -443,6 +463,7 @@ class LocationComponentTest : BaseActivityTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.accuracyColor(color)
@@ -453,6 +474,7 @@ class LocationComponentTest : BaseActivityTest() {
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
// Check that the source property changes correctly
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
mapboxMap.querySourceFeatures(LOCATION_SOURCE).also {
it.forEach {
assertThat(it.getStringProperty(PROPERTY_ACCURACY_COLOR), `is`(equalTo(rgbaColor)))
@@ -470,11 +492,12 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point
assertThat(component.locationEngine, nullValue())
@@ -491,7 +514,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
@@ -514,7 +537,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
@@ -540,7 +563,7 @@ class LocationComponentTest : BaseActivityTest() {
component.onStop()
component.onStart()
assertThat(component.isLocationComponentEnabled, `is`(false))
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
assertThat(component.isLocationComponentEnabled, `is`(true))
}
@@ -554,7 +577,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
assertThat(component.isLocationComponentEnabled, `is`(true))
component.onStop()
@@ -571,7 +594,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.isLocationComponentEnabled = false
assertThat(component.isLocationComponentEnabled, `is`(false))
@@ -589,7 +612,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.onStop()
@@ -608,7 +631,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
mapboxMap.setStyle(Style.Builder().fromUrl(Style.DARK))
component.onStop()
@@ -625,12 +648,13 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.onStop()
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE).isEmpty(), `is`(true))
}
}
@@ -643,13 +667,15 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.onStop()
component.forceLocationUpdate(location)
component.onStart()
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
+ mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point
assertEquals(point.latitude(), location.latitude, 0.1)
assertEquals(point.longitude(), location.longitude, 0.1)
@@ -664,7 +690,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
@@ -673,6 +699,7 @@ class LocationComponentTest : BaseActivityTest() {
component.onStart()
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point
assertEquals(point.latitude(), location.latitude, 0.1)
assertEquals(point.longitude(), location.longitude, 0.1)
@@ -693,9 +720,9 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
- styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE)
+ styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
val options = LocationComponentOptions.builder(context)
.accuracyColor(Color.RED)
.build()
@@ -719,9 +746,9 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
- styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE)
+ styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
pushSourceUpdates(styleChangeIdlingResource) {
component.forceLocationUpdate(location)
@@ -742,8 +769,9 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE)
- component.activateLocationComponent(context, false)
+ styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
+ uiController.loopMainThreadForAtLeast(100)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
val options = LocationComponentOptions.builder(context)
@@ -768,7 +796,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.GPS
location.bearing = 77f
@@ -776,11 +804,15 @@ class LocationComponentTest : BaseActivityTest() {
uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY)
assertThat(mapboxMap.style, notNullValue())
assertThat(mapboxMap.style?.getSource(LOCATION_SOURCE), notNullValue())
+ mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
assertEquals(77.0, mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(PROPERTY_GPS_BEARING) as Double, 0.1)
location.bearing = 92f
component.forceLocationUpdate(location)
uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) // Waiting for the animation to finish
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
+ mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
assertEquals(92.0, mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(PROPERTY_GPS_BEARING) as Double, 0.1)
}
}
@@ -793,7 +825,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING_GPS
location.bearing = 77f
@@ -822,7 +854,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.NONE_GPS
val latitude = mapboxMap.cameraPosition.target.latitude
@@ -854,7 +886,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.NONE
val latitude = mapboxMap.cameraPosition.target.latitude
@@ -887,7 +919,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
component.cameraMode = CameraMode.NONE
@@ -906,7 +938,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.NONE
val zoom = mapboxMap.cameraPosition.zoom
@@ -925,7 +957,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
component.zoomWhileTracking(10.0)
@@ -944,7 +976,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
component.zoomWhileTracking(15.0)
@@ -964,7 +996,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
@@ -987,7 +1019,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
component.zoomWhileTracking(15.0)
@@ -1007,7 +1039,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.NONE
val tilt = mapboxMap.cameraPosition.tilt
@@ -1026,7 +1058,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
component.tiltWhileTracking(30.0)
@@ -1045,7 +1077,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
component.tiltWhileTracking(30.0)
@@ -1065,7 +1097,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
val tilt = mapboxMap.cameraPosition.tilt
@@ -1087,7 +1119,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
component.tiltWhileTracking(30.0)
@@ -1107,7 +1139,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING_GPS
component.forceLocationUpdate(location)
@@ -1131,7 +1163,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
val target = LatLng(51.0, 17.0)
assertTrue(target.distanceTo(LatLng(location)) > LocationComponentConstants.INSTANT_LOCATION_TRANSITION_THRESHOLD)
@@ -1154,7 +1186,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
assertTrue(component.compassEngine is LocationComponentCompassEngine)
}
@@ -1168,7 +1200,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
val engine: CompassEngine = object : CompassEngine {
override fun addCompassListener(compassListener: CompassListener) {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
index b8f146f983..12ae701d0a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
@@ -75,7 +75,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
@@ -94,7 +94,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
@@ -114,7 +114,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.COMPASS
component.forceLocationUpdate(location)
@@ -134,7 +134,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.GPS
component.forceLocationUpdate(location)
@@ -154,7 +154,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
@@ -183,7 +183,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
@@ -207,7 +207,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
@@ -239,7 +239,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.applyStyle(LocationComponentOptions.builder(context).staleStateTimeout(100).build())
component.forceLocationUpdate(location)
@@ -268,10 +268,10 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.applyStyle(LocationComponentOptions.builder(context).staleStateTimeout(1).build())
- styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE)
+ styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
pushSourceUpdates(styleChangeIdlingResource) {
component.forceLocationUpdate(location)
}
@@ -288,9 +288,10 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE)
+ styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
+ uiController.loopMainThreadForAtLeast(100)
var show = true
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
pushSourceUpdates(styleChangeIdlingResource) {
component.isLocationComponentEnabled = show
show = !show
@@ -310,7 +311,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0))
component.forceLocationUpdate(location)
@@ -330,7 +331,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
@@ -364,7 +365,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt
index 55ad7179ec..5aded25d1e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt
@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.location.utils
import android.support.test.espresso.IdlingResource
-import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
+import java.util.logging.Handler
/**
* Resource, that's idling until the provided style is loaded.
@@ -32,14 +32,10 @@ class StyleChangeIdlingResource : IdlingResource {
callback?.onTransitionToIdle()
}
- fun waitForStyle(mapView: MapView, mapboxMap: MapboxMap, styleUrl: String) {
+ fun waitForStyle(mapboxMap: MapboxMap, styleUrl: String) {
isIdle = false
- mapView.addOnDidFinishLoadingStyleListener(object : MapView.OnDidFinishLoadingStyleListener {
- override fun onDidFinishLoadingStyle() {
- mapView.removeOnDidFinishLoadingStyleListener(this)
- setIdle()
- }
- })
- mapboxMap.setStyle(Style.Builder().fromUrl(styleUrl))
+ mapboxMap.setStyle(Style.Builder().fromUrl(styleUrl)) {
+ setIdle()
+ }
}
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt
new file mode 100644
index 0000000000..1f9acbb291
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt
@@ -0,0 +1,45 @@
+package com.mapbox.mapboxsdk.testapp.maps
+
+import android.support.test.espresso.UiController
+import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.maps.MapView
+import com.mapbox.mapboxsdk.maps.MapboxMap
+import com.mapbox.mapboxsdk.maps.Style
+import com.mapbox.mapboxsdk.style.layers.SymbolLayer
+import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
+import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest
+import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class StyleLoadTest : BaseActivityTest() {
+
+ private lateinit var mapView: MapView
+
+ override fun getActivityClass(): Class<*> {
+ return EspressoTestActivity::class.java
+ }
+
+ @Before
+ override fun beforeTest() {
+ super.beforeTest()
+ mapView = (rule.activity as EspressoTestActivity).mapView
+ }
+
+ @Test
+ fun updateSourceAfterStyleLoad() {
+ validateTestSetup()
+ MapboxMapAction.invoke(mapboxMap) { uiController: UiController, mapboxMap: MapboxMap ->
+ val source = GeoJsonSource("id")
+ val layer = SymbolLayer("id", "id")
+ mapboxMap.setStyle(Style.Builder().withSource(source).withLayer(layer))
+ uiController.loopMainThreadForAtLeast(100)
+ mapboxMap.setStyle(Style.Builder().fromUrl(Style.MAPBOX_STREETS))
+ uiController.loopMainThreadForAtLeast(100)
+ source.setGeoJson("{}")
+ }
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java
index caa15d05be..1bcab3932e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java
@@ -3,19 +3,14 @@ package com.mapbox.mapboxsdk.testapp.utils;
import android.app.Activity;
import android.os.Handler;
import android.os.Looper;
-import android.support.annotation.NonNull;
import android.support.annotation.WorkerThread;
import android.support.test.espresso.IdlingResource;
-
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
-import junit.framework.Assert;
-
-public class OnMapReadyIdlingResource implements IdlingResource, OnMapReadyCallback {
+public class OnMapReadyIdlingResource implements IdlingResource {
private boolean styleLoaded;
private MapboxMap mapboxMap;
@@ -61,10 +56,4 @@ public class OnMapReadyIdlingResource implements IdlingResource, OnMapReadyCallb
public MapboxMap getMapboxMap() {
return mapboxMap;
}
-
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- Assert.assertNotNull("MapboxMap should not be null", mapboxMap);
- this.mapboxMap = mapboxMap;
- }
} \ No newline at end of file