From 16eca5500dab2f253f52920edaed477f5e43f413 Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 5 Mar 2020 19:02:18 -0800 Subject: [PATCH] Enabling event verification for Launcher3 Will help investigating otherwise mysterious failures. Change-Id: I805ed136baf6d86921fdb4782304fcdafbd3af5c --- .../launcher3/tapl/AddToHomeScreenPrompt.java | 11 ++++++---- .../tapl/LauncherInstrumentation.java | 20 +++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java b/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java index 468f54c0d9..5daac394b9 100644 --- a/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java +++ b/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java @@ -42,10 +42,13 @@ public class AddToHomeScreenPrompt { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { if (mLauncher.getNavigationModel() != LauncherInstrumentation.NavigationModel.THREE_BUTTON) { - mLauncher.expectEvent( - TestProtocol.SEQUENCE_TIS, LauncherInstrumentation.EVENT_TOUCH_DOWN_TIS); - mLauncher.expectEvent( - TestProtocol.SEQUENCE_TIS, LauncherInstrumentation.EVENT_TOUCH_UP_TIS); + if (!mLauncher.isLauncher3()) { + mLauncher.expectEvent( + TestProtocol.SEQUENCE_TIS, + LauncherInstrumentation.EVENT_TOUCH_DOWN_TIS); + mLauncher.expectEvent( + TestProtocol.SEQUENCE_TIS, LauncherInstrumentation.EVENT_TOUCH_UP_TIS); + } } mLauncher.waitForObjectInContainer( mWidgetCell.getParent().getParent().getParent().getParent(), diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 9b12a62bde..d894843261 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -677,7 +677,7 @@ public final class LauncherInstrumentation { try (LauncherInstrumentation.Closable c = addContextLayer(action)) { mDevice.waitForIdle(); - if (getNavigationModel() == NavigationModel.TWO_BUTTON) { + if (!isLauncher3() && getNavigationModel() == NavigationModel.TWO_BUTTON) { expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_DOWN_TIS); expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_UP_TIS); } @@ -962,7 +962,7 @@ public final class LauncherInstrumentation { void clickLauncherObject(UiObject2 object) { expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_TOUCH_DOWN); expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_TOUCH_UP); - if (getNavigationModel() != NavigationModel.THREE_BUTTON) { + if (!isLauncher3() && getNavigationModel() != NavigationModel.THREE_BUTTON) { expectEvent(TestProtocol.SEQUENCE_TIS, LauncherInstrumentation.EVENT_TOUCH_DOWN_TIS); expectEvent(TestProtocol.SEQUENCE_TIS, LauncherInstrumentation.EVENT_TOUCH_UP_TIS); } @@ -1104,24 +1104,25 @@ public final class LauncherInstrumentation { public void sendPointer(long downTime, long currentTime, int action, Point point, GestureScope gestureScope) { + final boolean notLauncher3 = !isLauncher3(); switch (action) { case MotionEvent.ACTION_DOWN: if (gestureScope != GestureScope.OUTSIDE) { expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_DOWN); } - if (getNavigationModel() != NavigationModel.THREE_BUTTON) { + if (notLauncher3 && getNavigationModel() != NavigationModel.THREE_BUTTON) { expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_DOWN_TIS); } break; case MotionEvent.ACTION_UP: - if (gestureScope != GestureScope.INSIDE) { + if (notLauncher3 && gestureScope != GestureScope.INSIDE) { expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_PILFER_POINTERS); } if (gestureScope != GestureScope.OUTSIDE) { expectEvent(TestProtocol.SEQUENCE_MAIN, gestureScope == GestureScope.INSIDE ? EVENT_TOUCH_UP : EVENT_TOUCH_CANCEL); } - if (getNavigationModel() != NavigationModel.THREE_BUTTON) { + if (notLauncher3 && getNavigationModel() != NavigationModel.THREE_BUTTON) { expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_UP_TIS); } break; @@ -1276,11 +1277,6 @@ public final class LauncherInstrumentation { public Closable eventsCheck() { Assert.assertTrue("Nested event checking", !sCheckingEvents); - if ("com.android.launcher3".equals(getLauncherPackageName())) { - // Not checking specific Launcher3 event sequences. - return () -> { - }; - } sCheckingEvents = true; mExpectedPid = getPid(); if (sEventChecker == null) sEventChecker = new LogEventChecker(); @@ -1304,6 +1300,10 @@ public final class LauncherInstrumentation { }; } + boolean isLauncher3() { + return "com.android.launcher3".equals(getLauncherPackageName()); + } + void expectEvent(String sequence, Pattern expected) { if (sCheckingEvents) sEventChecker.expectPattern(sequence, expected); }