[android] - improve reliability of UiAutomator tests
This commit is contained in:
@@ -2,15 +2,18 @@ package com.mapbox.mapboxsdk.maps
|
||||
|
||||
import android.content.Intent
|
||||
import android.support.test.InstrumentationRegistry
|
||||
import android.support.test.InstrumentationRegistry.getTargetContext
|
||||
import android.support.test.filters.SdkSuppress
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
import android.support.test.uiautomator.*
|
||||
import android.support.test.uiautomator.By
|
||||
import android.support.test.uiautomator.UiDevice
|
||||
import android.support.test.uiautomator.UiSelector
|
||||
import android.support.test.uiautomator.Until
|
||||
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
|
||||
@@ -57,17 +60,13 @@ class GLSurfaceViewReopenTest {
|
||||
|
||||
@Test
|
||||
fun reopenSimpleMapActivity() {
|
||||
// return to home screen
|
||||
device.pressHome()
|
||||
|
||||
// press recents apps button
|
||||
// press recent apps button to pause the app
|
||||
device.pressRecentApps()
|
||||
|
||||
// click to reopen app
|
||||
device.findObject(UiSelector().description("Mapbox Android SDK TestApp")).click()
|
||||
// return to app
|
||||
device.findObject(UiSelector().text(getTargetContext().getString(getTargetContext().applicationInfo.labelRes))).click()
|
||||
|
||||
// wait for idle
|
||||
device.waitForIdle(LAUNCH_TIMEOUT)
|
||||
sleep(LAUNCH_TIMEOUT)
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,6 @@ 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
|
||||
@@ -61,17 +58,13 @@ class TextureViewReopenTest {
|
||||
|
||||
@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()
|
||||
// return to app
|
||||
device.findObject(UiSelector().text(InstrumentationRegistry.getTargetContext().getString(InstrumentationRegistry.getTargetContext().applicationInfo.labelRes))).click()
|
||||
|
||||
// wait for idle
|
||||
device.waitForIdle(LAUNCH_TIMEOUT)
|
||||
sleep(LAUNCH_TIMEOUT)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user