From 0b339b527396e86e7c478f9006bc5f63541c4c5c Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 27 Mar 2019 16:56:29 -0700 Subject: [PATCH] Adding tracing for Lab-only flake: drag to workspace doesn't happen Bug: 129434166 Change-Id: I4433a4848b57da42412a9108a0965ff13c708c39 --- src/com/android/launcher3/TestProtocol.java | 3 ++ src/com/android/launcher3/Workspace.java | 4 +++ .../launcher3/dragndrop/DragController.java | 18 ++++++++++++ .../launcher3/dragndrop/DragDriver.java | 8 ++++++ .../launcher3/dragndrop/DragLayer.java | 4 +++ .../popup/PopupContainerWithArrow.java | 4 +++ .../AbstractStateChangeTouchController.java | 16 +++++++++++ .../launcher3/touch/ItemClickHandler.java | 13 +++++++-- .../touch/ItemLongClickListener.java | 4 +++ .../launcher3/views/BaseDragLayer.java | 21 ++++++++++++++ .../launcher3/ui/TaplTestsLauncher3.java | 28 +++++++++++-------- .../com/android/launcher3/tapl/Workspace.java | 2 ++ 12 files changed, 111 insertions(+), 14 deletions(-) diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/TestProtocol.java index 4eb3627566..72b4655900 100644 --- a/src/com/android/launcher3/TestProtocol.java +++ b/src/com/android/launcher3/TestProtocol.java @@ -40,4 +40,7 @@ public final class TestProtocol { "all-apps-to-overview-swipe-height"; public static final String REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT = "home-to-all-apps-swipe-height"; + + public static boolean sDebugTracing = false; + public static final String NO_DRAG_TAG = "b/129434166"; } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index d05f916372..d24a5a619e 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1446,6 +1446,10 @@ public class Workspace extends PagedView public DragView beginDragShared(View child, DragSource source, ItemInfo dragObject, DragPreviewProvider previewProvider, DragOptions dragOptions) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "beginDragShared"); + } float iconScale = 1f; if (child instanceof BubbleTextView) { Drawable icon = ((BubbleTextView) child).getIcon(); diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index 03dc66ee2b..8b100d9d5f 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -219,6 +219,9 @@ public class DragController implements DragDriver.EventListener, TouchController } private void callOnDragStart() { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, "callOnDragStart"); + } if (mOptions.preDragCondition != null) { mOptions.preDragCondition.onPreDragEnd(mDragObject, true /* dragStarted*/); } @@ -472,6 +475,9 @@ public class DragController implements DragDriver.EventListener, TouchController } private void handleMoveEvent(int x, int y) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, "handleMoveEvent1"); + } mDragObject.dragView.move(x, y); // Drop on someone? @@ -488,6 +494,10 @@ public class DragController implements DragDriver.EventListener, TouchController if (mIsInPreDrag && mOptions.preDragCondition != null && mOptions.preDragCondition.shouldStartDrag(mDistanceSinceScroll)) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "handleMoveEvent2"); + } callOnDragStart(); } } @@ -525,6 +535,10 @@ public class DragController implements DragDriver.EventListener, TouchController * Call this from a drag source view. */ public boolean onControllerTouchEvent(MotionEvent ev) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "onControllerTouchEvent1"); + } if (mDragDriver == null || mOptions == null || mOptions.isAccessibleDrag) { return false; } @@ -545,6 +559,10 @@ public class DragController implements DragDriver.EventListener, TouchController break; } + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "onControllerTouchEvent2"); + } return mDragDriver.onTouchEvent(ev); } diff --git a/src/com/android/launcher3/dragndrop/DragDriver.java b/src/com/android/launcher3/dragndrop/DragDriver.java index 84fc94dd25..551f2d0fc8 100644 --- a/src/com/android/launcher3/dragndrop/DragDriver.java +++ b/src/com/android/launcher3/dragndrop/DragDriver.java @@ -45,10 +45,18 @@ public abstract class DragDriver { public void onDragViewAnimationEnd() { } public boolean onTouchEvent(MotionEvent ev) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "onTouchEvent " + ev); + } final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_MOVE: + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "onTouchEvent MOVE"); + } mEventListener.onDriverDragMove(ev.getX(), ev.getY()); break; case MotionEvent.ACTION_UP: diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java index 6950a1fad6..9f902ed1b4 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -126,6 +126,10 @@ public class DragLayer extends BaseDragLayer { protected boolean findActiveController(MotionEvent ev) { if (mActivity.getStateManager().getState().disableInteraction) { // You Shall Not Pass!!! + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "mActiveController = null"); + } mActiveController = null; return true; } diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index 10ecc4f04d..080a0cb695 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -187,6 +187,10 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource, * @return the container if shown or null. */ public static PopupContainerWithArrow showForIcon(BubbleTextView icon) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "PopupContainerWithArrow.showForIcon"); + } Launcher launcher = Launcher.getLauncher(icon.getContext()); if (getOpen(launcher) != null) { // There is already an items container open, so don't open this one. diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java index c125c10d7a..ca32330c37 100644 --- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java +++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java @@ -229,6 +229,11 @@ public abstract class AbstractStateChangeTouchController @Override public void onDragStart(boolean start) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "AbstractStateChangeTouchController.onDragStart() called with: start = [" + + start + "]"); + } mStartState = mLauncher.getStateManager().getState(); if (mStartState == ALL_APPS) { mStartContainerType = LauncherLogProto.ContainerType.ALLAPPS; @@ -260,6 +265,11 @@ public abstract class AbstractStateChangeTouchController public boolean onDrag(float displacement) { float deltaProgress = mProgressMultiplier * (displacement - mDisplacementShift); float progress = deltaProgress + mStartProgress; + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "AbstractStateChangeTouchController.onDrag() called with: displacement = [" + + displacement + "], progress = [" + progress + "]"); + } updateProgress(progress); boolean isDragTowardPositive = (displacement - mDisplacementShift) < 0; if (progress <= 0) { @@ -384,6 +394,12 @@ public abstract class AbstractStateChangeTouchController ? MIN_PROGRESS_TO_ALL_APPS : SUCCESS_TRANSITION_PROGRESS; targetState = (interpolatedProgress > successProgress) ? mToState : mFromState; } + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "AbstractStateChangeTouchController.onDragEnd() called with: velocity = [" + + velocity + "], fling = [" + fling + "], target state: " + + targetState.getClass().getSimpleName()); + } final float endProgress; final float startProgress; diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java index 3639090021..3c77860b3f 100644 --- a/src/com/android/launcher3/touch/ItemClickHandler.java +++ b/src/com/android/launcher3/touch/ItemClickHandler.java @@ -23,7 +23,6 @@ import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_SUSPENDED; import static com.android.launcher3.Launcher.REQUEST_BIND_PENDING_APPWIDGET; import static com.android.launcher3.Launcher.REQUEST_RECONFIGURE_APPWIDGET; import static com.android.launcher3.model.AppLaunchTracker.CONTAINER_ALL_APPS; -import static com.android.launcher3.model.AppLaunchTracker.CONTAINER_DEFAULT; import android.app.AlertDialog; import android.content.Intent; @@ -33,6 +32,8 @@ import android.view.View; import android.view.View.OnClickListener; import android.widget.Toast; +import androidx.annotation.Nullable; + import com.android.launcher3.AppInfo; import com.android.launcher3.BubbleTextView; import com.android.launcher3.FolderInfo; @@ -50,8 +51,6 @@ import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.widget.PendingAppWidgetHostView; import com.android.launcher3.widget.WidgetAddFlowHandler; -import androidx.annotation.Nullable; - /** * Class for handling clicks on workspace and all-apps items */ @@ -67,6 +66,14 @@ public class ItemClickHandler { } private static void onClick(View v, String sourceContainer) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "onClick() called with: v = [" + v.getClass().getSimpleName() + + "], sourceContainer = [" + + (sourceContainer != null ? + sourceContainer.getClass().getSimpleName() : "null") + + "]"); + } // Make sure that rogue clicks don't get through while allapps is launching, or after the // view has detached (it's possible for this to happen if the view is removed mid touch). if (v.getWindowToken() == null) { diff --git a/src/com/android/launcher3/touch/ItemLongClickListener.java b/src/com/android/launcher3/touch/ItemLongClickListener.java index babbcdd16f..003b442776 100644 --- a/src/com/android/launcher3/touch/ItemLongClickListener.java +++ b/src/com/android/launcher3/touch/ItemLongClickListener.java @@ -74,6 +74,10 @@ public class ItemLongClickListener { } private static boolean onAllAppsItemLongClick(View v) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "onAllAppsItemLongClick"); + } Launcher launcher = Launcher.getLauncher(v.getContext()); if (!canStartDrag(launcher)) return false; // When we have exited all apps or are in transition, disregard long clicks diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java index 4545a1ee7c..bd6bfd6850 100644 --- a/src/com/android/launcher3/views/BaseDragLayer.java +++ b/src/com/android/launcher3/views/BaseDragLayer.java @@ -114,16 +114,28 @@ public abstract class BaseDragLayer } protected boolean findActiveController(MotionEvent ev) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "mActiveController = null"); + } mActiveController = null; AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mActivity); if (topView != null && topView.onControllerInterceptTouchEvent(ev)) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "setting controller1: " + topView.getClass().getSimpleName()); + } mActiveController = topView; return true; } for (TouchController controller : mControllers) { if (controller.onControllerInterceptTouchEvent(ev)) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "setting controller1: " + controller.getClass().getSimpleName()); + } mActiveController = controller; return true; } @@ -193,8 +205,17 @@ public abstract class BaseDragLayer } if (mActiveController != null) { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "BaseDragLayer before onControllerTouchEvent " + + mActiveController.getClass().getSimpleName()); + } return mActiveController.onControllerTouchEvent(ev); } else { + if (com.android.launcher3.TestProtocol.sDebugTracing) { + android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, + "BaseDragLayer no controller"); + } // In case no child view handled the touch event, we may not get onIntercept anymore return findActiveController(ev); } diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java index 6f2f280d12..91ebd9beae 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java @@ -34,6 +34,7 @@ import androidx.test.uiautomator.UiDevice; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; +import com.android.launcher3.TestProtocol; import com.android.launcher3.popup.ArrowPopup; import com.android.launcher3.tapl.AllApps; import com.android.launcher3.tapl.AppIcon; @@ -327,18 +328,23 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { @Test @PortraitLandscape public void testDragAppIcon() throws Throwable { - LauncherActivityInfo settingsApp = getSettingsApp(); + try { + TestProtocol.sDebugTracing = true; + LauncherActivityInfo settingsApp = getSettingsApp(); - final String appName = settingsApp.getLabel().toString(); - // 1. Open all apps and wait for load complete. - // 2. Drag icon to homescreen. - // 3. Verify that the icon works on homescreen. - mLauncher.getWorkspace(). - switchToAllApps(). - getAppIcon(appName). - dragToWorkspace(). - getWorkspaceAppIcon(appName). - launch(settingsApp.getComponentName().getPackageName()); + final String appName = settingsApp.getLabel().toString(); + // 1. Open all apps and wait for load complete. + // 2. Drag icon to homescreen. + // 3. Verify that the icon works on homescreen. + mLauncher.getWorkspace(). + switchToAllApps(). + getAppIcon(appName). + dragToWorkspace(). + getWorkspaceAppIcon(appName). + launch(settingsApp.getComponentName().getPackageName()); + } finally { + TestProtocol.sDebugTracing = false; + } } @Test diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index 9979f50a6d..22b5564663 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -136,7 +136,9 @@ public final class Workspace extends Home { static void dragIconToWorkspace(LauncherInstrumentation launcher, Launchable launchable, Point dest, int icon_drag_speed) { + LauncherInstrumentation.log("dragIconToWorkspace: begin"); launchable.getObject().drag(dest, icon_drag_speed); + LauncherInstrumentation.log("dragIconToWorkspace: end"); launcher.waitUntilGone("drop_target_bar"); }