diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index 352447f9a1..09c4b1f49a 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -232,17 +232,7 @@ public abstract class AbstractLauncherUiTest { 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 { @@ -275,6 +265,20 @@ public abstract class AbstractLauncherUiTest { } } + 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 { @@ -392,6 +396,7 @@ public abstract class AbstractLauncherUiTest { // flakiness. protected void waitForLauncherCondition( String message, Function condition, long timeout) { + verifyKeyguardInvisible(); if (!TestHelpers.isInLauncherProcess()) return; Wait.atMost(message, () -> getFromLauncher(condition), timeout, mLauncher); }