From 9764250b60a6f44fc78b3d87f7748eb419cc85de Mon Sep 17 00:00:00 2001 From: mpodolian Date: Fri, 21 Mar 2025 11:13:13 -0700 Subject: [PATCH] Launcher TAPL test for dragging task bar icon to the bubble bar. Added a test and TAPL objects to check dragging taskbar icons to the bubble bar. Fixes: 388910897 Test: TaplTestTaskBarIconDrag Flag: EXEMPT test Change-Id: I8a3e64a83c72a9f6b89b2f8a875ca6565d501701 --- .../taskbar/bubbles/BubbleDismissViewExt.kt | 5 +- .../taskbar/bubbles/BubbleDragController.java | 8 +- .../QuickstepTestInformationHandler.java | 10 ++ .../quickstep/TaplTestTaskbarIconDrag.kt | 92 +++++++++++ .../testing/shared/TestProtocol.java | 3 + .../android/launcher3/tapl/BaseOverview.java | 16 +- .../com/android/launcher3/tapl/BubbleBar.kt | 148 ++++++++++++++++++ .../launcher3/tapl/BubbleBarDragSource.java | 117 ++++++++++++++ .../launcher3/tapl/LaunchedAppState.java | 22 ++- .../tapl/LauncherInstrumentation.java | 11 ++ .../tapl/SearchResultFromTaskbarQsb.java | 8 +- .../com/android/launcher3/tapl/Taskbar.java | 18 ++- .../launcher3/tapl/TaskbarAllApps.java | 10 +- .../launcher3/tapl/TaskbarAllAppsQsb.java | 8 +- .../launcher3/tapl/TaskbarAppIcon.java | 16 +- 15 files changed, 465 insertions(+), 27 deletions(-) create mode 100644 quickstep/tests/src/com/android/quickstep/TaplTestTaskbarIconDrag.kt create mode 100644 tests/tapl/com/android/launcher3/tapl/BubbleBar.kt create mode 100644 tests/tapl/com/android/launcher3/tapl/BubbleBarDragSource.java diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDismissViewExt.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDismissViewExt.kt index 9f7802fe0e..bd6f2c9168 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDismissViewExt.kt +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDismissViewExt.kt @@ -18,7 +18,6 @@ package com.android.launcher3.taskbar.bubbles import com.android.launcher3.R -import com.android.wm.shell.shared.R as SharedR import com.android.wm.shell.shared.bubbles.DismissView /** @@ -37,8 +36,8 @@ fun DismissView.setup() { bottomMarginResId = R.dimen.bubblebar_dismiss_target_bottom_margin, floatingGradientHeightResId = R.dimen.bubblebar_dismiss_floating_gradient_height, floatingGradientColorResId = android.R.color.system_neutral1_900, - backgroundResId = SharedR.drawable.floating_dismiss_background, - iconResId = SharedR.drawable.floating_dismiss_ic_close, + backgroundResId = R.drawable.floating_dismiss_background, + iconResId = R.drawable.floating_dismiss_ic_close, applyMarginOverNavBarInset = false, ) ) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java index 0c33916cb2..41686deeee 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java @@ -674,7 +674,7 @@ public class BubbleDragController { } @Override - public void onInitialDragZoneSet(@NonNull DragZone dragZone) { + public void onInitialDragZoneSet(@Nullable DragZone dragZone) { mDragZone = dragZone; if (dragZone instanceof DragZone.Bubble.Left) { mBubbleBarLocation = BubbleBarLocation.LEFT; @@ -684,8 +684,8 @@ public class BubbleDragController { } @Override - public void onDragZoneChanged(@NonNull DraggedObject draggedObject, @NonNull DragZone from, - @NonNull DragZone to) { + public void onDragZoneChanged(@NonNull DraggedObject draggedObject, @Nullable DragZone from, + @Nullable DragZone to) { mDragZone = to; if (to instanceof DragZone.Bubble.Left && mBubbleBarLocation != BubbleBarLocation.LEFT) { @@ -703,6 +703,6 @@ public class BubbleDragController { } @Override - public void onDragEnded(@NonNull DragZone zone) {} + public void onDragEnded(@Nullable DragZone zone) {} } } diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java index d80c05b99e..30124de12f 100644 --- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -12,6 +12,7 @@ import android.view.WindowInsets; import androidx.annotation.Nullable; +import com.android.launcher3.R; import com.android.launcher3.taskbar.TaskbarActivityContext; import com.android.launcher3.testing.TestInformationHandler; import com.android.launcher3.testing.shared.TestProtocol; @@ -22,6 +23,7 @@ import com.android.quickstep.util.TISBindHelper; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.RecentsViewContainer; import com.android.systemui.shared.recents.model.Task; +import com.android.wm.shell.shared.bubbles.DeviceConfig; import java.util.ArrayList; import java.util.concurrent.CountDownLatch; @@ -99,6 +101,14 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { return response; } + case TestProtocol.REQUEST_GET_BUBBLE_BAR_DROP_TARGET_SIZE: { + int dimenResId = DeviceConfig.isSmallTablet(mContext) + ? R.dimen.drag_zone_bubble_fold : R.dimen.drag_zone_bubble_tablet; + response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, + mContext.getResources().getDimensionPixelSize(dimenResId)); + return response; + } + case TestProtocol.REQUEST_GET_OVERVIEW_CURRENT_PAGE_INDEX: { return getLauncherUIProperty(Bundle::putInt, launcher -> launcher.getOverviewPanel().getCurrentPage()); diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestTaskbarIconDrag.kt b/quickstep/tests/src/com/android/quickstep/TaplTestTaskbarIconDrag.kt new file mode 100644 index 0000000000..a56c82d64f --- /dev/null +++ b/quickstep/tests/src/com/android/quickstep/TaplTestTaskbarIconDrag.kt @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.quickstep + +import android.platform.test.annotations.RequiresFlagsEnabled +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.LargeTest +import com.android.launcher3.tapl.BubbleBar +import com.android.launcher3.util.LauncherLayoutBuilder +import com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME +import com.android.launcher3.util.TestUtil +import com.android.wm.shell.Flags +import org.junit.After +import org.junit.Assume +import org.junit.Test +import org.junit.runner.RunWith + +@LargeTest +@RunWith(AndroidJUnit4::class) +@RequiresFlagsEnabled(Flags.FLAG_ENABLE_BUBBLE_ANYTHING) +class TaplTestTaskbarIconDrag : AbstractQuickStepTest() { + + private var mLauncherLayout: AutoCloseable? = null + + override fun setUp() { + Assume.assumeTrue(mLauncher.isTablet) + super.setUp() + val layoutBuilder = + LauncherLayoutBuilder() + .atHotseat(0) + .putApp( + "com.google.android.apps.nexuslauncher.tests", + "com.android.launcher3.testcomponent.BaseTestingActivity", + ) + mLauncherLayout = TestUtil.setLauncherDefaultLayout(mTargetContext, layoutBuilder) + performInitialization() + mLauncher.enableBlockTimeout(true) + } + + @After + fun tearDown() { + mLauncher.enableBlockTimeout(false) + mLauncherLayout?.close() + } + + @Test + fun testAppIconDragOnOverviewFromTaskBarToBubbleBar() { + val overview = mLauncher.workspace.switchToOverview() + // test left drop target + overview.taskbar!! + .getAppIcon(TEST_APP_NAME) + .dragToBubbleBarLocation(/* isBubbleBarLeftDropTarget= */ true) + dismissExpandedBubbleBar(overview.bubbleBar) + } + + @Test + fun testAppIconDragInRunningAppFromTaskBarToBubbleBar() { + startAppFast(AbstractTaplTestsTaskbar.CALCULATOR_APP_PACKAGE) + val launchedAppState = mLauncher.launchedAppState + mLauncher.showTaskbarIfHidden() + // test right drop target + launchedAppState.taskbar + .getAppIcon(TEST_APP_NAME) + .dragToBubbleBarLocation(/* isBubbleBarLeftDropTarget= */ false) + // close expanded bubble + dismissExpandedBubbleBar(launchedAppState.bubbleBar) + } + + private fun dismissExpandedBubbleBar(bubbleBar: BubbleBar) { + // close expanded bubble bar + mLauncher.pressBack() + bubbleBar.verifyCollapsed() + // at this moment the bubble bar will be hidden, so need to show it again + mLauncher.showBubbleBarIfHidden() + // dismiss bubble bar + bubbleBar.dragToDismiss() + } +} diff --git a/shared/src/com/android/launcher3/testing/shared/TestProtocol.java b/shared/src/com/android/launcher3/testing/shared/TestProtocol.java index cdeab954fd..7c2c26eedd 100644 --- a/shared/src/com/android/launcher3/testing/shared/TestProtocol.java +++ b/shared/src/com/android/launcher3/testing/shared/TestProtocol.java @@ -154,6 +154,9 @@ public final class TestProtocol { public static final String REQUEST_GET_OVERVIEW_TASK_SIZE = "get-overivew-task-size"; public static final String REQUEST_GET_OVERVIEW_GRID_TASK_SIZE = "get-overivew-grid-task-size"; public static final String REQUEST_GET_OVERVIEW_PAGE_SPACING = "get-overview-page-spacing"; + + public static final String REQUEST_GET_BUBBLE_BAR_DROP_TARGET_SIZE = + "request-get-bubble-bar-drop-target-size"; public static final String REQUEST_GET_OVERVIEW_CURRENT_PAGE_INDEX = "get-overview-current-page-index"; public static final String REQUEST_GET_SPLIT_SELECTION_ACTIVE = "get-split-selection-active"; diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java index 214f1587f5..cdd8cb1ea1 100644 --- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java +++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java @@ -35,6 +35,7 @@ import androidx.test.uiautomator.BySelector; import androidx.test.uiautomator.Direction; import androidx.test.uiautomator.UiObject2; +import com.android.launcher3.tapl.Taskbar.TaskbarLocation; import com.android.launcher3.testing.shared.TestProtocol; import java.util.Collection; @@ -249,7 +250,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { */ public void touchTaskbarBottomCorner(boolean tapRight) { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { - Taskbar taskbar = new Taskbar(mLauncher); + Taskbar taskbar = new Taskbar(mLauncher, TaskbarLocation.OVERVIEW); if (mLauncher.isTransientTaskbar()) { mLauncher.runToState( () -> taskbar.touchBottomCorner(tapRight), @@ -430,7 +431,18 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { "want to get the taskbar")) { mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID); - return new Taskbar(mLauncher); + return new Taskbar(mLauncher, TaskbarLocation.OVERVIEW); + } + } + + /** + * Returns the bubble bar. + * The bubble bar must already be visible when calling this method. + */ + public BubbleBar getBubbleBar() { + try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( + "want to get the bubble bar")) { + return new BubbleBar(mLauncher); } } diff --git a/tests/tapl/com/android/launcher3/tapl/BubbleBar.kt b/tests/tapl/com/android/launcher3/tapl/BubbleBar.kt new file mode 100644 index 0000000000..e1ee31d4cb --- /dev/null +++ b/tests/tapl/com/android/launcher3/tapl/BubbleBar.kt @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.tapl + +import android.os.SystemClock +import android.view.MotionEvent +import androidx.test.uiautomator.UiObject2 +import org.junit.Assert + +/** + * **THE BubbleBar CONSTRUCTOR IS NOT INTENDED TO BE USED FROM TESTS** + * + * Provides an API for interacting with the bubble bar within launcher automation tests tests. + * + * Note that this class does not represent the state of the bubble bar being stashed. + */ +class BubbleBar(private val mLauncher: LauncherInstrumentation) { + + private val bubbleBarViewSelector = mLauncher.getLauncherObjectSelector(RES_ID_NAME_BUBBLE_BAR) + private val dismissViewSelector = mLauncher.getLauncherObjectSelector(RES_ID_NAME_DISMISS_VIEW) + + init { + Assert.assertFalse(bubbles.isEmpty()) + } + + /** + * Returns the selected bubble in the bubble bar. + * + * Bubbles in the collapsed bubble bar are reversed. The selected bubble is the last bubble in + * the view hierarchy. + */ + private val selectedBubble: UiObject2 + get() = bubbles.last() + + /** + * Returns all the bubbles in the bubble bar. + * + * Note that the overflow bubble is not included in the result because it is never visible when + * the bubble bar is collapsed. + */ + private val bubbles: List + get() = mLauncher.waitForLauncherObject(bubbleBarViewSelector).children + + /** Collapse the bubble bar if it is expanded */ + fun collapse() { + mLauncher.eventsCheck().use { + verifyExpanded { + mLauncher.waitForSystemUiObject(RES_ID_EXPANDED_VIEW) + mLauncher.addContextLayer("Clicked to collapse bubble bar").use { + selectedBubble.click() + verifyCollapsed() + } + } + } + } + + /** Expands the bubble bar if it is collapsed */ + fun expand() { + mLauncher.eventsCheck().use { + verifyCollapsed { + mLauncher.addContextLayer("Expand bubble bar").use { + mLauncher.waitForLauncherObject(bubbleBarViewSelector).click() + verifyExpanded() + } + } + } + } + + /** Verifies that the bubble bar is collapsed. */ + fun verifyCollapsed(furtherChecks: (() -> Unit)? = null) { + mLauncher.addContextLayer("Check bubble bar expanded view is gone").use { + mLauncher.waitUntilSystemUiObjectGone(RES_ID_EXPANDED_VIEW) + furtherChecks?.invoke() + } + } + + /** Verifies that the bubble bar is expanded. */ + fun verifyExpanded(furtherChecks: (() -> Unit)? = null) { + mLauncher.addContextLayer("Check bubble bar expanded view is visible").use { + mLauncher.waitForSystemUiObject(RES_ID_EXPANDED_VIEW) + furtherChecks?.invoke() + } + } + + /** + * Drags the bubble bar to the dismiss target. At the end of the gesture the bubble bar will be + * gone. + */ + fun dragToDismiss() { + mLauncher.eventsCheck().use { + mLauncher.addContextLayer("Bubble bar dragToDismiss").use { + val downTime = SystemClock.uptimeMillis() + val dragStart = mLauncher.waitForLauncherObject(bubbleBarViewSelector).visibleCenter + mLauncher.sendPointer( + downTime, + downTime, + MotionEvent.ACTION_DOWN, + dragStart, + LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER, + ) + val endPoint = mLauncher.waitForLauncherObject(dismissViewSelector).visibleCenter + + mLauncher.movePointer( + dragStart, + endPoint, + LaunchedAppState.DEFAULT_DRAG_STEPS, + /* isDecelerating= */ true, + downTime, + SystemClock.uptimeMillis(), + /* slowDown= */ false, + LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER, + ) + + mLauncher.sendPointer( + downTime, + SystemClock.uptimeMillis(), + MotionEvent.ACTION_UP, + endPoint, + LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER, + ) + + mLauncher.addContextLayer("Wait until bubble bar is gone").use { + mLauncher.waitUntilLauncherObjectGone(bubbleBarViewSelector) + } + } + } + } + + companion object { + const val RES_ID_NAME_BUBBLE_BAR = "taskbar_bubbles" + const val RES_ID_NAME_DISMISS_VIEW = "dismiss_view" + const val RES_ID_EXPANDED_VIEW = "bubble_expanded_view" + } +} diff --git a/tests/tapl/com/android/launcher3/tapl/BubbleBarDragSource.java b/tests/tapl/com/android/launcher3/tapl/BubbleBarDragSource.java new file mode 100644 index 0000000000..1245513d4f --- /dev/null +++ b/tests/tapl/com/android/launcher3/tapl/BubbleBarDragSource.java @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.tapl; + +import static com.android.launcher3.tapl.LaunchedAppState.DEFAULT_DRAG_STEPS; +import static com.android.launcher3.tapl.LauncherInstrumentation.DEFAULT_POLL_INTERVAL; +import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS; +import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_SHELL_DRAG_READY; + +import android.graphics.Point; +import android.graphics.Rect; +import android.os.SystemClock; +import android.view.MotionEvent; + +import com.android.launcher3.tapl.Taskbar.TaskbarLocation; +import com.android.launcher3.testing.shared.TestProtocol; + +/** {@link Launchable} that can serve as a source for dragging and dropping to the bubble bar. */ +public interface BubbleBarDragSource { + + /** + * Drags this app icon to the provided bubble bar location drop zone. + */ + default void dragToBubbleBarLocation(boolean isBubbleBarLeftDropTarget) { + Launchable launchable = getLaunchable(); + LauncherInstrumentation launcher = launchable.mLauncher; + int bubbleBarDropTargetHalfSize = launcher.getBubbleBarDropTargetSize() / 2; + final Point displaySize = launcher.getRealDisplaySize(); + int endX = isBubbleBarLeftDropTarget ? bubbleBarDropTargetHalfSize + : displaySize.x - bubbleBarDropTargetHalfSize; + final Point endPoint = new Point(endX, displaySize.y - bubbleBarDropTargetHalfSize); + dragToPoint(launcher, launchable, endPoint, + /* waitForShell = */ getTaskbarLocation() == TaskbarLocation.LAUNCHED_APP); + } + + private static void dragToPoint( + LauncherInstrumentation launcher, + Launchable launchable, + Point endPoint, + boolean waitForShell + ) { + try (LauncherInstrumentation.Closable e = launcher.eventsCheck()) { + try (LauncherInstrumentation.Closable c1 = launcher.addContextLayer( + "want to drag taskbar item to point: " + endPoint)) { + final long downTime = SystemClock.uptimeMillis(); + Point itemVisibleCenter = launchable.mObject.getVisibleCenter(); + Rect itemVisibleBounds = launcher.getVisibleBounds(launchable.mObject); + Point dragStart = launchable.startDrag( + downTime, + launchable::addExpectedEventsForLongClick, + /* runToSpringLoadedState= */ false); + try (LauncherInstrumentation.Closable c2 = launcher.addContextLayer( + "started item drag")) { + if (waitForShell) { + launcher.assertTrue("Shell drag not marked as ready", + launcher.waitAndGet(() -> { + LauncherInstrumentation.log("Checking shell drag ready"); + return launcher.getTestInfo(REQUEST_SHELL_DRAG_READY) + .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, + false); + }, WAIT_TIME_MS, DEFAULT_POLL_INTERVAL)); + } + launcher.movePointer( + dragStart, + endPoint, + DEFAULT_DRAG_STEPS, + /* isDecelerating= */ true, + downTime, + SystemClock.uptimeMillis(), + /* slowDown= */ false, + LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); + try (LauncherInstrumentation.Closable c3 = launcher.addContextLayer( + "perform drop")) { + LauncherInstrumentation.log("BubbleBarDragSource.dragToPoint: " + + "before drop " + itemVisibleCenter + " in " + itemVisibleBounds); + launcher.sendPointer( + downTime, + SystemClock.uptimeMillis(), + MotionEvent.ACTION_UP, + endPoint, + LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER); + try (LauncherInstrumentation.Closable c4 = launcher.addContextLayer( + "BubbleBar should appear")) { + new BubbleBar(launcher); + } + } + } + } + } + } + + /** + * NOT INTENDED TO BE USED FROM TESTS
+ * Returns the taskbar location + */ + TaskbarLocation getTaskbarLocation(); + + /** + * NOT INTENDED TO BE USED FROM TESTS
+ * This method requires public access, however should not be called in tests. + */ + Launchable getLaunchable(); +} diff --git a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java index b3ad930659..3e4cf80941 100644 --- a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java +++ b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java @@ -37,6 +37,7 @@ import androidx.annotation.NonNull; import androidx.test.uiautomator.Condition; import androidx.test.uiautomator.UiDevice; +import com.android.launcher3.tapl.Taskbar.TaskbarLocation; import com.android.launcher3.testing.shared.ResourceUtils; import com.android.launcher3.testing.shared.TestProtocol; @@ -46,7 +47,7 @@ import com.android.launcher3.testing.shared.TestProtocol; public final class LaunchedAppState extends Background { // More drag steps than Launchables to give the window manager time to register the drag. - private static final int DEFAULT_DRAG_STEPS = 35; + static final int DEFAULT_DRAG_STEPS = 35; // UNSTASHED_TASKBAR_HANDLE_HINT_SCALE value from TaskbarStashController. private static final float UNSTASHED_TASKBAR_HANDLE_HINT_SCALE = 1.1f; @@ -98,7 +99,18 @@ public final class LaunchedAppState extends Background { public Taskbar getTaskbar() { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to get the taskbar")) { - return new Taskbar(mLauncher); + return new Taskbar(mLauncher, TaskbarLocation.LAUNCHED_APP); + } + } + + /** + * Returns the bubble bar. + * The bubble bar must already be visible when calling this method. + */ + public BubbleBar getBubbleBar() { + try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( + "want to get the bubble bar")) { + return new BubbleBar(mLauncher); } } @@ -152,7 +164,7 @@ public final class LaunchedAppState extends Background { "swiping"); LauncherInstrumentation.log("swipeUpToUnstashTaskbar: sent linear swipe up gesture"); - return new Taskbar(mLauncher); + return new Taskbar(mLauncher, TaskbarLocation.LAUNCHED_APP); } finally { mLauncher.getTestInfo(REQUEST_DISABLE_BLOCK_TIMEOUT); } @@ -247,7 +259,7 @@ public final class LaunchedAppState extends Background { new Point(taskbarUnstashArea.x, taskbarUnstashArea.y), null, InputDevice.SOURCE_MOUSE); - return new Taskbar(mLauncher); + return new Taskbar(mLauncher, TaskbarLocation.LAUNCHED_APP); } } @@ -278,7 +290,7 @@ public final class LaunchedAppState extends Background { InputDevice.SOURCE_MOUSE); mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID); - return new Taskbar(mLauncher); + return new Taskbar(mLauncher, TaskbarLocation.LAUNCHED_APP); } } } diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 6f2e8efb86..56ee7b3f0a 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -443,6 +443,11 @@ public final class LauncherInstrumentation { .getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD); } + int getBubbleBarDropTargetSize() { + return getTestInfo(TestProtocol.REQUEST_GET_BUBBLE_BAR_DROP_TARGET_SIZE) + .getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD); + } + public int getOverviewCurrentPageIndex() { return getTestInfo(TestProtocol.REQUEST_GET_OVERVIEW_CURRENT_PAGE_INDEX) .getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD); @@ -1441,6 +1446,12 @@ public final class LauncherInstrumentation { return object; } + void waitUntilSystemUiObjectGone(String resId) { + BySelector systemObjectSelector = By.res(SYSTEMUI_PACKAGE, resId); + assertTrue("Unexpected system object visible: " + systemObjectSelector, + mDevice.wait(Until.gone(systemObjectSelector), WAIT_TIME_MS)); + } + @NonNull private UiObject2 getHomeButton() { UiModeManager uiManager = diff --git a/tests/tapl/com/android/launcher3/tapl/SearchResultFromTaskbarQsb.java b/tests/tapl/com/android/launcher3/tapl/SearchResultFromTaskbarQsb.java index f4b4a91744..5e157dd733 100644 --- a/tests/tapl/com/android/launcher3/tapl/SearchResultFromTaskbarQsb.java +++ b/tests/tapl/com/android/launcher3/tapl/SearchResultFromTaskbarQsb.java @@ -22,8 +22,12 @@ import androidx.test.uiautomator.UiObject2; */ public class SearchResultFromTaskbarQsb extends SearchResultFromQsb { - SearchResultFromTaskbarQsb(LauncherInstrumentation launcher) { + private final Taskbar.TaskbarLocation mTaskbarLocation; + + SearchResultFromTaskbarQsb(LauncherInstrumentation launcher, + Taskbar.TaskbarLocation taskbarLocation) { super(launcher); + mTaskbarLocation = taskbarLocation; } @Override @@ -33,7 +37,7 @@ public class SearchResultFromTaskbarQsb extends SearchResultFromQsb { @Override protected TaskbarAppIcon createAppIcon(UiObject2 icon) { - return new TaskbarAppIcon(mLauncher, icon); + return new TaskbarAppIcon(mLauncher, icon, mTaskbarLocation); } @Override diff --git a/tests/tapl/com/android/launcher3/tapl/Taskbar.java b/tests/tapl/com/android/launcher3/tapl/Taskbar.java index d4e6d3114b..ef04f0b751 100644 --- a/tests/tapl/com/android/launcher3/tapl/Taskbar.java +++ b/tests/tapl/com/android/launcher3/tapl/Taskbar.java @@ -41,10 +41,20 @@ import java.util.stream.Collectors; */ public final class Taskbar { - private final LauncherInstrumentation mLauncher; + /** The TaskbarLocation */ + enum TaskbarLocation { + /** Launched application. */ + LAUNCHED_APP, + /** Overview screen with recent apps. */ + OVERVIEW, + } - Taskbar(LauncherInstrumentation launcher) { + private final LauncherInstrumentation mLauncher; + private final TaskbarLocation mTaskbarLocation; + + Taskbar(LauncherInstrumentation launcher, TaskbarLocation taskbarLocation) { mLauncher = launcher; + mTaskbarLocation = taskbarLocation; try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "expect new taskbar to be visible")) { mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID); @@ -65,7 +75,7 @@ public final class Taskbar { "want to get a taskbar icon")) { return new TaskbarAppIcon(mLauncher, mLauncher.waitForObjectInContainer( mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID), - AppIcon.getAppIconSelector(appName, mLauncher))); + AppIcon.getAppIconSelector(appName, mLauncher)), mTaskbarLocation); } } @@ -147,7 +157,7 @@ public final class Taskbar { public TaskbarAllApps getAllApps() { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to get taskbar all apps object")) { - return new TaskbarAllApps(mLauncher); + return new TaskbarAllApps(mLauncher, mTaskbarLocation); } } diff --git a/tests/tapl/com/android/launcher3/tapl/TaskbarAllApps.java b/tests/tapl/com/android/launcher3/tapl/TaskbarAllApps.java index 3d39041124..d0839da5c2 100644 --- a/tests/tapl/com/android/launcher3/tapl/TaskbarAllApps.java +++ b/tests/tapl/com/android/launcher3/tapl/TaskbarAllApps.java @@ -18,6 +18,7 @@ package com.android.launcher3.tapl; import androidx.annotation.NonNull; import androidx.test.uiautomator.UiObject2; +import com.android.launcher3.tapl.Taskbar.TaskbarLocation; import com.android.launcher3.testing.shared.TestProtocol; /** @@ -25,8 +26,11 @@ import com.android.launcher3.testing.shared.TestProtocol; */ public class TaskbarAllApps extends AllApps { - TaskbarAllApps(LauncherInstrumentation launcher) { + private final TaskbarLocation mTaskbarLocation; + + TaskbarAllApps(LauncherInstrumentation launcher, TaskbarLocation taskbarLocation) { super(launcher); + mTaskbarLocation = taskbarLocation; } @Override @@ -43,7 +47,7 @@ public class TaskbarAllApps extends AllApps { @NonNull @Override protected TaskbarAppIcon createAppIcon(UiObject2 icon) { - return new TaskbarAppIcon(mLauncher, icon); + return new TaskbarAppIcon(mLauncher, icon, mTaskbarLocation); } @Override @@ -66,7 +70,7 @@ public class TaskbarAllApps extends AllApps { @NonNull @Override public TaskbarAllAppsQsb getQsb() { - return new TaskbarAllAppsQsb(mLauncher, verifyActiveContainer()); + return new TaskbarAllAppsQsb(mLauncher, verifyActiveContainer(), mTaskbarLocation); } @Override diff --git a/tests/tapl/com/android/launcher3/tapl/TaskbarAllAppsQsb.java b/tests/tapl/com/android/launcher3/tapl/TaskbarAllAppsQsb.java index 7cecd3e553..c893bf0e5d 100644 --- a/tests/tapl/com/android/launcher3/tapl/TaskbarAllAppsQsb.java +++ b/tests/tapl/com/android/launcher3/tapl/TaskbarAllAppsQsb.java @@ -22,8 +22,12 @@ import androidx.test.uiautomator.UiObject2; */ public class TaskbarAllAppsQsb extends Qsb { - TaskbarAllAppsQsb(LauncherInstrumentation launcher, UiObject2 allAppsContainer) { + private final Taskbar.TaskbarLocation mTaskbarLocation; + + TaskbarAllAppsQsb(LauncherInstrumentation launcher, UiObject2 allAppsContainer, + Taskbar.TaskbarLocation taskbarLocation) { super(launcher, allAppsContainer, "search_container_all_apps"); + mTaskbarLocation = taskbarLocation; } @Override @@ -33,6 +37,6 @@ public class TaskbarAllAppsQsb extends Qsb { @Override protected SearchResultFromTaskbarQsb createSearchResult() { - return new SearchResultFromTaskbarQsb(mLauncher); + return new SearchResultFromTaskbarQsb(mLauncher, mTaskbarLocation); } } diff --git a/tests/tapl/com/android/launcher3/tapl/TaskbarAppIcon.java b/tests/tapl/com/android/launcher3/tapl/TaskbarAppIcon.java index d05c112d76..d968e89cee 100644 --- a/tests/tapl/com/android/launcher3/tapl/TaskbarAppIcon.java +++ b/tests/tapl/com/android/launcher3/tapl/TaskbarAppIcon.java @@ -17,18 +17,25 @@ package com.android.launcher3.tapl; import androidx.test.uiautomator.UiObject2; +import com.android.launcher3.tapl.Taskbar.TaskbarLocation; + import java.util.regex.Pattern; /** * App icon specifically on the Taskbar. */ -public final class TaskbarAppIcon extends AppIcon implements SplitscreenDragSource { +public final class TaskbarAppIcon extends AppIcon implements SplitscreenDragSource, + BubbleBarDragSource { private static final Pattern LONG_CLICK_EVENT = Pattern.compile("onTaskbarItemLongClick"); private static final Pattern RIGHT_CLICK_EVENT = Pattern.compile("onTaskbarItemRightClick"); - TaskbarAppIcon(LauncherInstrumentation launcher, UiObject2 icon) { + private final TaskbarLocation mTaskbarLocation; + + TaskbarAppIcon(LauncherInstrumentation launcher, UiObject2 icon, + TaskbarLocation taskbarLocation) { super(launcher, icon); + this.mTaskbarLocation = taskbarLocation; } @Override @@ -61,6 +68,11 @@ public final class TaskbarAppIcon extends AppIcon implements SplitscreenDragSour return new TaskbarAppIconMenu(mLauncher, menu); } + @Override + public TaskbarLocation getTaskbarLocation() { + return mTaskbarLocation; + } + @Override public Launchable getLaunchable() { return this;