Remove expecting DOWN events in TAPL tests.
ACTION_UP is always preceded by ACTION_DOWN which means when launcher receives an UP events, down event is obviously sent. In b/325377690 , we started seeing only in P9 devices the DOWN events didn't reach TAPL. I added InputDispatcher logs which shows both DOWN and UP events are sent by system_server to NexusLauncher. However TAPL doesn't receive it. After spending lot of time debugging this, I think we are safe to remove DOWN event expectation in TAPL. Bug: 325377690 Test: Manual, TAPL presubmits Flag: NA Change-Id: I6d3587c488d45e3dc53d2c1c4f3b6b49285eae94
This commit is contained in:
@@ -62,7 +62,14 @@ public final class TestLogging {
|
||||
|
||||
public static void recordKeyEvent(String sequence, String message, KeyEvent event) {
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
recordEventSlow(sequence, message + ": " + event, true);
|
||||
// This removes expecting ACTION_DOWN key event in the test. ACTION_UP is
|
||||
// always preceded by ACTION_DOWN.
|
||||
// Sometimes test doesn't receive ACTION_DOWN key event and we will assume that
|
||||
// Launcher relies only on ACTION_UP.
|
||||
// However in the test we will send both ACTION_DOWN and ACTION_UP key events.
|
||||
// But stop reporting to tapl if action is down.
|
||||
boolean reportToTapl = event.getAction() != KeyEvent.ACTION_DOWN;
|
||||
recordEventSlow(sequence, message + ": " + event, reportToTapl);
|
||||
registerEventNotFromTest(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,9 +56,6 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer
|
||||
|
||||
private static final String BOTTOM_SHEET_RES_ID = "bottom_sheet_background";
|
||||
private static final String FAST_SCROLLER_RES_ID = "fast_scroller";
|
||||
|
||||
private static final Pattern EVENT_ALT_ESC_DOWN = Pattern.compile(
|
||||
"Key event: KeyEvent.*?action=ACTION_DOWN.*?keyCode=KEYCODE_ESCAPE.*?metaState=0");
|
||||
private static final Pattern EVENT_ALT_ESC_UP = Pattern.compile(
|
||||
"Key event: KeyEvent.*?action=ACTION_UP.*?keyCode=KEYCODE_ESCAPE.*?metaState=0");
|
||||
|
||||
@@ -407,7 +404,6 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer
|
||||
/** Presses the esc key to dismiss AllApps. */
|
||||
public void dismissByEscKey() {
|
||||
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.runToState(
|
||||
() -> mLauncher.getDevice().pressKeyCode(KEYCODE_ESCAPE),
|
||||
|
||||
@@ -45,9 +45,6 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
|
||||
protected static final String TASK_RES_ID = "task";
|
||||
|
||||
private static final Pattern EVENT_ALT_ESC_DOWN = Pattern.compile(
|
||||
"Key event: KeyEvent.*?action=ACTION_DOWN.*?keyCode=KEYCODE_ESCAPE.*?metaState=0");
|
||||
private static final Pattern EVENT_ALT_ESC_UP = Pattern.compile(
|
||||
"Key event: KeyEvent.*?action=ACTION_UP.*?keyCode=KEYCODE_ESCAPE.*?metaState=0");
|
||||
private static final Pattern EVENT_ENTER_DOWN = Pattern.compile(
|
||||
@@ -413,7 +410,6 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
|
||||
*/
|
||||
public Workspace dismissByEscKey() {
|
||||
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.runToState(
|
||||
() -> mLauncher.getDevice().pressKeyCode(KEYCODE_ESCAPE),
|
||||
@@ -432,7 +428,6 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
|
||||
*/
|
||||
public LaunchedAppState launchFocusedTaskByEnterKey(@NonNull String expectedPackageName) {
|
||||
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
|
||||
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ENTER_DOWN);
|
||||
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ENTER_UP);
|
||||
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, TASK_START_EVENT);
|
||||
|
||||
|
||||
@@ -37,15 +37,9 @@ 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");
|
||||
private static final Pattern EVENT_ALT_SHIFT_TAB_UP = Pattern.compile(
|
||||
"KeyboardQuickSwitchView key event: KeyEvent.*?action=ACTION_UP.*?keyCode=KEYCODE_TAB"
|
||||
+ ".*?metaState=META_ALT_ON|META_SHIFT_ON");
|
||||
private static final Pattern EVENT_ALT_ESC_DOWN = Pattern.compile(
|
||||
"KeyboardQuickSwitchView key event: KeyEvent.*?action=ACTION_DOWN"
|
||||
+ ".*?keyCode=KEYCODE_ESCAPE.*?metaState=META_ALT_ON");
|
||||
private static final Pattern EVENT_ALT_ESC_UP = Pattern.compile(
|
||||
"KeyboardQuickSwitchView key event: KeyEvent.*?action=ACTION_UP"
|
||||
+ ".*?keyCode=KEYCODE_ESCAPE.*?metaState=META_ALT_ON");
|
||||
@@ -87,8 +81,6 @@ public final class KeyboardQuickSwitch {
|
||||
"want to move keyboard quick switch focus forward");
|
||||
LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
|
||||
mLauncher.waitForLauncherObject(KEYBOARD_QUICK_SWITCH_RES_ID);
|
||||
|
||||
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",
|
||||
mLauncher.getDevice().pressKeyCode(
|
||||
@@ -122,7 +114,6 @@ public final class KeyboardQuickSwitch {
|
||||
LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
|
||||
mLauncher.waitForLauncherObject(KEYBOARD_QUICK_SWITCH_RES_ID);
|
||||
|
||||
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",
|
||||
mLauncher.getDevice().pressKeyCode(
|
||||
@@ -150,7 +141,6 @@ public final class KeyboardQuickSwitch {
|
||||
LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
|
||||
mLauncher.waitForLauncherObject(KEYBOARD_QUICK_SWITCH_RES_ID);
|
||||
|
||||
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",
|
||||
mLauncher.getDevice().pressKeyCode(
|
||||
|
||||
@@ -114,9 +114,6 @@ public final class LauncherInstrumentation {
|
||||
|
||||
static final Pattern EVENT_PILFER_POINTERS = Pattern.compile("pilferPointers");
|
||||
static final Pattern EVENT_START = Pattern.compile("start:");
|
||||
|
||||
private static final Pattern EVENT_KEY_BACK_DOWN =
|
||||
getKeyEventPattern("ACTION_DOWN", "KEYCODE_BACK");
|
||||
private static final Pattern EVENT_KEY_BACK_UP =
|
||||
getKeyEventPattern("ACTION_UP", "KEYCODE_BACK");
|
||||
private static final Pattern EVENT_ON_BACK_INVOKED = Pattern.compile("onBackInvoked");
|
||||
@@ -1218,7 +1215,6 @@ public final class LauncherInstrumentation {
|
||||
.isOnBackInvokedCallbackEnabled()) {
|
||||
expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ON_BACK_INVOKED);
|
||||
} else {
|
||||
expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_KEY_BACK_DOWN);
|
||||
expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_KEY_BACK_UP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,6 @@ import java.util.regex.Pattern;
|
||||
public class SelectModeButtons {
|
||||
private final UiObject2 mSelectModeButtons;
|
||||
private final LauncherInstrumentation mLauncher;
|
||||
|
||||
private static final Pattern EVENT_ALT_ESC_DOWN = Pattern.compile(
|
||||
"Key event: KeyEvent.*?action=ACTION_DOWN.*?keyCode=KEYCODE_ESCAPE.*?metaState=0");
|
||||
private static final Pattern EVENT_ALT_ESC_UP = Pattern.compile(
|
||||
"Key event: KeyEvent.*?action=ACTION_UP.*?keyCode=KEYCODE_ESCAPE.*?metaState=0");
|
||||
|
||||
@@ -69,7 +66,6 @@ public class SelectModeButtons {
|
||||
@NonNull
|
||||
public Overview dismissByEscKey() {
|
||||
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.runToState(
|
||||
() -> mLauncher.getDevice().pressKeyCode(KEYCODE_ESCAPE),
|
||||
|
||||
@@ -66,10 +66,6 @@ public final class Workspace extends Home {
|
||||
private static final String DROP_BAR_RES_ID = "drop_target_bar";
|
||||
private static final String DELETE_TARGET_TEXT_ID = "delete_target_text";
|
||||
private static final String UNINSTALL_TARGET_TEXT_ID = "uninstall_target_text";
|
||||
|
||||
static final Pattern EVENT_CTRL_W_DOWN = Pattern.compile(
|
||||
"Key event: KeyEvent.*?action=ACTION_DOWN.*?keyCode=KEYCODE_W"
|
||||
+ ".*?metaState=META_CTRL_ON");
|
||||
static final Pattern EVENT_CTRL_W_UP = Pattern.compile(
|
||||
"Key event: KeyEvent.*?action=ACTION_UP.*?keyCode=KEYCODE_W"
|
||||
+ ".*?metaState=META_CTRL_ON");
|
||||
@@ -822,7 +818,6 @@ public final class Workspace extends Home {
|
||||
public Widgets openAllWidgets() {
|
||||
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
|
||||
verifyActiveContainer();
|
||||
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_CTRL_W_DOWN);
|
||||
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_CTRL_W_UP);
|
||||
mLauncher.getDevice().pressKeyCode(KeyEvent.KEYCODE_W, KeyEvent.META_CTRL_ON);
|
||||
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer("pressed Ctrl+W")) {
|
||||
|
||||
Reference in New Issue
Block a user