summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobrun <tobrun.van.nuland@gmail.com>2019-03-15 13:40:28 +0100
committerTobrun <tobrun@mapbox.com>2019-03-25 15:22:29 +0100
commitb0c0de0bfa0aba08ad038a6b3370e1522eab50d0 (patch)
treefeaebb9d6ac89e6f040f28180d052adecce0b7a8
parentd761c50b5b231069b96ea4a47c5513dd8d848e5a (diff)
downloadqtlocation-mapboxgl-b0c0de0bfa0aba08ad038a6b3370e1522eab50d0.tar.gz
[android] - add integration test suite
-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
-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/OrientationTest.java41
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TextureViewReopenTest.kt77
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml10
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java117
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.kt71
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_viewpager.xml2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml1
16 files changed, 378 insertions, 314 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
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/OrientationTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/OrientationTest.java
deleted file mode 100644
index 536f452493..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.action.OrientationAction;
-import com.mapbox.mapboxsdk.testapp.action.WaitAction;
-import com.mapbox.mapboxsdk.testapp.activity.BaseTest;
-import com.mapbox.mapboxsdk.testapp.activity.camera.CameraAnimationTypeActivity;
-import org.junit.Test;
-
-import static com.mapbox.mapboxsdk.testapp.action.OrientationAction.orientationLandscape;
-import static com.mapbox.mapboxsdk.testapp.action.OrientationAction.orientationLandscapeReverse;
-import static com.mapbox.mapboxsdk.testapp.action.OrientationAction.orientationPortrait;
-import static com.mapbox.mapboxsdk.testapp.action.OrientationAction.orientationPortraitReverse;
-
-public class OrientationTest extends BaseTest {
-
- @Test
- public void testChangeDeviceOrientation() {
- OrientationAction.invoke(orientationLandscape());
- WaitAction.invoke(2200);
- OrientationAction.invoke(orientationPortrait());
- WaitAction.invoke(2500);
- OrientationAction.invoke(orientationLandscapeReverse());
- WaitAction.invoke(500);
- OrientationAction.invoke(orientationPortraitReverse());
- WaitAction.invoke(1250);
- OrientationAction.invoke(orientationLandscape());
- WaitAction.invoke(750);
- OrientationAction.invoke(orientationPortrait());
- WaitAction.invoke(950);
- OrientationAction.invoke(orientationLandscapeReverse());
- OrientationAction.invoke(orientationPortraitReverse());
- OrientationAction.invoke(orientationLandscape());
- OrientationAction.invoke(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/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
index ed136a596f..729e593c2e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
@@ -176,7 +176,7 @@
android:label="@string/activity_map_fragment_backstack">
<meta-data
android:name="@string/category"
- android:value="@string/category_fragment" />
+ android:value="@string/category_integration" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity" />
@@ -399,7 +399,7 @@
android:label="@string/activity_viewpager">
<meta-data
android:name="@string/category"
- android:value="@string/category_fragment" />
+ android:value="@string/category_integration" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity" />
@@ -900,7 +900,7 @@
android:label="@string/activity_recyclerview_textureview">
<meta-data
android:name="@string/category"
- android:value="@string/category_maplayout" />
+ android:value="@string/category_integration" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity" />
@@ -911,7 +911,7 @@
android:label="@string/activity_recyclerview_glsurfaceview">
<meta-data
android:name="@string/category"
- android:value="@string/category_maplayout" />
+ android:value="@string/category_integration" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity" />
@@ -922,7 +922,7 @@
android:label="@string/activity_nested_viewpager">
<meta-data
android:name="@string/category"
- android:value="@string/category_fragment" />
+ android:value="@string/category_integration" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity" />
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java
deleted file mode 100644
index c494842b14..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.activity.fragment;
-
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentStatePagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.support.v7.app.AppCompatActivity;
-
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
-import com.mapbox.mapboxsdk.maps.Style;
-import com.mapbox.mapboxsdk.maps.SupportMapFragment;
-import com.mapbox.mapboxsdk.testapp.R;
-
-/**
- * Test activity showcasing using the Android SDK ViewPager API to show MapFragments.
- */
-public class ViewPagerActivity extends AppCompatActivity {
-
- private ViewPager viewPager;
- private MapFragmentAdapter adapter;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_viewpager);
-
- viewPager = (ViewPager) findViewById(R.id.viewpager);
- if (viewPager != null) {
- adapter = new MapFragmentAdapter(getSupportFragmentManager());
- viewPager.setAdapter(adapter);
- }
- }
-
- @Override
- protected void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
-
- int currentPosition = viewPager.getCurrentItem();
- SupportMapFragment mapFragment;
-
- if (Math.abs(0 - currentPosition) <= 1) {
- mapFragment = (SupportMapFragment) adapter.instantiateItem(viewPager, 0);
- mapFragment.getMapAsync(mapboxMap -> {
- mapboxMap.setStyle(Style.MAPBOX_STREETS);
- });
- }
-
- if (Math.abs(1 - currentPosition) <= 1) {
- mapFragment = (SupportMapFragment) adapter.instantiateItem(viewPager, 1);
- mapFragment.getMapAsync(mapboxMap -> {
- mapboxMap.setStyle(Style.DARK);
- });
- }
-
- if (Math.abs(2 - currentPosition) <= 1) {
- mapFragment = (SupportMapFragment) adapter.instantiateItem(viewPager, 2);
- mapFragment.getMapAsync(mapboxMap -> {
- mapboxMap.setStyle(Style.SATELLITE);
- });
- }
- }
-
- static class MapFragmentAdapter extends FragmentStatePagerAdapter {
-
- private static int NUM_ITEMS = 3;
-
- MapFragmentAdapter(FragmentManager fragmentManager) {
- super(fragmentManager);
- }
-
- @Override
- public int getCount() {
- return NUM_ITEMS;
- }
-
- @Override
- public Fragment getItem(int position) {
- SupportMapFragment fragment = null;
- MapboxMapOptions options = new MapboxMapOptions();
- options.textureMode(true);
-
- switch (position) {
- case 0:
- options.camera(new CameraPosition.Builder().target(new LatLng(34.920526, 102.634774)).zoom(3).build());
- fragment = SupportMapFragment.newInstance(options);
- fragment.getMapAsync(mapboxMap -> {
- mapboxMap.setStyle(Style.MAPBOX_STREETS);
- });
- break;
- case 1:
- options.camera(new CameraPosition.Builder().target(new LatLng(62.326440, 92.764913)).zoom(3).build());
- fragment = SupportMapFragment.newInstance(options);
- fragment.getMapAsync(mapboxMap -> {
- mapboxMap.setStyle(Style.DARK);
- });
- break;
- case 2:
- options.camera(new CameraPosition.Builder().target(new LatLng(-25.007786, 133.623852)).zoom(3).build());
- fragment = SupportMapFragment.newInstance(options);
- fragment.getMapAsync(mapboxMap -> {
- mapboxMap.setStyle(Style.SATELLITE);
- });
- break;
- }
- return fragment;
- }
-
- @Override
- public CharSequence getPageTitle(int position) {
- return "Page " + position;
- }
- }
-}
-
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.kt
new file mode 100644
index 0000000000..8312661ebd
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.kt
@@ -0,0 +1,71 @@
+package com.mapbox.mapboxsdk.testapp.activity.fragment
+
+import android.os.Bundle
+import android.support.v4.app.Fragment
+import android.support.v4.app.FragmentManager
+import android.support.v4.app.FragmentStatePagerAdapter
+import android.support.v7.app.AppCompatActivity
+import com.mapbox.mapboxsdk.camera.CameraPosition
+import com.mapbox.mapboxsdk.geometry.LatLng
+import com.mapbox.mapboxsdk.maps.MapboxMapOptions
+import com.mapbox.mapboxsdk.maps.Style
+import com.mapbox.mapboxsdk.maps.SupportMapFragment
+import com.mapbox.mapboxsdk.testapp.R
+import kotlinx.android.synthetic.main.activity_viewpager.*
+
+/**
+ * Test activity showcasing using the Android SDK ViewPager API to show MapFragments.
+ */
+class ViewPagerActivity : AppCompatActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_viewpager)
+ viewPager.adapter = MapFragmentAdapter(supportFragmentManager)
+ }
+
+ override fun onRestoreInstanceState(savedInstanceState: Bundle) {
+ super.onRestoreInstanceState(savedInstanceState)
+ val currentPosition = viewPager!!.currentItem
+ for (i in 0 until FRAGMENT_COUNT) {
+ if (Math.abs(i - currentPosition) <= 1) {
+ viewPager.adapter?.instantiateItem(viewPager, 0)
+ break
+ }
+ }
+ }
+
+ internal class MapFragmentAdapter(fragmentManager: FragmentManager) : FragmentStatePagerAdapter(fragmentManager) {
+
+ override fun getCount(): Int {
+ return FRAGMENT_COUNT
+ }
+
+ override fun getItem(position: Int): Fragment {
+ return when (position) {
+ 0 -> createFragment(Style.MAPBOX_STREETS, LatLng(34.920526, 102.634774))
+ 1 -> createFragment(Style.DARK, LatLng(62.326440, 92.764913))
+ 2 -> createFragment(Style.SATELLITE, LatLng(-25.007786, 133.623852))
+ 3 -> createFragment(Style.LIGHT, LatLng(-19.922070, -43.939676))
+ 4 -> createFragment(Style.OUTDOORS, LatLng(46.881020, 9.098098))
+ else -> createFragment(Style.TRAFFIC_DAY, LatLng(40.722517, -74.000029))
+ }
+ }
+
+ private fun createFragment(@Style.StyleUrl style: String, latLng: LatLng): Fragment {
+ val options = MapboxMapOptions().camera(CameraPosition.Builder().target(latLng).zoom(3.0).build())
+ val fragment = SupportMapFragment.newInstance(options)
+ fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(style) }
+ return fragment
+ }
+
+ override fun getPageTitle(position: Int): CharSequence? {
+ return "Page $position"
+ }
+ }
+
+ companion object {
+ const val FRAGMENT_COUNT = 6
+ }
+}
+
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_viewpager.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_viewpager.xml
index 3edaff6985..516bf60b6b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_viewpager.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_viewpager.xml
@@ -5,7 +5,7 @@
android:layout_height="match_parent">
<com.mapbox.mapboxsdk.testapp.view.MapViewPager
- android:id="@+id/viewpager"
+ android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent">
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml
index a4403a34f7..918fd4cc3f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml
@@ -15,4 +15,5 @@
<string name="category_storage">Storage</string>
<string name="category_textureview">Texture View</string>
<string name="category_location">Location</string>
+ <string name="category_integration">_Integration</string>
</resources> \ No newline at end of file