summaryrefslogtreecommitdiff
path: root/tests/hostside
diff options
context:
space:
mode:
author Tyler Dewey <deweytyl@google.com> 2024-02-06 14:33:12 +0000
committer Tyler Dewey <deweytyl@google.com> 2024-02-06 14:33:14 +0000
commit4f57acb4766402d6c3068bc8420baf3bc35b9b6a (patch)
treea8570ad15ffe4112a1ffa83b1a89c1095902ce3f /tests/hostside
parentc3e7ee6d8507f10542ee495b3a4c99a7dec6de1e (diff)
Fix knock-on failures in Safety Center logging test when a failed UI assertion leaves the view open.
Change-Id: Id374b488f9e8cbd1b189beb1caa9114b0b26ede4 Relnote: Safety Center MTS test fix Bug: 323269529 Test: Treehugger
Diffstat (limited to 'tests/hostside')
-rw-r--r--tests/hostside/safetycenter/helper-app/src/android/safetycenter/hostside/device/SafetyCenterInteractionLoggingHelperTests.kt10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/hostside/safetycenter/helper-app/src/android/safetycenter/hostside/device/SafetyCenterInteractionLoggingHelperTests.kt b/tests/hostside/safetycenter/helper-app/src/android/safetycenter/hostside/device/SafetyCenterInteractionLoggingHelperTests.kt
index f37479180..6afcff85a 100644
--- a/tests/hostside/safetycenter/helper-app/src/android/safetycenter/hostside/device/SafetyCenterInteractionLoggingHelperTests.kt
+++ b/tests/hostside/safetycenter/helper-app/src/android/safetycenter/hostside/device/SafetyCenterInteractionLoggingHelperTests.kt
@@ -23,6 +23,7 @@ import android.safetycenter.SafetyCenterManager.EXTRA_SAFETY_SOURCE_ID
import android.safetycenter.SafetyCenterManager.EXTRA_SAFETY_SOURCE_ISSUE_ID
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.android.compatibility.common.util.UiAutomatorUtils2
import com.android.safetycenter.testing.SafetyCenterActivityLauncher.launchSafetyCenterActivity
import com.android.safetycenter.testing.SafetyCenterActivityLauncher.launchSafetyCenterQsActivity
import com.android.safetycenter.testing.SafetyCenterActivityLauncher.openPageAndExit
@@ -34,6 +35,7 @@ import com.android.safetycenter.testing.SafetyCenterTestRule
import com.android.safetycenter.testing.SafetySourceTestData
import com.android.safetycenter.testing.SafetySourceTestData.Companion.INFORMATION_ISSUE_ID
import com.android.safetycenter.testing.UiTestHelper.waitAllTextDisplayed
+import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -63,6 +65,14 @@ class SafetyCenterInteractionLoggingHelperTests {
SafetyCenterFlags.showSubpages = true
}
+ @After
+ fun tearDown() {
+ // When an assertion fails, it will end up leaving the previous view open, which screws
+ // with the logging assertions made by this test (polluting with view events from whatever
+ // view was left open). Here we preemptively clear whatever's open to get back to home
+ UiAutomatorUtils2.getUiDevice().pressHome()
+ }
+
@Test
fun openSafetyCenter() {
context.launchSafetyCenterActivity {}