summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt40
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt8
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt3
4 files changed, 44 insertions, 13 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 edc0d5de4a..d643dd1173 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
@@ -57,6 +57,11 @@ class LocationComponentTest : BaseActivityTest() {
initLocation
}
+ override fun validateTestSetup() {
+ super.validateTestSetup()
+ assertThat(mapboxMap.getStyle(), notNullValue())
+ }
+
@Before
override fun beforeTest() {
super.beforeTest()
@@ -152,7 +157,8 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- mapboxMap.setStyle(Style.LIGHT)
+
+ mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
component.activateLocationComponent(context, false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
@@ -231,6 +237,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun locationComponentOptions_loadsForegroundBitmapFromNameOption() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -272,6 +279,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun locationComponentOptions_loadsGpsNameWithGpsRenderMode() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -302,6 +310,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun locationComponentOptions_customIconNameRevertsToDefault() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -335,6 +344,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun locationComponentOptions_customGpsIconNameChangeBackWithMode() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -368,6 +378,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun stillStaleAfterResuming() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -402,6 +413,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun stillNotStaleAfterResuming() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -424,6 +436,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun locationComponentOptions_accuracyRingWithColor() {
+ validateTestSetup()
val color = Color.parseColor("#4A90E2")
val rgbaColor = ColorUtils.colorToRgbaString(color)
@@ -454,6 +467,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun forceLocationUpdate_doesMoveLocationLayerIconToCorrectPosition() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -474,6 +488,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun disablingComponentHidesPuck() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -496,6 +511,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun disablingComponentAndChangingStyleAllowsToEnableAgain() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -505,7 +521,7 @@ class LocationComponentTest : BaseActivityTest() {
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
component.isLocationComponentEnabled = false
- mapboxMap.setStyle(Style.LIGHT)
+ mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
component.isLocationComponentEnabled = true
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
@@ -517,6 +533,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun lifecycle_isDisabledOnStart() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -534,6 +551,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun lifecycle_keepsEnabledWhenStoppedAndStarted() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -550,6 +568,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun lifecycle_keepsDisabledWhenStoppedAndStarted() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -567,6 +586,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun lifecycle_ableToChangeStyleAfterResuming() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -576,7 +596,7 @@ class LocationComponentTest : BaseActivityTest() {
component.onStop()
component.onStart()
- mapboxMap.setStyle(Style.DARK)
+ mapboxMap.setStyle(Style.Builder().fromUrl(Style.DARK))
uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY)
}
}
@@ -585,12 +605,13 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun lifecycle_interruptedDuringStyleChange() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context, false)
component.isLocationComponentEnabled = true
- mapboxMap.setStyle(Style.DARK)
+ mapboxMap.setStyle(Style.Builder().fromUrl(Style.DARK))
component.onStop()
component.onStart()
uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY)
@@ -601,6 +622,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun lifecycle_forceLocationUpdateAfterStopped() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -618,6 +640,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun lifecycle_acceptAndReuseLocationUpdatesBeforeLayerStarted() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -638,13 +661,14 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun lifecycle_lifecycleChangeRightAfterStyleReload() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context, false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
- mapboxMap.setStyle(Style.LIGHT)
+ mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
component.onStop()
uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY)
component.onStart()
@@ -666,6 +690,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun mapChange_settingComponentStyle() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -691,6 +716,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun mapChange_forcingLocation() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -713,6 +739,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun mapChange_settingMapStyleBeforeComponentCreation() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -738,6 +765,7 @@ class LocationComponentTest : BaseActivityTest() {
@Test
fun animators_layerBearingCorrect() {
+ validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
@@ -747,6 +775,8 @@ class LocationComponentTest : BaseActivityTest() {
location.bearing = 77f
component.forceLocationUpdate(location)
uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY)
+ assertThat(mapboxMap.style, notNullValue())
+ assertThat(mapboxMap.style?.getSource(LOCATION_SOURCE), notNullValue())
assertEquals(77.0, mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(PROPERTY_GPS_BEARING) as Double, 0.1)
location.bearing = 92f
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 aa666eaa25..b8f146f983 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
@@ -79,7 +79,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
- assertThat(mapboxMap.getStyle().getSource(LOCATION_SOURCE), notNullValue())
+ assertThat(mapboxMap.getStyle()!!.getSource(LOCATION_SOURCE), notNullValue())
}
}
executeComponentTest(componentAction)
@@ -212,7 +212,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
- mapboxMap.setStyleUrl(Style.LIGHT)
+ mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY)
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
@@ -220,7 +220,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
assertThat(component.renderMode, `is`(equalTo(RenderMode.NORMAL)))
// Check that the Source has been re-added to the new map style
- val source: GeoJsonSource? = mapboxMap.getStyle().getSourceAs(LOCATION_SOURCE)
+ val source: GeoJsonSource? = mapboxMap.getStyle()!!.getSourceAs(LOCATION_SOURCE)
assertThat(source, notNullValue())
// Check that all layers visibilities are set to visible
@@ -253,7 +253,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
assertThat(renderCheck.invoke(), `is`(true))
- mapboxMap.setStyleUrl(Style.LIGHT)
+ mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt
index b1e31709c5..429f4e7ab1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt
@@ -15,7 +15,7 @@ import com.mapbox.mapboxsdk.style.layers.Property
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
fun MapboxMap.querySourceFeatures(sourceId: String): List<Feature> {
- return this.style.getSourceAs<GeoJsonSource>(sourceId)?.querySourceFeatures(null) ?: emptyList()
+ return this.style!!.getSourceAs<GeoJsonSource>(sourceId)?.querySourceFeatures(null) ?: emptyList()
}
fun MapboxMap.queryRenderedFeatures(location: Location, layerId: String): List<Feature> {
@@ -25,7 +25,7 @@ fun MapboxMap.queryRenderedFeatures(location: Location, layerId: String): List<F
}
fun MapboxMap.isLayerVisible(layerId: String): Boolean {
- return this.style.getLayer(layerId)?.visibility?.value?.equals(Property.VISIBLE)!!
+ return this.style!!.getLayer(layerId)?.visibility?.value?.equals(Property.VISIBLE)!!
}
fun MapboxMap.waitForSource(uiController: UiController, sourceId: String) {
@@ -99,7 +99,7 @@ class MapboxTestingUtils {
fun MapboxMap.addImageFromDrawable(string: String, drawable: Drawable) {
val bitmapFromDrawable = getBitmapFromDrawable(drawable)
- this.style.addImage(string, bitmapFromDrawable)
+ this.style!!.addImage(string, bitmapFromDrawable)
}
private fun getBitmapFromDrawable(drawable: Drawable): Bitmap {
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 34f172dbf1..55ad7179ec 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
@@ -3,6 +3,7 @@ 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
/**
* Resource, that's idling until the provided style is loaded.
@@ -39,6 +40,6 @@ class StyleChangeIdlingResource : IdlingResource {
setIdle()
}
})
- mapboxMap.setStyleUrl(styleUrl)
+ mapboxMap.setStyle(Style.Builder().fromUrl(styleUrl))
}
} \ No newline at end of file