Loading tests/tapl/com/android/launcher3/tapl/KeyboardQuickSwitch.java +64 −54 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ public final class KeyboardQuickSwitch { private static final Pattern EVENT_ALT_TAB_UP = Pattern.compile( "KeyboardQuickSwitchView key event: KeyEvent.*?action=ACTION_UP.*?keyCode=KEYCODE_TAB" + ".*?metaState=META_ALT_ON"); private static final Pattern EVENT_ALT_SHIFT_TAB_DOWN = Pattern.compile( "KeyboardQuickSwitchView key event: KeyEvent.*?action=ACTION_DOWN.*?keyCode=KEYCODE_TAB" + ".*?metaState=META_ALT_ON|META_SHIFT_ON"); Loading @@ -50,7 +49,10 @@ public final class KeyboardQuickSwitch { private static final Pattern EVENT_ALT_ESC_UP = Pattern.compile( "KeyboardQuickSwitchView key event: KeyEvent.*?action=ACTION_UP" + ".*?keyCode=KEYCODE_ESCAPE.*?metaState=META_ALT_ON"); private static final Pattern EVENT_ALT_LEFT_UP = Pattern.compile( private static final Pattern EVENT_KQS_ALT_LEFT_UP = Pattern.compile( "KeyboardQuickSwitchView key event: KeyEvent.*?action=ACTION_UP" + ".*?keyCode=KEYCODE_ALT_LEFT"); private static final Pattern EVENT_HOME_ALT_LEFT_UP = Pattern.compile( "Key event: KeyEvent.*?action=ACTION_UP" + ".*?keyCode=KEYCODE_ALT_LEFT"); Loading Loading @@ -82,10 +84,10 @@ public final class KeyboardQuickSwitch { */ public KeyboardQuickSwitch moveFocusForward() { try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "want to move keyboard quick switch focus forward")) { "want to move keyboard quick switch focus forward"); LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.waitForLauncherObject(KEYBOARD_QUICK_SWITCH_RES_ID); try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_TAB_DOWN); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_TAB_UP); mLauncher.assertTrue("Failed to press alt+tab", Loading @@ -100,7 +102,6 @@ public final class KeyboardQuickSwitch { } } } } /** * Focuses the next task in the Keyboard quick switch view. Loading @@ -117,10 +118,10 @@ public final class KeyboardQuickSwitch { */ public KeyboardQuickSwitch moveFocusBackward() { try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "want to move keyboard quick switch focus backward")) { "want to move keyboard quick switch focus backward"); LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.waitForLauncherObject(KEYBOARD_QUICK_SWITCH_RES_ID); try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_SHIFT_TAB_DOWN); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_SHIFT_TAB_UP); mLauncher.assertTrue("Failed to press alt+shift+tab", Loading @@ -136,7 +137,6 @@ public final class KeyboardQuickSwitch { } } } } /** * Dismisses the Keyboard Quick Switch view without launching the focused task. Loading @@ -146,10 +146,10 @@ public final class KeyboardQuickSwitch { */ public void dismiss() { try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "want to dismiss keyboard quick switch view")) { "want to dismiss keyboard quick switch view"); LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.waitForLauncherObject(KEYBOARD_QUICK_SWITCH_RES_ID); try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_ESC_DOWN); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_ESC_UP); mLauncher.assertTrue("Failed to press alt+tab", Loading @@ -159,14 +159,15 @@ public final class KeyboardQuickSwitch { try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer( "pressed alt+esc")) { mLauncher.waitUntilLauncherObjectGone(KEYBOARD_QUICK_SWITCH_RES_ID); if (mExpectHomeKeyEventsOnDismiss) { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_LEFT_UP); } mLauncher.unpressKeyCode(KeyEvent.KEYCODE_ALT_LEFT, 0); // Verify the final state is the same as the initial state mLauncher.verifyContainerType(mStartingContainerType); // Wait until the device has fully settled before unpressing the key code if (mExpectHomeKeyEventsOnDismiss) { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_HOME_ALT_LEFT_UP); } mLauncher.unpressKeyCode(KeyEvent.KEYCODE_ALT_LEFT, 0); } } } Loading @@ -180,8 +181,10 @@ public final class KeyboardQuickSwitch { * @param expectedPackageName the package name of the expected launched app */ public LaunchedAppState launchFocusedAppTask(@NonNull String expectedPackageName) { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { return (LaunchedAppState) launchFocusedTask(expectedPackageName); } } /** * Launches the currently-focused overview task. Loading @@ -190,15 +193,21 @@ public final class KeyboardQuickSwitch { * {@link #launchFocusedAppTask(String)}. */ public Overview launchFocusedOverviewTask() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { return (Overview) launchFocusedTask(null); } } private LauncherInstrumentation.VisibleContainer launchFocusedTask( @Nullable String expectedPackageName) { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "want to launch focused task: " + (expectedPackageName == null ? "Overview" : expectedPackageName))) { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_KQS_ALT_LEFT_UP); mLauncher.unpressKeyCode(KeyEvent.KEYCODE_ALT_LEFT, 0); try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer( "un-pressed left alt")) { mLauncher.waitUntilLauncherObjectGone(KEYBOARD_QUICK_SWITCH_RES_ID); if (expectedPackageName != null) { Loading @@ -210,3 +219,4 @@ public final class KeyboardQuickSwitch { } } } } tests/tapl/com/android/launcher3/tapl/KeyboardQuickSwitchSource.java +2 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,8 @@ interface KeyboardQuickSwitchSource { LauncherInstrumentation launcher = getLauncher(); try (LauncherInstrumentation.Closable c1 = launcher.addContextLayer( "want to show keyboard quick switch object")) { "want to show keyboard quick switch object"); LauncherInstrumentation.Closable e = launcher.eventsCheck()) { launcher.pressAndHoldKeyCode(KeyEvent.KEYCODE_TAB, KeyEvent.META_ALT_LEFT_ON); try (LauncherInstrumentation.Closable c2 = launcher.addContextLayer( Loading Loading
tests/tapl/com/android/launcher3/tapl/KeyboardQuickSwitch.java +64 −54 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ public final class KeyboardQuickSwitch { private static final Pattern EVENT_ALT_TAB_UP = Pattern.compile( "KeyboardQuickSwitchView key event: KeyEvent.*?action=ACTION_UP.*?keyCode=KEYCODE_TAB" + ".*?metaState=META_ALT_ON"); private static final Pattern EVENT_ALT_SHIFT_TAB_DOWN = Pattern.compile( "KeyboardQuickSwitchView key event: KeyEvent.*?action=ACTION_DOWN.*?keyCode=KEYCODE_TAB" + ".*?metaState=META_ALT_ON|META_SHIFT_ON"); Loading @@ -50,7 +49,10 @@ public final class KeyboardQuickSwitch { private static final Pattern EVENT_ALT_ESC_UP = Pattern.compile( "KeyboardQuickSwitchView key event: KeyEvent.*?action=ACTION_UP" + ".*?keyCode=KEYCODE_ESCAPE.*?metaState=META_ALT_ON"); private static final Pattern EVENT_ALT_LEFT_UP = Pattern.compile( private static final Pattern EVENT_KQS_ALT_LEFT_UP = Pattern.compile( "KeyboardQuickSwitchView key event: KeyEvent.*?action=ACTION_UP" + ".*?keyCode=KEYCODE_ALT_LEFT"); private static final Pattern EVENT_HOME_ALT_LEFT_UP = Pattern.compile( "Key event: KeyEvent.*?action=ACTION_UP" + ".*?keyCode=KEYCODE_ALT_LEFT"); Loading Loading @@ -82,10 +84,10 @@ public final class KeyboardQuickSwitch { */ public KeyboardQuickSwitch moveFocusForward() { try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "want to move keyboard quick switch focus forward")) { "want to move keyboard quick switch focus forward"); LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.waitForLauncherObject(KEYBOARD_QUICK_SWITCH_RES_ID); try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_TAB_DOWN); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_TAB_UP); mLauncher.assertTrue("Failed to press alt+tab", Loading @@ -100,7 +102,6 @@ public final class KeyboardQuickSwitch { } } } } /** * Focuses the next task in the Keyboard quick switch view. Loading @@ -117,10 +118,10 @@ public final class KeyboardQuickSwitch { */ public KeyboardQuickSwitch moveFocusBackward() { try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "want to move keyboard quick switch focus backward")) { "want to move keyboard quick switch focus backward"); LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.waitForLauncherObject(KEYBOARD_QUICK_SWITCH_RES_ID); try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_SHIFT_TAB_DOWN); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_SHIFT_TAB_UP); mLauncher.assertTrue("Failed to press alt+shift+tab", Loading @@ -136,7 +137,6 @@ public final class KeyboardQuickSwitch { } } } } /** * Dismisses the Keyboard Quick Switch view without launching the focused task. Loading @@ -146,10 +146,10 @@ public final class KeyboardQuickSwitch { */ public void dismiss() { try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "want to dismiss keyboard quick switch view")) { "want to dismiss keyboard quick switch view"); LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.waitForLauncherObject(KEYBOARD_QUICK_SWITCH_RES_ID); try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_ESC_DOWN); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_ESC_UP); mLauncher.assertTrue("Failed to press alt+tab", Loading @@ -159,14 +159,15 @@ public final class KeyboardQuickSwitch { try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer( "pressed alt+esc")) { mLauncher.waitUntilLauncherObjectGone(KEYBOARD_QUICK_SWITCH_RES_ID); if (mExpectHomeKeyEventsOnDismiss) { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ALT_LEFT_UP); } mLauncher.unpressKeyCode(KeyEvent.KEYCODE_ALT_LEFT, 0); // Verify the final state is the same as the initial state mLauncher.verifyContainerType(mStartingContainerType); // Wait until the device has fully settled before unpressing the key code if (mExpectHomeKeyEventsOnDismiss) { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_HOME_ALT_LEFT_UP); } mLauncher.unpressKeyCode(KeyEvent.KEYCODE_ALT_LEFT, 0); } } } Loading @@ -180,8 +181,10 @@ public final class KeyboardQuickSwitch { * @param expectedPackageName the package name of the expected launched app */ public LaunchedAppState launchFocusedAppTask(@NonNull String expectedPackageName) { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { return (LaunchedAppState) launchFocusedTask(expectedPackageName); } } /** * Launches the currently-focused overview task. Loading @@ -190,15 +193,21 @@ public final class KeyboardQuickSwitch { * {@link #launchFocusedAppTask(String)}. */ public Overview launchFocusedOverviewTask() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { return (Overview) launchFocusedTask(null); } } private LauncherInstrumentation.VisibleContainer launchFocusedTask( @Nullable String expectedPackageName) { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "want to launch focused task: " + (expectedPackageName == null ? "Overview" : expectedPackageName))) { mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_KQS_ALT_LEFT_UP); mLauncher.unpressKeyCode(KeyEvent.KEYCODE_ALT_LEFT, 0); try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer( "un-pressed left alt")) { mLauncher.waitUntilLauncherObjectGone(KEYBOARD_QUICK_SWITCH_RES_ID); if (expectedPackageName != null) { Loading @@ -210,3 +219,4 @@ public final class KeyboardQuickSwitch { } } } }
tests/tapl/com/android/launcher3/tapl/KeyboardQuickSwitchSource.java +2 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,8 @@ interface KeyboardQuickSwitchSource { LauncherInstrumentation launcher = getLauncher(); try (LauncherInstrumentation.Closable c1 = launcher.addContextLayer( "want to show keyboard quick switch object")) { "want to show keyboard quick switch object"); LauncherInstrumentation.Closable e = launcher.eventsCheck()) { launcher.pressAndHoldKeyCode(KeyEvent.KEYCODE_TAB, KeyEvent.META_ALT_LEFT_ON); try (LauncherInstrumentation.Closable c2 = launcher.addContextLayer( Loading