summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/BaseIntegrationTest.kt60
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/FragmentBackStackTest.kt59
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReopenTest.kt27
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt30
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/OrientationChangeTest.kt29
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReopenTest.kt29
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReuseTest.kt29
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt37
8 files changed, 300 insertions, 0 deletions
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..4d39b55a25
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/BaseIntegrationTest.kt
@@ -0,0 +1,60 @@
+package com.mapbox.mapboxsdk.integration
+
+import android.content.Intent
+import android.support.test.InstrumentationRegistry
+import android.support.test.uiautomator.*
+import org.hamcrest.CoreMatchers
+import org.hamcrest.MatcherAssert
+import org.junit.Before
+
+const val LAUNCH_TIMEOUT = 2500L
+private const val TEST_APP_PACKAGE = "com.mapbox.mapboxsdk.testapp"
+
+abstract class BaseIntegrationTest {
+
+ protected lateinit var device: UiDevice
+
+ @Before
+ open fun beforeTest() {
+ // Initialize UiDevice instance
+ device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
+
+ // Start from the home screen
+ device.pressHome()
+
+ // Wait for launcher
+ val launcherPackage: String = device.launcherPackageName
+ MatcherAssert.assertThat(launcherPackage, CoreMatchers.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(TEST_APP_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(TEST_APP_PACKAGE).depth(0)),
+ LAUNCH_TIMEOUT
+ )
+ }
+
+ fun openFeature(featureName: String) {
+ scrollRecyclerViewTo(featureName)
+ device.findObject(UiSelector().text(featureName)).clickAndWaitForNewWindow()
+ device.waitForIdle(LAUNCH_TIMEOUT)
+ }
+
+ fun scrollRecyclerViewTo(recycleItem: String) {
+ val appView = UiScrollable(UiSelector().scrollable(true))
+ appView.scrollIntoView(UiSelector().text(recycleItem))
+ }
+
+ fun pressHomeReturnWithRecentApps(){
+ device.pressRecentApps()
+ device.findObject(UiSelector().text(InstrumentationRegistry.getTargetContext().getString(InstrumentationRegistry.getTargetContext().applicationInfo.labelRes))).click()
+ }
+} \ 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..f46ec153c3
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/FragmentBackStackTest.kt
@@ -0,0 +1,59 @@
+package com.mapbox.mapboxsdk.integration
+
+import android.support.test.filters.LargeTest
+import android.support.test.runner.AndroidJUnit4
+import android.support.test.uiautomator.UiSelector
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * Regression test that validates MapFragment integration on the backstack
+ */
+@RunWith(AndroidJUnit4::class)
+class FragmentBackStackTest : BaseIntegrationTest() {
+
+ @Before
+ override fun beforeTest() {
+ super.beforeTest()
+ openFeature("Backstack Map Fragment")
+ }
+
+ @Test
+ @LargeTest
+ fun backPressedOnBackStack() {
+ device.waitForIdle()
+ clickReplaceFragmentButton()
+ device.waitForIdle()
+ backPressBackStack()
+ }
+
+ @Test
+ @LargeTest
+ fun backPressedOnBackStackResumed(){
+ device.waitForIdle()
+ clickReplaceFragmentButton()
+ device.waitForIdle()
+ pressHomeReturnWithRecentApps()
+ device.waitForIdle()
+ backPressBackStack()
+ }
+
+ @Test
+ @LargeTest
+ fun finishOnBackStack() {
+ device.waitForIdle()
+ clickReplaceFragmentButton()
+ device.waitForIdle()
+ device.findObject(UiSelector().description("Navigate up")).click()
+ }
+
+ private fun clickReplaceFragmentButton(){
+ device.findObject(UiSelector().text("REPLACE WITH EMPTY FRAGMENT")).click()
+ }
+
+ private fun backPressBackStack(){
+ device.pressBack() // pops fragment, showing map
+ device.pressBack() // finish activity
+ }
+} \ 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..07fea012eb
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReopenTest.kt
@@ -0,0 +1,27 @@
+package com.mapbox.mapboxsdk.integration
+
+import android.support.test.filters.LargeTest
+import android.support.test.runner.AndroidJUnit4
+import org.junit.Before
+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() {
+
+ @Before
+ override fun beforeTest() {
+ super.beforeTest()
+ openFeature("Simple Map")
+ }
+
+ @Test
+ @LargeTest
+ fun reopenSimpleMapActivity() {
+ pressHomeReturnWithRecentApps()
+ device.waitForIdle()
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt
new file mode 100644
index 0000000000..95f05566c3
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/GLSurfaceViewReuseTest.kt
@@ -0,0 +1,30 @@
+package com.mapbox.mapboxsdk.integration
+
+import android.support.test.filters.LargeTest
+import android.support.test.runner.AndroidJUnit4
+import org.junit.Before
+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() {
+
+ @Before
+ override fun beforeTest() {
+ super.beforeTest()
+ openFeature("RecyclerView GLSurfaceView")
+ }
+
+ @Test
+ @LargeTest
+ fun scrollRecylerView() {
+ device.waitForIdle()
+ scrollRecyclerViewTo("Twenty-one")
+ device.waitForIdle()
+ 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..b79303a1a8
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/OrientationChangeTest.kt
@@ -0,0 +1,29 @@
+package com.mapbox.mapboxsdk.integration
+
+import android.support.test.filters.LargeTest
+import android.support.test.runner.AndroidJUnit4
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class OrientationChangeTest : BaseIntegrationTest() {
+
+ @Before
+ override fun beforeTest() {
+ super.beforeTest()
+ openFeature("Simple Map")
+ }
+
+ @Test
+ @LargeTest
+ fun rotateSimpleMap() {
+ device.setOrientationLeft()
+ device.waitForIdle()
+ device.setOrientationNatural()
+ device.waitForIdle()
+ device.setOrientationRight()
+ device.waitForIdle()
+ 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..3de8ece8c3
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReopenTest.kt
@@ -0,0 +1,29 @@
+package com.mapbox.mapboxsdk.integration
+
+import android.support.test.filters.LargeTest
+import android.support.test.runner.AndroidJUnit4
+import org.junit.Before
+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() {
+
+ @Before
+ override fun beforeTest() {
+ super.beforeTest()
+ openFeature("TextureView debug")
+ }
+
+ @Test
+ @LargeTest
+ fun reopenTextureViewDebugActivity() {
+ pressHomeReturnWithRecentApps()
+ device.waitForIdle()
+ sleep(LAUNCH_TIMEOUT)
+ }
+} \ 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..6053e696d6
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/TextureViewReuseTest.kt
@@ -0,0 +1,29 @@
+package com.mapbox.mapboxsdk.integration
+
+import android.support.test.filters.LargeTest
+import android.support.test.runner.AndroidJUnit4
+import org.junit.Before
+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() {
+
+ @Before
+ override fun beforeTest() {
+ super.beforeTest()
+ openFeature("RecyclerView TextureView")
+ }
+
+ @Test
+ @LargeTest
+ fun scrollRecylerView() {
+ scrollRecyclerViewTo("Twenty-one")
+ device.waitForIdle()
+ 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..9f4b7591b6
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/integration/ViewPagerScrollTest.kt
@@ -0,0 +1,37 @@
+package com.mapbox.mapboxsdk.integration
+
+import android.support.test.filters.LargeTest
+import android.support.test.runner.AndroidJUnit4
+import android.support.test.uiautomator.UiSelector
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * Regression test that validates MapFragment integration with a ViewPager
+ */
+@RunWith(AndroidJUnit4::class)
+class ViewPagerScrollTest : BaseIntegrationTest() {
+
+ @Before
+ override fun beforeTest() {
+ super.beforeTest()
+ openFeature("ViewPager")
+ }
+
+ @Test
+ @LargeTest
+ fun scrollViewPager() {
+ for (i in 1..5) {
+ clickTab(i)
+ }
+
+ for (i in 4 downTo 0) {
+ clickTab(i)
+ }
+ }
+
+ private fun clickTab(index: Int) {
+ device.findObject(UiSelector().text("Page $index")).click()
+ }
+} \ No newline at end of file