Merge "Removing verifying motion events in TAPL" into udc-qpr-dev

This commit is contained in:
Vadim Tryshev
2023-09-06 22:53:58 +00:00
committed by Android (Google) Code Review
14 changed files with 62 additions and 173 deletions
@@ -17,7 +17,6 @@ package com.android.launcher3.testing;
import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST; import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST;
import static com.android.launcher3.config.FeatureFlags.ENABLE_GRID_ONLY_OVERVIEW; import static com.android.launcher3.config.FeatureFlags.ENABLE_GRID_ONLY_OVERVIEW;
import static com.android.launcher3.config.FeatureFlags.ENABLE_TRACKPAD_GESTURE;
import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE; import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
@@ -236,12 +235,6 @@ public class TestInformationHandler implements ResourceBasedOverride {
return response; return response;
} }
case TestProtocol.REQUEST_IS_TRACKPAD_GESTURE_ENABLED: {
response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD,
ENABLE_TRACKPAD_GESTURE.get());
return response;
}
case TestProtocol.REQUEST_ALL_APPS_TOP_PADDING: { case TestProtocol.REQUEST_ALL_APPS_TOP_PADDING: {
return getLauncherUIProperty(Bundle::putInt, return getLauncherUIProperty(Bundle::putInt,
l -> l.getAppsView().getActiveRecyclerView().getClipBounds().top); l -> l.getAppsView().getActiveRecyclerView().getClipBounds().top);
@@ -70,15 +70,12 @@ public final class TestLogging {
public static void recordMotionEvent(String sequence, String message, MotionEvent event) { public static void recordMotionEvent(String sequence, String message, MotionEvent event) {
final int action = event.getAction(); final int action = event.getAction();
if (Utilities.isRunningInTestHarness() && action != MotionEvent.ACTION_MOVE) { if (Utilities.isRunningInTestHarness() && action != MotionEvent.ACTION_MOVE) {
// "Expecting" in TAPL ACTION_DOWN, UP and CANCEL events was thought to be producing // "Expecting" in TAPL motion events was thought to be producing considerable noise in
// considerable noise in tests due to failed checks for expected events. So we are not // tests due to failed checks for expected events. So we are not sending them to TAPL.
// sending them to TAPL.
// Other events, such as EVENT_PILFER_POINTERS produce less noise and are thought to // Other events, such as EVENT_PILFER_POINTERS produce less noise and are thought to
// be more useful. // be more useful.
final boolean reportToTapl = action != MotionEvent.ACTION_DOWN // That's why we pass false as the value for the 'reportToTapl' parameter.
&& action != MotionEvent.ACTION_UP recordEventSlow(sequence, message + ": " + event, false);
&& action != MotionEvent.ACTION_CANCEL;
recordEventSlow(sequence, message + ": " + event, reportToTapl);
registerEventNotFromTest(event); registerEventNotFromTest(event);
} }
} }
@@ -120,7 +120,6 @@ public final class TestProtocol {
"get-activities-created-count"; "get-activities-created-count";
public static final String REQUEST_GET_ACTIVITIES = "get-activities"; public static final String REQUEST_GET_ACTIVITIES = "get-activities";
public static final String REQUEST_HAS_TIS = "has-touch-interaction-service"; public static final String REQUEST_HAS_TIS = "has-touch-interaction-service";
public static final String REQUEST_IS_TRACKPAD_GESTURE_ENABLED = "is-trackpad-gesture-enabled";
public static final String REQUEST_TASKBAR_ALL_APPS_TOP_PADDING = public static final String REQUEST_TASKBAR_ALL_APPS_TOP_PADDING =
"taskbar-all-apps-top-padding"; "taskbar-all-apps-top-padding";
public static final String REQUEST_ALL_APPS_TOP_PADDING = "all-apps-top-padding"; public static final String REQUEST_ALL_APPS_TOP_PADDING = "all-apps-top-padding";
@@ -184,7 +184,7 @@ public final class SecondaryDisplayLauncherTest extends AbstractLauncherUiTest {
mStartPoint = icon.getVisibleCenter(); mStartPoint = icon.getVisibleCenter();
mEndPoint = new Point(mStartPoint.x, mStartPoint.y); mEndPoint = new Point(mStartPoint.x, mStartPoint.y);
mLauncher.sendPointer(mDownTime, mDownTime, ACTION_DOWN, mStartPoint, mLauncher.sendPointer(mDownTime, mDownTime, ACTION_DOWN, mStartPoint,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
assertThat(findObjectByResourceName("popup_container")).isNotNull(); assertThat(findObjectByResourceName("popup_container")).isNotNull();
return appName; return appName;
} }
@@ -206,7 +206,7 @@ public final class SecondaryDisplayLauncherTest extends AbstractLauncherUiTest {
mStartPoint = icon.getVisibleCenter(); mStartPoint = icon.getVisibleCenter();
mEndPoint = new Point(mStartPoint.x, mStartPoint.y); mEndPoint = new Point(mStartPoint.x, mStartPoint.y);
mLauncher.sendPointer(mDownTime, mDownTime, ACTION_DOWN, mStartPoint, mLauncher.sendPointer(mDownTime, mDownTime, ACTION_DOWN, mStartPoint,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
assertThat(findObjectByResourceName("popup_container")).isNotNull(); assertThat(findObjectByResourceName("popup_container")).isNotNull();
return appName; return appName;
} }
@@ -214,12 +214,12 @@ public final class SecondaryDisplayLauncherTest extends AbstractLauncherUiTest {
private void moveAppToCenterOfScreen() { private void moveAppToCenterOfScreen() {
mEndPoint.set(mDevice.getDisplayWidth() / 2, mDevice.getDisplayHeight() / 2); mEndPoint.set(mDevice.getDisplayWidth() / 2, mDevice.getDisplayHeight() / 2);
mLauncher.movePointer(mDownTime, SystemClock.uptimeMillis(), DRAG_TIME_MS, true, mLauncher.movePointer(mDownTime, SystemClock.uptimeMillis(), DRAG_TIME_MS, true,
mStartPoint, mEndPoint, LauncherInstrumentation.GestureScope.INSIDE); mStartPoint, mEndPoint, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
} }
private void dropApp() { private void dropApp() {
mLauncher.sendPointer(mDownTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, mLauncher.sendPointer(mDownTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP,
mEndPoint, LauncherInstrumentation.GestureScope.INSIDE); mEndPoint, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
} }
private void removeAppByName(String appName) { private void removeAppByName(String appName) {
@@ -45,8 +45,8 @@ public class AddToHomeScreenPrompt {
mLauncher.clickObject( mLauncher.clickObject(
mLauncher.waitForObjectInContainer( mLauncher.waitForObjectInContainer(
mWidgetCell.getParent().getParent().getParent().getParent(), mWidgetCell.getParent().getParent().getParent().getParent(),
By.text(ADD_AUTOMATICALLY)), By.text(ADD_AUTOMATICALLY))
LauncherInstrumentation.GestureScope.OUTSIDE_WITHOUT_PILFER); );
mLauncher.waitUntilLauncherObjectGone(getSelector()); mLauncher.waitUntilLauncherObjectGone(getSelector());
} }
} }
@@ -66,10 +66,6 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine
} }
protected boolean zeroButtonToOverviewGestureStartsInLauncher() {
return mLauncher.isTablet();
}
protected boolean zeroButtonToOverviewGestureStateTransitionWhileHolding() { protected boolean zeroButtonToOverviewGestureStateTransitionWhileHolding() {
return false; return false;
} }
@@ -146,12 +142,9 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine
final int centerX = mLauncher.getDevice().getDisplayWidth() / 2; final int centerX = mLauncher.getDevice().getDisplayWidth() / 2;
final int startY = getSwipeStartY(); final int startY = getSwipeStartY();
final Point start = new Point(centerX, startY); final Point start = new Point(centerX, startY);
final LauncherInstrumentation.GestureScope gestureScope =
zeroButtonToOverviewGestureStartsInLauncher()
? LauncherInstrumentation.GestureScope.INSIDE_TO_OUTSIDE
: LauncherInstrumentation.GestureScope.OUTSIDE_WITH_PILFER;
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, start, gestureScope); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, start,
LauncherInstrumentation.GestureScope.EXPECT_PILFER);
if (!mLauncher.isLauncher3()) { if (!mLauncher.isLauncher3()) {
mLauncher.expectEvent(TestProtocol.SEQUENCE_PILFER, mLauncher.expectEvent(TestProtocol.SEQUENCE_PILFER,
@@ -167,10 +160,6 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine
final Point start = new Point(centerX, startY); final Point start = new Point(centerX, startY);
final Point end = final Point end =
new Point(centerX, startY - swipeHeight - mLauncher.getTouchSlop()); new Point(centerX, startY - swipeHeight - mLauncher.getTouchSlop());
final LauncherInstrumentation.GestureScope gestureScope =
zeroButtonToOverviewGestureStartsInLauncher()
? LauncherInstrumentation.GestureScope.INSIDE_TO_OUTSIDE
: LauncherInstrumentation.GestureScope.OUTSIDE_WITH_PILFER;
mLauncher.movePointer( mLauncher.movePointer(
downTime, downTime,
@@ -178,7 +167,7 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine
ZERO_BUTTON_SWIPE_UP_GESTURE_DURATION, ZERO_BUTTON_SWIPE_UP_GESTURE_DURATION,
start, start,
end, end,
gestureScope); LauncherInstrumentation.GestureScope.EXPECT_PILFER);
} }
private void sendUpPointerToEnterOverviewToLauncher(long downTime) { private void sendUpPointerToEnterOverviewToLauncher(long downTime) {
@@ -189,13 +178,9 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine
final Point end = final Point end =
new Point(centerX, startY - swipeHeight - mLauncher.getTouchSlop()); new Point(centerX, startY - swipeHeight - mLauncher.getTouchSlop());
final LauncherInstrumentation.GestureScope gestureScope =
zeroButtonToOverviewGestureStartsInLauncher()
? LauncherInstrumentation.GestureScope.INSIDE
: LauncherInstrumentation.GestureScope.OUTSIDE_WITHOUT_PILFER;
mLauncher.sendPointer(downTime, SystemClock.uptimeMillis(), mLauncher.sendPointer(downTime, SystemClock.uptimeMillis(),
MotionEvent.ACTION_UP, end, gestureScope); MotionEvent.ACTION_UP, end,
LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
} }
/** /**
@@ -227,7 +212,6 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine
LauncherInstrumentation.Closable c = mLauncher.addContextLayer( LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to quick switch to the previous app")) { "want to quick switch to the previous app")) {
verifyActiveContainer(); verifyActiveContainer();
final boolean launcherWasVisible = mLauncher.isLauncherVisible();
if (mLauncher.getNavigationModel() == NavigationModel.ZERO_BUTTON if (mLauncher.getNavigationModel() == NavigationModel.ZERO_BUTTON
|| mLauncher.getTrackpadGestureType() == TrackpadGestureType.FOUR_FINGER) { || mLauncher.getTrackpadGestureType() == TrackpadGestureType.FOUR_FINGER) {
final int startX; final int startX;
@@ -249,13 +233,10 @@ public abstract class Background extends LauncherInstrumentation.VisibleContaine
endY = startY; endY = startY;
} }
LauncherInstrumentation.GestureScope gestureScope =
launcherWasVisible
? LauncherInstrumentation.GestureScope.INSIDE_TO_OUTSIDE
: LauncherInstrumentation.GestureScope.OUTSIDE_WITH_PILFER;
mLauncher.executeAndWaitForEvent( mLauncher.executeAndWaitForEvent(
() -> mLauncher.linearGesture( () -> mLauncher.linearGesture(
startX, startY, endX, endY, 20, false, gestureScope), startX, startY, endX, endY, 20, false,
LauncherInstrumentation.GestureScope.EXPECT_PILFER),
event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED, event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
() -> "Quick switch gesture didn't change window state", "swiping"); () -> "Quick switch gesture didn't change window state", "swiping");
} else { } else {
@@ -58,11 +58,6 @@ public abstract class Home extends Background {
} }
} }
@Override
protected boolean zeroButtonToOverviewGestureStartsInLauncher() {
return true;
}
@Override @Override
protected boolean zeroButtonToOverviewGestureStateTransitionWhileHolding() { protected boolean zeroButtonToOverviewGestureStateTransitionWhileHolding() {
return true; return true;
@@ -60,8 +60,8 @@ public class HomeAllApps extends AllApps {
endY, endY,
5 /* steps */, 5 /* steps */,
NORMAL_STATE_ORDINAL, NORMAL_STATE_ORDINAL,
swipeDown ? LauncherInstrumentation.GestureScope.INSIDE swipeDown ? LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER
: LauncherInstrumentation.GestureScope.OUTSIDE_WITH_PILFER); : LauncherInstrumentation.GestureScope.EXPECT_PILFER);
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"swiped to workspace")) { "swiped to workspace")) {
@@ -152,7 +152,7 @@ public abstract class Launchable {
downTime, downTime,
MotionEvent.ACTION_DOWN, MotionEvent.ACTION_DOWN,
iconCenter, iconCenter,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
LauncherInstrumentation.log("movePointerForStartDrag: sent down"); LauncherInstrumentation.log("movePointerForStartDrag: sent down");
expectLongClickEvents.run(); expectLongClickEvents.run();
waitForLongPressConfirmation(); waitForLongPressConfirmation();
@@ -165,7 +165,7 @@ public abstract class Launchable {
downTime, downTime,
downTime, downTime,
/* slowDown= */ true, /* slowDown= */ true,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
} }
private int getStartDragThreshold() { private int getStartDragThreshold() {
@@ -128,13 +128,13 @@ public final class LaunchedAppState extends Background {
mLauncher.getRealDisplaySize().x / 2, unstashTargetY); mLauncher.getRealDisplaySize().x / 2, unstashTargetY);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, unstashTarget, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, unstashTarget,
LauncherInstrumentation.GestureScope.OUTSIDE_WITH_PILFER); LauncherInstrumentation.GestureScope.EXPECT_PILFER);
LauncherInstrumentation.log("showTaskbar: sent down"); LauncherInstrumentation.log("showTaskbar: sent down");
try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("pressed down")) { try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("pressed down")) {
mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID); mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, unstashTarget, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, unstashTarget,
LauncherInstrumentation.GestureScope.OUTSIDE_WITH_PILFER); LauncherInstrumentation.GestureScope.EXPECT_PILFER);
return new Taskbar(mLauncher); return new Taskbar(mLauncher);
} }
@@ -183,7 +183,7 @@ public final class LaunchedAppState extends Background {
downTime, downTime,
SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
/* slowDown= */ false, /* slowDown= */ false,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
try (LauncherInstrumentation.Closable c3 = launcher.addContextLayer( try (LauncherInstrumentation.Closable c3 = launcher.addContextLayer(
"moved pointer to drop point")) { "moved pointer to drop point")) {
@@ -194,7 +194,7 @@ public final class LaunchedAppState extends Background {
SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
MotionEvent.ACTION_UP, MotionEvent.ACTION_UP,
endPoint, endPoint,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
LauncherInstrumentation.log("SplitscreenDragSource.dragToSplitscreen: " LauncherInstrumentation.log("SplitscreenDragSource.dragToSplitscreen: "
+ "after drop"); + "after drop");
@@ -326,7 +326,7 @@ public final class LaunchedAppState extends Background {
null, InputDevice.SOURCE_MOUSE); null, InputDevice.SOURCE_MOUSE);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN,
new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y),
LauncherInstrumentation.GestureScope.OUTSIDE_WITHOUT_PILFER, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER,
InputDevice.SOURCE_MOUSE); InputDevice.SOURCE_MOUSE);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_BUTTON_PRESS, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_BUTTON_PRESS,
new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y),
@@ -336,7 +336,7 @@ public final class LaunchedAppState extends Background {
null, InputDevice.SOURCE_MOUSE); null, InputDevice.SOURCE_MOUSE);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP,
new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y),
LauncherInstrumentation.GestureScope.OUTSIDE_WITHOUT_PILFER, LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER,
InputDevice.SOURCE_MOUSE); InputDevice.SOURCE_MOUSE);
return mLauncher.getWorkspace(); return mLauncher.getWorkspace();
@@ -102,12 +102,6 @@ public final class LauncherInstrumentation {
static final Pattern EVENT_PILFER_POINTERS = Pattern.compile("pilferPointers"); static final Pattern EVENT_PILFER_POINTERS = Pattern.compile("pilferPointers");
static final Pattern EVENT_START = Pattern.compile("start:"); static final Pattern EVENT_START = Pattern.compile("start:");
static final Pattern EVENT_HOVER_ENTER_TIS = getTouchEventPatternTIS("ACTION_HOVER_ENTER");
static final Pattern EVENT_HOVER_EXIT_TIS = getTouchEventPatternTIS("ACTION_HOVER_EXIT");
static final Pattern EVENT_BUTTON_PRESS_TIS = getTouchEventPatternTIS("ACTION_BUTTON_PRESS");
static final Pattern EVENT_BUTTON_RELEASE_TIS =
getTouchEventPatternTIS("ACTION_BUTTON_RELEASE");
private static final Pattern EVENT_KEY_BACK_DOWN = private static final Pattern EVENT_KEY_BACK_DOWN =
getKeyEventPattern("ACTION_DOWN", "KEYCODE_BACK"); getKeyEventPattern("ACTION_DOWN", "KEYCODE_BACK");
private static final Pattern EVENT_KEY_BACK_UP = private static final Pattern EVENT_KEY_BACK_UP =
@@ -127,12 +121,10 @@ public final class LauncherInstrumentation {
public enum NavigationModel {ZERO_BUTTON, THREE_BUTTON} public enum NavigationModel {ZERO_BUTTON, THREE_BUTTON}
// Where the gesture happens: outside of Launcher, inside or from inside to outside and // Defines whether the gesture recognition triggers pilfer.
// whether the gesture recognition triggers pilfer.
public enum GestureScope { public enum GestureScope {
OUTSIDE_WITHOUT_PILFER, OUTSIDE_WITH_PILFER, INSIDE, INSIDE_TO_OUTSIDE, DONT_EXPECT_PILFER,
INSIDE_TO_OUTSIDE_WITH_KEYCODE, // For gestures that will trigger a keycode from TIS. EXPECT_PILFER,
OUTSIDE_WITH_KEYCODE,
} }
public enum TrackpadGestureType { public enum TrackpadGestureType {
@@ -204,28 +196,6 @@ public final class LauncherInstrumentation {
private TrackpadGestureType mTrackpadGestureType = TrackpadGestureType.NONE; private TrackpadGestureType mTrackpadGestureType = TrackpadGestureType.NONE;
private int mPointerCount = 0; private int mPointerCount = 0;
private static Pattern getTouchEventPatternWithPointerCount(String prefix, String action,
int pointerCount) {
return Pattern.compile(
prefix + ": MotionEvent.*?action=" + action + ".*?id\\[0\\]=0"
+ ".*?toolType\\[0\\]=TOOL_TYPE_FINGER.*?buttonState=0.*?pointerCount="
+ pointerCount);
}
private static Pattern getTouchEventPatternWithPointerCount(String action, int pointerCount) {
return getTouchEventPatternWithPointerCount("Touch event", action, pointerCount);
}
private static Pattern getTouchEventPatternTIS(String action) {
return getTouchEventPatternWithPointerCount("TouchInteractionService.onInputEvent", action,
1);
}
private static Pattern getTouchEventPatternTIS(String action, int pointerCount) {
return getTouchEventPatternWithPointerCount("TouchInteractionService.onInputEvent", action,
pointerCount);
}
private static Pattern getKeyEventPattern(String action, String keyCode) { private static Pattern getKeyEventPattern(String action, String keyCode) {
return Pattern.compile("Key event: KeyEvent.*action=" + action + ".*keyCode=" + keyCode); return Pattern.compile("Key event: KeyEvent.*action=" + action + ".*keyCode=" + keyCode);
} }
@@ -973,8 +943,8 @@ public final class LauncherInstrumentation {
GestureScope gestureScope = gestureStartFromLauncher GestureScope gestureScope = gestureStartFromLauncher
// Without the navigation bar layer, the gesture scope on tablets remains inside the // Without the navigation bar layer, the gesture scope on tablets remains inside the
// launcher process. // launcher process.
? (isTablet() ? GestureScope.INSIDE : GestureScope.INSIDE_TO_OUTSIDE) ? (isTablet() ? GestureScope.DONT_EXPECT_PILFER : GestureScope.EXPECT_PILFER)
: GestureScope.OUTSIDE_WITH_PILFER; : GestureScope.EXPECT_PILFER;
linearGesture( linearGesture(
displaySize.x / 2, displaySize.y - 1, displaySize.x / 2, displaySize.y - 1,
displaySize.x / 2, 0, displaySize.x / 2, 0,
@@ -1046,8 +1016,7 @@ public final class LauncherInstrumentation {
displaySize.x / 2, startY, displaySize.x / 2, startY,
displaySize.x / 2, endY, displaySize.x / 2, endY,
ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME, NORMAL_STATE_ORDINAL, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME, NORMAL_STATE_ORDINAL,
gestureStartFromLauncher ? GestureScope.INSIDE_TO_OUTSIDE GestureScope.EXPECT_PILFER);
: GestureScope.OUTSIDE_WITH_PILFER);
} }
} else { } else {
log("Hierarchy before clicking home:"); log("Hierarchy before clicking home:");
@@ -1082,15 +1051,12 @@ public final class LauncherInstrumentation {
if (getNavigationModel() == NavigationModel.ZERO_BUTTON if (getNavigationModel() == NavigationModel.ZERO_BUTTON
|| isThreeFingerTrackpadGesture) { || isThreeFingerTrackpadGesture) {
final Point displaySize = getRealDisplaySize(); final Point displaySize = getRealDisplaySize();
final GestureScope gestureScope =
launcherVisible ? GestureScope.INSIDE_TO_OUTSIDE_WITH_KEYCODE
: GestureScope.OUTSIDE_WITH_KEYCODE;
// TODO(b/225505986): change startY and endY back to displaySize.y / 2 once the // TODO(b/225505986): change startY and endY back to displaySize.y / 2 once the
// issue is solved. // issue is solved.
int startX = isThreeFingerTrackpadGesture ? displaySize.x / 4 : 0; int startX = isThreeFingerTrackpadGesture ? displaySize.x / 4 : 0;
int endX = isThreeFingerTrackpadGesture ? displaySize.x * 3 / 4 : displaySize.x / 2; int endX = isThreeFingerTrackpadGesture ? displaySize.x * 3 / 4 : displaySize.x / 2;
linearGesture(startX, displaySize.y / 4, endX, displaySize.y / 4, linearGesture(startX, displaySize.y / 4, endX, displaySize.y / 4,
10, false, gestureScope); 10, false, GestureScope.DONT_EXPECT_PILFER);
} else { } else {
waitForNavigationUiObject("back").click(); waitForNavigationUiObject("back").click();
} }
@@ -1500,15 +1466,17 @@ public final class LauncherInstrumentation {
* animations because in some scenarios there is a playing animations when the click is * animations because in some scenarios there is a playing animations when the click is
* attempted. * attempted.
*/ */
void clickObject(UiObject2 uiObject, GestureScope gestureScope) { void clickObject(UiObject2 uiObject) {
final long clickTime = SystemClock.uptimeMillis(); final long clickTime = SystemClock.uptimeMillis();
final Point center = uiObject.getVisibleCenter(); final Point center = uiObject.getVisibleCenter();
sendPointer(clickTime, clickTime, MotionEvent.ACTION_DOWN, center, gestureScope); sendPointer(clickTime, clickTime, MotionEvent.ACTION_DOWN, center,
sendPointer(clickTime, clickTime, MotionEvent.ACTION_UP, center, gestureScope); GestureScope.DONT_EXPECT_PILFER);
sendPointer(clickTime, clickTime, MotionEvent.ACTION_UP, center,
GestureScope.DONT_EXPECT_PILFER);
} }
void clickLauncherObject(UiObject2 object) { void clickLauncherObject(UiObject2 object) {
clickObject(object, GestureScope.INSIDE); clickObject(object);
} }
void scrollToLastVisibleRow( void scrollToLastVisibleRow(
@@ -1601,7 +1569,8 @@ public final class LauncherInstrumentation {
executeAndWaitForLauncherEvent( executeAndWaitForLauncherEvent(
() -> linearGesture( () -> linearGesture(
startX, startY, endX, endY, steps, slowDown, GestureScope.INSIDE), startX, startY, endX, endY, steps, slowDown,
GestureScope.DONT_EXPECT_PILFER),
event -> TestProtocol.SCROLL_FINISHED_MESSAGE.equals(event.getClassName()), event -> TestProtocol.SCROLL_FINISHED_MESSAGE.equals(event.getClassName()),
() -> "Didn't receive a scroll end message: " + startX + ", " + startY () -> "Didn't receive a scroll end message: " + startX + ", " + startY
+ ", " + endX + ", " + endY, + ", " + endX + ", " + endY,
@@ -1721,11 +1690,6 @@ public final class LauncherInstrumentation {
TestProtocol.TEST_INFO_RESPONSE_FIELD); TestProtocol.TEST_INFO_RESPONSE_FIELD);
} }
boolean isTrackpadGestureEnabled() {
return getTestInfo(TestProtocol.REQUEST_IS_TRACKPAD_GESTURE_ENABLED).getBoolean(
TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
boolean isGridOnlyOverviewEnabled() { boolean isGridOnlyOverviewEnabled() {
return getTestInfo(TestProtocol.REQUEST_FLAG_ENABLE_GRID_ONLY_OVERVIEW).getBoolean( return getTestInfo(TestProtocol.REQUEST_FLAG_ENABLE_GRID_ONLY_OVERVIEW).getBoolean(
TestProtocol.TEST_INFO_RESPONSE_FIELD); TestProtocol.TEST_INFO_RESPONSE_FIELD);
@@ -1743,7 +1707,6 @@ public final class LauncherInstrumentation {
int pointerCount = mPointerCount; int pointerCount = mPointerCount;
boolean isTrackpadGesture = mTrackpadGestureType != TrackpadGestureType.NONE; boolean isTrackpadGesture = mTrackpadGestureType != TrackpadGestureType.NONE;
boolean isTwoFingerTrackpadGesture = mTrackpadGestureType == TrackpadGestureType.TWO_FINGER;
switch (action & MotionEvent.ACTION_MASK) { switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
if (isTrackpadGesture) { if (isTrackpadGesture) {
@@ -1752,59 +1715,18 @@ public final class LauncherInstrumentation {
} }
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
if (hasTIS if (hasTIS && gestureScope == GestureScope.EXPECT_PILFER) {
&& (gestureScope == GestureScope.OUTSIDE_WITH_PILFER
|| gestureScope == GestureScope.INSIDE_TO_OUTSIDE)) {
expectEvent(TestProtocol.SEQUENCE_PILFER, EVENT_PILFER_POINTERS); expectEvent(TestProtocol.SEQUENCE_PILFER, EVENT_PILFER_POINTERS);
} }
break; break;
case MotionEvent.ACTION_HOVER_ENTER:
expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_HOVER_ENTER_TIS);
break;
case MotionEvent.ACTION_HOVER_EXIT:
expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_HOVER_EXIT_TIS);
break;
case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_POINTER_DOWN:
mPointerCount++; mPointerCount++;
if (gestureScope != GestureScope.OUTSIDE_WITH_PILFER
&& gestureScope != GestureScope.OUTSIDE_WITHOUT_PILFER
&& gestureScope != GestureScope.OUTSIDE_WITH_KEYCODE
&& (!isTrackpadGesture || isTwoFingerTrackpadGesture)) {
expectEvent(TestProtocol.SEQUENCE_MAIN, getTouchEventPatternWithPointerCount(
"ACTION_POINTER_DOWN", mPointerCount));
}
if (hasTIS && (isTrackpadGestureEnabled()
|| getNavigationModel() != NavigationModel.THREE_BUTTON)) {
expectEvent(TestProtocol.SEQUENCE_TIS, getTouchEventPatternTIS(
"ACTION_POINTER_DOWN", mPointerCount));
}
pointerCount = mPointerCount; pointerCount = mPointerCount;
break; break;
case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_POINTER_UP:
if (gestureScope != GestureScope.OUTSIDE_WITH_PILFER
&& gestureScope != GestureScope.OUTSIDE_WITHOUT_PILFER
&& gestureScope != GestureScope.OUTSIDE_WITH_KEYCODE
&& (!isTrackpadGesture || isTwoFingerTrackpadGesture)) {
expectEvent(TestProtocol.SEQUENCE_MAIN, getTouchEventPatternWithPointerCount(
"ACTION_POINTER_UP", mPointerCount));
}
// When the gesture is handled outside, it's cancelled within launcher. // When the gesture is handled outside, it's cancelled within launcher.
if (hasTIS && (isTrackpadGestureEnabled()
|| getNavigationModel() != NavigationModel.THREE_BUTTON)) {
if (gestureScope != GestureScope.INSIDE_TO_OUTSIDE_WITH_KEYCODE
&& gestureScope != GestureScope.OUTSIDE_WITH_KEYCODE) {
expectEvent(TestProtocol.SEQUENCE_TIS, getTouchEventPatternTIS(
"ACTION_POINTER_UP", mPointerCount));
}
}
mPointerCount--; mPointerCount--;
break; break;
case MotionEvent.ACTION_BUTTON_PRESS:
expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_BUTTON_PRESS_TIS);
break;
case MotionEvent.ACTION_BUTTON_RELEASE:
expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_BUTTON_RELEASE_TIS);
break;
} }
final MotionEvent event = isTrackpadGesture final MotionEvent event = isTrackpadGesture
@@ -1883,11 +1805,12 @@ public final class LauncherInstrumentation {
@NonNull final UiObject2 target, @NonNull String resName, Pattern longClickEvent) { @NonNull final UiObject2 target, @NonNull String resName, Pattern longClickEvent) {
final Point targetCenter = target.getVisibleCenter(); final Point targetCenter = target.getVisibleCenter();
final long downTime = SystemClock.uptimeMillis(); final long downTime = SystemClock.uptimeMillis();
sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, targetCenter, GestureScope.INSIDE); sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, targetCenter,
GestureScope.DONT_EXPECT_PILFER);
expectEvent(TestProtocol.SEQUENCE_MAIN, longClickEvent); expectEvent(TestProtocol.SEQUENCE_MAIN, longClickEvent);
final UiObject2 result = waitForLauncherObject(resName); final UiObject2 result = waitForLauncherObject(resName);
sendPointer(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, targetCenter, sendPointer(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, targetCenter,
GestureScope.INSIDE); GestureScope.DONT_EXPECT_PILFER);
return result; return result;
} }
@@ -2168,9 +2091,9 @@ public final class LauncherInstrumentation {
final long downTime = SystemClock.uptimeMillis(); final long downTime = SystemClock.uptimeMillis();
final Point tapTarget = new Point(x, y); final Point tapTarget = new Point(x, y);
sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, tapTarget, sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, tapTarget,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
sendPointer(downTime, downTime, MotionEvent.ACTION_UP, tapTarget, sendPointer(downTime, downTime, MotionEvent.ACTION_UP, tapTarget,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
} }
} }
@@ -124,7 +124,7 @@ public final class OverviewTask {
final int centerY = taskBounds.centerY(); final int centerY = taskBounds.centerY();
mLauncher.executeAndWaitForLauncherEvent( mLauncher.executeAndWaitForLauncherEvent(
() -> mLauncher.linearGesture(centerX, centerY, centerX, 0, 10, false, () -> mLauncher.linearGesture(centerX, centerY, centerX, 0, 10, false,
LauncherInstrumentation.GestureScope.INSIDE), LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER),
event -> TestProtocol.DISMISS_ANIMATION_ENDS_MESSAGE.equals(event.getClassName()), event -> TestProtocol.DISMISS_ANIMATION_ENDS_MESSAGE.equals(event.getClassName()),
() -> "Didn't receive a dismiss animation ends message: " + centerX + ", " () -> "Didn't receive a dismiss animation ends message: " + centerX + ", "
+ centerY, "swiping to dismiss"); + centerY, "swiping to dismiss");
@@ -76,13 +76,13 @@ public final class Taskbar {
mLauncher.getRealDisplaySize().x - 1, mLauncher.getRealDisplaySize().y - 1); mLauncher.getRealDisplaySize().x - 1, mLauncher.getRealDisplaySize().y - 1);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, stashTarget, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, stashTarget,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
LauncherInstrumentation.log("hideTaskbar: sent down"); LauncherInstrumentation.log("hideTaskbar: sent down");
try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("pressed down")) { try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("pressed down")) {
mLauncher.waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID); mLauncher.waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, stashTarget, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, stashTarget,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
} }
} finally { } finally {
mLauncher.getTestInfo(REQUEST_DISABLE_MANUAL_TASKBAR_STASHING); mLauncher.getTestInfo(REQUEST_DISABLE_MANUAL_TASKBAR_STASHING);
@@ -147,9 +147,9 @@ public final class Taskbar {
mLauncher.getRealDisplaySize().y - 1); mLauncher.getRealDisplaySize().y - 1);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, tapTarget, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, tapTarget,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, tapTarget, mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, tapTarget,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
} }
} }
} }
@@ -104,7 +104,8 @@ public final class Workspace extends Home {
windowCornerRadius, windowCornerRadius,
startY - swipeHeight - mLauncher.getTouchSlop(), startY - swipeHeight - mLauncher.getTouchSlop(),
12, 12,
ALL_APPS_STATE_ORDINAL, LauncherInstrumentation.GestureScope.INSIDE); ALL_APPS_STATE_ORDINAL,
LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"swiped to all apps")) { "swiped to all apps")) {
@@ -386,7 +387,7 @@ public final class Workspace extends Home {
Until.hasObject(installerAlert), LauncherInstrumentation.WAIT_TIME_MS)); Until.hasObject(installerAlert), LauncherInstrumentation.WAIT_TIME_MS));
final UiObject2 ok = device.findObject(By.text("OK")); final UiObject2 ok = device.findObject(By.text("OK"));
assertNotNull("OK button is not shown", ok); assertNotNull("OK button is not shown", ok);
launcher.clickObject(ok, LauncherInstrumentation.GestureScope.OUTSIDE_WITHOUT_PILFER); launcher.clickObject(ok);
assertTrue("Uninstall alert is not dismissed after clicking OK", device.wait( assertTrue("Uninstall alert is not dismissed after clicking OK", device.wait(
Until.gone(installerAlert), LauncherInstrumentation.WAIT_TIME_MS)); Until.gone(installerAlert), LauncherInstrumentation.WAIT_TIME_MS));
@@ -453,7 +454,7 @@ public final class Workspace extends Home {
launcher.runToState( launcher.runToState(
() -> launcher.sendPointer( () -> launcher.sendPointer(
downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest, downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest,
LauncherInstrumentation.GestureScope.INSIDE), LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER),
NORMAL_STATE_ORDINAL, NORMAL_STATE_ORDINAL,
"sending UP event"); "sending UP event");
if (expectedEvents != null) { if (expectedEvents != null) {
@@ -542,7 +543,7 @@ public final class Workspace extends Home {
executeAndWaitForPageScroll(launcher, executeAndWaitForPageScroll(launcher,
() -> launcher.movePointer(finalDragStart, screenEdge, DEFAULT_DRAG_STEPS, () -> launcher.movePointer(finalDragStart, screenEdge, DEFAULT_DRAG_STEPS,
true, downTime, downTime, true, true, downTime, downTime, true,
LauncherInstrumentation.GestureScope.INSIDE)); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER));
targetDest.x += displayX * (targetDest.x > 0 ? -1 : 1); targetDest.x += displayX * (targetDest.x > 0 ? -1 : 1);
dragStart = screenEdge; dragStart = screenEdge;
} }
@@ -551,7 +552,7 @@ public final class Workspace extends Home {
// we just have to put move the icon to the destination and drop it // we just have to put move the icon to the destination and drop it
launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, isDecelerating, launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, isDecelerating,
downTime, SystemClock.uptimeMillis(), false, downTime, SystemClock.uptimeMillis(), false,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents);
} }
} }
@@ -584,7 +585,7 @@ public final class Workspace extends Home {
// we just have to put move the icon to the destination and drop it // we just have to put move the icon to the destination and drop it
launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, isDecelerating, launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, isDecelerating,
downTime, SystemClock.uptimeMillis(), false, downTime, SystemClock.uptimeMillis(), false,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents);
} }
} }
@@ -621,7 +622,7 @@ public final class Workspace extends Home {
executeAndWaitForPageScroll(launcher, executeAndWaitForPageScroll(launcher,
() -> launcher.movePointer(finalDragStart, screenEdge, DEFAULT_DRAG_STEPS, () -> launcher.movePointer(finalDragStart, screenEdge, DEFAULT_DRAG_STEPS,
true, downTime, downTime, true, true, downTime, downTime, true,
LauncherInstrumentation.GestureScope.INSIDE)); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER));
currentPage = Workspace.geCurrentPage(launcher); currentPage = Workspace.geCurrentPage(launcher);
currentPosition = screenEdge; currentPosition = screenEdge;
} }
@@ -650,7 +651,7 @@ public final class Workspace extends Home {
launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, true, launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, true,
downTime, SystemClock.uptimeMillis(), false, downTime, SystemClock.uptimeMillis(), false,
LauncherInstrumentation.GestureScope.INSIDE); LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents); dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents);
} }