summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/AppCenter.kt15
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationRunner.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactoryTest.kt143
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/BaseIntegrationTest.kt3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/FragmentBackStackTest.kt7
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReopenTest.kt3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/OrientationChangeTest.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/QueryRenderedFeaturesBoxCountTest.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReopenTest.kt4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReuseTest.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt432
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt152
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/BaseLayerTest.kt3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapInstrumentationTest.kt41
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxTest.java4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/NativeMapViewTest.kt10
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/VisibleRegionTest.kt74
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/offline/OfflineDownloadTest.kt88
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotterTest.kt26
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseTest.java11
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/fragment/MapDialogFragmentTest.kt4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt5
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/RemoveUnusedImagesTest.kt15
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/CacheTest.kt88
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineManagerTest.kt30
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineUtilsTest.java4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/render/RenderTest.java4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceMapTest.kt7
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceStandaloneTest.kt3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceTestUtils.kt3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml11
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/assets/points-sf.geojson115
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java172
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.kt165
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/PixelTestActivity.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/NestedViewPagerActivity.kt11
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationModesActivity.java10
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/GLSurfaceRecyclerViewActivity.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/OverlayMapActivity.kt4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/TextureRecyclerViewActivity.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/ChangeResourcesCachePathActivity.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DeleteRegionActivity.java24
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DownloadRegionActivity.kt17
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/MergeOfflineRegionsActivity.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java9
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/storage/CacheManagementActivity.kt78
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt18
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java11
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FileUtils.kt1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_arrow_upward.xml9
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_cache_management.xml32
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_latlngbounds.xml63
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml1
65 files changed, 1505 insertions, 479 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/AppCenter.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/AppCenter.kt
new file mode 100644
index 0000000000..16eb3d1f1a
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/AppCenter.kt
@@ -0,0 +1,15 @@
+package com.mapbox.mapboxsdk
+
+import com.microsoft.appcenter.espresso.Factory
+import org.junit.After
+import org.junit.Rule
+
+abstract class AppCenter {
+ @get:Rule
+ var reportHelper = Factory.getReportHelper()!!
+
+ @After
+ open fun afterTest() {
+ reportHelper.label(javaClass.simpleName)
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationRunner.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationRunner.kt
index 6873b33262..5c275df078 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationRunner.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationRunner.kt
@@ -8,4 +8,4 @@ class InstrumentationRunner : AndroidJUnitRunner() {
override fun newApplication(cl: ClassLoader?, className: String?, context: Context?): Application {
return super.newApplication(cl, InstrumentationApplication::class.java.name, context)
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactoryTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactoryTest.kt
new file mode 100644
index 0000000000..50b9626edc
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactoryTest.kt
@@ -0,0 +1,143 @@
+package com.mapbox.mapboxsdk.camera
+
+import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.geometry.LatLng
+import com.mapbox.mapboxsdk.geometry.LatLngBounds
+import com.mapbox.mapboxsdk.testapp.activity.BaseTest
+import com.mapbox.mapboxsdk.testapp.activity.espresso.DeviceIndependentTestActivity
+import org.junit.Assert.assertEquals
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class CameraUpdateFactoryTest : BaseTest() {
+
+ override fun getActivityClass(): Class<*> {
+ return DeviceIndependentTestActivity::class.java
+ }
+
+ @Test
+ fun testLatLngBoundsUntiltedUnrotated() {
+ rule.runOnUiThread {
+ mapboxMap.cameraPosition = CameraPosition.Builder()
+ .target(LatLng(60.0, 24.0))
+ .bearing(0.0)
+ .tilt(0.0)
+ .build()
+
+ val bounds: LatLngBounds = LatLngBounds.Builder()
+ .include(LatLng(62.0, 26.0))
+ .include(LatLng(58.0, 22.0))
+ .build()
+
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0))
+
+ val cameraPosition = mapboxMap.cameraPosition
+ assertEquals("latitude should match:", 60.0, cameraPosition.target.latitude, 0.1)
+ assertEquals("longitude should match:", 24.0, cameraPosition.target.longitude, 0.1)
+ assertEquals("bearing should match:", 0.0, cameraPosition.bearing, 0.1)
+ assertEquals("zoom should match", 5.5, cameraPosition.zoom, 0.1)
+ assertEquals("tilt should match:", 0.0, cameraPosition.tilt, 0.1)
+ }
+ }
+
+ @Test
+ fun testLatLngBoundsTilted() {
+ rule.runOnUiThread {
+ mapboxMap.cameraPosition = CameraPosition.Builder()
+ .target(LatLng(60.0, 24.0))
+ .bearing(0.0)
+ .tilt(45.0)
+ .build()
+
+ val bounds: LatLngBounds = LatLngBounds.Builder()
+ .include(LatLng(62.0, 26.0))
+ .include(LatLng(58.0, 22.0))
+ .build()
+
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0))
+
+ val cameraPosition = mapboxMap.cameraPosition
+ assertEquals("latitude should match:", 60.0, cameraPosition.target.latitude, 0.1)
+ assertEquals("longitude should match:", 24.0, cameraPosition.target.longitude, 0.1)
+ assertEquals("bearing should match:", 0.0, cameraPosition.bearing, 0.1)
+ assertEquals("zoom should match", 6.0, cameraPosition.zoom, 0.1)
+ assertEquals("tilt should match:", 45.0, cameraPosition.tilt, 0.1)
+ }
+ }
+
+ @Test
+ fun testLatLngBoundsRotated() {
+ rule.runOnUiThread {
+ mapboxMap.cameraPosition = CameraPosition.Builder()
+ .target(LatLng(60.0, 24.0))
+ .bearing(30.0)
+ .tilt(0.0)
+ .build()
+
+ val bounds: LatLngBounds = LatLngBounds.Builder()
+ .include(LatLng(62.0, 26.0))
+ .include(LatLng(58.0, 22.0))
+ .build()
+
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0))
+
+ val cameraPosition = mapboxMap.cameraPosition
+ assertEquals("latitude should match:", 60.0, cameraPosition.target.latitude, 0.1)
+ assertEquals("longitude should match:", 24.0, cameraPosition.target.longitude, 0.1)
+ assertEquals("bearing should match:", 30.0, cameraPosition.bearing, 0.1)
+ assertEquals("zoom should match", 5.3, cameraPosition.zoom, 0.1)
+ assertEquals("tilt should match:", 0.0, cameraPosition.tilt, 0.1)
+ }
+ }
+
+ @Test
+ fun testLatLngBoundsTiltedRotated() {
+ rule.runOnUiThread {
+ mapboxMap.cameraPosition = CameraPosition.Builder()
+ .target(LatLng(60.0, 24.0))
+ .bearing(30.0)
+ .tilt(45.0)
+ .build()
+
+ val bounds: LatLngBounds = LatLngBounds.Builder()
+ .include(LatLng(62.0, 26.0))
+ .include(LatLng(58.0, 22.0))
+ .build()
+
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0))
+
+ val cameraPosition = mapboxMap.cameraPosition
+ assertEquals("latitude should match:", 60.0, cameraPosition.target.latitude, 0.1)
+ assertEquals("longitude should match:", 24.0, cameraPosition.target.longitude, 0.1)
+ assertEquals("bearing should match:", 30.0, cameraPosition.bearing, 0.1)
+ assertEquals("zoom should match", 5.6, cameraPosition.zoom, 0.1)
+ assertEquals("tilt should match:", 45.0, cameraPosition.tilt, 0.1)
+ }
+ }
+
+ @Test
+ fun testLatLngBoundsWithProvidedTiltAndRotation() {
+ rule.runOnUiThread {
+ mapboxMap.cameraPosition = CameraPosition.Builder()
+ .target(LatLng(60.0, 24.0))
+ .bearing(0.0)
+ .tilt(0.0)
+ .build()
+
+ val bounds: LatLngBounds = LatLngBounds.Builder()
+ .include(LatLng(62.0, 26.0))
+ .include(LatLng(58.0, 22.0))
+ .build()
+
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 30.0, 40.0, 0))
+
+ val cameraPosition = mapboxMap.cameraPosition
+ assertEquals("latitude should match:", 60.0, cameraPosition.target.latitude, 0.1)
+ assertEquals("longitude should match:", 24.0, cameraPosition.target.longitude, 0.1)
+ assertEquals("bearing should match:", 30.0, cameraPosition.bearing, 0.1)
+ assertEquals("zoom should match", 5.6, cameraPosition.zoom, 0.1)
+ assertEquals("tilt should match:", 40.0, cameraPosition.tilt, 0.1)
+ }
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/BaseIntegrationTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/BaseIntegrationTest.kt
index aeb8863790..2afff34d34 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/BaseIntegrationTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/BaseIntegrationTest.kt
@@ -5,11 +5,12 @@ import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.support.test.InstrumentationRegistry
import android.support.test.uiautomator.*
+import com.mapbox.mapboxsdk.AppCenter
import org.junit.Before
const val TIMEOUT_UI_SEARCH_WAIT = 5000L
-abstract class BaseIntegrationTest {
+abstract class BaseIntegrationTest : AppCenter() {
protected lateinit var device: UiDevice
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/FragmentBackStackTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/FragmentBackStackTest.kt
index b0f6436bdd..5673ffd4c1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/FragmentBackStackTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/FragmentBackStackTest.kt
@@ -3,15 +3,8 @@ package com.mapbox.mapboxsdk.integration
import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
-import android.support.test.uiautomator.By
-import android.support.test.uiautomator.SearchCondition
import android.support.test.uiautomator.UiSelector
-import android.support.test.uiautomator.Until
-import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.testapp.activity.fragment.FragmentBackStackActivity
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
-import kotlinx.android.synthetic.main.activity_backstack_fragment.view.*
-import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReopenTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReopenTest.kt
index f22b5f7c9d..40bc182bd7 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReopenTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReopenTest.kt
@@ -8,7 +8,6 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
-
/**
* Regression test that validates reopening an Activity with a GLSurfaceView
*/
@@ -27,4 +26,4 @@ class GLSurfaceViewReopenTest : BaseIntegrationTest() {
device.launchActivity(activityRule.activity, SimpleMapActivity::class.java)
device.waitForIdle()
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt
index 945fac677e..5bf45518ec 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt
@@ -4,8 +4,6 @@ import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
-import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/OrientationChangeTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/OrientationChangeTest.kt
index 941b7ea8dc..8d5b5eb8aa 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/OrientationChangeTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/OrientationChangeTest.kt
@@ -3,9 +3,7 @@ package com.mapbox.mapboxsdk.integration
import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
-import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/QueryRenderedFeaturesBoxCountTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/QueryRenderedFeaturesBoxCountTest.kt
index 076bcba7e6..e94d568e86 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/QueryRenderedFeaturesBoxCountTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/QueryRenderedFeaturesBoxCountTest.kt
@@ -27,4 +27,4 @@ class QueryRenderedFeaturesBoxCountTest : BaseIntegrationTest() {
device.launchActivity(activityRule.activity, QueryRenderedFeaturesBoxCountActivity::class.java)
device.waitForIdle()
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReopenTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReopenTest.kt
index 44da557904..cbfd5d6d55 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReopenTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReopenTest.kt
@@ -3,14 +3,10 @@ package com.mapbox.mapboxsdk.integration
import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
import com.mapbox.mapboxsdk.testapp.activity.textureview.TextureViewDebugModeActivity
-import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
-import java.lang.Thread.sleep
/**
* Regression test that validates reopening an Activity with a TextureView
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReuseTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReuseTest.kt
index 5c3d66c462..dc2f74df4a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReuseTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReuseTest.kt
@@ -3,9 +3,7 @@ package com.mapbox.mapboxsdk.integration
import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
import com.mapbox.mapboxsdk.testapp.activity.maplayout.TextureRecyclerViewActivity
-import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt
index b918801296..5178ea9fc0 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt
@@ -5,8 +5,6 @@ import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import android.support.test.uiautomator.UiSelector
import com.mapbox.mapboxsdk.testapp.activity.fragment.ViewPagerActivity
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
-import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
index f9827c767e..fb113502ee 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
@@ -54,7 +54,6 @@ class LocationComponentTest : EspressoTest() {
private lateinit var locationComponentActivationOptions: LocationComponentActivationOptions
-
override fun validateTestSetup() {
super.validateTestSetup()
assertThat(mapboxMap.style, notNullValue())
@@ -71,8 +70,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponent_initializesLocationEngineCorrectlyWhenOnesNotProvided() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
@@ -93,9 +97,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponent_initializesLocationEngineCorrectlyWhenOnesNotProvidedButHasOptions() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.locationComponentOptions(
@@ -131,9 +139,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponent_doesntInitializeEngineWhenNullProvided() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.locationEngine(null)
@@ -170,8 +182,13 @@ class LocationComponentTest : EspressoTest() {
fun settingMapStyleImmediatelyBeforeLoadingComponent_throwsInvalidStyle() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
component.activateLocationComponent(LocationComponentActivationOptions
@@ -188,9 +205,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponent_doesntShowUntilFirstLocationFix() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -222,10 +243,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponentOptions_disablingStaleStateDoesWorkCorrectly() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -258,9 +282,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponentOptions_loadsForegroundBitmapFromNameOption() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -306,9 +334,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponentOptions_loadsGpsNameWithGpsRenderMode() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -343,9 +375,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponentOptions_customIconNameRevertsToDefault() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -379,9 +415,13 @@ class LocationComponentTest : EspressoTest() {
fun locationComponentOptions_customGpsIconNameChangeBackWithMode() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -414,9 +454,13 @@ class LocationComponentTest : EspressoTest() {
fun stillStaleAfterResuming() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -451,9 +495,13 @@ class LocationComponentTest : EspressoTest() {
fun stillNotStaleAfterResuming() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -483,9 +531,13 @@ class LocationComponentTest : EspressoTest() {
val rgbaColor = ColorUtils.colorToRgbaString(color)
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -516,9 +568,13 @@ class LocationComponentTest : EspressoTest() {
fun forceLocationUpdate_doesMoveLocationLayerIconToCorrectPosition() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -541,9 +597,13 @@ class LocationComponentTest : EspressoTest() {
fun disablingComponentHidesPuck() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -568,9 +628,13 @@ class LocationComponentTest : EspressoTest() {
fun disablingComponentAndChangingStyleAllowsToEnableAgain() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -592,9 +656,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_isDisabledOnStart() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.onStop()
component.onStart()
@@ -619,9 +687,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_keepsEnabledWhenStoppedAndStarted() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
-
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -641,8 +713,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_keepsDisabledWhenStoppedAndStarted() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(
LocationComponentActivationOptions
.builder(context, style)
@@ -663,8 +740,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_ableToChangeStyleAfterResuming() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -685,8 +767,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_interruptedDuringStyleChange() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -705,8 +792,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_forceLocationUpdateAfterStopped() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -726,8 +818,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_acceptAndReuseLocationUpdatesBeforeLayerStarted() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -750,8 +847,13 @@ class LocationComponentTest : EspressoTest() {
fun lifecycle_lifecycleChangeRightAfterStyleReload() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -781,8 +883,13 @@ class LocationComponentTest : EspressoTest() {
fun mapChange_settingComponentStyle() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -810,8 +917,13 @@ class LocationComponentTest : EspressoTest() {
fun mapChange_forcingLocation() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -836,8 +948,13 @@ class LocationComponentTest : EspressoTest() {
fun mapChange_settingMapStyleBeforeComponentCreation() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
TestingAsyncUtils.waitForLayer(uiController, mapView)
@@ -868,8 +985,13 @@ class LocationComponentTest : EspressoTest() {
fun animators_layerBearingCorrect() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -896,8 +1018,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_cameraLatLngBearingCorrect() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -932,8 +1059,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_cameraBearingCorrect() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -971,8 +1103,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_cameraNoneCorrect() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1011,8 +1148,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_focalPointAdjustment() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1033,8 +1175,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_dontZoomWhileNotTracking() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1056,8 +1203,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_zoomWhileTracking() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1079,8 +1231,13 @@ class LocationComponentTest : EspressoTest() {
@Ignore
fun animators_zoomWhileTrackingCanceledOnModeChange() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1103,8 +1260,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_dontZoomWhileStopped() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1130,8 +1292,13 @@ class LocationComponentTest : EspressoTest() {
@Ignore
fun animators_cancelZoomWhileTracking() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1154,8 +1321,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_dontTiltWhileNotTracking() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1177,8 +1349,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_tiltWhileTracking() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1200,8 +1377,13 @@ class LocationComponentTest : EspressoTest() {
@Ignore
fun animators_tiltWhileTrackingCanceledOnModeChange() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1224,8 +1406,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun animators_dontTiltWhileStopped() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1250,8 +1437,13 @@ class LocationComponentTest : EspressoTest() {
@Ignore
fun animators_cancelTiltWhileTracking() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1273,8 +1465,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun cameraPositionAdjustedToTrackingModeWhenComponentEnabled() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1301,8 +1498,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun cameraPositionSnappedToTargetIfExceedsThreshold() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1330,8 +1532,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun compassEngine_onComponentInitializedDefaultIsProvided() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -1347,8 +1554,13 @@ class LocationComponentTest : EspressoTest() {
@Test
fun compassEngine_changesWhenNewProvided() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
index 95a3891b6d..110d879bf3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
@@ -35,6 +35,7 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
+import kotlin.math.abs
@RunWith(AndroidJUnit4::class)
class LocationLayerControllerTest : EspressoTest() {
@@ -67,8 +68,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun renderModeNormal_sourceDoesGetAdded() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -90,8 +96,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun renderModeNormal_trackingNormalLayersDoGetAdded() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -114,8 +125,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun renderModeCompass_bearingLayersDoGetAdded() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -138,8 +154,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun renderModeGps_navigationLayersDoGetAdded() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -162,8 +183,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun dontShowPuckWhenRenderModeSetAndComponentDisabled() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -187,8 +213,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun whenLocationComponentDisabled_doesSetAllLayersToVisibilityNone() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -213,8 +244,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun onMapChange_locationComponentLayersDoGetRedrawn() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -245,8 +281,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun whenStyleChanged_continuesUsingStaleIcons() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -271,8 +312,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun whenStyleChanged_isDisabled_hasLayerBelow_staysHidden() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -300,8 +346,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun whenStyleChanged_staleStateChanges() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -323,8 +374,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun whenStyleChanged_layerVisibilityUpdates() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
uiController.loopMainThreadForAtLeast(100)
var show = true
@@ -349,8 +405,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun accuracy_visibleWithNewLocation() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -372,8 +433,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun accuracy_visibleWhenCameraEased() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -387,10 +453,9 @@ class LocationLayerControllerTest : EspressoTest() {
uiController.loopMainThreadForAtLeast(300)
TestingAsyncUtils.waitForLayer(uiController, mapView)
-
- assertThat(Math.abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1
- && Math.abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1
- && Math.abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1,
+ assertThat(Math.abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1 &&
+ Math.abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1 &&
+ Math.abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1,
`is`(true))
val expectedRadius = Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/
@@ -405,8 +470,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun accuracy_visibleWhenCameraMoved() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -419,9 +489,10 @@ class LocationLayerControllerTest : EspressoTest() {
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, zoom))
TestingAsyncUtils.waitForLayer(uiController, mapView)
- assertThat(Math.abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1
- && Math.abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1
- && Math.abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1,
+ assertThat(
+ abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1 &&
+ abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1 &&
+ abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1,
`is`(true))
val expectedRadius = Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/
@@ -436,8 +507,13 @@ class LocationLayerControllerTest : EspressoTest() {
@Test
fun applyStyle_layerBelow_restoreLayerVisibility() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
- override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
- style: Style, uiController: UiController, context: Context) {
+ override fun onLocationComponentAction(
+ component: LocationComponent,
+ mapboxMap: MapboxMap,
+ style: Style,
+ uiController: UiController,
+ context: Context
+ ) {
component.activateLocationComponent(LocationComponentActivationOptions
.builder(context, style)
.useDefaultLocationEngine(false)
@@ -467,4 +543,4 @@ class LocationLayerControllerTest : EspressoTest() {
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/location/utils/LocationComponentAction.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt
index 64123cc8c4..daf6b89f59 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt
@@ -10,8 +10,10 @@ import com.mapbox.mapboxsdk.location.LocationComponent
import com.mapbox.mapboxsdk.maps.Style
import org.hamcrest.Matcher
-class LocationComponentAction(private val mapboxMap: MapboxMap,
- private val onPerformLocationComponentAction: OnPerformLocationComponentAction) : ViewAction {
+class LocationComponentAction(
+ private val mapboxMap: MapboxMap,
+ private val onPerformLocationComponentAction: OnPerformLocationComponentAction
+) : ViewAction {
override fun getConstraints(): Matcher<View> {
return isDisplayed()
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt
index edbb1c6c65..18da6d1d10 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt
@@ -7,7 +7,6 @@ import android.graphics.drawable.Drawable
import android.location.Location
import android.os.Handler
import android.os.Looper
-import android.support.test.espresso.UiController
import com.mapbox.geojson.Feature
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapboxMap
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt
index 5aded25d1e..050535f6df 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt
@@ -3,7 +3,6 @@ package com.mapbox.mapboxsdk.location.utils
import android.support.test.espresso.IdlingResource
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
-import java.util.logging.Handler
/**
* Resource, that's idling until the provided style is loaded.
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/BaseLayerTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/BaseLayerTest.kt
index 9a6f9c3c26..27c040fbb6 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/BaseLayerTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/BaseLayerTest.kt
@@ -2,11 +2,12 @@ package com.mapbox.mapboxsdk.maps
import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.style.layers.Layer
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
-abstract class BaseLayerTest {
+abstract class BaseLayerTest : AppCenter() {
private lateinit var nativeMapView: NativeMap
companion object {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapInstrumentationTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapInstrumentationTest.kt
new file mode 100644
index 0000000000..e93f54161e
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapInstrumentationTest.kt
@@ -0,0 +1,41 @@
+package com.mapbox.mapboxsdk.maps
+
+import android.graphics.PointF
+import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
+import com.mapbox.mapboxsdk.geometry.LatLng
+import com.mapbox.mapboxsdk.testapp.activity.BaseTest
+import com.mapbox.mapboxsdk.testapp.activity.espresso.DeviceIndependentTestActivity
+import org.junit.Assert.assertArrayEquals
+import org.junit.Assert.assertEquals
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class MapboxMapInstrumentationTest : BaseTest() {
+
+ override fun getActivityClass(): Class<*> {
+ return DeviceIndependentTestActivity::class.java
+ }
+
+ @Test
+ fun setPadding_cameraInvalidated() {
+ rule.runOnUiThread {
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 10.0))
+ val initialCameraPosition = mapboxMap.cameraPosition
+ val initialPoint = mapboxMap.projection.toScreenLocation(initialCameraPosition.target)
+
+ val bottomPadding = mapView.height / 4
+ val leftPadding = mapView.width / 4
+ mapboxMap.setPadding(leftPadding, 0, 0, bottomPadding)
+
+ val resultingCameraPosition = mapboxMap.cameraPosition
+ assertArrayEquals(intArrayOf(leftPadding, 0, 0, bottomPadding), mapboxMap.padding)
+ assertEquals(initialCameraPosition, resultingCameraPosition)
+ assertEquals(
+ PointF(initialPoint.x + leftPadding / 2, initialPoint.y - bottomPadding / 2),
+ mapboxMap.projection.toScreenLocation(resultingCameraPosition.target)
+ )
+ }
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxTest.java
index c8737e2802..50c10766af 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxTest.java
@@ -2,6 +2,8 @@ package com.mapbox.mapboxsdk.maps;
import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
+
+import com.mapbox.mapboxsdk.AppCenter;
import com.mapbox.mapboxsdk.Mapbox;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -11,7 +13,7 @@ import static junit.framework.Assert.assertSame;
import static junit.framework.Assert.assertTrue;
@RunWith(AndroidJUnit4.class)
-public class MapboxTest {
+public class MapboxTest extends AppCenter {
private static final String ACCESS_TOKEN = "pk.0000000001";
private static final String ACCESS_TOKEN_2 = "pk.0000000002";
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/NativeMapViewTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/NativeMapViewTest.kt
index a1fe6af659..d5834db553 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/NativeMapViewTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/NativeMapViewTest.kt
@@ -5,6 +5,7 @@ import android.graphics.PointF
import android.support.test.InstrumentationRegistry
import android.support.test.annotation.UiThreadTest
import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.geometry.LatLngBounds
@@ -19,7 +20,7 @@ import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
-class NativeMapViewTest {
+class NativeMapViewTest : AppCenter() {
private lateinit var nativeMapView: NativeMap
@@ -94,7 +95,6 @@ class NativeMapViewTest {
assertEquals("Longitude should match", expected.longitude, actual.longitude, DELTA)
}
-
@Test
@UiThreadTest
fun testBearingDefault() {
@@ -159,7 +159,7 @@ class NativeMapViewTest {
@UiThreadTest
fun testLatLngForPixel() {
val expected = LATLNG_TEST
- nativeMapView.setLatLng(LATLNG_TEST,0)
+ nativeMapView.setLatLng(LATLNG_TEST, 0)
val actual = nativeMapView.latLngForPixel(
PointF((WIDTH / 2).toFloat(), (HEIGHT / 2).toFloat())
)
@@ -366,11 +366,11 @@ class NativeMapViewTest {
class DummyRenderer(context: Context) : MapRenderer(context, null) {
override fun requestRender() {
- //no-op
+ // no-op
}
override fun queueEvent(runnable: Runnable?) {
- //no-op
+ // no-op
}
}
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt
index 85a4bd65a8..6b59411ae8 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt
@@ -8,10 +8,10 @@ import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
import org.junit.Assert.assertEquals
import org.junit.Test
-class TransformTest: EspressoTest() {
+class TransformTest : EspressoTest() {
companion object {
- val initialCameraUpdate = CameraUpdateFactory.newLatLngZoom(LatLng(12.0,12.0), 12.0)!!
+ val initialCameraUpdate = CameraUpdateFactory.newLatLngZoom(LatLng(12.0, 12.0), 12.0)!!
}
@Test
@@ -23,7 +23,7 @@ class TransformTest: EspressoTest() {
val expectedCameraPosition = mapboxMap.cameraPosition
mapboxMap.moveCamera(initialCameraUpdate)
- mapboxMap.setPadding(250,250,0,0)
+ mapboxMap.setPadding(250, 250, 0, 0)
mapboxMap.scrollBy(400.0f, 0.0f)
val actualCameraPosition = mapboxMap.cameraPosition
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/VisibleRegionTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/VisibleRegionTest.kt
index 139695461d..684b13af5d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/VisibleRegionTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/VisibleRegionTest.kt
@@ -8,8 +8,7 @@ import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke
import com.mapbox.mapboxsdk.testapp.activity.BaseTest
import com.mapbox.mapboxsdk.testapp.activity.espresso.PixelTestActivity
-import org.junit.Assert.assertFalse
-import org.junit.Assert.assertTrue
+import org.junit.Assert.*
import org.junit.Test
class VisibleRegionTest : BaseTest() {
@@ -70,7 +69,7 @@ class VisibleRegionTest : BaseTest() {
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
- assertTrue(filtered.size == 1)
+ assertEquals(1, filtered.size)
assertTrue(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)))
}
}
@@ -89,14 +88,18 @@ class VisibleRegionTest : BaseTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 4f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width * 3f / 4f, 0f)
)
mapboxMap.setPadding(mapView.width / 4, 0, 0, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
- val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
- assertTrue(filtered.size == 6)
+ val filtered = latLngs.filter {
+ visibleRegion.latLngBounds.contains(it)
+ }
+ assertEquals(5, filtered.size)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f)))
}
}
@@ -115,14 +118,16 @@ class VisibleRegionTest : BaseTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 4f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height * 3f / 4f)
)
mapboxMap.setPadding(0, mapView.height / 4, 0, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
- assertTrue(filtered.size == 6)
+ assertEquals(5, filtered.size)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f)))
}
}
@@ -141,14 +146,16 @@ class VisibleRegionTest : BaseTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 4f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width * 3f / 4f, 0f)
)
mapboxMap.setPadding(0, 0, mapView.width / 4, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
- assertTrue(filtered.size == 6)
+ assertEquals(5, filtered.size)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)))
}
}
@@ -167,14 +174,16 @@ class VisibleRegionTest : BaseTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 4f),
+ mapboxMap.getLatLngFromScreenCoords(0f, mapView.height * 3f / 4f)
)
mapboxMap.setPadding(0, 0, 0, mapView.height / 4)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
- assertTrue(filtered.size == 6)
+ assertEquals(5, filtered.size)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat())))
}
}
@@ -228,7 +237,7 @@ class VisibleRegionTest : BaseTest() {
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
- assertTrue(filtered.size == 1)
+ assertEquals(1, filtered.size)
assertTrue(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)))
}
}
@@ -250,14 +259,17 @@ class VisibleRegionTest : BaseTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 4f, 0f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width * 3f / 4f, mapView.height / 2f)
+ .also { it.longitude += 360 }
)
mapboxMap.setPadding(mapView.width / 4, 0, 0, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
- assertTrue(filtered.size == 6)
+ assertEquals(5, filtered.size)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f)))
}
}
@@ -267,7 +279,6 @@ class VisibleRegionTest : BaseTest() {
validateTestSetup()
invoke(mapboxMap) { ui: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
- ui.loopMainThreadForAtLeast(5000)
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
@@ -280,14 +291,17 @@ class VisibleRegionTest : BaseTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 4f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height * 3f / 4f)
+ .also { it.longitude += 360 }
)
mapboxMap.setPadding(0, mapView.height / 4, 0, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
- assertTrue(filtered.size == 6)
+ assertEquals(5, filtered.size)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f)))
}
}
@@ -309,14 +323,17 @@ class VisibleRegionTest : BaseTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 4f, 0f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width * 3f / 4f, mapView.height / 2f)
+ .also { it.longitude += 360 }
)
mapboxMap.setPadding(0, 0, mapView.width / 4, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
- assertTrue(filtered.size == 6)
+ assertEquals(5, filtered.size)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)))
}
}
@@ -338,14 +355,17 @@ class VisibleRegionTest : BaseTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 4f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height * 3f / 4f)
+ .also { it.longitude += 360 }
)
mapboxMap.setPadding(0, 0, 0, mapView.height / 4)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
- assertTrue(filtered.size == 6)
+ assertEquals(5, filtered.size)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat())))
}
}
@@ -355,7 +375,7 @@ class VisibleRegionTest : BaseTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
- val d = Math.min(mapboxMap.width, mapboxMap.height) / 4;
+ val d = Math.min(mapboxMap.width, mapboxMap.height) / 4
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
@@ -364,9 +384,8 @@ class VisibleRegionTest : BaseTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
)
-
for (bearing in 45 until 360 step 45) {
- mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()));
+ mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()))
val visibleRegion = mapboxMap.projection.visibleRegion
assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
}
@@ -378,7 +397,7 @@ class VisibleRegionTest : BaseTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
- val d = Math.min(mapboxMap.width, mapboxMap.height) / 4;
+ val d = Math.min(mapboxMap.width, mapboxMap.height) / 4
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
@@ -388,9 +407,8 @@ class VisibleRegionTest : BaseTest() {
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
)
-
for (bearing in 45 until 360 step 45) {
- mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()));
+ mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()))
val visibleRegion = mapboxMap.projection.visibleRegion
assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/offline/OfflineDownloadTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/offline/OfflineDownloadTest.kt
new file mode 100644
index 0000000000..5c574f9332
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/offline/OfflineDownloadTest.kt
@@ -0,0 +1,88 @@
+package com.mapbox.mapboxsdk.offline
+
+import android.support.test.rule.ActivityTestRule
+import android.support.test.runner.AndroidJUnit4
+import com.mapbox.geojson.Point
+import com.mapbox.mapboxsdk.log.Logger
+import com.mapbox.mapboxsdk.maps.Style
+import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
+import java.util.concurrent.TimeoutException
+
+/**
+ * Integration test that validates downloading an offline region from a point geometry at zoomlevel 17
+ */
+@RunWith(AndroidJUnit4::class)
+class OfflineDownloadTest : OfflineRegion.OfflineRegionObserver {
+
+ @Rule
+ @JvmField
+ var rule = ActivityTestRule(FeatureOverviewActivity::class.java)
+
+ private val countDownLatch = CountDownLatch(1)
+ private lateinit var offlineRegion: OfflineRegion
+
+ @Test(timeout = 30000)
+ fun offlineDownload() {
+ rule.runOnUiThreadActivity {
+ OfflineManager.getInstance(rule.activity).createOfflineRegion(
+ createTestRegionDefinition(),
+ ByteArray(0),
+ object : OfflineManager.CreateOfflineRegionCallback {
+ override fun onCreate(region: OfflineRegion?) {
+ region?.let {
+ offlineRegion = it
+ offlineRegion.setDownloadState(OfflineRegion.STATE_ACTIVE)
+ offlineRegion.setObserver(this@OfflineDownloadTest)
+ }
+ }
+
+ override fun onError(error: String?) {
+ Logger.e(TAG, "Error while creating offline region: $error")
+ }
+ })
+ }
+
+ if (!countDownLatch.await(30, TimeUnit.SECONDS)) {
+ throw TimeoutException()
+ }
+ }
+
+ override fun onStatusChanged(status: OfflineRegionStatus?) {
+ status?.let {
+ if (it.isComplete) {
+ offlineRegion.setDownloadState(OfflineRegion.STATE_INACTIVE)
+ countDownLatch.countDown()
+ }
+ }
+ }
+
+ override fun onError(error: OfflineRegionError?) {
+ Logger.e(TAG, "Error while downloading offline region: $error")
+ }
+
+ override fun mapboxTileCountLimitExceeded(limit: Long) {
+ Logger.e(TAG, "Tile count limited exceeded: $limit")
+ }
+
+ fun createTestRegionDefinition(): OfflineRegionDefinition {
+ return OfflineGeometryRegionDefinition(
+ Style.MAPBOX_STREETS,
+ Point.fromLngLat(50.847857, 4.360137),
+ 17.0,
+ 17.0,
+ 1.0f,
+ false
+ )
+ }
+
+ companion object {
+ const val TAG = "OfflineDownloadTest"
+ }
+}
+
+fun ActivityTestRule<*>.runOnUiThreadActivity(runnable: () -> Unit) = activity.runOnUiThread(runnable) \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotterTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotterTest.kt
new file mode 100644
index 0000000000..e295b5b10b
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotterTest.kt
@@ -0,0 +1,26 @@
+package com.mapbox.mapboxsdk.snapshotter
+
+import android.support.test.rule.ActivityTestRule
+import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.testapp.activity.snapshot.MapSnapshotterMarkerActivity
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * Integration test that validates if a snapshot is created with MapSnapshotterMarkerActivity
+ */
+@RunWith(AndroidJUnit4::class)
+class MapSnapshotterTest {
+
+ @Rule
+ @JvmField
+ var rule = ActivityTestRule(MapSnapshotterMarkerActivity::class.java)
+
+ @Test(timeout = 10000)
+ fun mapSnapshotter() {
+ while (rule.activity.mapSnapshot == null) {
+ Thread.sleep(250)
+ }
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseTest.java
index c91afe9b60..45dac23611 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseTest.java
@@ -1,8 +1,11 @@
package com.mapbox.mapboxsdk.testapp.activity;
+import android.content.Context;
import android.support.annotation.CallSuper;
import android.support.annotation.UiThread;
import android.support.test.rule.ActivityTestRule;
+
+import com.mapbox.mapboxsdk.AppCenter;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
@@ -22,7 +25,7 @@ import static junit.framework.TestCase.assertTrue;
/**
* Base class for all Activity test hooking into an existing Activity that will load style.
*/
-public abstract class BaseTest {
+public abstract class BaseTest extends AppCenter {
private static final int WAIT_TIMEOUT = 30; //seconds
@@ -46,7 +49,7 @@ public abstract class BaseTest {
@After
@CallSuper
public void afterTest() {
- // override to add logic
+ super.afterTest();
}
@UiThread
@@ -93,4 +96,8 @@ public abstract class BaseTest {
}
}
+ protected Context getContext() {
+ return rule.getActivity();
+ }
+
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/fragment/MapDialogFragmentTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/fragment/MapDialogFragmentTest.kt
index 2731b20db7..f695f3efe2 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/fragment/MapDialogFragmentTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/fragment/MapDialogFragmentTest.kt
@@ -7,8 +7,8 @@ import android.support.test.espresso.matcher.ViewMatchers.withId
import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.testapp.R
-import com.mapbox.mapboxsdk.testapp.action.WaitAction
import com.mapbox.mapboxsdk.testapp.activity.maplayout.MapInDialogActivity
import org.junit.Ignore
import org.junit.Rule
@@ -20,7 +20,7 @@ import org.junit.runner.RunWith
*/
@RunWith(AndroidJUnit4::class)
@LargeTest
-class MapDialogFragmentTest {
+class MapDialogFragmentTest : AppCenter() {
@get:Rule
var activityRule: ActivityTestRule<MapInDialogActivity> = ActivityTestRule(MapInDialogActivity::class.java)
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt
index 4de4b1d55b..b569f7ca3d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt
@@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.testapp.maps
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.testapp.R
@@ -16,7 +17,7 @@ import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
@RunWith(AndroidJUnit4::class)
-class ImageMissingTest {
+class ImageMissingTest : AppCenter() {
@Rule
@JvmField
@@ -151,4 +152,4 @@ class ImageMissingTest {
}
"""
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/RemoveUnusedImagesTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/RemoveUnusedImagesTest.kt
index d42494b3e9..41b100b4d2 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/RemoveUnusedImagesTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/RemoveUnusedImagesTest.kt
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.testapp.maps
import android.graphics.Bitmap
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapView
@@ -20,7 +21,7 @@ import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
@RunWith(AndroidJUnit4::class)
-class RemoveUnusedImagesTest {
+class RemoveUnusedImagesTest : AppCenter() {
@Rule
@JvmField
@@ -35,7 +36,7 @@ class RemoveUnusedImagesTest {
rule.runOnUiThread {
mapView = rule.activity.findViewById(R.id.mapView)
mapView.getMapAsync {
- mapboxMap = it;
+ mapboxMap = it
mapboxMap.setStyle(Style.Builder().fromJson(styleJson))
}
}
@@ -46,7 +47,7 @@ class RemoveUnusedImagesTest {
var callbackLatch = CountDownLatch(2)
rule.runOnUiThread {
mapView.addOnStyleImageMissingListener {
- mapboxMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
+ mapboxMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
}
// Remove layer and source, so that rendered tiles are no longer used, therefore, map must
@@ -68,7 +69,7 @@ class RemoveUnusedImagesTest {
}
}
- if(!latch.await(5, TimeUnit.SECONDS) && !callbackLatch.await(5, TimeUnit.SECONDS)){
+ if (!latch.await(5, TimeUnit.SECONDS) && !callbackLatch.await(5, TimeUnit.SECONDS)) {
throw TimeoutException()
}
}
@@ -77,7 +78,7 @@ class RemoveUnusedImagesTest {
fun testRemoveUnusedImagesDefaultListener() {
rule.runOnUiThread {
mapView.addOnStyleImageMissingListener {
- mapboxMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
+ mapboxMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
}
// Remove layer and source, so that rendered tiles are no longer used, thus
@@ -96,7 +97,7 @@ class RemoveUnusedImagesTest {
}
}
- if(!latch.await(5, TimeUnit.SECONDS)){
+ if (!latch.await(5, TimeUnit.SECONDS)) {
throw TimeoutException()
}
}
@@ -159,4 +160,4 @@ class RemoveUnusedImagesTest {
}
"""
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt
index ac73b028f3..951750f354 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt
@@ -2,16 +2,13 @@ package com.mapbox.mapboxsdk.testapp.maps
import android.support.test.espresso.UiController
import android.support.test.runner.AndroidJUnit4
-import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.style.layers.SymbolLayer
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity
import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils
-import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/CacheTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/CacheTest.kt
new file mode 100644
index 0000000000..e28aec558c
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/CacheTest.kt
@@ -0,0 +1,88 @@
+package com.mapbox.mapboxsdk.testapp.offline
+
+import android.content.Context
+import android.support.test.rule.ActivityTestRule
+import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.offline.OfflineManager
+import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
+import org.junit.Assert
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import java.util.concurrent.CountDownLatch
+
+@RunWith(AndroidJUnit4::class)
+class CacheTest {
+
+ @Rule
+ @JvmField
+ var rule = ActivityTestRule(FeatureOverviewActivity::class.java)
+
+ private val context: Context by lazy { rule.activity }
+
+ private val countDownLatch = CountDownLatch(1)
+
+ @Test
+ fun testSetMaximumAmbientCacheSize() {
+ rule.activity.runOnUiThread {
+ OfflineManager.getInstance(context).setMaximumAmbientCacheSize(10000000, object : OfflineManager.FileSourceCallback {
+ override fun onSuccess() {
+ countDownLatch.countDown()
+ }
+
+ override fun onError(message: String) {
+ Assert.assertNull("onError should not be called", message)
+ }
+ })
+ }
+ countDownLatch.await()
+ }
+
+ @Test
+ fun testSetClearAmbientCache() {
+ rule.activity.runOnUiThread {
+ OfflineManager.getInstance(context).clearAmbientCache(object : OfflineManager.FileSourceCallback {
+ override fun onSuccess() {
+ countDownLatch.countDown()
+ }
+
+ override fun onError(message: String) {
+ Assert.assertNull("onError should not be called", message)
+ }
+ })
+ }
+ countDownLatch.await()
+ }
+
+ @Test
+ fun testSetInvalidateAmbientCache() {
+ rule.activity.runOnUiThread {
+ OfflineManager.getInstance(context).invalidateAmbientCache(object : OfflineManager.FileSourceCallback {
+ override fun onSuccess() {
+ countDownLatch.countDown()
+ }
+
+ override fun onError(message: String) {
+ Assert.assertNull("onError should not be called", message)
+ }
+ })
+ }
+ countDownLatch.await()
+ }
+
+ @Test
+ fun testSetResetDatabase() {
+ rule.activity.runOnUiThread {
+ OfflineManager.getInstance(context).resetDatabase(object : OfflineManager.FileSourceCallback {
+ override fun onSuccess() {
+ countDownLatch.countDown()
+ }
+
+ override fun onError(message: String) {
+ Assert.assertNull("onError should not be called", message)
+ }
+ })
+ }
+ countDownLatch.await()
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineManagerTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineManagerTest.kt
index 8e5f3f7c5f..6b73623ae7 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineManagerTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineManagerTest.kt
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.testapp.offline
import android.content.Context
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.offline.OfflineManager
import com.mapbox.mapboxsdk.offline.OfflineRegion
import com.mapbox.mapboxsdk.storage.FileSource
@@ -18,7 +19,7 @@ import java.util.concurrent.CountDownLatch
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(AndroidJUnit4::class)
-class OfflineManagerTest {
+class OfflineManagerTest : AppCenter() {
companion object {
private const val TEST_DB_FILE_NAME = "offline_test.db"
@@ -34,7 +35,7 @@ class OfflineManagerTest {
@Test(timeout = 30_000)
fun a_copyFileFromAssets() {
val latch = CountDownLatch(1)
- rule.runOnUiThread {
+ rule.activity.runOnUiThread {
FileUtils.CopyFileFromAssetsTask(rule.activity, object : FileUtils.OnFileCopiedFromAssetsListener {
override fun onFileCopiedFromAssets() {
latch.countDown()
@@ -51,7 +52,7 @@ class OfflineManagerTest {
@Test(timeout = 30_000)
fun b_mergeRegion() {
val latch = CountDownLatch(1)
- rule.runOnUiThread {
+ rule.activity.runOnUiThread {
OfflineManager.getInstance(context).mergeOfflineRegions(
FileSource.getResourcesCachePath(rule.activity) + "/" + TEST_DB_FILE_NAME,
object : OfflineManager.MergeOfflineRegionsCallback {
@@ -71,7 +72,7 @@ class OfflineManagerTest {
@Test(timeout = 30_000)
fun c_listRegion() {
val latch = CountDownLatch(1)
- rule.runOnUiThread {
+ rule.activity.runOnUiThread {
OfflineManager.getInstance(context).listOfflineRegions(object : OfflineManager.ListOfflineRegionsCallback {
override fun onList(offlineRegions: Array<out OfflineRegion>?) {
assert(offlineRegions?.size == 1)
@@ -88,9 +89,26 @@ class OfflineManagerTest {
}
@Test(timeout = 30_000)
- fun d_deleteRegion() {
+ fun d_invalidateRegion() {
val latch = CountDownLatch(1)
- rule.runOnUiThread {
+ rule.activity.runOnUiThread {
+ mergedRegion.invalidate(object : OfflineRegion.OfflineRegionInvalidateCallback {
+ override fun onInvalidate() {
+ latch.countDown()
+ }
+
+ override fun onError(error: String?) {
+ throw RuntimeException("Unable to delete region")
+ }
+ })
+ }
+ latch.await()
+ }
+
+ @Test(timeout = 30_000)
+ fun e_deleteRegion() {
+ val latch = CountDownLatch(1)
+ rule.activity.runOnUiThread {
mergedRegion.delete(object : OfflineRegion.OfflineRegionDeleteCallback {
override fun onDelete() {
latch.countDown()
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineUtilsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineUtilsTest.java
index 40fba08c25..48eb8e832d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineUtilsTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineUtilsTest.java
@@ -1,6 +1,8 @@
package com.mapbox.mapboxsdk.testapp.offline;
import android.support.test.runner.AndroidJUnit4;
+
+import com.mapbox.mapboxsdk.AppCenter;
import com.mapbox.mapboxsdk.testapp.utils.OfflineUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -13,7 +15,7 @@ import static junit.framework.Assert.assertEquals;
import static junit.framework.TestCase.assertTrue;
@RunWith(AndroidJUnit4.class)
-public class OfflineUtilsTest {
+public class OfflineUtilsTest extends AppCenter {
private static final String REGION_NAME = "hello world";
private static final String CONVERTED_REGION_NAME = "{\"FIELD_REGION_NAME\":\"hello world\"}";
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/render/RenderTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/render/RenderTest.java
index 14b138e917..c74e110b6c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/render/RenderTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/render/RenderTest.java
@@ -7,6 +7,8 @@ import android.support.test.espresso.IdlingResourceTimeoutException;
import android.support.test.rule.ActivityTestRule;
import android.support.test.rule.GrantPermissionRule;
import android.support.test.runner.AndroidJUnit4;
+
+import com.mapbox.mapboxsdk.AppCenter;
import com.mapbox.mapboxsdk.testapp.activity.render.RenderTestActivity;
import com.mapbox.mapboxsdk.testapp.utils.SnapshotterIdlingResource;
import org.junit.After;
@@ -28,7 +30,7 @@ import static android.support.test.espresso.matcher.ViewMatchers.withId;
* Instrumentation render tests
*/
@RunWith(AndroidJUnit4.class)
-public class RenderTest {
+public class RenderTest extends AppCenter {
private static final int RENDER_TEST_TIMEOUT = 30;
private SnapshotterIdlingResource idlingResource;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceMapTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceMapTest.kt
index 5e3489d755..b67e6eded5 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceMapTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceMapTest.kt
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.testapp.storage
import android.support.test.annotation.UiThreadTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.storage.FileSource
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity
import junit.framework.Assert
@@ -15,7 +16,7 @@ import org.junit.runner.RunWith
import java.util.concurrent.CountDownLatch
@RunWith(AndroidJUnit4::class)
-open class FileSourceMapTest {
+open class FileSourceMapTest : AppCenter() {
private lateinit var fileSourceTestUtils: FileSourceTestUtils
@@ -42,8 +43,8 @@ open class FileSourceMapTest {
}
override fun onError(message: String) {
- Assert.assertEquals("Cannot set path, file source is activated."
- + " Make sure that the map or a resources download is not running.", message)
+ Assert.assertEquals("Cannot set path, file source is activated." +
+ " Make sure that the map or a resources download is not running.", message)
latch.countDown()
}
})
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceStandaloneTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceStandaloneTest.kt
index 08a15b0c54..428d0ed757 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceStandaloneTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceStandaloneTest.kt
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.testapp.storage
import android.support.test.annotation.UiThreadTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.storage.FileSource
import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
import org.junit.*
@@ -12,7 +13,7 @@ import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
@RunWith(AndroidJUnit4::class)
-class FileSourceStandaloneTest {
+class FileSourceStandaloneTest : AppCenter() {
private lateinit var fileSourceTestUtils: FileSourceTestUtils
private lateinit var fileSource: FileSource
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceTestUtils.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceTestUtils.kt
index c79d3b2752..0010880414 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceTestUtils.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/storage/FileSourceTestUtils.kt
@@ -2,12 +2,13 @@ package com.mapbox.mapboxsdk.testapp.storage
import android.app.Activity
import android.support.annotation.WorkerThread
+import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.storage.FileSource
import junit.framework.Assert
import java.io.File
import java.util.concurrent.CountDownLatch
-class FileSourceTestUtils(private val activity: Activity) {
+class FileSourceTestUtils(private val activity: Activity) : AppCenter() {
val originalPath = FileSource.getResourcesCachePath(activity)
val testPath = "$originalPath/test"
val testPath2 = "$originalPath/test2"
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
index bb2bef35fb..d2a5032c81 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
@@ -709,6 +709,17 @@
android:value=".activity.FeatureOverviewActivity" />
</activity>
<activity
+ android:name=".activity.storage.CacheManagementActivity"
+ android:description="@string/description_cache_management"
+ android:label="@string/activity_cache_management">
+ <meta-data
+ android:name="@string/category"
+ android:value="@string/category_storage" />
+ <meta-data
+ android:name="android.support.PARENT_ACTIVITY"
+ android:value=".activity.FeatureOverviewActivity" />
+ </activity>
+ <activity
android:name=".activity.maplayout.BottomSheetActivity"
android:description="@string/description_bottom_sheet"
android:label="@string/activity_bottom_sheet">
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/assets/points-sf.geojson b/platform/android/MapboxGLAndroidSDKTestApp/src/main/assets/points-sf.geojson
new file mode 100644
index 0000000000..9c96c4ef9f
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/assets/points-sf.geojson
@@ -0,0 +1,115 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 237.5580596923828,
+ 37.78563944612241
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 237.58346557617185,
+ 37.743571187449064
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 237.51068115234375,
+ 37.72347854862523
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 237.51583099365234,
+ 37.77125750792944
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 237.5913619995117,
+ 37.795406713958236
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 237.56080627441403,
+ 37.69441603823106
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 237.62981414794922,
+ 37.722392304715825
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 237.52235412597656,
+ 37.807071480609274
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 237.53608703613278,
+ 37.75334401310656
+ ]
+ }
+ },
+ {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 237.57591247558594,
+ 37.77071473849609
+ ]
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java
deleted file mode 100644
index 6d73ee776e..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java
+++ /dev/null
@@ -1,172 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.activity.camera;
-
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.design.widget.BottomSheetBehavior;
-import android.support.v7.app.AppCompatActivity;
-import android.view.View;
-
-import com.mapbox.mapboxsdk.annotations.MarkerOptions;
-import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.geometry.LatLngBounds;
-import com.mapbox.mapboxsdk.maps.MapView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.Style;
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.view.LockableBottomSheetBehavior;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Test activity showcasing using the LatLngBounds camera API.
- */
-public class LatLngBoundsActivity extends AppCompatActivity implements View.OnClickListener {
-
- private static final List<LatLng> LOCATIONS = new ArrayList<LatLng>() {
- {
- add(new LatLng(37.806866, -122.422502));
- add(new LatLng(37.812905, -122.477605));
- add(new LatLng(37.826944, -122.423188));
- add(new LatLng(37.752676, -122.447736));
- add(new LatLng(37.769305, -122.479322));
- add(new LatLng(37.749834, -122.417867));
- add(new LatLng(37.756149, -122.405679));
- add(new LatLng(37.751403, -122.387397));
- add(new LatLng(37.793064, -122.391517));
- add(new LatLng(37.769122, -122.427394));
- }
- };
- private static final LatLngBounds BOUNDS = new LatLngBounds.Builder().includes(LOCATIONS).build();
- private static final int ANIMATION_DURATION_LONG = 450;
- private static final int ANIMATION_DURATION_SHORT = 250;
- private static final int BOUNDS_PADDING_DIVIDER_SMALL = 3;
- private static final int BOUNDS_PADDING_DIVIDER_LARGE = 9;
-
- private MapView mapView;
- private MapboxMap mapboxMap;
- private View bottomSheet;
- private LockableBottomSheetBehavior bottomSheetBehavior;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_latlngbounds);
- initBottomSheet();
- initMapView(savedInstanceState);
- }
-
- private void initMapView(Bundle savedInstanceState) {
- mapView = findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(map -> {
- mapboxMap = map;
- disableGestures();
- moveToBounds(bottomSheet.getMeasuredHeight(), BOUNDS_PADDING_DIVIDER_SMALL, ANIMATION_DURATION_SHORT);
- loadStyle();
- });
- }
-
- private void loadStyle() {
- mapboxMap.setStyle(new Style.Builder().fromUri(Style.MAPBOX_STREETS), style -> {
- addMarkers();
- initFab();
- });
- }
-
- private void disableGestures() {
- mapboxMap.getUiSettings().setTiltGesturesEnabled(false);
- mapboxMap.getUiSettings().setRotateGesturesEnabled(false);
- }
-
- private void addMarkers() {
- for (LatLng location : LOCATIONS) {
- mapboxMap.addMarker(new MarkerOptions().position(location));
- }
- }
-
- private void initFab() {
- findViewById(R.id.fab).setOnClickListener(this);
- }
-
- @Override
- public void onClick(View v) {
- bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
- v.animate().alpha(0.0f).setDuration(ANIMATION_DURATION_SHORT);
- }
-
- private void initBottomSheet() {
- bottomSheet = findViewById(R.id.bottom_sheet);
- bottomSheetBehavior = (LockableBottomSheetBehavior) BottomSheetBehavior.from(bottomSheet);
- bottomSheetBehavior.setLocked(true);
- bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
- @Override
- public void onStateChanged(@NonNull View bottomSheet, int newState) {
- if (newState == BottomSheetBehavior.STATE_SETTLING && mapboxMap != null) {
- moveToBounds(0, BOUNDS_PADDING_DIVIDER_LARGE, ANIMATION_DURATION_LONG);
- }
- }
-
- @Override
- public void onSlide(@NonNull View bottomSheet, float slideOffset) {
-
- }
- });
- }
-
- private void moveToBounds(int verticalOffset, int boundsPaddingDivider, int duration) {
- int paddingHorizontal = mapView.getMeasuredWidth() / boundsPaddingDivider;
- int paddingVertical = (mapView.getMeasuredHeight() - verticalOffset) / boundsPaddingDivider;
- mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(
- BOUNDS,
- paddingHorizontal,
- paddingVertical,
- paddingHorizontal,
- paddingVertical + verticalOffset),
- duration
- );
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.kt
new file mode 100644
index 0000000000..23707f52a5
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.kt
@@ -0,0 +1,165 @@
+package com.mapbox.mapboxsdk.testapp.activity.camera
+
+import android.content.Context
+import android.os.Bundle
+import android.support.design.widget.BottomSheetBehavior
+import android.support.v7.app.AppCompatActivity
+import android.view.View
+import com.mapbox.geojson.FeatureCollection
+import com.mapbox.geojson.FeatureCollection.fromJson
+import com.mapbox.geojson.Point
+import com.mapbox.mapboxsdk.geometry.LatLng
+import com.mapbox.mapboxsdk.geometry.LatLngBounds
+import com.mapbox.mapboxsdk.maps.MapboxMap
+import com.mapbox.mapboxsdk.maps.Style
+import com.mapbox.mapboxsdk.style.layers.Property.ICON_ANCHOR_CENTER
+import com.mapbox.mapboxsdk.style.layers.PropertyFactory.*
+import com.mapbox.mapboxsdk.style.layers.SymbolLayer
+import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
+import com.mapbox.mapboxsdk.testapp.R
+import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil.loadStringFromAssets
+import com.mapbox.mapboxsdk.utils.BitmapUtils
+import kotlinx.android.synthetic.main.activity_latlngbounds.*
+import java.net.URISyntaxException
+
+/**
+ * Test activity showcasing using the LatLngBounds camera API.
+ */
+class LatLngBoundsActivity : AppCompatActivity() {
+
+ private lateinit var mapboxMap: MapboxMap
+ private lateinit var bottomSheetBehavior: BottomSheetBehavior<*>
+ private lateinit var bounds: LatLngBounds
+
+ private val peekHeight by lazy {
+ 375.toPx(this) // 375dp
+ }
+
+ private val additionalPadding by lazy {
+ 32.toPx(this) // 32dp
+ }
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_latlngbounds)
+ initMapView(savedInstanceState)
+ }
+
+ private fun initMapView(savedInstanceState: Bundle?) {
+ mapView.onCreate(savedInstanceState)
+ mapView.getMapAsync { map ->
+ mapboxMap = map
+
+ val featureCollection: FeatureCollection = fromJson(loadStringFromAssets(this, "points-sf.geojson"))
+ bounds = createBounds(featureCollection)
+
+ map.getCameraForLatLngBounds(bounds, createPadding(peekHeight))?.let {
+ map.cameraPosition = it
+ }
+
+ try {
+ loadStyle(featureCollection)
+ } catch (e: URISyntaxException) {
+ e.printStackTrace()
+ }
+ }
+ }
+
+ private fun loadStyle(featureCollection: FeatureCollection) {
+ mapboxMap.setStyle(Style.Builder()
+ .fromUri(Style.MAPBOX_STREETS)
+ .withLayer(SymbolLayer("symbol", "symbol")
+ .withProperties(
+ iconAllowOverlap(true),
+ iconIgnorePlacement(true),
+ iconImage("icon"),
+ iconAnchor(ICON_ANCHOR_CENTER)
+ )
+ )
+ .withSource(GeoJsonSource("symbol", featureCollection))
+ .withImage("icon", BitmapUtils.getDrawableFromRes(this@LatLngBoundsActivity, R.drawable.ic_android)!!)
+ ) {
+ initBottomSheet()
+ fab.setOnClickListener { bottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED }
+ }
+ }
+
+ private fun initBottomSheet() {
+ bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet)
+ bottomSheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
+ override fun onSlide(bottomSheet: View, slideOffset: Float) {
+ val offset = convertSlideOffset(slideOffset)
+ val bottomPadding = (peekHeight * offset).toInt()
+
+ mapboxMap.getCameraForLatLngBounds(bounds, createPadding(bottomPadding))?.let {
+ mapboxMap.cameraPosition = it
+ }
+ }
+
+ override fun onStateChanged(bottomSheet: View, newState: Int) {
+ // no-op
+ }
+ })
+ }
+
+ // slideOffset ranges from NaN to -1.0, range from 1.0 to 0 instead
+ fun convertSlideOffset(slideOffset: Float): Float {
+ return if (slideOffset.equals(Float.NaN)) {
+ 1.0f
+ } else {
+ 1 + slideOffset
+ }
+ }
+
+ fun createPadding(bottomPadding: Int): IntArray {
+ return intArrayOf(additionalPadding, additionalPadding, additionalPadding, bottomPadding)
+ }
+
+ private fun createBounds(featureCollection: FeatureCollection): LatLngBounds {
+ val boundsBuilder = LatLngBounds.Builder()
+ featureCollection.features()?.let {
+ for (feature in it) {
+ val point = feature.geometry() as Point
+ boundsBuilder.include(LatLng(point.latitude(), point.longitude()))
+ }
+ }
+ return boundsBuilder.build()
+ }
+
+ override fun onStart() {
+ super.onStart()
+ mapView.onStart()
+ }
+
+ override fun onResume() {
+ super.onResume()
+ mapView.onResume()
+ }
+
+ override fun onPause() {
+ super.onPause()
+ mapView.onPause()
+ }
+
+ override fun onStop() {
+ super.onStop()
+ mapView.onStop()
+ }
+
+ override fun onLowMemory() {
+ super.onLowMemory()
+ mapView.onLowMemory()
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ mapView.onDestroy()
+ }
+
+ override fun onSaveInstanceState(outState: Bundle) {
+ super.onSaveInstanceState(outState)
+ mapView.onSaveInstanceState(outState)
+ }
+}
+
+fun Int.toPx(context: Context): Int = (this * context.resources.displayMetrics.density).toInt() \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/PixelTestActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/PixelTestActivity.kt
index b69d1ee5ed..7de4da1985 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/PixelTestActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/PixelTestActivity.kt
@@ -63,4 +63,4 @@ class PixelTestActivity : AppCompatActivity(), OnMapReadyCallback {
super.onLowMemory()
mapView.onLowMemory()
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/NestedViewPagerActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/NestedViewPagerActivity.kt
index 37909662ab..de7f0bb5ac 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/NestedViewPagerActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/NestedViewPagerActivity.kt
@@ -17,7 +17,6 @@ import android.widget.TextView
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapboxMapOptions
-import com.mapbox.mapboxsdk.maps.OnMapReadyCallback
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.maps.SupportMapFragment
import com.mapbox.mapboxsdk.testapp.R
@@ -106,7 +105,7 @@ class NestedViewPagerActivity : AppCompatActivity() {
class MapPagerAdapter(private val context: Context, fm: FragmentManager?) : FragmentStatePagerAdapter(fm) {
override fun getItem(position: Int): Fragment {
- val options = MapboxMapOptions.createFromAttributes(context, null)
+ val options = MapboxMapOptions.createFromAttributes(context)
options.textureMode(true)
options.doubleTapGesturesEnabled(false)
options.rotateGesturesEnabled(false)
@@ -127,7 +126,8 @@ class NestedViewPagerActivity : AppCompatActivity() {
options.camera(CameraPosition.Builder().target(LatLng(62.326440, 92.764913)).zoom(3.0).build())
val fragment = SupportMapFragment.newInstance(options)
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.DARK) }
- return fragment }
+ return fragment
+ }
3 -> {
return EmptyFragment.newInstance()
}
@@ -135,7 +135,8 @@ class NestedViewPagerActivity : AppCompatActivity() {
options.camera(CameraPosition.Builder().target(LatLng(-25.007786, 133.623852)).zoom(3.0).build())
val fragment = SupportMapFragment.newInstance(options)
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.SATELLITE) }
- return fragment }
+ return fragment
+ }
5 -> {
return EmptyFragment.newInstance()
}
@@ -162,4 +163,4 @@ class NestedViewPagerActivity : AppCompatActivity() {
}
}
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.kt
index b6fba01d81..d1cb9acab6 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.kt
@@ -45,7 +45,7 @@ class ViewPagerActivity : AppCompatActivity() {
}
override fun getItem(position: Int): Fragment? {
- val options = MapboxMapOptions.createFromAttributes(context, null)
+ val options = MapboxMapOptions.createFromAttributes(context)
options.textureMode(true)
options.camera(
CameraPosition.Builder()
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt
index d01c8eb508..7c111865d1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.kt
@@ -83,7 +83,7 @@ class SnapshotActivity : AppCompatActivity(), OnMapReadyCallback {
}
companion object {
- const val TAG ="Mbgl-SnapshotActivity"
+ const val TAG = "Mbgl-SnapshotActivity"
const val LOG_MESSAGE = "OnSnapshot"
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt
index 6a01d14249..9411c1c6a7 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt
@@ -119,7 +119,7 @@ class LocationFragmentActivity : AppCompatActivity() {
}
override fun onFailure(exception: Exception) {
- //noop
+ // noop
}
override fun onStart() {
@@ -172,4 +172,4 @@ class LocationFragmentActivity : AppCompatActivity() {
return textView
}
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationModesActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationModesActivity.java
index f9adf608a1..6ec64e1d0c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationModesActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationModesActivity.java
@@ -356,6 +356,8 @@ public class LocationModesActivity extends AppCompatActivity implements OnMapRea
private void showTrackingListDialog() {
List<String> trackingTypes = new ArrayList<>();
trackingTypes.add("None");
+ trackingTypes.add("None Compass");
+ trackingTypes.add("None GPS");
trackingTypes.add("Tracking");
trackingTypes.add("Tracking Compass");
trackingTypes.add("Tracking GPS");
@@ -370,6 +372,10 @@ public class LocationModesActivity extends AppCompatActivity implements OnMapRea
locationTrackingBtn.setText(selectedTrackingType);
if (selectedTrackingType.contentEquals("None")) {
setCameraTrackingMode(CameraMode.NONE);
+ } else if (selectedTrackingType.contentEquals("None Compass")) {
+ setCameraTrackingMode(CameraMode.NONE_COMPASS);
+ } else if (selectedTrackingType.contentEquals("None GPS")) {
+ setCameraTrackingMode(CameraMode.NONE_GPS);
} else if (selectedTrackingType.contentEquals("Tracking")) {
setCameraTrackingMode(CameraMode.TRACKING);
} else if (selectedTrackingType.contentEquals("Tracking Compass")) {
@@ -409,6 +415,10 @@ public class LocationModesActivity extends AppCompatActivity implements OnMapRea
this.cameraMode = currentMode;
if (currentMode == CameraMode.NONE) {
locationTrackingBtn.setText("None");
+ } else if (currentMode == CameraMode.NONE_COMPASS) {
+ locationTrackingBtn.setText("None Compass");
+ } else if (currentMode == CameraMode.NONE_GPS) {
+ locationTrackingBtn.setText("None GPS");
} else if (currentMode == CameraMode.TRACKING) {
locationTrackingBtn.setText("Tracking");
} else if (currentMode == CameraMode.TRACKING_COMPASS) {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java
index 4af6777995..9db7cb2c9d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java
@@ -133,7 +133,7 @@ public class BottomSheetActivity extends AppCompatActivity {
Bundle bundle = new Bundle();
bundle.putInt("mapcounter", mapCounter);
mapFragment.setArguments(bundle);
- MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(context, null);
+ MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(context);
mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions));
return mapFragment;
}
@@ -211,7 +211,7 @@ public class BottomSheetActivity extends AppCompatActivity {
public static BottomSheetFragment newInstance(Context context) {
BottomSheetFragment mapFragment = new BottomSheetFragment();
- MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(context, null);
+ MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(context);
mapboxMapOptions.renderSurfaceOnTop(true);
mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions));
return mapFragment;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/GLSurfaceRecyclerViewActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/GLSurfaceRecyclerViewActivity.kt
index 3acb7aa382..eae8c71f7e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/GLSurfaceRecyclerViewActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/GLSurfaceRecyclerViewActivity.kt
@@ -151,4 +151,4 @@ open class GLSurfaceRecyclerViewActivity : AppCompatActivity() {
}
}
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/OverlayMapActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/OverlayMapActivity.kt
index d0f3f2e964..3666459951 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/OverlayMapActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/OverlayMapActivity.kt
@@ -65,7 +65,7 @@ class OverlayMapActivity : AppCompatActivity() {
class OverlayView(context: Context) : View(context) {
private lateinit var paint: Paint
-
+
@SuppressLint("DrawAllocation") // only happens once
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
@@ -83,4 +83,4 @@ class OverlayMapActivity : AppCompatActivity() {
}
}
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/TextureRecyclerViewActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/TextureRecyclerViewActivity.kt
index 940d4b4f19..2f3017435b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/TextureRecyclerViewActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/TextureRecyclerViewActivity.kt
@@ -12,4 +12,4 @@ class TextureRecyclerViewActivity : GLSurfaceRecyclerViewActivity() {
override fun getMapItemLayoutId(): Int {
return R.layout.item_map_texture
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/ChangeResourcesCachePathActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/ChangeResourcesCachePathActivity.kt
index 74b5bde17d..4e1963d7fc 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/ChangeResourcesCachePathActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/ChangeResourcesCachePathActivity.kt
@@ -74,7 +74,7 @@ class ChangeResourcesCachePathActivity : AppCompatActivity(),
offlineManager.listOfflineRegions(object : OfflineManager.ListOfflineRegionsCallback {
override fun onList(offlineRegions: Array<out OfflineRegion>?) {
- Logger.i(TAG, "Number of saved offline regions in the new path: ${offlineRegions?.size.toString()}")
+ Logger.i(TAG, "Number of saved offline regions in the new path: ${offlineRegions?.size}")
}
override fun onError(error: String?) {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DeleteRegionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DeleteRegionActivity.java
index 037c51f723..11ee68702f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DeleteRegionActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DeleteRegionActivity.java
@@ -12,7 +12,6 @@ import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
-
import com.mapbox.mapboxsdk.offline.OfflineManager;
import com.mapbox.mapboxsdk.offline.OfflineRegion;
import com.mapbox.mapboxsdk.testapp.R;
@@ -25,7 +24,8 @@ import java.util.List;
/**
* Test activity showing integration of deleting an OfflineRegion.
*/
-public class DeleteRegionActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {
+public class DeleteRegionActivity extends AppCompatActivity implements AdapterView.OnItemClickListener,
+ AdapterView.OnItemLongClickListener {
private OfflineRegionAdapter adapter;
@@ -34,10 +34,11 @@ public class DeleteRegionActivity extends AppCompatActivity implements AdapterVi
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_offline_region_delete);
- ListView listView = (ListView) findViewById(R.id.listView);
+ ListView listView = findViewById(R.id.listView);
listView.setAdapter(adapter = new OfflineRegionAdapter(this));
listView.setEmptyView(findViewById(android.R.id.empty));
listView.setOnItemClickListener(this);
+ listView.setOnItemLongClickListener(this);
}
@Override
@@ -58,6 +59,23 @@ public class DeleteRegionActivity extends AppCompatActivity implements AdapterVi
builder.show();
}
+ @Override
+ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
+ final OfflineRegion region = adapter.getItem(position);
+ region.invalidate(new OfflineRegion.OfflineRegionInvalidateCallback() {
+ @Override
+ public void onInvalidate() {
+ Toast.makeText(DeleteRegionActivity.this, "Invalidate region success", Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onError(String error) {
+ Toast.makeText(DeleteRegionActivity.this, "Error:" + error, Toast.LENGTH_LONG).show();
+ }
+ });
+ return true;
+ }
+
private void delete(OfflineRegion region) {
region.delete(new OfflineRegion.OfflineRegionDeleteCallback() {
@Override
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DownloadRegionActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DownloadRegionActivity.kt
index 41dbe56112..36a8ccf0f1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DownloadRegionActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DownloadRegionActivity.kt
@@ -145,7 +145,8 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
}
if (status.completedResourceCount > status.requiredResourceCount &&
- previousCompletedResourceCount <= status.requiredResourceCount) {
+ previousCompletedResourceCount <= status.requiredResourceCount
+ ) {
logMessage("FAILURE! Completed > required")
}
}
@@ -279,11 +280,9 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
}
override fun onStartTrackingTouch(seekBar: SeekBar) {
-
}
override fun onStopTrackingTouch(seekBar: SeekBar) {
-
}
})
@@ -293,17 +292,19 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
}
override fun onStartTrackingTouch(seekBar: SeekBar) {
-
}
override fun onStopTrackingTouch(seekBar: SeekBar) {
-
}
})
}
- private fun validCoordinates(latitudeNorth: Double, longitudeEast: Double, latitudeSouth: Double,
- longitudeWest: Double): Boolean {
+ private fun validCoordinates(
+ latitudeNorth: Double,
+ longitudeEast: Double,
+ latitudeSouth: Double,
+ longitudeWest: Double
+ ): Boolean {
if (latitudeNorth < -90 || latitudeNorth > 90) {
return false
} else if (longitudeEast < -180 || longitudeEast > 180) {
@@ -315,4 +316,4 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
}
return true
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/MergeOfflineRegionsActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/MergeOfflineRegionsActivity.kt
index 12169dbe8f..0f59191d06 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/MergeOfflineRegionsActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/MergeOfflineRegionsActivity.kt
@@ -144,4 +144,4 @@ class MergeOfflineRegionsActivity : AppCompatActivity() {
super.onSaveInstanceState(outState)
mapView.onSaveInstanceState(outState)
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java
index d7ceda699e..dea10198b6 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/snapshot/MapSnapshotterMarkerActivity.java
@@ -6,6 +6,8 @@ import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
@@ -64,6 +66,7 @@ public class MapSnapshotterMarkerActivity extends AppCompatActivity implements M
@SuppressLint("ClickableViewAccessibility")
@Override
public void onSnapshotReady(MapSnapshot snapshot) {
+ this.mapSnapshot = snapshot;
Timber.i("Snapshot ready");
ImageView imageView = (ImageView) findViewById(R.id.snapshot_image);
Bitmap image = addMarker(snapshot);
@@ -93,4 +96,10 @@ public class MapSnapshotterMarkerActivity extends AppCompatActivity implements M
return snapshot.getBitmap();
}
+ @VisibleForTesting
+ @Nullable
+ public MapSnapshot getMapSnapshot() {
+ return mapSnapshot;
+ }
+
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/storage/CacheManagementActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/storage/CacheManagementActivity.kt
new file mode 100644
index 0000000000..54427ad20d
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/storage/CacheManagementActivity.kt
@@ -0,0 +1,78 @@
+package com.mapbox.mapboxsdk.testapp.activity.storage
+
+import android.os.Bundle
+import android.os.Looper
+import android.support.design.widget.Snackbar
+import android.support.v7.app.AppCompatActivity
+import com.mapbox.mapboxsdk.offline.OfflineManager
+import com.mapbox.mapboxsdk.testapp.R
+import junit.framework.Assert.assertTrue
+import kotlinx.android.synthetic.main.activity_cache_management.*
+
+/**
+ * Test activity showcasing the cache management APIs
+ */
+class CacheManagementActivity : AppCompatActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_cache_management)
+
+ val fileSource = OfflineManager.getInstance(this)
+ resetDatabaseButton.setOnClickListener {
+ fileSource.resetDatabase(object : OfflineManager.FileSourceCallback {
+ override fun onSuccess() {
+ showSnackbar("Reset database success")
+ }
+
+ override fun onError(message: String) {
+ showSnackbar("Reset database fail: $message")
+ }
+ })
+ }
+
+ invalidateAmbientCacheButton.setOnClickListener {
+ fileSource.invalidateAmbientCache(object : OfflineManager.FileSourceCallback {
+ override fun onSuccess() {
+ showSnackbar("Invalidate ambient cache success")
+ }
+
+ override fun onError(message: String) {
+ showSnackbar("Invalidate ambient cache fail: $message")
+ }
+ })
+ }
+
+ clearAmbientCacheButton.setOnClickListener {
+ fileSource.clearAmbientCache(object : OfflineManager.FileSourceCallback {
+ override fun onSuccess() {
+ showSnackbar("Clear ambient cache success")
+ }
+
+ override fun onError(message: String) {
+ showSnackbar("Clear ambient cache fail: $message")
+ }
+ })
+ }
+
+ setMaximumAmbientCacheSizeButton.setOnClickListener {
+ fileSource.setMaximumAmbientCacheSize(5000000, object : OfflineManager.FileSourceCallback {
+ override fun onSuccess() {
+ showSnackbar("Set maximum ambient cache size success")
+ }
+
+ override fun onError(message: String) {
+ showSnackbar("Set maximum ambient cache size fail: $message")
+ }
+ })
+ }
+ }
+
+ fun showSnackbar(message: String) {
+ // validate that all callbacks occur on main thread
+ assertTrue(Looper.myLooper() == Looper.getMainLooper())
+
+ // show snackbar
+ Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show()
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt
index 0b784675e9..6de00e24f9 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt
@@ -171,11 +171,17 @@ class DraggableMarkerActivity : AppCompatActivity() {
* @param touchAreaMaxX maximum value of X-axis motion event
* @param touchAreaMaxY maximum value of Y-axis motion event
*/
- class DraggableSymbolsManager(mapView: MapView, private val mapboxMap: MapboxMap,
- private val symbolsCollection: FeatureCollection,
- private val symbolsSource: GeoJsonSource, private val symbolsLayerId: String,
- private val touchAreaShiftX: Int = 0, private val touchAreaShiftY: Int = 0,
- private val touchAreaMaxX: Int = mapView.width, private val touchAreaMaxY: Int = mapView.height) {
+ class DraggableSymbolsManager(
+ mapView: MapView,
+ private val mapboxMap: MapboxMap,
+ private val symbolsCollection: FeatureCollection,
+ private val symbolsSource: GeoJsonSource,
+ private val symbolsLayerId: String,
+ private val touchAreaShiftY: Int = 0,
+ private val touchAreaShiftX: Int = 0,
+ private val touchAreaMaxX: Int = mapView.width,
+ private val touchAreaMaxY: Int = mapView.height
+ ) {
private val androidGesturesManager: AndroidGesturesManager = AndroidGesturesManager(mapView.context, false)
private var draggedSymbolId: String? = null
@@ -322,4 +328,4 @@ class DraggableMarkerActivity : AppCompatActivity() {
private fun MapboxMap.queryRenderedSymbols(latLng: LatLng, layerId: String): List<Feature> {
return this.queryRenderedFeatures(this.projection.toScreenLocation(latLng), layerId)
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java
index 243fa67ec4..3d65a92f72 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java
@@ -43,7 +43,9 @@ import static com.mapbox.mapboxsdk.style.expressions.Expression.format;
import static com.mapbox.mapboxsdk.style.expressions.Expression.formatEntry;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
+import static com.mapbox.mapboxsdk.style.expressions.Expression.match;
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgb;
+import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
import static com.mapbox.mapboxsdk.style.expressions.Expression.switchCase;
import static com.mapbox.mapboxsdk.style.expressions.Expression.toBool;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap;
@@ -51,6 +53,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAnchor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconIgnorePlacement;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOpacity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAllowOverlap;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAnchor;
@@ -114,7 +117,7 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap.
setContentView(R.layout.activity_symbollayer);
// Create map configuration
- MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(this, null);
+ MapboxMapOptions mapboxMapOptions = MapboxMapOptions.createFromAttributes(this);
mapboxMapOptions.camera(new CameraPosition.Builder().target(
new LatLng(52.35273, 4.91638))
.zoom(13)
@@ -198,6 +201,12 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap.
// use DDS
boolean selected = feature.getBooleanProperty(SELECTED_FEATURE_PROPERTY);
feature.addBooleanProperty(SELECTED_FEATURE_PROPERTY, !selected);
+
+ // validate symbol flicker regression for #13407
+ markerSymbolLayer.setProperties(iconOpacity(match(
+ get(ID_FEATURE_PROPERTY), literal(1.0f),
+ stop(feature.getStringProperty("id"), selected ? 0.3f : 1.0f)
+ )));
}
}
markerSource.setGeoJson(markerCollection);
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FileUtils.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FileUtils.kt
index 457ad928db..e0c1ca4207 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FileUtils.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FileUtils.kt
@@ -19,7 +19,6 @@ class FileUtils {
override fun doInBackground(vararg strings: String): Boolean? {
val assetName = strings[0]
val destinationPath = strings[1]
-
contextWeakReference.get()?.let {
try {
copyAsset(it, assetName, destinationPath)
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_arrow_upward.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_arrow_upward.xml
new file mode 100644
index 0000000000..c64ae35166
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_arrow_upward.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M4,12l1.41,1.41L11,7.83V20h2V7.83l5.58,5.59L20,12l-8,-8 -8,8z"/>
+</vector>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_cache_management.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_cache_management.xml
new file mode 100644
index 0000000000..a79ed9352b
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_cache_management.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/container"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <Button
+ android:id="@+id/resetDatabaseButton"
+ android:text="Reset Database"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+
+ <Button
+ android:id="@+id/invalidateAmbientCacheButton"
+ android:text="Invalidate Ambient Cache"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+
+ <Button
+ android:id="@+id/clearAmbientCacheButton"
+ android:text="Clear Ambient Cache"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+
+ <Button
+ android:id="@+id/setMaximumAmbientCacheSizeButton"
+ android:text="Set Maximum Ambient Cache Size to 5mb"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+
+</LinearLayout> \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_latlngbounds.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_latlngbounds.xml
index e565c3c9d1..e25fd1882c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_latlngbounds.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_latlngbounds.xml
@@ -1,36 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:id="@+id/coordinator_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fitsSystemWindows="true"
- android:orientation="vertical">
-
- <com.mapbox.mapboxsdk.maps.MapView
- android:id="@id/mapView"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
+ android:fitsSystemWindows="true"
+ android:orientation="vertical">
+
+ <com.mapbox.mapboxsdk.maps.MapView
+ android:id="@id/mapView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.v4.widget.NestedScrollView
- android:id="@+id/bottom_sheet"
- android:layout_width="match_parent"
- android:layout_height="375dp"
- android:background="@color/primaryDark"
- app:behavior_hideable="true"
- app:behavior_skipCollapsed="false"
- app:layout_behavior="com.mapbox.mapboxsdk.testapp.view.LockableBottomSheetBehavior"/>
+ android:id="@+id/bottomSheet"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@color/primaryDark"
+ app:behavior_hideable="true"
+ app:behavior_peekHeight="375dp"
+ app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
+
+ <TextView
+ android:text="Hello World"
+ android:gravity="center"
+ android:textSize="120sp"
+ android:textColor="@android:color/white"
+ android:background="@color/primary"
+ android:layout_width="match_parent"
+ android:layout_height="375dp"/>
+
+ </android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
- android:id="@+id/fab"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="@dimen/fab_margin"
- android:src="@drawable/ic_arrow_downward"
- app:backgroundTint="@color/primary"
- app:layout_anchor="@id/bottom_sheet"
- app:layout_anchorGravity="top|end"/>
+ android:id="@+id/fab"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/fab_margin"
+ android:src="@drawable/ic_arrow_upward"
+ app:backgroundTint="@color/primary"
+ app:layout_anchor="@id/bottomSheet"
+ app:layout_anchorGravity="top|end"/>
</android.support.design.widget.CoordinatorLayout> \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml
index 684220f2c4..082eb39256 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml
@@ -51,6 +51,7 @@
<string name="description_map_in_dialog">Display a map inside a dialog fragment</string>
<string name="description_circle_layer">Show bus stops and route in Singapore</string>
<string name="description_url_transform">Transform urls on the fly</string>
+ <string name="description_cache_management">Control the cache management with FileSource API</string>
<string name="description_restricted_bounds">Limit viewport to Iceland</string>
<string name="description_fill_extrusion_layer">Shows how to add 3D extruded shapes</string>
<string name="description_building_fill_extrusion_layer">Shows how to show 3D extruded buildings</string>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml
index 027198c71b..94566ea995 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml
@@ -50,6 +50,7 @@
<string name="activity_map_visibility">Visibility Map</string>
<string name="activity_map_in_dialog">Dialog with map</string>
<string name="activity_url_transform">Url transform</string>
+ <string name="activity_cache_management">Cache management</string>
<string name="activity_restricted_bounds">Restrict camera to a bounds</string>
<string name="activity_fill_extrusion_layer">Fill extrusions</string>
<string name="activity_building_fill_extrusion_layer">Building layer</string>