Loading quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -163,7 +163,7 @@ public class FallbackRecentsTest { public void setUp() { mLauncher.onTestStart(); AbstractLauncherUiTest.waitForSetupWizardDismissal(); AbstractLauncherUiTest.verifyKeyguardInvisible(); AbstractLauncherUiTest.onTestStart(); } @After Loading tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +27 −16 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import android.platform.test.flag.junit.SetFlagsRule; import android.system.OsConstants; import android.util.Log; import androidx.annotation.NonNull; import androidx.test.InstrumentationRegistry; import androidx.test.uiautomator.By; import androidx.test.uiautomator.BySelector; Loading Loading @@ -108,7 +109,7 @@ public abstract class AbstractLauncherUiTest { private static final String SYSTEMUI_PACKAGE = "com.android.systemui"; protected LooperExecutor mMainThreadExecutor = MAIN_EXECUTOR; protected final UiDevice mDevice = UiDevice.getInstance(getInstrumentation()); protected final UiDevice mDevice = getUiDevice(); protected final LauncherInstrumentation mLauncher = new LauncherInstrumentation(); protected Context mTargetContext; protected String mTargetPackage; Loading Loading @@ -160,7 +161,7 @@ public abstract class AbstractLauncherUiTest { if (TestHelpers.isInLauncherProcess()) { Debug.dumpHprofData(fileName); } else { final UiDevice device = UiDevice.getInstance(getInstrumentation()); final UiDevice device = getUiDevice(); device.executeShellCommand( "am dumpheap " + device.getLauncherPackageName() + " " + fileName); } Loading Loading @@ -249,11 +250,6 @@ public abstract class AbstractLauncherUiTest { mLauncher.onTestStart(); waitForSetupWizardDismissal(); if (TestStabilityRule.isPresubmit()) { aggressivelyUnlockSysUi(); } else { verifyKeyguardInvisible(); } final String launcherPackageName = mDevice.getLauncherPackageName(); try { Loading Loading @@ -285,23 +281,38 @@ public abstract class AbstractLauncherUiTest { } } onTestStart(); } /** Method that should be called when a test starts. */ public static void onTestStart() { if (TestStabilityRule.isPresubmit()) { aggressivelyUnlockSysUi(); } else { verifyKeyguardInvisible(); } } private static boolean hasSystemUiObject(String resId) { return getUiDevice().hasObject( By.res(SYSTEMUI_PACKAGE, resId)); } private boolean hasSystemUiObject(String resId) { return mDevice.hasObject(By.res(SYSTEMUI_PACKAGE, resId)); @NonNull private static UiDevice getUiDevice() { return UiDevice.getInstance(getInstrumentation()); } // Seeing if this will decrease: b/303755862 void aggressivelyUnlockSysUi() { private static void aggressivelyUnlockSysUi() { final UiDevice device = getUiDevice(); for (int i = 0; i < 10 && hasSystemUiObject("keyguard_status_view"); ++i) { Log.d(TAG, "Before attempting to unlock the phone"); try { mDevice.executeShellCommand("input keyevent 82"); device.executeShellCommand("input keyevent 82"); } catch (IOException e) { throw new RuntimeException(e); } mDevice.waitForIdle(); device.waitForIdle(); } Assert.assertTrue("Keyguard still visible", TestHelpers.wait( Loading @@ -323,7 +334,7 @@ public abstract class AbstractLauncherUiTest { public static void waitForSetupWizardDismissal() { if (sFirstTimeWaitingForWizard && TestStabilityRule.isPresubmit()) { try { UiDevice.getInstance(getInstrumentation()).executeShellCommand( getUiDevice().executeShellCommand( "am force-stop com.google.android.setupwizard"); } catch (IOException e) { throw new RuntimeException(e); Loading @@ -339,7 +350,7 @@ public abstract class AbstractLauncherUiTest { // wizardDismissed); } public static void verifyKeyguardInvisible() { private static void verifyKeyguardInvisible() { final boolean keyguardAlreadyVisible = sSeenKeyguard; sSeenKeyguard = sSeenKeyguard Loading Loading
quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -163,7 +163,7 @@ public class FallbackRecentsTest { public void setUp() { mLauncher.onTestStart(); AbstractLauncherUiTest.waitForSetupWizardDismissal(); AbstractLauncherUiTest.verifyKeyguardInvisible(); AbstractLauncherUiTest.onTestStart(); } @After Loading
tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +27 −16 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import android.platform.test.flag.junit.SetFlagsRule; import android.system.OsConstants; import android.util.Log; import androidx.annotation.NonNull; import androidx.test.InstrumentationRegistry; import androidx.test.uiautomator.By; import androidx.test.uiautomator.BySelector; Loading Loading @@ -108,7 +109,7 @@ public abstract class AbstractLauncherUiTest { private static final String SYSTEMUI_PACKAGE = "com.android.systemui"; protected LooperExecutor mMainThreadExecutor = MAIN_EXECUTOR; protected final UiDevice mDevice = UiDevice.getInstance(getInstrumentation()); protected final UiDevice mDevice = getUiDevice(); protected final LauncherInstrumentation mLauncher = new LauncherInstrumentation(); protected Context mTargetContext; protected String mTargetPackage; Loading Loading @@ -160,7 +161,7 @@ public abstract class AbstractLauncherUiTest { if (TestHelpers.isInLauncherProcess()) { Debug.dumpHprofData(fileName); } else { final UiDevice device = UiDevice.getInstance(getInstrumentation()); final UiDevice device = getUiDevice(); device.executeShellCommand( "am dumpheap " + device.getLauncherPackageName() + " " + fileName); } Loading Loading @@ -249,11 +250,6 @@ public abstract class AbstractLauncherUiTest { mLauncher.onTestStart(); waitForSetupWizardDismissal(); if (TestStabilityRule.isPresubmit()) { aggressivelyUnlockSysUi(); } else { verifyKeyguardInvisible(); } final String launcherPackageName = mDevice.getLauncherPackageName(); try { Loading Loading @@ -285,23 +281,38 @@ public abstract class AbstractLauncherUiTest { } } onTestStart(); } /** Method that should be called when a test starts. */ public static void onTestStart() { if (TestStabilityRule.isPresubmit()) { aggressivelyUnlockSysUi(); } else { verifyKeyguardInvisible(); } } private static boolean hasSystemUiObject(String resId) { return getUiDevice().hasObject( By.res(SYSTEMUI_PACKAGE, resId)); } private boolean hasSystemUiObject(String resId) { return mDevice.hasObject(By.res(SYSTEMUI_PACKAGE, resId)); @NonNull private static UiDevice getUiDevice() { return UiDevice.getInstance(getInstrumentation()); } // Seeing if this will decrease: b/303755862 void aggressivelyUnlockSysUi() { private static void aggressivelyUnlockSysUi() { final UiDevice device = getUiDevice(); for (int i = 0; i < 10 && hasSystemUiObject("keyguard_status_view"); ++i) { Log.d(TAG, "Before attempting to unlock the phone"); try { mDevice.executeShellCommand("input keyevent 82"); device.executeShellCommand("input keyevent 82"); } catch (IOException e) { throw new RuntimeException(e); } mDevice.waitForIdle(); device.waitForIdle(); } Assert.assertTrue("Keyguard still visible", TestHelpers.wait( Loading @@ -323,7 +334,7 @@ public abstract class AbstractLauncherUiTest { public static void waitForSetupWizardDismissal() { if (sFirstTimeWaitingForWizard && TestStabilityRule.isPresubmit()) { try { UiDevice.getInstance(getInstrumentation()).executeShellCommand( getUiDevice().executeShellCommand( "am force-stop com.google.android.setupwizard"); } catch (IOException e) { throw new RuntimeException(e); Loading @@ -339,7 +350,7 @@ public abstract class AbstractLauncherUiTest { // wizardDismissed); } public static void verifyKeyguardInvisible() { private static void verifyKeyguardInvisible() { final boolean keyguardAlreadyVisible = sSeenKeyguard; sSeenKeyguard = sSeenKeyguard Loading