Return to home after hibernation/autorevoke tests
To prevent affecting other test after running (i.e.AutoRevokeTest)
and for more consistency, leave the unused apps page after test finishes
Bug: 182811830
Test: atest CtsOsTestCases
Test: forrest run
Change-Id: I79fea84f4e578e75c19245f4d001dbf39d472d8b
diff --git a/tests/tests/os/src/android/os/cts/AppHibernationIntegrationTest.kt b/tests/tests/os/src/android/os/cts/AppHibernationIntegrationTest.kt
index 3432250..ff71956 100644
--- a/tests/tests/os/src/android/os/cts/AppHibernationIntegrationTest.kt
+++ b/tests/tests/os/src/android/os/cts/AppHibernationIntegrationTest.kt
@@ -38,6 +38,7 @@
import com.android.compatibility.common.util.SystemUtil.runShellCommandOrThrow
import com.android.compatibility.common.util.UiAutomatorUtils
import org.hamcrest.CoreMatchers
+import org.junit.After
import org.junit.Assert.assertFalse
import org.junit.Assert.assertThat
import org.junit.Assert.assertTrue
@@ -81,6 +82,11 @@
runShellCommandOrThrow("input keyevent 82")
}
+ @After
+ fun cleanUp() {
+ goHome()
+ }
+
@Test
fun testUnusedApp_getsForceStopped() {
withDeviceConfig(NAMESPACE_APP_HIBERNATION, "app_hibernation_enabled", "true") {
diff --git a/tests/tests/os/src/android/os/cts/AppHibernationUtils.kt b/tests/tests/os/src/android/os/cts/AppHibernationUtils.kt
index 0f27184..6374a7b 100644
--- a/tests/tests/os/src/android/os/cts/AppHibernationUtils.kt
+++ b/tests/tests/os/src/android/os/cts/AppHibernationUtils.kt
@@ -146,6 +146,10 @@
waitForIdle()
}
+fun goHome() {
+ runShellCommandOrThrow("input keyevent KEYCODE_HOME")
+}
+
fun waitFindObject(uiAutomation: UiAutomation, selector: BySelector): UiObject2 {
try {
return UiAutomatorUtils.waitFindObject(selector)
diff --git a/tests/tests/os/src/android/os/cts/AutoRevokeTest.kt b/tests/tests/os/src/android/os/cts/AutoRevokeTest.kt
index 897ef5f..5587915 100644
--- a/tests/tests/os/src/android/os/cts/AutoRevokeTest.kt
+++ b/tests/tests/os/src/android/os/cts/AutoRevokeTest.kt
@@ -57,6 +57,7 @@
import org.hamcrest.CoreMatchers.equalTo
import org.hamcrest.Matcher
import org.hamcrest.Matchers.greaterThan
+import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertThat
@@ -123,6 +124,11 @@
}
}
+ @After
+ fun cleanUp() {
+ goHome()
+ }
+
@AppModeFull(reason = "Uses separate apps for testing")
@Test
fun testUnusedApp_getsPermissionRevoked() {
@@ -392,10 +398,6 @@
}
}
- private fun goHome() {
- runShellCommandOrThrow("input keyevent KEYCODE_HOME")
- }
-
private fun goBack() {
runShellCommandOrThrow("input keyevent KEYCODE_BACK")
}