summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TextureViewReopenTest.kt
diff options
context:
space:
mode:
authortobrun <tobrun.van.nuland@gmail.com>2019-02-19 09:40:05 +0100
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2019-02-23 09:42:50 +0200
commit4b8cff5b15f8bacda754d43a50bb40dc0bd01af5 (patch)
tree413675a5b5e1037eb9b459e8b69889265e4a3095 /platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TextureViewReopenTest.kt
parent6a840d45f03e9bbaf29094a1da772732c5d8dacf (diff)
downloadqtlocation-mapboxgl-4b8cff5b15f8bacda754d43a50bb40dc0bd01af5.tar.gz
[android] - add UiAutomator tests for testing clicking home and returning with recent apps
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TextureViewReopenTest.kt')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TextureViewReopenTest.kt73
1 files changed, 73 insertions, 0 deletions
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
new file mode 100644
index 0000000000..6ccfa70bdf
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TextureViewReopenTest.kt
@@ -0,0 +1,73 @@
+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 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 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