diff options
author | Łukasz Paczos <lukas.paczos@gmail.com> | 2018-09-05 14:30:36 +0200 |
---|---|---|
committer | Łukasz Paczos <lukasz.paczos@mapbox.com> | 2018-09-12 13:59:11 +0200 |
commit | 907612e93d8a2b156d4604fda348707ccb347836 (patch) | |
tree | 830bc854430f31e5f688d3d849fbb81599ea0ce0 /platform/android/MapboxGLAndroidSDKTestApp/src/androidTest | |
parent | cf7752c80c1dab6a818fb5093bee5cd964990525 (diff) | |
download | qtlocation-mapboxgl-907612e93d8a2b156d4604fda348707ccb347836.tar.gz |
[android] updated naming scheme and packages structure for LocationLayerPlugin, now called LocationComponent
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest')
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt (renamed from platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPluginTest.kt) | 676 | ||||
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt (renamed from platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerTest.kt) | 184 | ||||
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt (renamed from platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/LocationLayerPluginAction.kt) | 18 | ||||
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt (renamed from platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/MapboxTestingUtils.kt) | 2 | ||||
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/OnMapFragmentReadyIdlingResource.kt (renamed from platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/OnMapFragmentReadyIdlingResource.kt) | 2 | ||||
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/OnMapReadyIdlingResource.java (renamed from platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/OnMapReadyIdlingResource.java) | 2 | ||||
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt (renamed from platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/StyleChangeIdlingResource.kt) | 2 |
7 files changed, 443 insertions, 443 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPluginTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt index e9552f974b..1d7c0c404b 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPluginTest.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt @@ -1,4 +1,4 @@ -package com.mapbox.mapboxsdk.plugins.locationlayer +package com.mapbox.mapboxsdk.location import android.Manifest import android.R @@ -19,14 +19,14 @@ 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.CameraMode -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.CameraMode +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.testapp.activity.BaseActivityTest import com.mapbox.mapboxsdk.testapp.activity.SingleActivity import com.mapbox.mapboxsdk.utils.ColorUtils @@ -37,7 +37,7 @@ import org.junit.Assert.assertTrue import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) -class LocationLayerPluginTest : BaseActivityTest() { +class LocationComponentTest : BaseActivityTest() { @Rule @JvmField @@ -49,7 +49,7 @@ class LocationLayerPluginTest : 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 @@ -65,14 +65,14 @@ class LocationLayerPluginTest : BaseActivityTest() { } @Test - fun locationLayerPlugin_initializesLocationEngineCorrectlyWhenOnesNotProvided() { + fun locationComponent_initializesLocationEngineCorrectlyWhenOnesNotProvided() { validateTestSetup() - 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) + component.activateLocationComponent(context) - val locationEngine = plugin.locationEngine + val locationEngine = component.locationEngine assertThat(locationEngine, notNullValue()) uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) @@ -80,82 +80,82 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayerPlugin_initializesLocationEngineCorrectlyWhenOnesNotProvidedButHasOptions() { + fun locationComponent_initializesLocationEngineCorrectlyWhenOnesNotProvidedButHasOptions() { validateTestSetup() - 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( + component.activateLocationComponent( context, - LocationLayerOptions.builder(context) + LocationComponentOptions.builder(context) .staleStateTimeout(200) .enableStaleState(false) .accuracyAlpha(.5f) .accuracyColor(Color.BLUE) .build()) - val locationEngine = plugin.locationEngine - val pluginOptions = plugin.locationLayerOptions + val locationEngine = component.locationEngine + val componentOptions = component.locationComponentOptions assertThat(locationEngine, notNullValue()) - assertThat(pluginOptions, notNullValue()) + assertThat(componentOptions, notNullValue()) uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) assertThat(locationEngine?.isConnected, `is`(true)) - assertThat(pluginOptions?.accuracyAlpha(), `is`(.5f)) - assertThat(pluginOptions?.accuracyColor(), `is`(Color.BLUE)) + assertThat(componentOptions?.accuracyAlpha(), `is`(.5f)) + assertThat(componentOptions?.accuracyColor(), `is`(Color.BLUE)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayerPlugin_doesntInitializeEngineWhenNullProvided() { + fun locationComponent_doesntInitializeEngineWhenNullProvided() { validateTestSetup() - 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( + component.activateLocationComponent( null, - LocationLayerOptions.builder(context) + LocationComponentOptions.builder(context) .staleStateTimeout(200) .enableStaleState(false) .accuracyAlpha(.5f) .accuracyColor(Color.BLUE) .build()) - val locationEngine = plugin.locationEngine - val pluginOptions = plugin.locationLayerOptions + val locationEngine = component.locationEngine + val componentOptions = component.locationComponentOptions assertThat(locationEngine, nullValue()) - assertThat(pluginOptions, notNullValue()) + assertThat(componentOptions, notNullValue()) uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) - assertThat(pluginOptions?.accuracyAlpha(), `is`(.5f)) - assertThat(pluginOptions?.accuracyColor(), `is`(Color.BLUE)) + assertThat(componentOptions?.accuracyAlpha(), `is`(.5f)) + assertThat(componentOptions?.accuracyColor(), `is`(Color.BLUE)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun settingMapStyleImmediatelyBeforeLoadingPlugin_doesStillLoadLayersProperly() { + fun settingMapStyleImmediatelyBeforeLoadingComponent_doesStillLoadLayersProperly() { validateTestSetup() - 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) { mapboxMap.setStyle(Style.LIGHT) - plugin.activateLocationLayerPlugin(context, false) - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) - assertThat(plugin.renderMode, `is`(equalTo(RenderMode.NORMAL))) + assertThat(component.renderMode, `is`(equalTo(RenderMode.NORMAL))) assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true)) assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true)) assertThat(mapboxMap.isLayerVisible(SHADOW_LAYER), `is`(true)) @@ -164,16 +164,16 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayer_doesntShowUntilFirstLocationFix() { + fun locationComponent_doesntShowUntilFirstLocationFix() { validateTestSetup() - 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) // Source should be present but empty val mapView = (rule.activity as SingleActivity).mapView @@ -182,14 +182,14 @@ class LocationLayerPluginTest : BaseActivityTest() { .isEmpty(), `is`(true)) // Force the first location update - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) // Check if the puck is visible assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(false)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } // @@ -197,18 +197,18 @@ class LocationLayerPluginTest : BaseActivityTest() { // @Test - fun locationLayerOptions_disablingStaleStateDoesWorkCorrectly() { + fun locationComponentOptions_disablingStaleStateDoesWorkCorrectly() { validateTestSetup() - 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, - LocationLayerOptions.builder(context) + component.activateLocationComponent(context, + LocationComponentOptions.builder(context) .staleStateTimeout(200) .enableStaleState(false) .build()) - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) uiController.loopMainThreadForAtLeast(200) uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) @@ -221,16 +221,16 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayerOptions_loadsForegroundBitmapFromNameOption() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun locationComponentOptions_loadsForegroundBitmapFromNameOption() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, - LocationLayerOptions.builder(context) + component.activateLocationComponent(context, + LocationComponentOptions.builder(context) .foregroundName("custom-foreground-bitmap") .backgroundName("custom-background-bitmap") .foregroundStaleName("custom-foreground-stale-bitmap") @@ -247,7 +247,7 @@ class LocationLayerPluginTest : BaseActivityTest() { mapboxMap.addImageFromDrawable("custom-bearing-bitmap", it) } - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(false)) @@ -260,22 +260,22 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayerOptions_loadsGpsNameWithGpsRenderMode() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun locationComponentOptions_loadsGpsNameWithGpsRenderMode() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, - LocationLayerOptions.builder(context) + component.activateLocationComponent(context, + LocationComponentOptions.builder(context) .foregroundName("custom-foreground-bitmap") .gpsName("custom-gps-bitmap") .build()) - plugin.renderMode = RenderMode.GPS - plugin.forceLocationUpdate(location) + component.renderMode = RenderMode.GPS + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) val foregroundDrawable = ContextCompat.getDrawable(context, R.drawable.ic_media_play) foregroundDrawable?.let { @@ -288,28 +288,28 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayerOptions_customIconNameRevertsToDefault() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun locationComponentOptions_customIconNameRevertsToDefault() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, - LocationLayerOptions.builder(context) + component.activateLocationComponent(context, + LocationComponentOptions.builder(context) .foregroundName("custom-foreground-bitmap") .gpsName("custom-gps-bitmap") .build()) - plugin.renderMode = RenderMode.GPS - plugin.forceLocationUpdate(location) + component.renderMode = RenderMode.GPS + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) val foregroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON) assertThat(foregroundId, `is`(equalTo("custom-gps-bitmap"))) - plugin.applyStyle(LocationLayerOptions.builder(context).build()) + component.applyStyle(LocationComponentOptions.builder(context).build()) uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) val revertedForegroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON) @@ -317,28 +317,28 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayerOptions_customGpsIconNameChangeBackWithMode() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun locationComponentOptions_customGpsIconNameChangeBackWithMode() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, - LocationLayerOptions.builder(context) + component.activateLocationComponent(context, + LocationComponentOptions.builder(context) .gpsName("custom-gps-bitmap") .build()) - plugin.renderMode = RenderMode.GPS - plugin.forceLocationUpdate(location) + component.renderMode = RenderMode.GPS + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) val foregroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON) assertThat(foregroundId, `is`(equalTo("custom-gps-bitmap"))) - plugin.renderMode = RenderMode.NORMAL + component.renderMode = RenderMode.NORMAL uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) val revertedForegroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON) @@ -346,27 +346,27 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun stillStaleAfterResuming() { - 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, - LocationLayerOptions.builder(context) + component.activateLocationComponent(context, + LocationComponentOptions.builder(context) .staleStateTimeout(200) .build()) - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) uiController.loopMainThreadForAtLeast(250) // engaging stale state uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true)) - plugin.onStop() - plugin.onStart() + component.onStop() + component.onStart() mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true)) @@ -374,44 +374,44 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun stillNotStaleAfterResuming() { - 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) assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(false)) - plugin.onStop() - plugin.onStart() + component.onStop() + component.onStart() uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(false)) assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(true)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun locationLayerOptions_accuracyRingWithColor() { + fun locationComponentOptions_accuracyRingWithColor() { val color = Color.parseColor("#4A90E2") val rgbaColor = ColorUtils.colorToRgbaString(color) - 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, - LocationLayerOptions.builder(context) + component.activateLocationComponent(context, + LocationComponentOptions.builder(context) .accuracyColor(color) .build()) - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) // Check that the source property changes correctly @@ -423,173 +423,173 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun forceLocationUpdate_doesMoveLocationLayerIconToCorrectPosition() { - 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) val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point - assertThat(plugin.locationEngine, nullValue()) + assertThat(component.locationEngine, nullValue()) assertEquals(point.latitude(), location.latitude, 0.1) assertEquals(point.longitude(), location.longitude, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun disablingPluginHidesPuck() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun disablingComponentHidesPuck() { + 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) val point: Point = mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER)[0].geometry() as Point assertEquals(point.latitude(), location.latitude, 0.1) assertEquals(point.longitude(), location.longitude, 0.1) - plugin.deactivateLocationLayerPlugin() + component.deactivateLocationComponent() uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(true)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun disablingPluginAndChangingStyleAllowsToEnableAgain() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun disablingComponentAndChangingStyleAllowsToEnableAgain() { + 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.setStyle(Style.LIGHT) - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_isDisabledOnStart() { - 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) { - assertThat(plugin.isLocationLayerEnabled, `is`(false)) - plugin.onStop() - plugin.onStart() - assertThat(plugin.isLocationLayerEnabled, `is`(false)) - plugin.activateLocationLayerPlugin(context, false) - assertThat(plugin.isLocationLayerEnabled, `is`(true)) + assertThat(component.isLocationLayerEnabled, `is`(false)) + component.onStop() + component.onStart() + assertThat(component.isLocationLayerEnabled, `is`(false)) + component.activateLocationComponent(context, false) + assertThat(component.isLocationLayerEnabled, `is`(true)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_keepsEnabledWhenStoppedAndStarted() { - 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) - assertThat(plugin.isLocationLayerEnabled, `is`(true)) - plugin.onStop() - plugin.onStart() - assertThat(plugin.isLocationLayerEnabled, `is`(true)) + component.activateLocationComponent(context, false) + assertThat(component.isLocationLayerEnabled, `is`(true)) + component.onStop() + component.onStart() + assertThat(component.isLocationLayerEnabled, `is`(true)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_keepsDisabledWhenStoppedAndStarted() { - 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.deactivateLocationLayerPlugin() - assertThat(plugin.isLocationLayerEnabled, `is`(false)) - plugin.onStop() - plugin.onStart() - assertThat(plugin.isLocationLayerEnabled, `is`(false)) + component.activateLocationComponent(context, false) + component.deactivateLocationComponent() + assertThat(component.isLocationLayerEnabled, `is`(false)) + component.onStop() + component.onStart() + assertThat(component.isLocationLayerEnabled, `is`(false)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_ableToChangeStyleAfterResuming() { - 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) - plugin.onStop() - plugin.onStart() + component.onStop() + component.onStart() mapboxMap.setStyle(Style.DARK) uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_interruptedDuringStyleChange() { - 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.setStyle(Style.DARK) - plugin.onStop() - plugin.onStart() + component.onStop() + component.onStart() uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_forceLocationUpdateAfterStopped() { - 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.onStop() - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.onStop() + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE).isEmpty(), `is`(true)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_acceptAndReuseLocationUpdatesBeforeLayerStarted() { - 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.onStop() - plugin.forceLocationUpdate(location) - plugin.onStart() + component.activateLocationComponent(context, false) + component.onStop() + component.forceLocationUpdate(location) + component.onStart() mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point @@ -597,20 +597,20 @@ class LocationLayerPluginTest : BaseActivityTest() { assertEquals(point.longitude(), location.longitude, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun lifecycle_lifecycleChangeRightAfterStyleReload() { - 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.setStyle(Style.LIGHT) - plugin.onStop() + component.onStop() uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY) - plugin.onStart() + component.onStart() mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point @@ -624,28 +624,28 @@ class LocationLayerPluginTest : BaseActivityTest() { assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false)) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun mapChange_settingPluginStyle() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun mapChange_settingComponentStyle() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE) - val options = LocationLayerOptions.builder(context) + val options = LocationComponentOptions.builder(context) .accuracyColor(Color.RED) .build() pushSourceUpdates(styleChangeIdlingResource) { - plugin.applyStyle(options) + component.applyStyle(options) } 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())) @@ -653,44 +653,44 @@ class LocationLayerPluginTest : BaseActivityTest() { @Test fun mapChange_forcingLocation() { - 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) styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE) pushSourceUpdates(styleChangeIdlingResource) { - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) } 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())) } @Test - fun mapChange_settingMapStyleBeforePluginCreation() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun mapChange_settingMapStyleBeforeComponentCreation() { + 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) - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) - val options = LocationLayerOptions.builder(context) + val options = LocationComponentOptions.builder(context) .accuracyColor(Color.RED) .build() pushSourceUpdates(styleChangeIdlingResource) { - plugin.forceLocationUpdate(location) - plugin.applyStyle(options) + component.forceLocationUpdate(location) + component.applyStyle(options) } } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) // Waiting for style to finish loading while pushing updates onView(withId(R.id.content)).check(matches(isDisplayed())) @@ -698,35 +698,35 @@ class LocationLayerPluginTest : BaseActivityTest() { @Test fun animators_layerBearingCorrect() { - 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 + component.activateLocationComponent(context, false) + component.renderMode = RenderMode.GPS location.bearing = 77f - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) assertEquals(77.0, mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(PROPERTY_GPS_BEARING) as Double, 0.1) location.bearing = 92f - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) // Waiting for the animation to finish assertEquals(92.0, mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(PROPERTY_GPS_BEARING) as Double, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_cameraLatLngBearingCorrect() { - 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.cameraMode = CameraMode.TRACKING_GPS + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING_GPS location.bearing = 77f - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) assertEquals(77.0, mapboxMap.cameraPosition.bearing, 0.1) assertEquals(location.latitude, mapboxMap.cameraPosition.target.latitude, 0.1) @@ -735,7 +735,7 @@ class LocationLayerPluginTest : BaseActivityTest() { location.bearing = 92f location.latitude = 30.0 location.longitude = 35.0 - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) // Waiting for the animation to finish assertEquals(92.0, mapboxMap.cameraPosition.bearing, 0.1) assertEquals(location.latitude, mapboxMap.cameraPosition.target.latitude, 0.1) @@ -743,21 +743,21 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_cameraBearingCorrect() { - 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.cameraMode = CameraMode.NONE_GPS + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.NONE_GPS val latitude = mapboxMap.cameraPosition.target.latitude val longitude = mapboxMap.cameraPosition.target.longitude location.bearing = 77f - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) assertEquals(77.0, mapboxMap.cameraPosition.bearing, 0.1) assertEquals(latitude, mapboxMap.cameraPosition.target.latitude, 0.1) @@ -766,7 +766,7 @@ class LocationLayerPluginTest : BaseActivityTest() { location.bearing = 92f location.latitude = 30.0 location.longitude = 35.0 - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) assertEquals(92.0, mapboxMap.cameraPosition.bearing, 0.1) assertEquals(latitude, mapboxMap.cameraPosition.target.latitude, 0.1) @@ -774,22 +774,22 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_cameraNoneCorrect() { - 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.cameraMode = CameraMode.NONE + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.NONE val latitude = mapboxMap.cameraPosition.target.latitude val longitude = mapboxMap.cameraPosition.target.longitude val bearing = mapboxMap.cameraPosition.bearing location.bearing = 77f - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) assertEquals(bearing, mapboxMap.cameraPosition.bearing, 0.1) assertEquals(latitude, mapboxMap.cameraPosition.target.latitude, 0.1) @@ -798,7 +798,7 @@ class LocationLayerPluginTest : BaseActivityTest() { location.bearing = 92f location.latitude = 30.0 location.longitude = 35.0 - plugin.forceLocationUpdate(location) + component.forceLocationUpdate(location) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) // Waiting for the animation to finish assertEquals(bearing, mapboxMap.cameraPosition.bearing, 0.1) assertEquals(latitude, mapboxMap.cameraPosition.target.latitude, 0.1) @@ -806,231 +806,231 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_focalPointAdjustment() { - 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.cameraMode = CameraMode.TRACKING - plugin.cameraMode = CameraMode.NONE - plugin.forceLocationUpdate(location) + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING + component.cameraMode = CameraMode.NONE + component.forceLocationUpdate(location) mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER) assertThat(mapboxMap.uiSettings.focalPoint, nullValue()) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_dontZoomWhileNotTracking() { - 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.cameraMode = CameraMode.NONE + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.NONE val zoom = mapboxMap.cameraPosition.zoom - plugin.zoomWhileTracking(10.0) + component.zoomWhileTracking(10.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION) assertEquals(zoom, mapboxMap.cameraPosition.zoom, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_zoomWhileTracking() { - 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.cameraMode = CameraMode.TRACKING - plugin.zoomWhileTracking(10.0) + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING + component.zoomWhileTracking(10.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION) assertEquals(10.0, mapboxMap.cameraPosition.zoom, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test @Ignore fun animators_zoomWhileTrackingCanceledOnModeChange() { - 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.cameraMode = CameraMode.TRACKING - plugin.zoomWhileTracking(15.0) + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING + component.zoomWhileTracking(15.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION / 2) - plugin.cameraMode = CameraMode.NONE + component.cameraMode = CameraMode.NONE uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION / 2) assertEquals(15.0 / 2.0, mapboxMap.cameraPosition.zoom, 3.0) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_dontZoomWhileStopped() { - 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) - plugin.cameraMode = CameraMode.TRACKING + component.cameraMode = CameraMode.TRACKING uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY) val zoom = mapboxMap.cameraPosition.zoom - plugin.onStop() - plugin.zoomWhileTracking(10.0) + component.onStop() + component.zoomWhileTracking(10.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION) assertEquals(zoom, mapboxMap.cameraPosition.zoom, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test @Ignore fun animators_cancelZoomWhileTracking() { - 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.cameraMode = CameraMode.TRACKING - plugin.zoomWhileTracking(15.0) + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING + component.zoomWhileTracking(15.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION / 2) - plugin.cancelZoomWhileTrackingAnimation() + component.cancelZoomWhileTrackingAnimation() uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION / 2) assertEquals(15.0 / 2.0, mapboxMap.cameraPosition.zoom, 3.0) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_dontTiltWhileNotTracking() { - 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.cameraMode = CameraMode.NONE + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.NONE val tilt = mapboxMap.cameraPosition.tilt - plugin.tiltWhileTracking(30.0) + component.tiltWhileTracking(30.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION) assertEquals(tilt, mapboxMap.cameraPosition.tilt, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_tiltWhileTracking() { - 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.cameraMode = CameraMode.TRACKING - plugin.tiltWhileTracking(30.0) + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING + component.tiltWhileTracking(30.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION) assertEquals(30.0, mapboxMap.cameraPosition.tilt, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test @Ignore fun animators_tiltWhileTrackingCanceledOnModeChange() { - 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.cameraMode = CameraMode.TRACKING - plugin.tiltWhileTracking(30.0) + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING + component.tiltWhileTracking(30.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION / 2) - plugin.cameraMode = CameraMode.NONE + component.cameraMode = CameraMode.NONE uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION / 2) assertEquals(30.0 / 2.0, mapboxMap.cameraPosition.tilt, 3.0) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun animators_dontTiltWhileStopped() { - 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.cameraMode = CameraMode.TRACKING + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING val tilt = mapboxMap.cameraPosition.tilt - plugin.onStop() - plugin.tiltWhileTracking(30.0) + component.onStop() + component.tiltWhileTracking(30.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION) assertEquals(tilt, mapboxMap.cameraPosition.tilt, 0.1) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test @Ignore fun animators_cancelTiltWhileTracking() { - 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.cameraMode = CameraMode.TRACKING - plugin.tiltWhileTracking(30.0) + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING + component.tiltWhileTracking(30.0) uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION / 2) - plugin.cancelTiltWhileTrackingAnimation() + component.cancelTiltWhileTrackingAnimation() uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION / 2) assertEquals(30.0 / 2.0, mapboxMap.cameraPosition.tilt, 3.0) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun cameraPositionAdjustedToTrackingModeWhenPluginEnabled() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun cameraPositionAdjustedToTrackingModeWhenComponentEnabled() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - plugin.cameraMode = CameraMode.TRACKING_GPS - plugin.forceLocationUpdate(location) - plugin.deactivateLocationLayerPlugin() + component.activateLocationComponent(context, false) + component.cameraMode = CameraMode.TRACKING_GPS + component.forceLocationUpdate(location) + component.deactivateLocationComponent() mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(LatLng(51.0, 17.0))) mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(90.0)) - plugin.activateLocationLayerPlugin(context, false) + component.activateLocationComponent(context, false) uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) assertEquals(location.bearing.toDouble(), mapboxMap.cameraPosition.bearing, 0.1) @@ -1039,28 +1039,28 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test - fun compassEngine_onPluginInitializedDefaultIsProvided() { - val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction { - override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, + fun compassEngine_onComponentInitializedDefaultIsProvided() { + val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { + override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context) { - plugin.activateLocationLayerPlugin(context, false) - assertTrue(plugin.compassEngine is LocationLayerCompassEngine) + component.activateLocationComponent(context, false) + assertTrue(component.compassEngine is LocationComponentCompassEngine) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @Test fun compassEngine_changesWhenNewProvided() { - 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) val engine: CompassEngine = object : CompassEngine { override fun addCompassListener(compassListener: CompassListener) { } @@ -1083,13 +1083,13 @@ class LocationLayerPluginTest : BaseActivityTest() { } } - plugin.compassEngine = engine - assertThat(plugin.compassEngine, notNullValue()) - assertThat(plugin.compassEngine, `is`(equalTo(engine))) + component.compassEngine = engine + assertThat(component.compassEngine, notNullValue()) + assertThat(component.compassEngine, `is`(equalTo(engine))) } } - executePluginTest(pluginAction) + executeComponentTest(componentAction) } @After @@ -1098,7 +1098,7 @@ class LocationLayerPluginTest : 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)) } }
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt index a0f23ce485..c50d1817fd 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerTest.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt @@ -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)) } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/LocationLayerPluginAction.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt index af2c9adf35..ad80a3333e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/LocationLayerPluginAction.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt @@ -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) } }
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/MapboxTestingUtils.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt index b77ab127d9..591901385f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/MapboxTestingUtils.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt @@ -1,4 +1,4 @@ -package com.mapbox.mapboxsdk.plugins.utils +package com.mapbox.mapboxsdk.location.utils import android.graphics.Bitmap import android.graphics.Canvas diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/OnMapFragmentReadyIdlingResource.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/OnMapFragmentReadyIdlingResource.kt index fa6b732770..4d02a4d2bf 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/OnMapFragmentReadyIdlingResource.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/OnMapFragmentReadyIdlingResource.kt @@ -1,4 +1,4 @@ -package com.mapbox.mapboxsdk.plugins.utils +package com.mapbox.mapboxsdk.location.utils import android.os.Handler import android.os.Looper diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/OnMapReadyIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/OnMapReadyIdlingResource.java index f084343594..9adb30ee32 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/OnMapReadyIdlingResource.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/OnMapReadyIdlingResource.java @@ -1,4 +1,4 @@ -package com.mapbox.mapboxsdk.plugins.utils; +package com.mapbox.mapboxsdk.location.utils; import android.app.Activity; import android.os.Handler; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/StyleChangeIdlingResource.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt index ab2c855c65..0f37498a29 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/plugins/utils/StyleChangeIdlingResource.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt @@ -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 |