summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationApplication.kt10
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationRunner.kt11
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/BaseIntegrationTest.kt39
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/FragmentBackStackTest.kt52
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReopenTest.kt30
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt31
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/OrientationChangeTest.kt34
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReopenTest.kt33
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReuseTest.kt31
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt38
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt96
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt34
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/GLSurfaceViewReopenTest.kt73
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxTest.java3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/OrientationTest.java41
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TextureViewReopenTest.kt77
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/VisibleRegionTest.kt80
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/module/telemetry/PerformanceEventTest.java188
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/OrientationAction.java (renamed from platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/OrientationChangeAction.java)18
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/WaitAction.java7
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseTest.java126
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/EspressoTest.java18
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java161
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraForTest.java340
-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/geometry/GeoJsonConversionTest.java118
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt8
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/offline/OfflineManagerTest.kt123
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CustomGeometrySourceTest.kt21
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java26
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/GeoJsonSourceTests.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.java46
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.kt75
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java13
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java28
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/FinishLoadingStyleIdlingResource.java35
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/LoadStyleIdlingResource.java40
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/MapboxIdlingResource.java46
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java60
41 files changed, 1193 insertions, 1042 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationApplication.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationApplication.kt
new file mode 100644
index 0000000000..ea48bdc00f
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationApplication.kt
@@ -0,0 +1,10 @@
+package com.mapbox.mapboxsdk
+
+import com.mapbox.mapboxsdk.testapp.MapboxApplication
+
+class InstrumentationApplication : MapboxApplication() {
+ override fun initializeLeakCanary(): Boolean {
+ // do not initialize leak canary during instrumentation tests
+ return true
+ }
+} \ 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
new file mode 100644
index 0000000000..6873b33262
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/InstrumentationRunner.kt
@@ -0,0 +1,11 @@
+package com.mapbox.mapboxsdk
+
+import android.app.Application
+import android.content.Context
+import android.support.test.runner.AndroidJUnitRunner
+
+class InstrumentationRunner : AndroidJUnitRunner() {
+ override fun newApplication(cl: ClassLoader?, className: String?, context: Context?): Application {
+ return super.newApplication(cl, InstrumentationApplication::class.java.name, context)
+ }
+}
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
new file mode 100644
index 0000000000..aeb8863790
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/BaseIntegrationTest.kt
@@ -0,0 +1,39 @@
+package com.mapbox.mapboxsdk.integration
+
+import android.content.Context
+import android.content.Intent
+import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
+import android.support.test.InstrumentationRegistry
+import android.support.test.uiautomator.*
+import org.junit.Before
+
+const val TIMEOUT_UI_SEARCH_WAIT = 5000L
+
+abstract class BaseIntegrationTest {
+
+ protected lateinit var device: UiDevice
+
+ @Before
+ open fun beforeTest() {
+ device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
+ }
+}
+
+/**
+ * Launches an activity with FLAG_ACTIVITY_NEW_TASK.
+ * <p>
+ * To resume an activity, you need to add a single instance launchmode to your manifest configuration.
+ * <p>
+ */
+fun UiDevice.launchActivity(context: Context, clazz: Class<*>) {
+ val applicationPackage = InstrumentationRegistry.getTargetContext().packageName
+ val intent = Intent(context, clazz)
+ intent.addFlags(FLAG_ACTIVITY_NEW_TASK)
+ InstrumentationRegistry.getContext().startActivity(intent)
+ wait(Until.hasObject(By.pkg(applicationPackage).depth(0)), TIMEOUT_UI_SEARCH_WAIT)
+}
+
+fun UiDevice.scrollRecyclerViewTo(recycleItem: String) {
+ val appView = UiScrollable(UiSelector().scrollable(true))
+ appView.scrollIntoView(UiSelector().text(recycleItem))
+} \ No newline at end of file
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
new file mode 100644
index 0000000000..b0f6436bdd
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/FragmentBackStackTest.kt
@@ -0,0 +1,52 @@
+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
+
+/**
+ * Regression test that validates MapFragment integration on the backstack
+ */
+@RunWith(AndroidJUnit4::class)
+class FragmentBackStackTest : BaseIntegrationTest() {
+
+ @get:Rule
+ var activityRule: ActivityTestRule<FragmentBackStackActivity> = ActivityTestRule(FragmentBackStackActivity::class.java)
+
+ @Test
+ @LargeTest
+ fun backPressedOnBackStackResumed() {
+ device.waitForIdle()
+ clickReplaceFragmentButton()
+ device.pressHome()
+ device.waitForIdle()
+ device.launchActivity(activityRule.activity.applicationContext, FragmentBackStackActivity::class.java)
+ backPressBackStack()
+ device.waitForIdle()
+ }
+
+ private fun clickReplaceFragmentButton() {
+ device.findObject(UiSelector().description(textDescription)).click()
+ }
+
+ private fun backPressBackStack() {
+ device.pressBack() // pops fragment, showing map
+ device.pressBack() // finish activity
+ }
+
+ private companion object {
+ const val textDescription = "btn_change_fragment"
+ }
+} \ No newline at end of file
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
new file mode 100644
index 0000000000..f22b5f7c9d
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReopenTest.kt
@@ -0,0 +1,30 @@
+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.SimpleMapActivity
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+
+/**
+ * Regression test that validates reopening an Activity with a GLSurfaceView
+ */
+@RunWith(AndroidJUnit4::class)
+class GLSurfaceViewReopenTest : BaseIntegrationTest() {
+
+ @get:Rule
+ var activityRule: ActivityTestRule<SimpleMapActivity> = ActivityTestRule(SimpleMapActivity::class.java)
+
+ @Test
+ @LargeTest
+ fun reopenSimpleMapActivity() {
+ device.waitForIdle()
+ device.pressHome()
+ device.waitForIdle()
+ device.launchActivity(activityRule.activity, SimpleMapActivity::class.java)
+ device.waitForIdle()
+ }
+}
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
new file mode 100644
index 0000000000..945fac677e
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt
@@ -0,0 +1,31 @@
+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
+
+/**
+ * Regression test that validates if a GLSurfaceView surface can be recreated without crashing.
+ */
+@RunWith(AndroidJUnit4::class)
+class GLSurfaceViewReuseTest : BaseIntegrationTest() {
+
+ @get:Rule
+ var activityRule: ActivityTestRule<GLSurfaceRecyclerViewActivity> = ActivityTestRule(GLSurfaceRecyclerViewActivity::class.java)
+
+ @Test
+ @LargeTest
+ fun scrollRecyclerView() {
+ device.waitForIdle()
+ device.scrollRecyclerViewTo("Twenty-one")
+ device.waitForIdle()
+ device.scrollRecyclerViewTo("One")
+ device.waitForIdle()
+ }
+} \ No newline at end of file
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
new file mode 100644
index 0000000000..941b7ea8dc
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/OrientationChangeTest.kt
@@ -0,0 +1,34 @@
+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
+
+@RunWith(AndroidJUnit4::class)
+class OrientationChangeTest : BaseIntegrationTest() {
+
+ @get:Rule
+ var activityRule: ActivityTestRule<SimpleMapActivity> = ActivityTestRule(SimpleMapActivity::class.java)
+
+ @Test
+ @LargeTest
+ fun rotateSimpleMap() {
+ device.setOrientationLeft()
+ device.waitForIdle()
+ device.setOrientationNatural()
+ device.waitForIdle()
+ device.setOrientationRight()
+ device.waitForIdle()
+ device.setOrientationNatural()
+ device.setOrientationLeft()
+ device.setOrientationNatural()
+ device.setOrientationRight()
+ device.setOrientationNatural()
+ }
+} \ 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
new file mode 100644
index 0000000000..44da557904
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReopenTest.kt
@@ -0,0 +1,33 @@
+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
+ */
+@RunWith(AndroidJUnit4::class)
+class TextureViewReopenTest : BaseIntegrationTest() {
+
+ @get:Rule
+ var activityRule: ActivityTestRule<TextureViewDebugModeActivity> = ActivityTestRule(TextureViewDebugModeActivity::class.java)
+
+ @Test
+ @LargeTest
+ fun reopenTextureViewDebugActivity() {
+ device.waitForIdle()
+ device.pressHome()
+ device.waitForIdle()
+ device.launchActivity(activityRule.activity, TextureViewDebugModeActivity::class.java)
+ device.waitForIdle()
+ }
+} \ No newline at end of file
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
new file mode 100644
index 0000000000..5c3d66c462
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReuseTest.kt
@@ -0,0 +1,31 @@
+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
+
+/**
+ * Regression test that validates if a GLSurfaceView surface can be recreated without crashing.
+ */
+@RunWith(AndroidJUnit4::class)
+class TextureViewReuseTest : BaseIntegrationTest() {
+
+ @get:Rule
+ var activityRule: ActivityTestRule<TextureRecyclerViewActivity> = ActivityTestRule(TextureRecyclerViewActivity::class.java)
+
+ @Test
+ @LargeTest
+ fun scrollRecyclerView() {
+ device.waitForIdle()
+ device.scrollRecyclerViewTo("Twenty-one")
+ device.waitForIdle()
+ device.scrollRecyclerViewTo("One")
+ device.waitForIdle()
+ }
+} \ No newline at end of file
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
new file mode 100644
index 0000000000..b918801296
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt
@@ -0,0 +1,38 @@
+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.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
+
+/**
+ * Regression test that validates MapFragment integration with a ViewPager
+ */
+@RunWith(AndroidJUnit4::class)
+class ViewPagerScrollTest : BaseIntegrationTest() {
+
+ @get:Rule
+ var activityRule: ActivityTestRule<ViewPagerActivity> = ActivityTestRule(ViewPagerActivity::class.java)
+
+ @Test
+ @LargeTest
+ fun scrollViewPager() {
+ for (i in 1..4) {
+ clickTab(i)
+ }
+
+ for (i in 3 downTo 0) {
+ clickTab(i)
+ }
+ }
+
+ private fun clickTab(index: Int) {
+ device.findObject(UiSelector().text("Page $index")).click()
+ }
+} \ No newline at end of file
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 dde03d8a14..f9827c767e 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
@@ -82,7 +82,7 @@ class LocationComponentTest : EspressoTest() {
val locationEngine = component.locationEngine
assertThat(locationEngine, notNullValue())
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
}
}
@@ -118,7 +118,7 @@ class LocationComponentTest : EspressoTest() {
assertThat(locationEngine, notNullValue())
assertThat(componentOptions, notNullValue())
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(componentOptions?.accuracyAlpha(), `is`(.5f))
assertThat(componentOptions?.accuracyColor(), `is`(Color.BLUE))
}
@@ -157,7 +157,7 @@ class LocationComponentTest : EspressoTest() {
assertThat(locationEngine, nullValue())
assertThat(componentOptions, notNullValue())
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(componentOptions?.accuracyAlpha(), `is`(.5f))
assertThat(componentOptions?.accuracyColor(), `is`(Color.BLUE))
}
@@ -205,7 +205,7 @@ class LocationComponentTest : EspressoTest() {
// Force the first location update
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
// Check if the puck is visible
assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(false))
@@ -240,7 +240,7 @@ class LocationComponentTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
uiController.loopMainThreadForAtLeast(300) // waiting for stale state
mapboxMap.querySourceFeatures(LOCATION_SOURCE).also { feature ->
@@ -287,7 +287,7 @@ class LocationComponentTest : EspressoTest() {
}
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
val feature = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0]
assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(false))
@@ -329,7 +329,7 @@ class LocationComponentTest : EspressoTest() {
mapboxMap.addImageFromDrawable("custom-foreground-bitmap", it)
mapboxMap.addImageFromDrawable("custom-gps-bitmap", it)
}
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
val foregroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON)
assertThat(foregroundId, `is`(equalTo("custom-gps-bitmap")))
@@ -360,13 +360,13 @@ class LocationComponentTest : EspressoTest() {
component.renderMode = RenderMode.GPS
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
val foregroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON)
assertThat(foregroundId, `is`(equalTo("custom-gps-bitmap")))
component.applyStyle(LocationComponentOptions.builder(context).build())
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertEquals(FOREGROUND_ICON, mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON))
}
@@ -395,13 +395,13 @@ class LocationComponentTest : EspressoTest() {
component.renderMode = RenderMode.GPS
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
val foregroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON)
assertThat(foregroundId, `is`(equalTo("custom-gps-bitmap")))
component.renderMode = RenderMode.NORMAL
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertEquals(FOREGROUND_ICON, mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON))
}
@@ -430,14 +430,14 @@ class LocationComponentTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
uiController.loopMainThreadForAtLeast(250) // engaging stale state
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true))
component.onStop()
component.onStart()
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true))
assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(false))
@@ -461,13 +461,13 @@ class LocationComponentTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(false))
component.onStop()
component.onStart()
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(false))
assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(true))
@@ -499,7 +499,7 @@ class LocationComponentTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
mapboxMap.querySourceFeatures(LOCATION_SOURCE).also { feature ->
feature.forEach {
@@ -526,7 +526,7 @@ class LocationComponentTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point
assertThat(component.locationEngine, nullValue())
@@ -550,14 +550,14 @@ class LocationComponentTest : EspressoTest() {
.build())
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
val point: Point = mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER)[0].geometry() as Point
assertEquals(point.latitude(), location.latitude, 0.1)
assertEquals(point.longitude(), location.longitude, 0.1)
component.isLocationComponentEnabled = false
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(true))
}
}
@@ -580,7 +580,7 @@ class LocationComponentTest : EspressoTest() {
component.isLocationComponentEnabled = false
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
component.isLocationComponentEnabled = true
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
}
@@ -675,7 +675,7 @@ class LocationComponentTest : EspressoTest() {
component.onStart()
mapboxMap.setStyle(Style.Builder().fromUrl(Style.DARK))
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
}
}
executeComponentTest(componentAction)
@@ -695,7 +695,7 @@ class LocationComponentTest : EspressoTest() {
mapboxMap.setStyle(Style.Builder().fromUrl(Style.DARK))
component.onStop()
component.onStart()
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
}
}
executeComponentTest(componentAction)
@@ -714,7 +714,7 @@ class LocationComponentTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.onStop()
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE).isEmpty(), `is`(true))
}
@@ -736,7 +736,7 @@ class LocationComponentTest : EspressoTest() {
component.onStop()
component.forceLocationUpdate(location)
component.onStart()
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point
assertEquals(point.latitude(), location.latitude, 0.1)
@@ -760,9 +760,9 @@ class LocationComponentTest : EspressoTest() {
component.forceLocationUpdate(location)
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
component.onStop()
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
component.onStart()
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point
assertEquals(point.latitude(), location.latitude, 0.1)
@@ -797,7 +797,7 @@ class LocationComponentTest : EspressoTest() {
component.applyStyle(options)
}
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
}
}
executeComponentTest(componentAction)
@@ -823,7 +823,7 @@ class LocationComponentTest : EspressoTest() {
component.forceLocationUpdate(location)
}
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
}
}
executeComponentTest(componentAction)
@@ -839,7 +839,7 @@ class LocationComponentTest : EspressoTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
style: Style, uiController: UiController, context: Context) {
styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
locationComponentActivationOptions = LocationComponentActivationOptions
.builder(context, mapboxMap.style!!)
@@ -878,13 +878,13 @@ class LocationComponentTest : EspressoTest() {
component.renderMode = RenderMode.GPS
location.bearing = 77f
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS)
assertEquals(77f, mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(PROPERTY_GPS_BEARING).toFloat(), 0.1f)
location.bearing = 92f
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS) // Waiting for the animation to finish
assertEquals(92.0f, mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(PROPERTY_GPS_BEARING).toFloat(), 0.1f)
}
@@ -906,7 +906,7 @@ class LocationComponentTest : EspressoTest() {
component.cameraMode = CameraMode.TRACKING_GPS
location.bearing = 77f
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS)
assertEquals(77.0, mapboxMap.cameraPosition.bearing, 0.1)
@@ -917,7 +917,7 @@ class LocationComponentTest : EspressoTest() {
location.latitude = 30.0
location.longitude = 35.0
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS) // Waiting for the animation to finish
assertEquals(92.0, mapboxMap.cameraPosition.bearing, 0.1)
@@ -945,7 +945,7 @@ class LocationComponentTest : EspressoTest() {
location.bearing = 77f
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS)
assertEquals(77.0, mapboxMap.cameraPosition.bearing, 0.1)
@@ -956,7 +956,7 @@ class LocationComponentTest : EspressoTest() {
location.latitude = 30.0
location.longitude = 35.0
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS)
assertEquals(92.0, mapboxMap.cameraPosition.bearing, 0.1)
@@ -985,7 +985,7 @@ class LocationComponentTest : EspressoTest() {
location.bearing = 77f
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS)
assertEquals(bearing, mapboxMap.cameraPosition.bearing, 0.1)
@@ -996,7 +996,7 @@ class LocationComponentTest : EspressoTest() {
location.latitude = 30.0
location.longitude = 35.0
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS)
assertEquals(bearing, mapboxMap.cameraPosition.bearing, 0.1)
@@ -1021,7 +1021,7 @@ class LocationComponentTest : EspressoTest() {
component.cameraMode = CameraMode.TRACKING
component.cameraMode = CameraMode.NONE
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.uiSettings.focalPoint, nullValue())
}
@@ -1044,7 +1044,7 @@ class LocationComponentTest : EspressoTest() {
val zoom = mapboxMap.cameraPosition.zoom
component.zoomWhileTracking(10.0)
uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertEquals(zoom, mapboxMap.cameraPosition.zoom, 0.1)
}
@@ -1066,7 +1066,7 @@ class LocationComponentTest : EspressoTest() {
component.cameraMode = CameraMode.TRACKING
component.zoomWhileTracking(10.0)
uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertEquals(10.0, mapboxMap.cameraPosition.zoom, 0.1)
}
@@ -1091,7 +1091,7 @@ class LocationComponentTest : EspressoTest() {
uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION / 2)
component.cameraMode = CameraMode.NONE
uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION / 2)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertEquals(15.0 / 2.0, mapboxMap.cameraPosition.zoom, 3.0)
}
@@ -1117,7 +1117,7 @@ class LocationComponentTest : EspressoTest() {
component.onStop()
component.zoomWhileTracking(10.0)
uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertEquals(zoom, mapboxMap.cameraPosition.zoom, 0.1)
}
@@ -1142,7 +1142,7 @@ class LocationComponentTest : EspressoTest() {
uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION / 2)
component.cancelZoomWhileTrackingAnimation()
uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_ZOOM_ANIM_DURATION / 2)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertEquals(15.0 / 2.0, mapboxMap.cameraPosition.zoom, 3.0)
}
@@ -1165,7 +1165,7 @@ class LocationComponentTest : EspressoTest() {
val tilt = mapboxMap.cameraPosition.tilt
component.tiltWhileTracking(30.0)
uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertEquals(tilt, mapboxMap.cameraPosition.tilt, 0.1)
}
@@ -1187,7 +1187,7 @@ class LocationComponentTest : EspressoTest() {
component.cameraMode = CameraMode.TRACKING
component.tiltWhileTracking(30.0)
uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertEquals(30.0, mapboxMap.cameraPosition.tilt, 0.1)
}
@@ -1212,7 +1212,7 @@ class LocationComponentTest : EspressoTest() {
uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION / 2)
component.cameraMode = CameraMode.NONE
uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION / 2)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertEquals(30.0 / 2.0, mapboxMap.cameraPosition.tilt, 3.0)
}
@@ -1237,7 +1237,7 @@ class LocationComponentTest : EspressoTest() {
component.onStop()
component.tiltWhileTracking(30.0)
uiController.loopMainThreadForAtLeast(DEFAULT_TRACKING_TILT_ANIM_DURATION)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertEquals(tilt, mapboxMap.cameraPosition.tilt, 0.1)
}
@@ -1286,7 +1286,7 @@ class LocationComponentTest : EspressoTest() {
mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(LatLng(51.0, 17.0)))
mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(90.0))
component.isLocationComponentEnabled = true
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS)
assertEquals(location.bearing.toDouble(), mapboxMap.cameraPosition.bearing, 0.1)
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 37b3e8b802..fb450de527 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
@@ -75,7 +75,7 @@ class LocationLayerControllerTest : EspressoTest() {
.build())
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(style.getSource(LOCATION_SOURCE), notNullValue())
}
@@ -99,7 +99,7 @@ class LocationLayerControllerTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
@@ -123,7 +123,7 @@ class LocationLayerControllerTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.COMPASS
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
@@ -147,7 +147,7 @@ class LocationLayerControllerTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.GPS
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
@@ -171,7 +171,7 @@ class LocationLayerControllerTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
component.isLocationComponentEnabled = false
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
component.renderMode = RenderMode.GPS
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(false))
@@ -197,7 +197,7 @@ class LocationLayerControllerTest : EspressoTest() {
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
component.isLocationComponentEnabled = false
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
// Check that all layers visibilities are set to none
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(false))
@@ -223,7 +223,7 @@ class LocationLayerControllerTest : EspressoTest() {
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
styleChangeIdlingResource.waitForStyle(mapboxMap, Style.LIGHT)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(component.renderMode, `is`(equalTo(RenderMode.NORMAL)))
@@ -254,13 +254,13 @@ class LocationLayerControllerTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.applyStyle(LocationComponentOptions.builder(context).staleStateTimeout(100).build())
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
uiController.loopMainThreadForAtLeast(150)
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true))
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true))
}
@@ -279,9 +279,9 @@ class LocationLayerControllerTest : EspressoTest() {
.build())
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
component.isLocationComponentEnabled = false
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(true))
val options =
@@ -291,7 +291,7 @@ class LocationLayerControllerTest : EspressoTest() {
.build()
component.applyStyle(options)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(true))
}
}
@@ -338,7 +338,7 @@ class LocationLayerControllerTest : EspressoTest() {
show = !show
}
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
}
}
executeComponentTest(componentAction)
@@ -359,7 +359,7 @@ class LocationLayerControllerTest : EspressoTest() {
component.isLocationComponentEnabled = true
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0))
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
uiController.loopMainThreadForAtLeast(ACCURACY_RADIUS_ANIMATION_DURATION)
assertEquals(Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/,
@@ -386,7 +386,7 @@ class LocationLayerControllerTest : EspressoTest() {
val zoom = 16.0
mapboxMap.easeCamera(CameraUpdateFactory.newLatLngZoom(target, zoom), 300)
uiController.loopMainThreadForAtLeast(300)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(Math.abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1
@@ -418,7 +418,7 @@ class LocationLayerControllerTest : EspressoTest() {
val target = LatLng(location)
val zoom = 16.0
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, zoom))
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(Math.abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1
&& Math.abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1
@@ -445,7 +445,7 @@ class LocationLayerControllerTest : EspressoTest() {
.build())
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
component.applyStyle(LocationComponentOptions.builder(context).layerBelow("road-label").build())
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/GLSurfaceViewReopenTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/GLSurfaceViewReopenTest.kt
deleted file mode 100644
index 98b251027f..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/GLSurfaceViewReopenTest.kt
+++ /dev/null
@@ -1,73 +0,0 @@
-package com.mapbox.mapboxsdk.maps
-
-import android.content.Intent
-import android.support.test.InstrumentationRegistry
-import android.support.test.filters.SdkSuppress
-import android.support.test.runner.AndroidJUnit4
-import android.support.test.uiautomator.*
-import org.hamcrest.CoreMatchers.notNullValue
-import org.hamcrest.MatcherAssert.assertThat
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import java.lang.Thread.sleep
-
-private const val BASIC_SAMPLE_PACKAGE = "com.mapbox.mapboxsdk.testapp"
-private const val LAUNCH_TIMEOUT = 5000L
-
-@RunWith(AndroidJUnit4::class)
-@SdkSuppress(minSdkVersion = 18)
-class GLSurfaceViewReopenTest {
-
- private lateinit var device: UiDevice
-
- @Before
- fun startSimpleMapActivityFromHomeScreen() {
- // Initialize UiDevice instance
- device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
-
- // Start from the home screen
- device.pressHome()
-
- // Wait for launcher
- val launcherPackage: String = device.launcherPackageName
- assertThat(launcherPackage, notNullValue())
- device.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT)
-
- // Launch the app
- val context = InstrumentationRegistry.getInstrumentation().context
- val intent = context.packageManager.getLaunchIntentForPackage(BASIC_SAMPLE_PACKAGE).apply {
- // Clear out any previous instances
- addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
- }
- context.startActivity(intent)
-
- // Wait for the app to appear
- device.wait(
- Until.hasObject(By.pkg(BASIC_SAMPLE_PACKAGE).depth(0)),
- LAUNCH_TIMEOUT
- )
-
- // open SimpleMapActivity
- device.findObject(UiSelector().text("Simple Map")).clickAndWaitForNewWindow()
-
- // wait for idle
- device.waitForIdle(LAUNCH_TIMEOUT)
- }
-
- @Test
- fun reopenSimpleMapActivity() {
- // return to home screen
- device.pressHome()
-
- // press recents apps button
- device.pressRecentApps()
-
- // click to reopen app
- device.findObject(UiSelector().description("Mapbox Android SDK TestApp")).click()
-
- // wait for idle
- device.waitForIdle(LAUNCH_TIMEOUT)
- sleep(LAUNCH_TIMEOUT)
- }
-} \ 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 b56d267b81..c8737e2802 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
@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk.maps;
+import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
import com.mapbox.mapboxsdk.Mapbox;
import org.junit.Test;
@@ -16,6 +17,7 @@ public class MapboxTest {
private static final String ACCESS_TOKEN_2 = "pk.0000000002";
@Test
+ @UiThreadTest
public void testConnected() {
assertTrue(Mapbox.isConnected());
@@ -31,6 +33,7 @@ public class MapboxTest {
}
@Test
+ @UiThreadTest
public void setAccessToken() {
String realToken = Mapbox.getAccessToken();
Mapbox.setAccessToken(ACCESS_TOKEN);
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/OrientationTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/OrientationTest.java
deleted file mode 100644
index 14a2c3bdbf..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/OrientationTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import com.mapbox.mapboxsdk.testapp.activity.BaseTest;
-import com.mapbox.mapboxsdk.testapp.activity.camera.CameraAnimationTypeActivity;
-import org.junit.Test;
-
-import static android.support.test.espresso.Espresso.onView;
-import static android.support.test.espresso.matcher.ViewMatchers.isRoot;
-import static com.mapbox.mapboxsdk.testapp.action.OrientationChangeAction.orientationLandscape;
-import static com.mapbox.mapboxsdk.testapp.action.OrientationChangeAction.orientationLandscapeReverse;
-import static com.mapbox.mapboxsdk.testapp.action.OrientationChangeAction.orientationPortrait;
-import static com.mapbox.mapboxsdk.testapp.action.OrientationChangeAction.orientationPortraitReverse;
-
-public class OrientationTest extends BaseTest {
-
- @Test
- public void testChangeDeviceOrientation() {
- onView(isRoot()).perform(orientationLandscape());
- waitAction(2200);
- onView(isRoot()).perform(orientationPortrait());
- waitAction(2500);
- onView(isRoot()).perform(orientationLandscapeReverse());
- waitAction(500);
- onView(isRoot()).perform(orientationPortraitReverse());
- waitAction(1250);
- onView(isRoot()).perform(orientationLandscape());
- waitAction(750);
- onView(isRoot()).perform(orientationPortrait());
- waitAction(950);
- onView(isRoot()).perform(orientationLandscapeReverse());
- onView(isRoot()).perform(orientationPortraitReverse());
- onView(isRoot()).perform(orientationLandscape());
- onView(isRoot()).perform(orientationPortrait());
- }
-
- @Override
- protected Class getActivityClass() {
- return CameraAnimationTypeActivity.class;
- }
-
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TextureViewReopenTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TextureViewReopenTest.kt
deleted file mode 100644
index cd139ccc40..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TextureViewReopenTest.kt
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.mapbox.mapboxsdk.maps
-
-import android.content.Intent
-import android.support.test.InstrumentationRegistry
-import android.support.test.filters.SdkSuppress
-import android.support.test.runner.AndroidJUnit4
-import android.support.test.uiautomator.*
-import org.hamcrest.CoreMatchers.notNullValue
-import org.hamcrest.MatcherAssert.assertThat
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import java.lang.Thread.sleep
-import android.support.test.uiautomator.UiSelector
-import android.support.test.uiautomator.UiScrollable
-
-private const val BASIC_SAMPLE_PACKAGE = "com.mapbox.mapboxsdk.testapp"
-private const val LAUNCH_TIMEOUT = 5000L
-
-@RunWith(AndroidJUnit4::class)
-@SdkSuppress(minSdkVersion = 18)
-class TextureViewReopenTest {
-
- private lateinit var device: UiDevice
-
- @Before
- fun startSimpleMapActivityFromHomeScreen() {
- // Initialize UiDevice instance
- device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
-
- // Start from the home screen
- device.pressHome()
-
- // Wait for launcher
- val launcherPackage: String = device.launcherPackageName
- assertThat(launcherPackage, notNullValue())
- device.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT)
-
- // Launch the app
- val context = InstrumentationRegistry.getInstrumentation().context
- val intent = context.packageManager.getLaunchIntentForPackage(BASIC_SAMPLE_PACKAGE).apply {
- // Clear out any previous instances
- addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
- }
- context.startActivity(intent)
-
- // Wait for the app to appear
- device.wait(
- Until.hasObject(By.pkg(BASIC_SAMPLE_PACKAGE).depth(0)),
- LAUNCH_TIMEOUT
- )
-
- // open TextureView debug activity
- val appView = UiScrollable(UiSelector().scrollable(true))
- appView.scrollIntoView(UiSelector().text("TextureView debug"))
- device.findObject(UiSelector().text("TextureView debug")).clickAndWaitForNewWindow()
-
- // wait for idle
- device.waitForIdle(LAUNCH_TIMEOUT)
- }
-
- @Test
- fun reopenTextureViewDebugActivity() {
- // return to home screen
- device.pressHome()
-
- // press recent apps button
- device.pressRecentApps()
-
- // click to reopen app
- device.findObject(UiSelector().description("Mapbox Android SDK TestApp")).click()
-
- // wait for idle
- device.waitForIdle(LAUNCH_TIMEOUT)
- sleep(LAUNCH_TIMEOUT)
- }
-} \ No newline at end of file
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 4866812e67..139695461d 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
@@ -1,25 +1,27 @@
-package com.mapbox.mapboxsdk.testapp.maps
+package com.mapbox.mapboxsdk.maps
import android.graphics.PointF
import android.support.test.espresso.UiController
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
import com.mapbox.mapboxsdk.geometry.LatLng
-import com.mapbox.mapboxsdk.maps.MapView
-import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke
-import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity
+
+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.Test
-class VisibleRegionTest : EspressoTest() {
+class VisibleRegionTest : BaseTest() {
- private lateinit var mapView: MapView
+ override fun getActivityClass(): Class<*> {
+ return PixelTestActivity::class.java
+ }
- override fun beforeTest() {
+ override
+ fun beforeTest() {
super.beforeTest()
- mapView = (rule.activity as EspressoTestActivity).mapView
+ mapView = (rule.activity as PixelTestActivity).mapView
}
@Test
@@ -263,9 +265,9 @@ class VisibleRegionTest : EspressoTest() {
@Test
fun paddedTopVisibleRegionOverDatelineTest() {
validateTestSetup()
- invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
+ 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),
@@ -299,7 +301,7 @@ class VisibleRegionTest : EspressoTest() {
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
- .also { it.longitude += 360 },
+ .also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
@@ -355,11 +357,11 @@ class VisibleRegionTest : EspressoTest() {
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
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),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f + d / 2f, mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f - d / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f + d / 2f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f - d / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
)
@@ -371,29 +373,29 @@ class VisibleRegionTest : EspressoTest() {
}
}
- @Test
- fun visibleRotatedRegionOverDatelineTest() {
- 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 latLngs = listOf(
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f + d / 2f, mapView.height / 2f)
- .also { it.longitude += 360 },
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f - d / 2f),
- mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
- )
-
-
- for (bearing in 45 until 360 step 45) {
- mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()));
- val visibleRegion = mapboxMap.projection.visibleRegion
- assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
- }
- }
+ @Test
+ fun visibleRotatedRegionOverDatelineTest() {
+ 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 latLngs = listOf(
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f + d / 2f, mapView.height / 2f)
+ .also { it.longitude += 360 },
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f - d / 2f),
+ mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
+ )
+
+
+ for (bearing in 45 until 360 step 45) {
+ mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()));
+ val visibleRegion = mapboxMap.projection.visibleRegion
+ assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
+ }
}
+ }
private fun MapboxMap.getLatLngFromScreenCoords(x: Float, y: Float): LatLng {
return this.projection.fromScreenLocation(PointF(x, y))
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/module/telemetry/PerformanceEventTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/module/telemetry/PerformanceEventTest.java
new file mode 100644
index 0000000000..6f256b4e56
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/module/telemetry/PerformanceEventTest.java
@@ -0,0 +1,188 @@
+package com.mapbox.mapboxsdk.module.telemetry;
+
+import android.app.ActivityManager;
+import android.content.Context;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Parcel;
+import android.support.test.runner.AndroidJUnit4;
+import android.util.DisplayMetrics;
+import android.view.Display;
+import android.view.WindowManager;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import com.mapbox.mapboxsdk.Mapbox;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(AndroidJUnit4.class)
+public class PerformanceEventTest {
+
+ @Test
+ public void checksPerformanceEventWithMetaData() throws Exception {
+ PerformanceEvent event = obtainPerformanceEvent();
+ assertNotNull(event);
+
+ Parcel parcel = Parcel.obtain();
+
+ event.writeToParcel(parcel, 0);
+ parcel.setDataPosition(0);
+
+ PerformanceEvent newPerfEvent = PerformanceEvent.CREATOR.createFromParcel(parcel);
+ assertNotNull(newPerfEvent);
+
+ compare(event, newPerfEvent, "attributes", "style_id");
+ compare(event, newPerfEvent, "counters", "int_value");
+ compare(event, newPerfEvent, "counters", "long_value");
+ compare(event, newPerfEvent, "counters", "double_value");
+ assertEquals(getMetadata(event), getMetadata(newPerfEvent));
+ }
+
+ @Test
+ public void checksPerformanceEventOnlyRequiredData() throws Exception {
+ Bundle bundle = new Bundle();
+ bundle.putString("property ignored", "value will be ignored");
+ PerformanceEvent event = new PerformanceEvent(UUID.randomUUID().toString(), bundle);
+ assertNotNull(event);
+
+ Parcel parcel = Parcel.obtain();
+ event.writeToParcel(parcel, 0);
+ parcel.setDataPosition(0);
+
+ PerformanceEvent newPerfEvent = PerformanceEvent.CREATOR.createFromParcel(parcel);
+ assertNotNull(newPerfEvent);
+
+ assertEquals(getAttributes(event).size(), 0);
+ assertEquals(getCounters(event).size(), 0);
+ assertEquals(getAttributes(newPerfEvent).size(), 0);
+ assertEquals(getCounters(newPerfEvent).size(), 0);
+ assertEquals(getMetadata(event), getMetadata(newPerfEvent));
+ }
+
+
+ private PerformanceEvent obtainPerformanceEvent() {
+ String styleStr = "mapbox://styles/mapbox/streets-v11";
+ boolean testPerfEvent = true;
+ Double doubleValue = 40.5;
+ Long longValue = 40L;
+ Integer intValue = 40;
+
+ List<Attribute<String>> attributes = new ArrayList<>();
+ attributes.add(
+ new Attribute<>("style_id", styleStr));
+ attributes.add(
+ new Attribute<>("test_perf_event", String.valueOf(testPerfEvent)));
+
+ List<Attribute<? extends Number>> counters = new ArrayList();
+ counters.add(new Attribute<>("long_value", longValue));
+ counters.add(new Attribute<>("double_value", doubleValue));
+ counters.add(new Attribute<>("int_value", intValue));
+
+ Gson gson = new Gson();
+
+ Bundle bundle = new Bundle();
+ bundle.putString("attributes", gson.toJson(attributes));
+ bundle.putString("counters", gson.toJson(counters));
+
+ JsonObject metaData = new JsonObject();
+ metaData.addProperty("os", "android");
+ metaData.addProperty("manufacturer", Build.MANUFACTURER);
+ metaData.addProperty("brand", Build.BRAND);
+ metaData.addProperty("device", Build.MODEL);
+ metaData.addProperty("version", Build.VERSION.RELEASE);
+ metaData.addProperty("abi", Build.CPU_ABI);
+ metaData.addProperty("country", Locale.getDefault().getISO3Country());
+ metaData.addProperty("ram", getRam());
+ metaData.addProperty("screenSize", getWindowSize());
+ bundle.putString("metadata", metaData.toString());
+
+ return new PerformanceEvent(UUID.randomUUID().toString(), bundle);
+ }
+
+ private void compare(PerformanceEvent event1, PerformanceEvent event2, String listFieldName, String name)
+ throws NoSuchFieldException, IllegalAccessException {
+ Object value1 = getValue(event1, listFieldName, name);
+ Object value2 = getValue(event2, listFieldName, name);
+
+ if (value1 instanceof Double && value2 instanceof Double) {
+ assertEquals((Double)value1, (Double)value2, 0.00006);
+ } else {
+ assertEquals(value1, value2);
+ }
+ }
+
+ private Object getPrivateFieldValue(Object object, String fieldName)
+ throws NoSuchFieldException, IllegalAccessException {
+ Field field = object.getClass().getDeclaredField(fieldName);
+ field.setAccessible(true);
+ return field.get(object);
+ }
+
+ private Object getValue(PerformanceEvent event, String listFieldName, String name)
+ throws NoSuchFieldException, IllegalAccessException {
+ ArrayList list = (ArrayList)getPrivateFieldValue(event, listFieldName);
+ for (Object element : list) {
+ Object elementName = getPrivateFieldValue(element, "name");
+ if (elementName != null && elementName.equals((String)name)) {
+ return getPrivateFieldValue(element, "value");
+ }
+ }
+ return null;
+ }
+
+ private JsonObject getMetadata(PerformanceEvent event)
+ throws NoSuchFieldException, IllegalAccessException {
+ return (JsonObject)getPrivateFieldValue(event, "metadata");
+ }
+
+ private ArrayList getAttributes(PerformanceEvent event)
+ throws NoSuchFieldException, IllegalAccessException {
+ return (ArrayList)getPrivateFieldValue(event, "attributes");
+ }
+
+ private ArrayList getCounters(PerformanceEvent event)
+ throws NoSuchFieldException, IllegalAccessException {
+ return (ArrayList)getPrivateFieldValue(event, "counters");
+ }
+
+ private static String getRam() {
+ ActivityManager actManager =
+ (ActivityManager) Mapbox.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
+ ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
+ actManager.getMemoryInfo(memInfo);
+ return String.valueOf(memInfo.totalMem);
+ }
+
+ private static String getWindowSize() {
+ WindowManager windowManager =
+ (WindowManager) Mapbox.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
+ Display display = windowManager.getDefaultDisplay();
+ DisplayMetrics metrics = new DisplayMetrics();
+ display.getMetrics(metrics);
+ int width = metrics.widthPixels;
+ int height = metrics.heightPixels;
+
+ return "{" + width + "," + height + "}";
+ }
+
+ private class Attribute<T> {
+ private String name;
+ private T value;
+
+ Attribute(String name, T value) {
+ this.name = name;
+ this.value = value;
+ }
+ }
+}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/OrientationChangeAction.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/OrientationAction.java
index 7f73d6a7f3..1bf5a87970 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/OrientationChangeAction.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/OrientationAction.java
@@ -1,6 +1,5 @@
package com.mapbox.mapboxsdk.testapp.action;
-
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
@@ -11,30 +10,31 @@ import android.view.View;
import android.view.ViewGroup;
import org.hamcrest.Matcher;
+import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.matcher.ViewMatchers.isRoot;
-public class OrientationChangeAction implements ViewAction {
+public class OrientationAction implements ViewAction {
private final int orientation;
- private OrientationChangeAction(int orientation) {
+ private OrientationAction(int orientation) {
this.orientation = orientation;
}
public static ViewAction orientationLandscape() {
- return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ return new OrientationAction(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
public static ViewAction orientationPortrait() {
- return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ return new OrientationAction(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
public static ViewAction orientationLandscapeReverse() {
- return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
+ return new OrientationAction(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
}
public static ViewAction orientationPortraitReverse() {
- return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
+ return new OrientationAction(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
}
@Override
@@ -61,6 +61,10 @@ public class OrientationChangeAction implements ViewAction {
activity.setRequestedOrientation(orientation);
}
+ public static void invoke(ViewAction action) {
+ onView(isRoot()).perform(action);
+ }
+
private Activity getActivity(Context context) {
while (context instanceof ContextWrapper) {
if (context instanceof Activity) {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/WaitAction.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/WaitAction.java
index 5d98ccb7f8..e3741f3d42 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/WaitAction.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/action/WaitAction.java
@@ -3,10 +3,11 @@ package com.mapbox.mapboxsdk.testapp.action;
import android.support.test.espresso.UiController;
import android.support.test.espresso.ViewAction;
import android.view.View;
-
import org.hamcrest.Matcher;
+import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.isRoot;
public final class WaitAction implements ViewAction {
@@ -30,5 +31,9 @@ public final class WaitAction implements ViewAction {
public void perform(UiController uiController, View view) {
uiController.loopMainThreadForAtLeast(loopTime);
}
+
+ public static void invoke(long loopTime) {
+ onView(isRoot()).perform(new WaitAction(loopTime));
+ }
}
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 ea69f8adae..c91afe9b60 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,116 +1,96 @@
package com.mapbox.mapboxsdk.testapp.activity;
-import android.app.Activity;
-import android.support.test.espresso.Espresso;
-import android.support.test.espresso.IdlingRegistry;
-import android.support.test.espresso.IdlingResource;
-import android.support.test.espresso.IdlingResourceTimeoutException;
-import android.support.test.espresso.ViewInteraction;
+import android.support.annotation.CallSuper;
+import android.support.annotation.UiThread;
import android.support.test.rule.ActivityTestRule;
-
import com.mapbox.mapboxsdk.Mapbox;
+import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
-import com.mapbox.mapboxsdk.testapp.action.WaitAction;
-import com.mapbox.mapboxsdk.testapp.utils.FinishLoadingStyleIdlingResource;
-
-import com.mapbox.mapboxsdk.testapp.utils.MapboxIdlingResource;
-import junit.framework.Assert;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestName;
-
import timber.log.Timber;
-import static android.support.test.espresso.Espresso.onView;
-import static android.support.test.espresso.assertion.ViewAssertions.matches;
-import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
-import static android.support.test.espresso.matcher.ViewMatchers.withId;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import static junit.framework.TestCase.assertNotNull;
+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 {
+ private static final int WAIT_TIMEOUT = 30; //seconds
+
@Rule
- public ActivityTestRule<Activity> rule = new ActivityTestRule<>(getActivityClass());
+ public ActivityTestRule rule = new ActivityTestRule<>(getActivityClass());
@Rule
- public TestName testNameRule = new TestName();
+ public TestName testName = new TestName();
protected MapboxMap mapboxMap;
- protected MapboxIdlingResource idlingResource;
+ protected MapView mapView;
+ private final CountDownLatch latch = new CountDownLatch(1);
@Before
+ @CallSuper
public void beforeTest() {
- try {
- Timber.e(String.format(
- "%s - %s - %s",
- getClass().getSimpleName(),
- testNameRule.getMethodName(),
- "@Before test: register idle resource"
- ));
- idlingResource = (MapboxIdlingResource) generateIdlingResource();
- IdlingRegistry.getInstance().register(idlingResource);
- Espresso.onIdle();
- mapboxMap = idlingResource.getMapboxMap();
- } catch (IdlingResourceTimeoutException idlingResourceTimeoutException) {
- throw new RuntimeException(
- String.format(
- "Could not start %s test for %s.",
- testNameRule.getMethodName(),
- getActivityClass().getSimpleName()
- )
- );
- }
+ initialiseMap();
+ holdTestRunnerForStyleLoad();
}
- protected IdlingResource generateIdlingResource() {
- return new FinishLoadingStyleIdlingResource(rule.getActivity());
+ @After
+ @CallSuper
+ public void afterTest() {
+ // override to add logic
+ }
+
+ @UiThread
+ @CallSuper
+ protected void initMap(MapboxMap mapboxMap) {
+ this.mapboxMap = mapboxMap;
+ mapboxMap.getStyle(style -> latch.countDown());
}
protected void validateTestSetup() {
if (!Mapbox.isConnected()) {
Timber.e("Not connected to the internet while running test");
}
-
- checkViewIsDisplayed(R.id.mapView);
- Assert.assertNotNull(mapboxMap);
- }
-
- protected MapboxMap getMapboxMap() {
- return mapboxMap;
+ assertNotNull("MapView isn't initialised", mapView);
+ assertNotNull("MapboxMap isn't initialised", mapboxMap);
+ assertNotNull("Style isn't initialised", mapboxMap.getStyle());
+ assertTrue("Style isn't fully loaded", mapboxMap.getStyle().isFullyLoaded());
}
protected abstract Class getActivityClass();
- protected void checkViewIsDisplayed(int id) {
- onView(withId(id)).check(matches(isDisplayed()));
- }
-
- protected void waitAction() {
- waitAction(500);
- }
-
- protected void waitAction(long waitTime) {
- onView(withId(R.id.mapView)).perform(new WaitAction(waitTime));
- }
-
- protected ViewInteraction onMapView() {
- return onView(withId(R.id.mapView));
+ private void initialiseMap() {
+ try {
+ rule.runOnUiThread(() -> {
+ mapView = rule.getActivity().findViewById(R.id.mapView);
+ mapView.getMapAsync(this::initMap);
+ });
+ } catch (Throwable throwable) {
+ throwable.printStackTrace();
+ }
}
- protected MapboxMapAction getMapboxMapAction(MapboxMapAction.OnInvokeActionListener onInvokeActionListener) {
- return new MapboxMapAction(onInvokeActionListener, mapboxMap);
- }
+ private void holdTestRunnerForStyleLoad() {
+ boolean interrupted;
+ try {
+ interrupted = latch.await(WAIT_TIMEOUT, TimeUnit.SECONDS);
+ } catch (InterruptedException ignore) {
+ interrupted = true;
+ }
- @After
- public void afterTest() {
- Timber.e(String.format("%s - %s", testNameRule.getMethodName(), "@After test: unregister idle resource"));
- IdlingRegistry.getInstance().unregister(idlingResource);
+ if (!interrupted) {
+ Timber.e("Timeout occurred for %s", testName.getMethodName());
+ validateTestSetup();
+ }
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/EspressoTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/EspressoTest.java
index dfb4a46180..97a73ba1cb 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/EspressoTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/EspressoTest.java
@@ -1,24 +1,28 @@
package com.mapbox.mapboxsdk.testapp.activity;
-import android.support.test.espresso.IdlingResource;
+import android.support.annotation.UiThread;
+import com.mapbox.mapboxsdk.maps.MapboxMap;
+import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
-import com.mapbox.mapboxsdk.testapp.utils.LoadStyleIdlingResource;
+
/**
* Base class for all tests using EspressoTestActivity as wrapper.
* <p>
- * Uses {@link LoadStyleIdlingResource} to load "assets/streets.json" as style.
+ * Loads "assets/streets.json" as style.
* </p>
*/
public class EspressoTest extends BaseTest {
@Override
- protected IdlingResource generateIdlingResource() {
- return new LoadStyleIdlingResource(rule.getActivity());
+ protected final Class getActivityClass() {
+ return EspressoTestActivity.class;
}
+ @UiThread
@Override
- protected final Class getActivityClass() {
- return EspressoTestActivity.class;
+ protected void initMap(MapboxMap mapboxMap) {
+ mapboxMap.setStyle(new Style.Builder().fromUrl("asset://streets.json"));
+ super.initMap(mapboxMap);
}
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java
index 9fb823a377..559213af3d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java
@@ -1,6 +1,7 @@
package com.mapbox.mapboxsdk.testapp.annotations;
import android.app.Activity;
+import android.support.test.annotation.UiThreadTest;
import android.support.v4.content.res.ResourcesCompat;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
@@ -31,117 +32,107 @@ public class IconTest extends EspressoTest {
@Before
public void beforeTest() {
super.beforeTest();
- iconMap = new IconManagerResolver(getMapboxMap()).getIconMap();
- }
-
- @Test
- public void testEmpty() {
- assertTrue(iconMap.isEmpty());
+ iconMap = new IconManagerResolver(mapboxMap).getIconMap();
}
@Test
+ @UiThreadTest
public void testAddSameIconMarker() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- Icon defaultMarker = IconFactory.getInstance(rule.getActivity()).defaultMarker();
- mapboxMap.addMarker(new MarkerOptions().position(new LatLng()));
- mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
- assertEquals(1, iconMap.size());
- assertEquals(2, iconMap.get(defaultMarker), 0);
- }));
+ Icon defaultMarker = IconFactory.getInstance(rule.getActivity()).defaultMarker();
+ mapboxMap.addMarker(new MarkerOptions().position(new LatLng()));
+ mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
+ assertEquals(1, iconMap.size());
+ assertEquals(2, iconMap.get(defaultMarker), 0);
}
@Test
+ @UiThreadTest
public void testAddDifferentIconMarker() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- Icon icon = IconFactory.getInstance(rule.getActivity()).fromResource(R.drawable.mapbox_logo_icon);
- getMapboxMap().addMarker(new MarkerOptions().icon(icon).position(new LatLng()));
- getMapboxMap().addMarker(new MarkerOptions().position(new LatLng(1, 1)));
- assertEquals(iconMap.size(), 2);
- assertTrue(iconMap.containsKey(icon));
- assertTrue(iconMap.get(icon) == 1);
- }));
+ Icon icon = IconFactory.getInstance(rule.getActivity()).fromResource(R.drawable.mapbox_logo_icon);
+ mapboxMap.addMarker(new MarkerOptions().icon(icon).position(new LatLng()));
+ mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
+ assertEquals(iconMap.size(), 2);
+ assertTrue(iconMap.containsKey(icon));
+ assertTrue(iconMap.get(icon) == 1);
}
@Test
+ @UiThreadTest
public void testAddRemoveIconMarker() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- Icon icon = IconFactory.getInstance(rule.getActivity()).fromResource(R.drawable.mapbox_logo_icon);
- Marker marker = mapboxMap.addMarker(new MarkerOptions().icon(icon).position(new LatLng()));
- mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
- assertEquals(iconMap.size(), 2);
- assertTrue(iconMap.containsKey(icon));
- assertTrue(iconMap.get(icon) == 1);
-
- mapboxMap.removeMarker(marker);
- assertEquals(iconMap.size(), 1);
- assertFalse(iconMap.containsKey(icon));
- }));
+ Icon icon = IconFactory.getInstance(rule.getActivity()).fromResource(R.drawable.mapbox_logo_icon);
+ Marker marker = mapboxMap.addMarker(new MarkerOptions().icon(icon).position(new LatLng()));
+ mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
+ assertEquals(iconMap.size(), 2);
+ assertTrue(iconMap.containsKey(icon));
+ assertTrue(iconMap.get(icon) == 1);
+
+ mapboxMap.removeMarker(marker);
+ assertEquals(iconMap.size(), 1);
+ assertFalse(iconMap.containsKey(icon));
}
@Test
+ @UiThreadTest
public void testAddRemoveDefaultMarker() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- Marker marker = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
- assertEquals(iconMap.size(), 1);
+ Marker marker = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
+ assertEquals(iconMap.size(), 1);
- mapboxMap.removeMarker(marker);
- assertEquals(iconMap.size(), 0);
+ mapboxMap.removeMarker(marker);
+ assertEquals(iconMap.size(), 0);
- mapboxMap.addMarker(new MarkerOptions().position(new LatLng()));
- assertEquals(iconMap.size(), 1);
- }));
+ mapboxMap.addMarker(new MarkerOptions().position(new LatLng()));
+ assertEquals(iconMap.size(), 1);
}
@Test
+ @UiThreadTest
public void testAddRemoveMany() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- Activity activity = rule.getActivity();
- IconFactory iconFactory = IconFactory.getInstance(activity);
-
- // add 2 default icon markers
- Marker defaultMarkerOne = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
- Marker defaultMarkerTwo = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(2, 1)));
-
- // add 4 unique icon markers
- mapboxMap.addMarker(new MarkerOptions()
- .icon(iconFactory.fromResource(R.drawable.mapbox_logo_icon))
- .position(new LatLng(3, 1))
- );
- mapboxMap.addMarker(new MarkerOptions()
- .icon(iconFactory.fromResource(R.drawable.mapbox_compass_icon))
- .position(new LatLng(4, 1))
- );
- mapboxMap.addMarker(new MarkerOptions()
- .icon(IconUtils.drawableToIcon(activity, R.drawable.ic_stars,
- ResourcesCompat.getColor(activity.getResources(),
- R.color.blueAccent, activity.getTheme())))
- .position(new LatLng(5, 1))
- );
- mapboxMap.addMarker(new MarkerOptions()
- .icon(iconFactory.fromResource(R.drawable.ic_android))
- .position(new LatLng(6, 1))
- );
-
- assertEquals("Amount of icons should match 5", 5, iconMap.size());
- assertEquals("Refcounter of default marker should match 2", 2, iconMap.get(iconFactory.defaultMarker()), 0);
-
- mapboxMap.removeMarker(defaultMarkerOne);
-
- assertEquals("Amount of icons should match 5", 5, iconMap.size());
- assertEquals("Refcounter of default marker should match 1", 1, iconMap.get(iconFactory.defaultMarker()), 0);
-
- mapboxMap.removeMarker(defaultMarkerTwo);
-
- assertEquals("Amount of icons should match 4", 4, iconMap.size());
- assertNull("DefaultMarker shouldn't exist anymore", iconMap.get(iconFactory.defaultMarker()));
-
- mapboxMap.clear();
- assertEquals("Amount of icons should match 0", 0, iconMap.size());
- }));
+ Activity activity = rule.getActivity();
+ IconFactory iconFactory = IconFactory.getInstance(activity);
+
+ // add 2 default icon markers
+ Marker defaultMarkerOne = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
+ Marker defaultMarkerTwo = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(2, 1)));
+
+ // add 4 unique icon markers
+ mapboxMap.addMarker(new MarkerOptions()
+ .icon(iconFactory.fromResource(R.drawable.mapbox_logo_icon))
+ .position(new LatLng(3, 1))
+ );
+ mapboxMap.addMarker(new MarkerOptions()
+ .icon(iconFactory.fromResource(R.drawable.mapbox_compass_icon))
+ .position(new LatLng(4, 1))
+ );
+ mapboxMap.addMarker(new MarkerOptions()
+ .icon(IconUtils.drawableToIcon(activity, R.drawable.ic_stars,
+ ResourcesCompat.getColor(activity.getResources(),
+ R.color.blueAccent, activity.getTheme())))
+ .position(new LatLng(5, 1))
+ );
+ mapboxMap.addMarker(new MarkerOptions()
+ .icon(iconFactory.fromResource(R.drawable.ic_android))
+ .position(new LatLng(6, 1))
+ );
+
+ assertEquals("Amount of icons should match 5", 5, iconMap.size());
+ assertEquals("Refcounter of default marker should match 2", 2, iconMap.get(iconFactory.defaultMarker()), 0);
+
+ mapboxMap.removeMarker(defaultMarkerOne);
+
+ assertEquals("Amount of icons should match 5", 5, iconMap.size());
+ assertEquals("Refcounter of default marker should match 1", 1, iconMap.get(iconFactory.defaultMarker()), 0);
+
+ mapboxMap.removeMarker(defaultMarkerTwo);
+
+ assertEquals("Amount of icons should match 4", 4, iconMap.size());
+ assertNull("DefaultMarker shouldn't exist anymore", iconMap.get(iconFactory.defaultMarker()));
+
+ mapboxMap.clear();
+ assertEquals("Amount of icons should match 0", 0, iconMap.size());
}
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraForTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraForTest.java
index eb38bddf84..4365ea95ff 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraForTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraForTest.java
@@ -1,6 +1,7 @@
package com.mapbox.mapboxsdk.testapp.camera;
import android.support.annotation.NonNull;
+import android.support.test.annotation.UiThreadTest;
import com.mapbox.geojson.Point;
import com.mapbox.geojson.Polygon;
import com.mapbox.mapboxsdk.camera.CameraPosition;
@@ -18,123 +19,117 @@ import static org.junit.Assert.assertEquals;
public class CameraForTest extends BaseTest {
@Test
+ @UiThreadTest
public void testGetCameraForLatLngBounds() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
- LatLngBounds.from(10, 10, -10, -10));
- CameraPosition expectedPosition = new CameraPosition.Builder()
- .target(new LatLng()).zoom(4.16).tilt(0).bearing(0).build();
- assertEquals("Latitude should match",
- expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
- assertEquals("Longitude should match",
- expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
- assertEquals("Bearing should match",
- expectedPosition.zoom, actualPosition.zoom, 0.01f);
- assertEquals("Tilt should match", expectedPosition.tilt, actualPosition.tilt, 0.01f);
- }));
+ CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
+ LatLngBounds.from(10, 10, -10, -10));
+ CameraPosition expectedPosition = new CameraPosition.Builder()
+ .target(new LatLng()).zoom(4.16).tilt(0).bearing(0).build();
+ assertEquals("Latitude should match",
+ expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
+ assertEquals("Longitude should match",
+ expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
+ assertEquals("Bearing should match",
+ expectedPosition.zoom, actualPosition.zoom, 0.01f);
+ assertEquals("Tilt should match", expectedPosition.tilt, actualPosition.tilt, 0.01f);
}
@Test
+ @UiThreadTest
public void testGetCameraForLatLngBoundsPadding() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
- LatLngBounds.from(10, 10, -10, -10), new int[] {5, 5, 5, 5});
- CameraPosition expectedPosition = new CameraPosition.Builder()
- .target(new LatLng()).zoom(4.13).tilt(0).bearing(0).build();
- assertEquals("Latitude should match",
- expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
- assertEquals("Longitude should match",
- expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
- assertEquals("Zoom should match",
- expectedPosition.zoom, actualPosition.zoom, 0.01f);
- assertEquals("Tilt should match",
- expectedPosition.tilt, actualPosition.tilt, 0.01f);
- assertEquals("Bearing should match",
- expectedPosition.bearing, actualPosition.bearing, 0.01f);
- }));
+ CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
+ LatLngBounds.from(10, 10, -10, -10), new int[] {5, 5, 5, 5});
+ CameraPosition expectedPosition = new CameraPosition.Builder()
+ .target(new LatLng()).zoom(4.13).tilt(0).bearing(0).build();
+ assertEquals("Latitude should match",
+ expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
+ assertEquals("Longitude should match",
+ expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
+ assertEquals("Zoom should match",
+ expectedPosition.zoom, actualPosition.zoom, 0.01f);
+ assertEquals("Tilt should match",
+ expectedPosition.tilt, actualPosition.tilt, 0.01f);
+ assertEquals("Bearing should match",
+ expectedPosition.bearing, actualPosition.bearing, 0.01f);
}
@Test
+ @UiThreadTest
public void testGetCameraForLatLngBoundsBearing() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
- LatLngBounds.from(10, 10, -10, -10), 45, 0);
- CameraPosition expectedPosition = new CameraPosition.Builder()
- .target(new LatLng()).zoom(3.66).tilt(0).bearing(45).build();
- assertEquals("Latitude should match",
- expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
- assertEquals("Longitude should match",
- expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
- assertEquals("Zoom should match",
- expectedPosition.zoom, actualPosition.zoom, 0.01f);
- assertEquals("Tilt should match",
- expectedPosition.tilt, actualPosition.tilt, 0.01f);
- assertEquals("Bearing should match",
- expectedPosition.bearing, actualPosition.bearing, 0.01f);
- }));
+ CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
+ LatLngBounds.from(10, 10, -10, -10), 45, 0);
+ CameraPosition expectedPosition = new CameraPosition.Builder()
+ .target(new LatLng()).zoom(3.66).tilt(0).bearing(45).build();
+ assertEquals("Latitude should match",
+ expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
+ assertEquals("Longitude should match",
+ expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
+ assertEquals("Zoom should match",
+ expectedPosition.zoom, actualPosition.zoom, 0.01f);
+ assertEquals("Tilt should match",
+ expectedPosition.tilt, actualPosition.tilt, 0.01f);
+ assertEquals("Bearing should match",
+ expectedPosition.bearing, actualPosition.bearing, 0.01f);
}
@Test
+ @UiThreadTest
public void testGetCameraForLatLngBoundsTilt() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
- LatLngBounds.from(10, 10, -10, -10), 0, 45);
- CameraPosition expectedPosition = new CameraPosition.Builder()
- .target(new LatLng(-0.264576975267, 0)).zoom(4.13).tilt(45).bearing(0).build();
- assertEquals("Latitude should match",
- expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
- assertEquals("Longitude should match",
- expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
- assertEquals("Zoom should match",
- expectedPosition.zoom, actualPosition.zoom, 0.01f);
- assertEquals("Tilt should match",
- expectedPosition.tilt, actualPosition.tilt, 0.01f);
- assertEquals("Bearing should match",
- expectedPosition.bearing, actualPosition.bearing, 0.01f);
- }));
+ CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
+ LatLngBounds.from(10, 10, -10, -10), 0, 45);
+ CameraPosition expectedPosition = new CameraPosition.Builder()
+ .target(new LatLng(-0.264576975267, 0)).zoom(4.13).tilt(45).bearing(0).build();
+ assertEquals("Latitude should match",
+ expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
+ assertEquals("Longitude should match",
+ expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
+ assertEquals("Zoom should match",
+ expectedPosition.zoom, actualPosition.zoom, 0.01f);
+ assertEquals("Tilt should match",
+ expectedPosition.tilt, actualPosition.tilt, 0.01f);
+ assertEquals("Bearing should match",
+ expectedPosition.bearing, actualPosition.bearing, 0.01f);
}
@Test
+ @UiThreadTest
public void testGetCameraForLatLngBoundsAll() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
- LatLngBounds.from(10, 10, -10, -10), new int[] {5, 5, 5, 5}, 45, 45);
- CameraPosition expectedPosition = new CameraPosition.Builder()
- .target(new LatLng(-0.3732134634, -0.3713191053)).zoom(3.63).tilt(45).bearing(45).build();
- assertEquals("Latitude should match",
- expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
- assertEquals("Longitude should match",
- expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
- assertEquals("Zoom should match",
- expectedPosition.zoom, actualPosition.zoom, 0.01f);
- assertEquals("Tilt should match",
- expectedPosition.tilt, actualPosition.tilt, 0.01f);
- assertEquals("Bearing should match",
- expectedPosition.bearing, actualPosition.bearing, 0.01f);
- }));
+ CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
+ LatLngBounds.from(10, 10, -10, -10), new int[] {5, 5, 5, 5}, 45, 45);
+ CameraPosition expectedPosition = new CameraPosition.Builder()
+ .target(new LatLng(-0.3732134634, -0.3713191053)).zoom(3.63).tilt(45).bearing(45).build();
+ assertEquals("Latitude should match",
+ expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
+ assertEquals("Longitude should match",
+ expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
+ assertEquals("Zoom should match",
+ expectedPosition.zoom, actualPosition.zoom, 0.01f);
+ assertEquals("Tilt should match",
+ expectedPosition.tilt, actualPosition.tilt, 0.01f);
+ assertEquals("Bearing should match",
+ expectedPosition.bearing, actualPosition.bearing, 0.01f);
}
@Test
+ @UiThreadTest
public void testGetCameraForGeometry() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- List<List<Point>> polygonDefinition = getPolygonDefinition();
- CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition));
- CameraPosition expectedPosition = new CameraPosition.Builder()
- .target(new LatLng()).zoom(4.16).tilt(0).bearing(0).build();
- assertEquals("Latitude should match",
- expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
- assertEquals("Longitude should match",
- expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
- assertEquals("Bearing should match",
- expectedPosition.zoom, actualPosition.zoom, 0.01f);
- assertEquals("Tilt should match", expectedPosition.tilt, actualPosition.tilt, 0.01f);
- }));
+ List<List<Point>> polygonDefinition = getPolygonDefinition();
+ CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition));
+ CameraPosition expectedPosition = new CameraPosition.Builder()
+ .target(new LatLng()).zoom(4.16).tilt(0).bearing(0).build();
+ assertEquals("Latitude should match",
+ expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
+ assertEquals("Longitude should match",
+ expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
+ assertEquals("Bearing should match",
+ expectedPosition.zoom, actualPosition.zoom, 0.01f);
+ assertEquals("Tilt should match", expectedPosition.tilt, actualPosition.tilt, 0.01f);
}
@NonNull
@@ -154,113 +149,108 @@ public class CameraForTest extends BaseTest {
}
@Test
+ @UiThreadTest
public void testGetCameraForGeometryPadding() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- List<List<Point>> polygonDefinition = getPolygonDefinition();
- CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition),
- new int[] {5, 5, 5, 5});
- CameraPosition expectedPosition = new CameraPosition.Builder()
- .target(new LatLng()).zoom(4.13).tilt(0).bearing(0).build();
- assertEquals("Latitude should match",
- expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
- assertEquals("Longitude should match",
- expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
- assertEquals("Zoom should match",
- expectedPosition.zoom, actualPosition.zoom, 0.01f);
- assertEquals("Tilt should match",
- expectedPosition.tilt, actualPosition.tilt, 0.01f);
- assertEquals("Bearing should match",
- expectedPosition.bearing, actualPosition.bearing, 0.01f);
- }));
+ List<List<Point>> polygonDefinition = getPolygonDefinition();
+ CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition),
+ new int[] {5, 5, 5, 5});
+ CameraPosition expectedPosition = new CameraPosition.Builder()
+ .target(new LatLng()).zoom(4.13).tilt(0).bearing(0).build();
+ assertEquals("Latitude should match",
+ expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
+ assertEquals("Longitude should match",
+ expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
+ assertEquals("Zoom should match",
+ expectedPosition.zoom, actualPosition.zoom, 0.01f);
+ assertEquals("Tilt should match",
+ expectedPosition.tilt, actualPosition.tilt, 0.01f);
+ assertEquals("Bearing should match",
+ expectedPosition.bearing, actualPosition.bearing, 0.01f);
}
@Test
+ @UiThreadTest
public void testGetCameraForGeometryBearing() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- List<List<Point>> polygonDefinition = getPolygonDefinition();
- CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition), 45, 0);
- CameraPosition expectedPosition = new CameraPosition.Builder()
- .target(new LatLng()).zoom(3.66).tilt(0).bearing(45).build();
- assertEquals("Latitude should match",
- expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
- assertEquals("Longitude should match",
- expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
- assertEquals("Zoom should match",
- expectedPosition.zoom, actualPosition.zoom, 0.01f);
- assertEquals("Tilt should match",
- expectedPosition.tilt, actualPosition.tilt, 0.01f);
- assertEquals("Bearing should match",
- expectedPosition.bearing, actualPosition.bearing, 0.01f);
- }));
+ List<List<Point>> polygonDefinition = getPolygonDefinition();
+ CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition), 45, 0);
+ CameraPosition expectedPosition = new CameraPosition.Builder()
+ .target(new LatLng()).zoom(3.66).tilt(0).bearing(45).build();
+ assertEquals("Latitude should match",
+ expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
+ assertEquals("Longitude should match",
+ expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
+ assertEquals("Zoom should match",
+ expectedPosition.zoom, actualPosition.zoom, 0.01f);
+ assertEquals("Tilt should match",
+ expectedPosition.tilt, actualPosition.tilt, 0.01f);
+ assertEquals("Bearing should match",
+ expectedPosition.bearing, actualPosition.bearing, 0.01f);
}
@Test
+ @UiThreadTest
public void testGetCameraForGeometryTilt() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- List<List<Point>> polygonDefinition = getPolygonDefinition();
- CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition), 0, 45);
- CameraPosition expectedPosition = new CameraPosition.Builder()
- .target(new LatLng(-0.2645769752, 0)).zoom(4.13).tilt(45).bearing(0).build();
- assertEquals("Latitude should match",
- expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
- assertEquals("Longitude should match",
- expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
- assertEquals("Zoom should match",
- expectedPosition.zoom, actualPosition.zoom, 0.01f);
- assertEquals("Tilt should match",
- expectedPosition.tilt, actualPosition.tilt, 0.01f);
- assertEquals("Bearing should match",
- expectedPosition.bearing, actualPosition.bearing, 0.01f);
- }));
+ List<List<Point>> polygonDefinition = getPolygonDefinition();
+ CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition), 0, 45);
+ CameraPosition expectedPosition = new CameraPosition.Builder()
+ .target(new LatLng(-0.2645769752, 0)).zoom(4.13).tilt(45).bearing(0).build();
+ assertEquals("Latitude should match",
+ expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
+ assertEquals("Longitude should match",
+ expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
+ assertEquals("Zoom should match",
+ expectedPosition.zoom, actualPosition.zoom, 0.01f);
+ assertEquals("Tilt should match",
+ expectedPosition.tilt, actualPosition.tilt, 0.01f);
+ assertEquals("Bearing should match",
+ expectedPosition.bearing, actualPosition.bearing, 0.01f);
}
@Test
+ @UiThreadTest
public void testGetCameraForGeometryAll() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- List<List<Point>> polygonDefinition = getPolygonDefinition();
- CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition),
- new int[] {5, 5, 5, 5}, 45, 45);
- CameraPosition expectedPosition = new CameraPosition.Builder()
- .target(new LatLng(-0.373213463, -0.37131910534)).zoom(3.63).tilt(45).bearing(45).build();
- assertEquals("Latitude should match",
- expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
- assertEquals("Longitude should match",
- expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
- assertEquals("Zoom should match",
- expectedPosition.zoom, actualPosition.zoom, 0.01f);
- assertEquals("Tilt should match",
- expectedPosition.tilt, actualPosition.tilt, 0.01f);
- assertEquals("Bearing should match",
- expectedPosition.bearing, actualPosition.bearing, 0.01f);
- }));
+ List<List<Point>> polygonDefinition = getPolygonDefinition();
+ CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition),
+ new int[] {5, 5, 5, 5}, 45, 45);
+ CameraPosition expectedPosition = new CameraPosition.Builder()
+ .target(new LatLng(-0.373213463, -0.37131910534)).zoom(3.63).tilt(45).bearing(45).build();
+ assertEquals("Latitude should match",
+ expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
+ assertEquals("Longitude should match",
+ expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
+ assertEquals("Zoom should match",
+ expectedPosition.zoom, actualPosition.zoom, 0.01f);
+ assertEquals("Tilt should match",
+ expectedPosition.tilt, actualPosition.tilt, 0.01f);
+ assertEquals("Bearing should match",
+ expectedPosition.bearing, actualPosition.bearing, 0.01f);
}
@Test
+ @UiThreadTest
public void testGetCameraForGeometryDeprecatedApi() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- List<List<Point>> polygonDefinition = getPolygonDefinition();
- CameraPosition actualPosition = mapboxMap.getCameraForGeometry(
- Polygon.fromLngLats(polygonDefinition),
- new int[] {5, 5, 5, 5},
- 45, 0);
- CameraPosition expectedPosition = new CameraPosition.Builder()
- .target(new LatLng()).zoom(3.63).tilt(0).bearing(45).build();
- assertEquals("Latitude should match",
- expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
- assertEquals("Longitude should match",
- expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
- assertEquals("Zoom should match",
- expectedPosition.zoom, actualPosition.zoom, 0.01f);
- assertEquals("Tilt should match",
- expectedPosition.tilt, actualPosition.tilt, 0.01f);
- assertEquals("Bearing should match",
- expectedPosition.bearing, actualPosition.bearing, 0.01f);
- }));
+ List<List<Point>> polygonDefinition = getPolygonDefinition();
+ CameraPosition actualPosition = mapboxMap.getCameraForGeometry(
+ Polygon.fromLngLats(polygonDefinition),
+ new int[] {5, 5, 5, 5},
+ 45, 0);
+ CameraPosition expectedPosition = new CameraPosition.Builder()
+ .target(new LatLng()).zoom(3.63).tilt(0).bearing(45).build();
+ assertEquals("Latitude should match",
+ expectedPosition.target.getLatitude(), actualPosition.target.getLatitude(), 0.00001f);
+ assertEquals("Longitude should match",
+ expectedPosition.target.getLongitude(), actualPosition.target.getLongitude(), 0.00001f);
+ assertEquals("Zoom should match",
+ expectedPosition.zoom, actualPosition.zoom, 0.01f);
+ assertEquals("Tilt should match",
+ expectedPosition.tilt, actualPosition.tilt, 0.01f);
+ assertEquals("Bearing should match",
+ expectedPosition.bearing, actualPosition.bearing, 0.01f);
}
@Override
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 418191e91a..2731b20db7 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
@@ -10,6 +10,7 @@ import android.support.test.runner.AndroidJUnit4
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
import org.junit.Test
import org.junit.runner.RunWith
@@ -25,9 +26,10 @@ class MapDialogFragmentTest {
var activityRule: ActivityTestRule<MapInDialogActivity> = ActivityTestRule(MapInDialogActivity::class.java)
@Test
+ @Ignore
fun openCloseDialog() {
onView(withId(R.id.button_open_dialog)).perform(click())
- onView(withId(R.id.mapView)).perform(WaitAction(2500))
+ Thread.sleep(2500)
Espresso.pressBack()
}
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java
index c34e76a6e5..f30b3aa8cf 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java
@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk.testapp.geometry;
+import android.support.test.annotation.UiThreadTest;
import com.google.gson.JsonArray;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.FeatureCollection;
@@ -13,11 +14,13 @@ import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.CustomGeometrySource;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import com.mapbox.mapboxsdk.style.sources.GeometryTileProvider;
+import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils;
-
import org.junit.Test;
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.matcher.ViewMatchers.isRoot;
import static com.mapbox.geojson.Feature.fromGeometry;
import static com.mapbox.geojson.FeatureCollection.fromFeatures;
import static com.mapbox.geojson.GeometryCollection.fromGeometries;
@@ -35,101 +38,94 @@ public class GeoJsonConversionTest extends EspressoTest {
// Regression test for #12343
@Test
+ @UiThreadTest
public void testEmptyFeatureCollection() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.getStyle().addSource(
- new CustomGeometrySource("test-id",
- new CustomProvider(fromFeatures(singletonList(fromGeometry(fromGeometries(emptyList())))))
- )
- );
- mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
- }));
+ mapboxMap.getStyle().addSource(
+ new CustomGeometrySource("test-id",
+ new CustomProvider(fromFeatures(singletonList(fromGeometry(fromGeometries(emptyList())))))
+ )
+ );
+ mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}
@Test
+ @UiThreadTest
public void testPointFeatureCollection() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.getStyle().addSource(
- new CustomGeometrySource("test-id",
- new CustomProvider(fromFeatures(singletonList(fromGeometry(Point.fromLngLat(0.0, 0.0)))))
- )
- );
- mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
- }));
+ mapboxMap.getStyle().addSource(
+ new CustomGeometrySource("test-id",
+ new CustomProvider(fromFeatures(singletonList(fromGeometry(Point.fromLngLat(0.0, 0.0)))))
+ )
+ );
+ mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}
@Test
+ @UiThreadTest
public void testMultiPointFeatureCollection() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.getStyle().addSource(
- new CustomGeometrySource("test-id",
- new CustomProvider(fromFeatures(singletonList(fromGeometry(fromLngLats(emptyList())))))
- )
- );
- mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
- }));
+ mapboxMap.getStyle().addSource(
+ new CustomGeometrySource("test-id",
+ new CustomProvider(fromFeatures(singletonList(fromGeometry(fromLngLats(emptyList())))))
+ )
+ );
+ mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}
-
@Test
+ @UiThreadTest
public void testPolygonFeatureCollection() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.getStyle().addSource(
- new CustomGeometrySource("test-id",
- new CustomProvider(fromFeatures(singletonList(fromGeometry(Polygon.fromLngLats(emptyList())))))
- )
- );
- mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
- }));
+ mapboxMap.getStyle().addSource(
+ new CustomGeometrySource("test-id",
+ new CustomProvider(fromFeatures(singletonList(fromGeometry(Polygon.fromLngLats(emptyList())))))
+ )
+ );
+ mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}
@Test
+ @UiThreadTest
public void testMultiPolygonFeatureCollection() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.getStyle().addSource(
- new CustomGeometrySource("test-id",
- new CustomProvider(fromFeatures(singletonList(fromGeometry(fromPolygon(Polygon.fromLngLats(emptyList()))))))
- )
- );
- mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
- }));
+ mapboxMap.getStyle().addSource(
+ new CustomGeometrySource("test-id",
+ new CustomProvider(fromFeatures(singletonList(fromGeometry(fromPolygon(Polygon.fromLngLats(emptyList()))))))
+ )
+ );
+ mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}
@Test
+ @UiThreadTest
public void testLineStringFeatureCollection() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.getStyle().addSource(
- new CustomGeometrySource("test-id",
- new CustomProvider(fromFeatures(singletonList(fromGeometry(fromLngLats(emptyList())))))
- )
- );
- mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
- }));
+ mapboxMap.getStyle().addSource(
+ new CustomGeometrySource("test-id",
+ new CustomProvider(fromFeatures(singletonList(fromGeometry(fromLngLats(emptyList())))))
+ )
+ );
+ mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}
@Test
+ @UiThreadTest
public void testMultiLineStringFeatureCollection() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.getStyle().addSource(
- new CustomGeometrySource("test-id",
- new CustomProvider(fromFeatures(singletonList(fromGeometry(fromLineString(fromLngLats(emptyList()))))))
- )
- );
- mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
- }));
+ mapboxMap.getStyle().addSource(
+ new CustomGeometrySource("test-id",
+ new CustomProvider(fromFeatures(singletonList(fromGeometry(fromLineString(fromLngLats(emptyList()))))))
+ )
+ );
+ mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}
+
@Test
public void testNegativeNumberPropertyConversion() {
validateTestSetup();
- onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
+ onView(isRoot()).perform(new MapboxMapAction((uiController, mapboxMap) -> {
LatLng latLng = new LatLng();
Feature feature = Feature.fromGeometry(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
@@ -148,10 +144,10 @@ public class GeoJsonConversionTest extends EspressoTest {
);
mapboxMap.getStyle().addLayer(layer);
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng)).isEmpty());
- }));
+ }, mapboxMap));
}
class CustomProvider implements GeometryTileProvider {
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 84af279bd0..ac73b028f3 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
@@ -18,14 +18,6 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class StyleLoadTest : EspressoTest() {
- private lateinit var mapView: MapView
-
- @Before
- override fun beforeTest() {
- super.beforeTest()
- mapView = (rule.activity as EspressoTestActivity).mapView
- }
-
@Test
fun updateSourceAfterStyleLoad() {
validateTestSetup()
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java
index 0fadd33325..ca5c9adc1f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.testapp.maps.widgets;
import android.app.Instrumentation;
import android.content.Intent;
import android.net.Uri;
+import android.os.Build;
import android.support.test.espresso.UiController;
import android.support.test.espresso.ViewAction;
import android.support.test.espresso.intent.Intents;
@@ -31,12 +32,14 @@ import static android.support.test.espresso.intent.Intents.intended;
import static android.support.test.espresso.intent.Intents.intending;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasAction;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasData;
+import static android.support.test.espresso.matcher.RootMatchers.isDialog;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.anything;
import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assume.assumeTrue;
public class AttributionTest extends EspressoTest {
@@ -126,15 +129,20 @@ public class AttributionTest extends EspressoTest {
@Test
public void testTelemetryDialog() {
+ assumeTrue(
+ "Can only run on API Level 23 or newer because of instability",
+ Build.VERSION.SDK_INT >= 23
+ );
+
validateTestSetup();
// click on View to open dialog
onView(withId(R.id.attributionView)).perform(click());
- onView(withText(R.string.mapbox_attributionsDialogTitle)).check(matches(isDisplayed()));
+ onView(withText(R.string.mapbox_attributionsDialogTitle)).inRoot(isDialog()).check(matches(isDisplayed()));
// click on item to open second dialog
- onView(withText(R.string.mapbox_telemetrySettings)).perform(click());
- onView(withText(R.string.mapbox_attributionTelemetryTitle)).check(matches(isDisplayed()));
+ onView(withText(R.string.mapbox_telemetrySettings)).inRoot(isDialog()).perform(click());
+ onView(withText(R.string.mapbox_attributionTelemetryTitle)).inRoot(isDialog()).check(matches(isDisplayed()));
}
@After
@@ -206,4 +214,4 @@ public class AttributionTest extends EspressoTest {
interface InvokeViewAction {
void onViewAction(UiController uiController, View view);
}
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java
index 1cdf1423a3..8b62ee7612 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/CompassViewTest.java
@@ -4,6 +4,7 @@ import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.action.WaitAction;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
import org.junit.Ignore;
@@ -55,7 +56,7 @@ public class CompassViewTest extends EspressoTest {
.build()
)));
onView(withId(R.id.compassView)).perform(click());
- waitAction();
+ WaitAction.invoke(500);
onView(withId(R.id.compassView)).check(matches(not(isDisplayed())));
invoke(mapboxMap, (uiController, mapboxMap) -> {
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
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 144d67feee..8e5f3f7c5f 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
@@ -1,59 +1,43 @@
package com.mapbox.mapboxsdk.testapp.offline
import android.content.Context
-import android.support.test.espresso.Espresso
-import android.support.test.espresso.IdlingRegistry
-import android.support.test.espresso.UiController
-import android.support.test.espresso.idling.CountingIdlingResource
+import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
-import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.offline.OfflineManager
import com.mapbox.mapboxsdk.offline.OfflineRegion
import com.mapbox.mapboxsdk.storage.FileSource
-import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke
-import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
+import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
import com.mapbox.mapboxsdk.testapp.utils.FileUtils
+import org.junit.FixMethodOrder
+import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
import java.io.IOException
+import java.util.concurrent.CountDownLatch
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(AndroidJUnit4::class)
-class OfflineManagerTest : EspressoTest() {
+class OfflineManagerTest {
companion object {
private const val TEST_DB_FILE_NAME = "offline_test.db"
+ private lateinit var mergedRegion: OfflineRegion
}
- private val context: Context by lazy { rule.activity }
-
- private lateinit var offlineIdlingResource: CountingIdlingResource
-
- override fun beforeTest() {
- super.beforeTest()
- offlineIdlingResource = CountingIdlingResource("idling_resource")
- IdlingRegistry.getInstance().register(offlineIdlingResource)
- }
+ @Rule
+ @JvmField
+ var rule = ActivityTestRule(FeatureOverviewActivity::class.java)
- @Test
- fun offlineMergeListDeleteTest() {
- validateTestSetup()
+ private val context: Context by lazy { rule.activity }
- invoke(mapboxMap) { _: UiController, _: MapboxMap ->
- offlineIdlingResource.increment()
+ @Test(timeout = 30_000)
+ fun a_copyFileFromAssets() {
+ val latch = CountDownLatch(1)
+ rule.runOnUiThread {
FileUtils.CopyFileFromAssetsTask(rule.activity, object : FileUtils.OnFileCopiedFromAssetsListener {
override fun onFileCopiedFromAssets() {
- OfflineManager.getInstance(context).mergeOfflineRegions(
- FileSource.getResourcesCachePath(rule.activity) + "/" + TEST_DB_FILE_NAME,
- object : OfflineManager.MergeOfflineRegionsCallback {
- override fun onMerge(offlineRegions: Array<out OfflineRegion>?) {
- assert(offlineRegions?.size == 1)
- offlineIdlingResource.decrement()
- }
-
- override fun onError(error: String?) {
- throw RuntimeException("Unable to merge external offline database. $error")
- }
- })
+ latch.countDown()
}
override fun onError() {
@@ -61,43 +45,62 @@ class OfflineManagerTest : EspressoTest() {
}
}).execute(TEST_DB_FILE_NAME, FileSource.getResourcesCachePath(rule.activity))
}
+ latch.await()
+ }
+
+ @Test(timeout = 30_000)
+ fun b_mergeRegion() {
+ val latch = CountDownLatch(1)
+ rule.runOnUiThread {
+ OfflineManager.getInstance(context).mergeOfflineRegions(
+ FileSource.getResourcesCachePath(rule.activity) + "/" + TEST_DB_FILE_NAME,
+ object : OfflineManager.MergeOfflineRegionsCallback {
+ override fun onMerge(offlineRegions: Array<out OfflineRegion>?) {
+ assert(offlineRegions?.size == 1)
+ latch.countDown()
+ }
+
+ override fun onError(error: String?) {
+ throw RuntimeException("Unable to merge external offline database. $error")
+ }
+ })
+ }
+ latch.await()
+ }
- invoke(mapboxMap) { _: UiController, _: MapboxMap ->
- offlineIdlingResource.increment()
+ @Test(timeout = 30_000)
+ fun c_listRegion() {
+ val latch = CountDownLatch(1)
+ rule.runOnUiThread {
OfflineManager.getInstance(context).listOfflineRegions(object : OfflineManager.ListOfflineRegionsCallback {
override fun onList(offlineRegions: Array<out OfflineRegion>?) {
assert(offlineRegions?.size == 1)
- if (offlineRegions != null) {
- for (region in offlineRegions) {
- offlineIdlingResource.increment()
- region.delete(object : OfflineRegion.OfflineRegionDeleteCallback {
- override fun onDelete() {
- offlineIdlingResource.decrement()
- }
-
- override fun onError(error: String?) {
- throw RuntimeException("Unable to delete region with ID: ${region.id}. $error")
- }
- })
- }
- } else {
- throw RuntimeException("Unable to find merged region.")
- }
- offlineIdlingResource.decrement()
+ mergedRegion = offlineRegions!![0]
+ latch.countDown()
}
override fun onError(error: String?) {
- throw RuntimeException("Unable to obtain offline regions list. $error")
+ throw RuntimeException("Unable to merge external offline database. $error")
}
})
}
-
- // waiting for offline idling resource
- Espresso.onIdle()
+ latch.await()
}
- override fun afterTest() {
- super.afterTest()
- IdlingRegistry.getInstance().unregister(offlineIdlingResource)
+ @Test(timeout = 30_000)
+ fun d_deleteRegion() {
+ val latch = CountDownLatch(1)
+ rule.runOnUiThread {
+ mergedRegion.delete(object : OfflineRegion.OfflineRegionDeleteCallback {
+ override fun onDelete() {
+ latch.countDown()
+ }
+
+ override fun onError(error: String?) {
+ throw RuntimeException("Unable to delete region")
+ }
+ })
+ }
+ latch.await()
}
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CustomGeometrySourceTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CustomGeometrySourceTest.kt
index eb458ab8f5..a6238ebf14 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CustomGeometrySourceTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CustomGeometrySourceTest.kt
@@ -6,8 +6,9 @@ import com.mapbox.mapboxsdk.style.sources.CustomGeometrySource
import com.mapbox.mapboxsdk.style.sources.CustomGeometrySource.THREAD_POOL_LIMIT
import com.mapbox.mapboxsdk.style.sources.CustomGeometrySource.THREAD_PREFIX
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke
-import com.mapbox.mapboxsdk.testapp.action.OrientationChangeAction.orientationLandscape
-import com.mapbox.mapboxsdk.testapp.action.OrientationChangeAction.orientationPortrait
+import com.mapbox.mapboxsdk.testapp.action.OrientationAction.orientationLandscape
+import com.mapbox.mapboxsdk.testapp.action.OrientationAction.orientationPortrait
+import com.mapbox.mapboxsdk.testapp.action.WaitAction
import com.mapbox.mapboxsdk.testapp.activity.BaseTest
import com.mapbox.mapboxsdk.testapp.activity.style.GridSourceActivity
import com.mapbox.mapboxsdk.testapp.activity.style.GridSourceActivity.ID_GRID_LAYER
@@ -25,11 +26,11 @@ class CustomGeometrySourceTest : BaseTest() {
@Ignore
fun sourceNotLeakingThreadsTest() {
validateTestSetup()
- waitAction(4000)
+ WaitAction.invoke(4000)
onView(isRoot()).perform(orientationLandscape())
- waitAction(2000)
+ WaitAction.invoke(2000)
onView(isRoot()).perform(orientationPortrait())
- waitAction(2000)
+ WaitAction.invoke(2000)
Assert.assertFalse("Threads should be shutdown when the source is destroyed.",
Thread.getAllStackTraces().keys.filter {
it.name.startsWith(THREAD_PREFIX)
@@ -42,9 +43,9 @@ class CustomGeometrySourceTest : BaseTest() {
validateTestSetup()
invoke(mapboxMap) { uiController, mapboxMap ->
mapboxMap.style!!.removeLayer(ID_GRID_LAYER)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
mapboxMap.style!!.removeSource(ID_GRID_SOURCE)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
Assert.assertTrue("There should be no threads running when the source is removed.",
Thread.getAllStackTraces().keys.filter {
it.name.startsWith(CustomGeometrySource.THREAD_PREFIX)
@@ -58,12 +59,12 @@ class CustomGeometrySourceTest : BaseTest() {
validateTestSetup()
invoke(mapboxMap) { uiController, mapboxMap ->
mapboxMap.style!!.removeLayer((rule.activity as GridSourceActivity).layer)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
mapboxMap.style!!.removeSource(ID_GRID_SOURCE)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
mapboxMap.style!!.addSource((rule.activity as GridSourceActivity).source)
mapboxMap.style!!.addLayer((rule.activity as GridSourceActivity).layer)
- TestingAsyncUtils.waitForLayer(uiController, idlingResource.mapView)
+ TestingAsyncUtils.waitForLayer(uiController, mapView)
Assert.assertTrue("Threads should be restarted when the source is re-added to the map.",
Thread.getAllStackTraces().keys.filter {
it.name.startsWith(CustomGeometrySource.THREAD_PREFIX)
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
index 75dcbf1209..ff3b2a9d6d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
@@ -252,7 +252,7 @@ public class ExpressionTest extends EspressoTest {
)
));
mapboxMap.getStyle().addLayer(layer);
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
@@ -262,7 +262,7 @@ public class ExpressionTest extends EspressoTest {
literal(ColorUtils.colorToRgbaString(Color.RED))
)
));
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
@@ -272,7 +272,7 @@ public class ExpressionTest extends EspressoTest {
literal(ColorUtils.colorToRgbaString(Color.RED))
)
));
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
});
@@ -292,7 +292,7 @@ public class ExpressionTest extends EspressoTest {
formatEntry("test")
);
layer.setProperties(textField(expression));
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
@@ -315,7 +315,7 @@ public class ExpressionTest extends EspressoTest {
formatEntry("test", formatFontScale(1.75))
);
layer.setProperties(textField(expression));
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
@@ -341,7 +341,7 @@ public class ExpressionTest extends EspressoTest {
)
);
layer.setProperties(textField(expression));
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
@@ -371,7 +371,7 @@ public class ExpressionTest extends EspressoTest {
)
);
layer.setProperties(textField(expression));
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
@@ -402,7 +402,7 @@ public class ExpressionTest extends EspressoTest {
)
);
layer.setProperties(textField(expression));
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
@@ -436,7 +436,7 @@ public class ExpressionTest extends EspressoTest {
formatEntry("\ntest2", formatFontScale(2), formatTextColor(Color.BLUE))
);
layer.setProperties(textField(expression));
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
@@ -472,7 +472,7 @@ public class ExpressionTest extends EspressoTest {
)
);
layer.setProperties(textField(expression));
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
@@ -504,7 +504,7 @@ public class ExpressionTest extends EspressoTest {
formatEntry("\ntest2", formatFontScale(2))
);
layer.setProperties(textField(expression), textColor("rgba(128, 0, 0, 1)"));
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
@@ -524,7 +524,7 @@ public class ExpressionTest extends EspressoTest {
mapboxMap.getStyle().addLayer(layer);
layer.setProperties(textField("test"));
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
@@ -550,7 +550,7 @@ public class ExpressionTest extends EspressoTest {
new FormattedSection("test", null, null, "rgba(0, 255, 0, 1)")
);
layer.setProperties(textField(formatted), textColor("rgba(128, 0, 0, 1)"));
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/GeoJsonSourceTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/GeoJsonSourceTests.java
index 92d060fee4..99e0ae4016 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/GeoJsonSourceTests.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/GeoJsonSourceTests.java
@@ -94,7 +94,7 @@ public class GeoJsonSourceTests extends EspressoTest {
}
source.setGeoJson(Point.fromLngLat(20, 55));
- TestingAsyncUtils.INSTANCE.waitForLayer(uiController, idlingResource.getMapView());
+ TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertEquals(1, mapboxMap.queryRenderedFeatures(
mapboxMap.getProjection().toScreenLocation(
new LatLng(55, 20)), "layer").size());
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.java
deleted file mode 100644
index 0e4c8f3f2e..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.style;
-
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.support.test.runner.AndroidJUnit4;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
-
-import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * CRUD tests around Image
- */
-@RunWith(AndroidJUnit4.class)
-public class ImageTest extends EspressoTest {
-
- private static final String IMAGE_ID = "test.image";
-
- @Test
- public void testAddGetImage() {
- validateTestSetup();
- MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
- Drawable drawable = rule.getActivity().getResources().getDrawable(R.drawable.ic_launcher_round);
- assertTrue(drawable instanceof BitmapDrawable);
-
- Bitmap bitmapSet = ((BitmapDrawable) drawable).getBitmap();
- mapboxMap.getStyle().addImage(IMAGE_ID, bitmapSet);
-
- // adding an image requires converting the image with an asynctask
- uiController.loopMainThreadForAtLeast(200);
-
- Bitmap bitmapGet = mapboxMap.getStyle().getImage(IMAGE_ID);
- assertTrue(bitmapGet.sameAs(bitmapSet));
-
- mapboxMap.getStyle().removeImage(IMAGE_ID);
- assertNull(mapboxMap.getStyle().getImage(IMAGE_ID));
- });
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.kt
new file mode 100644
index 0000000000..9cef677e7c
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.kt
@@ -0,0 +1,75 @@
+package com.mapbox.mapboxsdk.testapp.style
+
+import android.graphics.Bitmap
+import android.graphics.drawable.BitmapDrawable
+import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.testapp.R
+import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction
+import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
+import org.junit.Assert.assertNull
+import org.junit.Assert.assertTrue
+import org.junit.Test
+import org.junit.runner.RunWith
+import java.util.*
+
+/**
+ * CRUD tests around Image
+ */
+@RunWith(AndroidJUnit4::class)
+class ImageTest : EspressoTest() {
+
+ companion object {
+ private const val IMAGE_ID = "test.image"
+ }
+
+ @Test
+ fun testAddGetImage() {
+ validateTestSetup()
+ MapboxMapAction.invoke(mapboxMap) { uiController, mapboxMap ->
+ val drawable = rule.activity.resources.getDrawable(R.drawable.ic_launcher_round)
+ assertTrue(drawable is BitmapDrawable)
+
+ val bitmapSet = (drawable as BitmapDrawable).bitmap
+ mapboxMap.style!!.addImage(IMAGE_ID, bitmapSet)
+
+ // adding an image requires converting the image with an asynctask
+ uiController.loopMainThreadForAtLeast(200)
+
+ val bitmapGet = mapboxMap.style!!.getImage(IMAGE_ID)
+ assertTrue(bitmapGet!!.similarTo(bitmapSet))
+
+ mapboxMap.style!!.removeImage(IMAGE_ID)
+ assertNull(mapboxMap.style!!.getImage(IMAGE_ID))
+ }
+ }
+}
+
+/**
+ * Alternative implementation of Bitmap.sameAs #14060
+ */
+fun Bitmap.similarTo(other: Bitmap): Boolean {
+ if (invalidConfig(other)) {
+ return false
+ }
+
+ // Allocate arrays
+ val argb = IntArray(width * height)
+ val argbOther = IntArray(other.width * other.height)
+ getPixels(argb, 0, width, 0, 0, width, height)
+ other.getPixels(argbOther, 0, width, 0, 0, width, height)
+
+ // Alpha channel special check
+ if (config == Bitmap.Config.ALPHA_8) {
+ // in this case we have to manually compare the alpha channel as the rest is garbage.
+ val length = width * height
+ for (i in 0 until length) {
+ if (argb[i] and -0x1000000 != argbOther[i] and -0x1000000) {
+ return false
+ }
+ }
+ return true
+ }
+ return Arrays.equals(argb, argbOther)
+}
+
+fun Bitmap.invalidConfig(other: Bitmap): Boolean = this.config != other.config || this.width != other.width || this.height != other.height \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
index ed39f36e32..a4a34e752e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
@@ -2,12 +2,10 @@ package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import android.graphics.PointF;
-import android.support.test.espresso.Espresso;
import android.support.test.espresso.UiController;
import android.support.test.espresso.ViewAction;
import android.support.test.runner.AndroidJUnit4;
import android.view.View;
-
import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
@@ -22,20 +20,16 @@ import com.mapbox.mapboxsdk.style.sources.Source;
import com.mapbox.mapboxsdk.style.sources.VectorSource;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
-
import junit.framework.Assert;
-
import org.hamcrest.Matcher;
-import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
+import timber.log.Timber;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
-import timber.log.Timber;
-
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
@@ -366,11 +360,6 @@ public class RuntimeStyleTests extends EspressoTest {
}
}
- @After
- public void unregisterIntentServiceIdlingResource() {
- Espresso.unregisterIdlingResources(idlingResource);
- }
-
public abstract class BaseViewAction implements ViewAction {
@Override
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
index 149064d684..ae2c6d98f6 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
@@ -559,7 +559,7 @@ public class SymbolLayerTest extends BaseLayerTest {
assertNull(layer.getTextJustify().getValue());
// Set and Get
- String propertyValue = TEXT_JUSTIFY_LEFT;
+ String propertyValue = TEXT_JUSTIFY_AUTO;
layer.setProperties(textJustify(propertyValue));
assertEquals(layer.getTextJustify().getValue(), propertyValue);
}
@@ -579,6 +579,32 @@ public class SymbolLayerTest extends BaseLayerTest {
@Test
@UiThreadTest
+ public void testTextRadialOffsetAsConstant() {
+ Timber.i("text-radial-offset");
+ assertNotNull(layer);
+ assertNull(layer.getTextRadialOffset().getValue());
+
+ // Set and Get
+ Float propertyValue = 0.3f;
+ layer.setProperties(textRadialOffset(propertyValue));
+ assertEquals(layer.getTextRadialOffset().getValue(), propertyValue);
+ }
+
+ @Test
+ @UiThreadTest
+ public void testTextVariableAnchorAsConstant() {
+ Timber.i("text-variable-anchor");
+ assertNotNull(layer);
+ assertNull(layer.getTextVariableAnchor().getValue());
+
+ // Set and Get
+ String[] propertyValue = new String[0];
+ layer.setProperties(textVariableAnchor(propertyValue));
+ assertEquals(layer.getTextVariableAnchor().getValue(), propertyValue);
+ }
+
+ @Test
+ @UiThreadTest
public void testTextAnchorAsConstant() {
Timber.i("text-anchor");
assertNotNull(layer);
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/FinishLoadingStyleIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/FinishLoadingStyleIdlingResource.java
deleted file mode 100644
index 323d2c0f15..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/FinishLoadingStyleIdlingResource.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.utils;
-
-import android.app.Activity;
-import android.os.Handler;
-import android.os.Looper;
-import android.support.annotation.WorkerThread;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public class FinishLoadingStyleIdlingResource extends MapboxIdlingResource {
-
- @WorkerThread
- public FinishLoadingStyleIdlingResource(final Activity activity) {
- new Handler(Looper.getMainLooper()).post(() -> inflateMap(activity));
- }
-
- @Override
- public void initMap(MapboxMap mapboxMap) {
- super.initMap(mapboxMap);
- mapboxMap.getStyle(style -> {
- assertNotNull(style);
- assertTrue(style.isFullyLoaded());
- if (resourceCallback != null) {
- resourceCallback.onTransitionToIdle();
- }
- });
- }
-
- @Override
- public boolean isIdleNow() {
- return getMapboxMap() != null && getMapboxMap().getStyle() != null;
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/LoadStyleIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/LoadStyleIdlingResource.java
deleted file mode 100644
index 5dead21fbb..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/LoadStyleIdlingResource.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.utils;
-
-import android.app.Activity;
-import android.os.Handler;
-import android.os.Looper;
-import android.support.annotation.UiThread;
-import android.support.annotation.WorkerThread;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.Style;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public class LoadStyleIdlingResource extends MapboxIdlingResource {
-
- private Style style;
-
- @WorkerThread
- public LoadStyleIdlingResource(final Activity activity) {
- new Handler(Looper.getMainLooper()).post(() -> inflateMap(activity));
- }
-
- @UiThread
- public void initMap(MapboxMap mapboxMap) {
- super.initMap(mapboxMap);
- mapboxMap.setStyle("asset://streets.json", style -> {
- assertNotNull(style);
- assertTrue(style.isFullyLoaded());
- this.style = style;
- if (resourceCallback != null) {
- resourceCallback.onTransitionToIdle();
- }
- });
- }
-
- @Override
- public boolean isIdleNow() {
- return style != null;
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/MapboxIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/MapboxIdlingResource.java
deleted file mode 100644
index a05221d618..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/MapboxIdlingResource.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.utils;
-
-import android.app.Activity;
-import android.support.annotation.UiThread;
-import android.support.test.espresso.IdlingResource;
-import com.mapbox.mapboxsdk.maps.MapView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.testapp.R;
-
-public abstract class MapboxIdlingResource implements IdlingResource {
-
- private MapView mapView;
- private MapboxMap mapboxMap;
- IdlingResource.ResourceCallback resourceCallback;
-
- @UiThread
- void inflateMap(Activity activity) {
- mapView = activity.findViewById(R.id.mapView);
- if (mapView != null) {
- mapView.getMapAsync(this::initMap);
- }
- }
-
- @UiThread
- protected void initMap(MapboxMap mapboxMap) {
- this.mapboxMap = mapboxMap;
- }
-
- @Override
- public String getName() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
- this.resourceCallback = resourceCallback;
- }
-
- public MapboxMap getMapboxMap() {
- return mapboxMap;
- }
-
- public MapView getMapView() {
- return mapView;
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java
deleted file mode 100644
index 7696447289..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.utils;
-
-import android.app.Activity;
-import android.os.Handler;
-import android.os.Looper;
-import android.support.annotation.WorkerThread;
-import android.support.test.espresso.IdlingResource;
-
-import com.mapbox.mapboxsdk.maps.MapView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.Style;
-import com.mapbox.mapboxsdk.testapp.R;
-
-public class OnMapReadyIdlingResource implements IdlingResource {
-
- private boolean styleLoaded;
- private MapboxMap mapboxMap;
- private IdlingResource.ResourceCallback resourceCallback;
-
- @WorkerThread
- public OnMapReadyIdlingResource(final Activity activity) {
- Handler handler = new Handler(Looper.getMainLooper());
- handler.post(() -> {
- MapView mapView = activity.findViewById(R.id.mapView);
- if (mapView != null) {
- mapView.addOnDidFinishLoadingStyleListener(() -> {
- styleLoaded = true;
- if (resourceCallback != null) {
- resourceCallback.onTransitionToIdle();
- }
- });
- mapView.getMapAsync(this::initMap);
- }
- });
- }
-
- private void initMap(MapboxMap mapboxMap) {
- this.mapboxMap = mapboxMap;
- mapboxMap.setStyle(new Style.Builder().fromUrl("asset://streets.json"));
- }
-
- @Override
- public String getName() {
- return getClass().getSimpleName();
- }
-
- @Override
- public boolean isIdleNow() {
- return styleLoaded;
- }
-
- @Override
- public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
- this.resourceCallback = resourceCallback;
- }
-
- public MapboxMap getMapboxMap() {
- return mapboxMap;
- }
-} \ No newline at end of file