summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobrun <tobrun.van.nuland@gmail.com>2019-02-19 09:40:05 +0100
committertobrun <tobrun.van.nuland@gmail.com>2019-02-19 09:40:05 +0100
commitf9edc2a85a960a80d51b9a9e576848c6da3d55c5 (patch)
tree2b0c0516e7ab4166598da597c2f0a7d2a8437c3d
parent1c99b199c62f239ef2a9e1f2f23b0d10533b381a (diff)
downloadqtlocation-mapboxgl-upstream/tvn-surface-creation-refactor.tar.gz
[android] - add UiAutomator tests for testing clicking home and returning with recent appsupstream/tvn-surface-creation-refactor
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/build.gradle1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/AndroidManifest.xml4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/GLSurfaceViewReopenTest.kt77
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TextureViewReopenTest.kt73
-rw-r--r--platform/android/gradle/dependencies.gradle2
5 files changed, 157 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
index b61397b7c1..d20758fad4 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
+++ b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
@@ -76,6 +76,7 @@ dependencies {
androidTestImplementation dependenciesList.testEspressoCore
androidTestImplementation dependenciesList.testEspressoIntents
androidTestImplementation dependenciesList.testEspressoContrib
+ androidTestImplementation dependenciesList.testUiAutomator
}
apply from: "${rootDir}/gradle/gradle-make.gradle"
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/AndroidManifest.xml
new file mode 100644
index 0000000000..a9dd564e46
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/AndroidManifest.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:tools="http://schemas.android.com/tools" package="${applicationId}">
+ <uses-sdk tools:overrideLibrary="android.support.test.uiautomator.v18"/>
+</manifest> \ 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
new file mode 100644
index 0000000000..eb44463d72
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/GLSurfaceViewReopenTest.kt
@@ -0,0 +1,77 @@
+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 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 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/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
diff --git a/platform/android/gradle/dependencies.gradle b/platform/android/gradle/dependencies.gradle
index c9df677cb3..8a4215369a 100644
--- a/platform/android/gradle/dependencies.gradle
+++ b/platform/android/gradle/dependencies.gradle
@@ -12,6 +12,7 @@ ext {
mapboxGestures : '0.4.0',
supportLib : '27.1.1',
constraintLayout: '1.1.2',
+ uiAutomator : '2.1.3',
espresso : '3.0.2',
testRunner : '1.0.2',
leakCanary : '1.6.2',
@@ -45,6 +46,7 @@ ext {
testEspressoCore : "com.android.support.test.espresso:espresso-core:${versions.espresso}",
testEspressoIntents : "com.android.support.test.espresso:espresso-intents:${versions.espresso}",
testEspressoContrib : "com.android.support.test.espresso:espresso-contrib:${versions.espresso}",
+ testUiAutomator : "com.android.support.test.uiautomator:uiautomator-v18:${versions.uiAutomator}",
supportAnnotations : "com.android.support:support-annotations:${versions.supportLib}",
supportAppcompatV7 : "com.android.support:appcompat-v7:${versions.supportLib}",