From 387fea97317d5b2a3455ee37244bd44b1921eea7 Mon Sep 17 00:00:00 2001 From: Fengjiang Li Date: Wed, 20 Dec 2023 14:19:28 -0800 Subject: [PATCH 1/2] Update TaplAddWidgetTest#testResizeWidget() and WidgetResizeFrame#resize() API to pass launcher's cellBoarderSpace and use its height to expand widget To expand widget vertically, the drag distance has to be >= 0.66 * (cellHeight + cellBoarderSpace.y). The TAPL test should add cellBoarderSpace.y onto the vertical drag distance to make test less flaky. Bug: 291104076 Test: Postsubmit passed https://android-build.corp.google.com/builds/abtd/run/L49100030001703948 Flag: NA Change-Id: I602cf29b83df6875abd8eadfe255a2adb13f03cb --- .../android/launcher3/testing/TestInformationHandler.java | 6 ++++++ .../com/android/launcher3/testing/shared/TestProtocol.java | 1 + .../com/android/launcher3/tapl/LauncherInstrumentation.java | 5 +++++ .../tapl/com/android/launcher3/tapl/WidgetResizeFrame.java | 3 ++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index ccff095c0e..8c938acbd4 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -153,6 +153,12 @@ public class TestInformationHandler implements ResourceBasedOverride { }, this::getCurrentActivity); } + case TestProtocol.REQUEST_CELL_LAYOUT_BOARDER_HEIGHT: { + response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, + mDeviceProfile.cellLayoutBorderSpacePx.y); + return response; + } + case TestProtocol.REQUEST_SYSTEM_GESTURE_REGION: { return getUIProperty(Bundle::putParcelable, activity -> { WindowInsetsCompat insets = WindowInsetsCompat.toWindowInsetsCompat( diff --git a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java index 3e188e6fb1..2f9945d17e 100644 --- a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java +++ b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java @@ -121,6 +121,7 @@ public final class TestProtocol { public static final String REQUEST_IS_TABLET = "is-tablet"; public static final String REQUEST_NUM_ALL_APPS_COLUMNS = "num-all-apps-columns"; public static final String REQUEST_IS_TWO_PANELS = "is-two-panel"; + public static final String REQUEST_CELL_LAYOUT_BOARDER_HEIGHT = "cell-layout-boarder-height"; public static final String REQUEST_START_DRAG_THRESHOLD = "start-drag-threshold"; public static final String REQUEST_SHELL_DRAG_READY = "shell-drag-ready"; public static final String REQUEST_GET_ACTIVITIES_CREATED_COUNT = diff --git a/tests/multivalentTests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/multivalentTests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index fef93b7626..6c9f5ed620 100644 --- a/tests/multivalentTests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/multivalentTests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -405,6 +405,11 @@ public final class LauncherInstrumentation { .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD); } + int getCellLayoutBoarderHeight() { + return getTestInfo(TestProtocol.REQUEST_CELL_LAYOUT_BOARDER_HEIGHT) + .getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD); + } + int getFocusedTaskHeightForTablet() { return getTestInfo(TestProtocol.REQUEST_GET_FOCUSED_TASK_HEIGHT_FOR_TABLET).getInt( TestProtocol.TEST_INFO_RESPONSE_FIELD); diff --git a/tests/multivalentTests/tapl/com/android/launcher3/tapl/WidgetResizeFrame.java b/tests/multivalentTests/tapl/com/android/launcher3/tapl/WidgetResizeFrame.java index d0573e077b..3895302794 100644 --- a/tests/multivalentTests/tapl/com/android/launcher3/tapl/WidgetResizeFrame.java +++ b/tests/multivalentTests/tapl/com/android/launcher3/tapl/WidgetResizeFrame.java @@ -57,7 +57,8 @@ public class WidgetResizeFrame { Rect originalWidgetSize = widget.getVisibleBounds(); Point targetStart = bottomResizeHandle.getVisibleCenter(); Point targetDest = bottomResizeHandle.getVisibleCenter(); - targetDest.offset(0, originalWidgetSize.height()); + targetDest.offset(0, + originalWidgetSize.height() + mLauncher.getCellLayoutBoarderHeight()); final long downTime = SystemClock.uptimeMillis(); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, targetStart, From b9ba4b98137c91fc14abe81e88edddc09ea45041 Mon Sep 17 00:00:00 2001 From: Fengjiang Li Date: Thu, 1 Feb 2024 10:57:19 -0800 Subject: [PATCH 2/2] Fix small gap between widget resize frame and widget background. There is a 1dp gap on left/top/right/bottom between widget resize frame and widget background. Increasing the margin by 1dp will fill this gap. Fix: 291104076 Test: See https://b.corp.google.com/issues/291104076#comment9 Flag: NONE Change-Id: I471c27b8b5d59850a4bf342fc2d8fee50d6fd65d --- res/values/dimens.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 603e697395..b19ee0c41f 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -56,7 +56,7 @@ 13dp 24dp - 22dp + 23dp 24dp