Add Tapl support for swiping from All Apps to Workspace.

This mirrors the way we swipe from Workspace to All Apps, with minor
differences for selecting the start position of the swipe motion.

Bug: 260218332
Test: included
Change-Id: I9fe2284b1c920ebed87a6bab3dfc9c8c29aa2d5d
This commit is contained in:
Luca Zuccarini
2022-11-23 14:37:31 +00:00
parent 238bbfaf7b
commit 55d828b6f5
3 changed files with 52 additions and 1 deletions

View File

@@ -193,6 +193,15 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
isInState(() -> LauncherState.ALL_APPS));
}
@Test
@PortraitLandscape
public void testAllAppsSwitchToWorkspace() {
assertNotNull("switchToWorkspace() returned null",
mLauncher.getWorkspace().switchToAllApps().switchToWorkspace());
assertTrue("Launcher internal state is not Workspace",
isInState(() -> LauncherState.NORMAL));
}
@Test
@PortraitLandscape
public void testAllAppsDeadzoneForTablet() throws Exception {

View File

@@ -244,7 +244,7 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
return mLauncher.waitForObjectInContainer(allAppsContainer, "apps_list_view");
}
private UiObject2 getSearchBox(UiObject2 allAppsContainer) {
protected UiObject2 getSearchBox(UiObject2 allAppsContainer) {
return mLauncher.waitForObjectInContainer(allAppsContainer, "search_container_all_apps");
}

View File

@@ -15,11 +15,17 @@
*/
package com.android.launcher3.tapl;
import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL;
import android.graphics.Rect;
import androidx.annotation.NonNull;
import androidx.test.uiautomator.UiObject2;
import com.android.launcher3.testing.shared.TestProtocol;
import java.util.Objects;
public class HomeAllApps extends AllApps {
private static final String BOTTOM_SHEET_RES_ID = "bottom_sheet_background";
@@ -27,6 +33,42 @@ public class HomeAllApps extends AllApps {
super(launcher);
}
/**
* Swipes down to Workspace.
*
* @return the Workspace object.
*/
@NonNull
public Workspace switchToWorkspace() {
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
LauncherInstrumentation.Closable c =
mLauncher.addContextLayer("want to switch from all apps to workspace")) {
UiObject2 allAppsContainer = verifyActiveContainer();
final Rect searchBoxBounds = Objects.requireNonNull(
mLauncher.getVisibleBounds(getSearchBox(allAppsContainer)));
final int startX = searchBoxBounds.centerX();
final int startY = searchBoxBounds.bottom;
final int endY = mLauncher.getDevice().getDisplayHeight();
LauncherInstrumentation.log(
"switchToWorkspace: startY = " + startY + ", endY = " + endY
+ ", slop = " + mLauncher.getTouchSlop());
mLauncher.swipeToState(
startX,
startY,
startX,
endY,
12 /* steps */,
NORMAL_STATE_ORDINAL, LauncherInstrumentation.GestureScope.INSIDE);
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"swiped to workspace")) {
return mLauncher.getWorkspace();
}
}
}
@Override
protected LauncherInstrumentation.ContainerType getContainerType() {
return LauncherInstrumentation.ContainerType.HOME_ALL_APPS;