Insert a check that keyguard is invisible into waitForLauncherCondition
This will unify diagnostics because otherwise waitForLauncherCondition would fail with a different message if keyguard is present.
Test: presubmit
Bug: 187761685
Flag: N/A
Change-Id: I1a34b4c2ad859b87263733a8a65527b8357e1950
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index d7c4ae3..604fe42 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -242,17 +242,7 @@
public void setUp() throws Exception {
mLauncher.onTestStart();
- final boolean keyguardAlreadyVisible = sSeenKeygard;
-
- sSeenKeygard = sSeenKeygard
- || !TestHelpers.wait(
- Until.gone(By.res(SYSTEMUI_PACKAGE, "keyguard_status_view")), 60000);
-
- Assert.assertFalse(
- "Keyguard is visible, which is likely caused by a crash in SysUI, seeing keyguard"
- + " for the first time = "
- + !keyguardAlreadyVisible,
- sSeenKeygard);
+ verifyKeyguardInvisible();
final String launcherPackageName = mDevice.getLauncherPackageName();
try {
@@ -285,6 +275,20 @@
}
}
+ private static void verifyKeyguardInvisible() {
+ final boolean keyguardAlreadyVisible = sSeenKeygard;
+
+ sSeenKeygard = sSeenKeygard
+ || !TestHelpers.wait(
+ Until.gone(By.res(SYSTEMUI_PACKAGE, "keyguard_status_view")), 60000);
+
+ Assert.assertFalse(
+ "Keyguard is visible, which is likely caused by a crash in SysUI, seeing keyguard"
+ + " for the first time = "
+ + !keyguardAlreadyVisible,
+ sSeenKeygard);
+ }
+
@After
public void verifyLauncherState() {
try {
@@ -402,6 +406,7 @@
// flakiness.
protected void waitForLauncherCondition(
String message, Function<Launcher, Boolean> condition, long timeout) {
+ verifyKeyguardInvisible();
if (!TestHelpers.isInLauncherProcess()) return;
Wait.atMost(message, () -> getFromLauncher(condition), timeout, mLauncher);
}