[android] updated naming scheme and packages structure for LocationLayerPlugin, now called LocationComponent
This commit is contained in:
committed by
Łukasz Paczos
parent
cf7752c80c
commit
907612e93d
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer
|
||||
package com.mapbox.mapboxsdk.location
|
||||
|
||||
import android.Manifest
|
||||
import android.R
|
||||
@@ -17,13 +17,13 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
|
||||
import com.mapbox.mapboxsdk.constants.Style
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.*
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode
|
||||
import com.mapbox.mapboxsdk.plugins.utils.*
|
||||
import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.MAPBOX_HEAVY_STYLE
|
||||
import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.MAP_CONNECTION_DELAY
|
||||
import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.MAP_RENDER_DELAY
|
||||
import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.pushSourceUpdates
|
||||
import com.mapbox.mapboxsdk.location.LocationComponentConstants.*
|
||||
import com.mapbox.mapboxsdk.location.modes.RenderMode
|
||||
import com.mapbox.mapboxsdk.location.utils.*
|
||||
import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAPBOX_HEAVY_STYLE
|
||||
import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAP_CONNECTION_DELAY
|
||||
import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAP_RENDER_DELAY
|
||||
import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.pushSourceUpdates
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest
|
||||
import com.mapbox.mapboxsdk.testapp.activity.SingleActivity
|
||||
@@ -39,7 +39,7 @@ import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class LocationLayerTest : BaseActivityTest() {
|
||||
class LocationLayerControllerTest : BaseActivityTest() {
|
||||
|
||||
@Rule
|
||||
@JvmField
|
||||
@@ -51,7 +51,7 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
|
||||
private lateinit var styleChangeIdlingResource: StyleChangeIdlingResource
|
||||
private val location: Location by lazy {
|
||||
val initLocation = Location("test")
|
||||
val initLocation = Location("")
|
||||
initLocation.latitude = 15.0
|
||||
initLocation.longitude = 17.0
|
||||
initLocation.bearing = 10f
|
||||
@@ -72,16 +72,16 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
|
||||
@Test
|
||||
fun renderModeNormal_sourceDoesGetAdded() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.renderMode = RenderMode.NORMAL
|
||||
component.activateLocationComponent(context, false)
|
||||
component.renderMode = RenderMode.NORMAL
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
|
||||
assertThat(mapboxMap.getSource(LOCATION_SOURCE), notNullValue())
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
//
|
||||
@@ -90,12 +90,12 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
|
||||
@Test
|
||||
fun renderModeNormal_trackingNormalLayersDoGetAdded() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.renderMode = RenderMode.NORMAL
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.renderMode = RenderMode.NORMAL
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
|
||||
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
|
||||
@@ -104,17 +104,17 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun renderModeCompass_bearingLayersDoGetAdded() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.renderMode = RenderMode.COMPASS
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.renderMode = RenderMode.COMPASS
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
|
||||
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
|
||||
@@ -123,17 +123,17 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(true))
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun renderModeGps_navigationLayersDoGetAdded() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.renderMode = RenderMode.GPS
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.renderMode = RenderMode.GPS
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
|
||||
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
|
||||
@@ -142,20 +142,20 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun dontShowPuckWhenRenderModeSetAndPluginDisabled() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
fun dontShowPuckWhenRenderModeSetAndComponentDisabled() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
plugin.deactivateLocationLayerPlugin()
|
||||
component.deactivateLocationComponent()
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER, shouldDisappear = true)
|
||||
plugin.renderMode = RenderMode.GPS
|
||||
component.renderMode = RenderMode.GPS
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
|
||||
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(false))
|
||||
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(false))
|
||||
@@ -164,19 +164,19 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenLocationLayerPluginDisabled_doesSetAllLayersToVisibilityNone() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
fun whenLocationComponentDisabled_doesSetAllLayersToVisibilityNone() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.renderMode = RenderMode.NORMAL
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.renderMode = RenderMode.NORMAL
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
plugin.deactivateLocationLayerPlugin()
|
||||
component.deactivateLocationComponent()
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER, shouldDisappear = true)
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
|
||||
|
||||
@@ -188,24 +188,24 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onMapChange_locationLayerLayersDoGetRedrawn() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
fun onMapChange_locationComponentLayersDoGetRedrawn() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.renderMode = RenderMode.NORMAL
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.renderMode = RenderMode.NORMAL
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
mapboxMap.setStyleUrl(Style.LIGHT)
|
||||
uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY)
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
|
||||
assertThat(plugin.renderMode, `is`(equalTo(RenderMode.NORMAL)))
|
||||
assertThat(component.renderMode, `is`(equalTo(RenderMode.NORMAL)))
|
||||
|
||||
// Check that the Source has been re-added to the new map style
|
||||
val source: GeoJsonSource? = mapboxMap.getSourceAs(LOCATION_SOURCE)
|
||||
@@ -219,17 +219,17 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenStyleChanged_continuesUsingStaleIcons() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.applyStyle(LocationLayerOptions.builder(context).staleStateTimeout(100).build())
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.applyStyle(LocationComponentOptions.builder(context).staleStateTimeout(100).build())
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
uiController.loopMainThreadForAtLeast(150)
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
|
||||
@@ -243,23 +243,23 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true))
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenStyleChanged_staleStateChanges() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.applyStyle(LocationLayerOptions.builder(context).staleStateTimeout(1).build())
|
||||
component.activateLocationComponent(context, false)
|
||||
component.applyStyle(LocationComponentOptions.builder(context).staleStateTimeout(1).build())
|
||||
styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE)
|
||||
pushSourceUpdates(styleChangeIdlingResource) {
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.forceLocationUpdate(location)
|
||||
}
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
|
||||
// Waiting for style to finish loading while pushing updates
|
||||
onView(withId(R.id.content)).check(matches(isDisplayed()))
|
||||
@@ -267,16 +267,16 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
|
||||
@Test
|
||||
fun whenStyleChanged_layerVisibilityUpdates() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
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)
|
||||
var show = true
|
||||
pushSourceUpdates(styleChangeIdlingResource) {
|
||||
if (show) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
component.activateLocationComponent(context, false)
|
||||
} else {
|
||||
plugin.deactivateLocationLayerPlugin()
|
||||
component.deactivateLocationComponent()
|
||||
}
|
||||
show = !show
|
||||
}
|
||||
@@ -284,7 +284,7 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY)
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
|
||||
// Waiting for style to finish loading while pushing updates
|
||||
onView(withId(R.id.content)).check(matches(isDisplayed()))
|
||||
@@ -292,12 +292,12 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
|
||||
@Test
|
||||
fun accuracy_visibleWithNewLocation() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
component.activateLocationComponent(context, false)
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0))
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
uiController.loopMainThreadForAtLeast(ACCURACY_RADIUS_ANIMATION_DURATION)
|
||||
|
||||
@@ -306,16 +306,16 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
.getNumberProperty(PROPERTY_ACCURACY_RADIUS).toFloat(), 0.1f)
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun accuracy_visibleWhenCameraEased() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0), 300)
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY + 300)
|
||||
@@ -325,17 +325,17 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
.getNumberProperty(PROPERTY_ACCURACY_RADIUS).toFloat(), 0.1f)
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun accuracy_visibleWhenCameraMoved() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
component.activateLocationComponent(context, false)
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.forceLocationUpdate(location)
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0))
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY + 300)
|
||||
@@ -345,7 +345,7 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
.getNumberProperty(PROPERTY_ACCURACY_RADIUS).toFloat(), 0.1f)
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -354,7 +354,7 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
IdlingRegistry.getInstance().unregister(styleChangeIdlingResource)
|
||||
}
|
||||
|
||||
private fun executePluginTest(listener: LocationLayerPluginAction.OnPerformLocationLayerPluginAction) {
|
||||
onView(withId(R.id.content)).perform(LocationLayerPluginAction(mapboxMap, listener))
|
||||
private fun executeComponentTest(listener: LocationComponentAction.OnPerformLocationComponentAction) {
|
||||
onView(withId(R.id.content)).perform(LocationComponentAction(mapboxMap, listener))
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.utils
|
||||
package com.mapbox.mapboxsdk.location.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.support.test.espresso.UiController
|
||||
@@ -6,11 +6,11 @@ import android.support.test.espresso.ViewAction
|
||||
import android.support.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import android.view.View
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin
|
||||
import com.mapbox.mapboxsdk.location.LocationComponent
|
||||
import org.hamcrest.Matcher
|
||||
|
||||
class LocationLayerPluginAction(private val mapboxMap: MapboxMap,
|
||||
private val onPerformLocationLayerPluginAction: OnPerformLocationLayerPluginAction) : ViewAction {
|
||||
class LocationComponentAction(private val mapboxMap: MapboxMap,
|
||||
private val onPerformLocationComponentAction: OnPerformLocationComponentAction) : ViewAction {
|
||||
|
||||
override fun getConstraints(): Matcher<View> {
|
||||
return isDisplayed()
|
||||
@@ -21,20 +21,20 @@ class LocationLayerPluginAction(private val mapboxMap: MapboxMap,
|
||||
}
|
||||
|
||||
override fun perform(uiController: UiController, view: View) {
|
||||
val plugin = mapboxMap.locationLayerPlugin
|
||||
val component = mapboxMap.locationComponent
|
||||
|
||||
while (mapboxMap.getSource("mapbox-location-source") == null) {
|
||||
uiController.loopMainThreadForAtLeast(MapboxTestingUtils.MAP_RENDER_DELAY)
|
||||
}
|
||||
|
||||
onPerformLocationLayerPluginAction.onLocationLayerPluginAction(
|
||||
plugin,
|
||||
onPerformLocationComponentAction.onLocationComponentAction(
|
||||
component,
|
||||
mapboxMap,
|
||||
uiController,
|
||||
view.context)
|
||||
}
|
||||
|
||||
interface OnPerformLocationLayerPluginAction {
|
||||
fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, uiController: UiController, context: Context)
|
||||
interface OnPerformLocationComponentAction {
|
||||
fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.utils
|
||||
package com.mapbox.mapboxsdk.location.utils
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.utils
|
||||
package com.mapbox.mapboxsdk.location.utils
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.utils;
|
||||
package com.mapbox.mapboxsdk.location.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Handler;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.utils
|
||||
package com.mapbox.mapboxsdk.location.utils
|
||||
|
||||
import android.support.test.espresso.IdlingResource
|
||||
import com.mapbox.mapboxsdk.maps.MapView
|
||||
Reference in New Issue
Block a user