Merge "Adding Support for Tapl Workspace Tests into PlatformScenario" into main

This commit is contained in:
Jagrut Desai authored and Android (Google) Code Review committed 2023-12-20 19:11:36 +00:00
commit d89b61a487
2 files changed
+19 -11

No files matched your search

@@ -15,7 +15,6 @@
*/
package com.android.launcher3.ui.workspace;
import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize;
import static com.android.launcher3.util.TestConstants.AppNames.CHROME_APP_NAME;
import static org.junit.Assert.assertEquals;
@@ -23,8 +22,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import android.platform.test.annotations.PlatinumTest;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.tapl.HomeAppIcon;
@@ -70,7 +67,6 @@ public class TaplWorkspaceTest extends AbstractLauncherUiTest {
* move between workspaces. After, make sure we can launch an app from the Workspace.
* @throws Exception if we can't set the defaults icons that will appear at the beginning.
*/
@PlatinumTest(focusArea = "launcher")
@Test
public void testWorkspace() throws Exception {
// Set workspace that includes the chrome Activity app icon on the hotseat.
@@ -123,7 +119,6 @@ public class TaplWorkspaceTest extends AbstractLauncherUiTest {
* Similar to {@link TaplWorkspaceTest#testWorkspace} but here we also make sure we can delete
* the pages.
*/
@PlatinumTest(focusArea = "launcher")
@Test
public void testAddAndDeletePageAndFling() {
Workspace workspace = mLauncher.getWorkspace();
@@ -192,16 +192,24 @@ public final class Workspace extends Home {
}
/**
* Ensures that workspace is scrollable. If it's not, drags an icon icons from hotseat to the
* second screen.
* Ensures that workspace is scrollable. If it's not, drags a chrome app icon from hotseat
* to the second screen.
*/
public void ensureWorkspaceIsScrollable() {
ensureWorkspaceIsScrollable("Chrome");
}
/**
* Ensures that workspace is scrollable. If it's not, drags an icon of a given app name from
* hotseat to the second screen.
*/
public void ensureWorkspaceIsScrollable(String appName) {
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
final UiObject2 workspace = verifyActiveContainer();
if (!isWorkspaceScrollable(workspace)) {
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"dragging icon to a second page of workspace to make it scrollable")) {
dragIcon(workspace, getHotseatAppIcon("Chrome"), pagesPerScreen());
dragIcon(workspace, getHotseatAppIcon(appName), pagesPerScreen());
verifyActiveContainer();
}
}
@@ -450,7 +458,12 @@ public final class Workspace extends Home {
}
/** Returns the index of the current page */
private static int geCurrentPage(LauncherInstrumentation launcher) {
public int getCurrentPage() {
return getCurrentPage(mLauncher);
}
/** Returns the index of the current page */
private static int getCurrentPage(LauncherInstrumentation launcher) {
return launcher.getTestInfo(TestProtocol.REQUEST_WORKSPACE_CURRENT_PAGE_INDEX).getInt(
TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
@@ -637,7 +650,7 @@ public final class Workspace extends Home {
Point currentPosition, int destinationWorkspaceIndex, int y) {
final long downTime = SystemClock.uptimeMillis();
int displayX = launcher.getRealDisplaySize().x;
int currentPage = Workspace.geCurrentPage(launcher);
int currentPage = Workspace.getCurrentPage(launcher);
int counter = 0;
while (currentPage != destinationWorkspaceIndex) {
counter++;
@@ -656,7 +669,7 @@ public final class Workspace extends Home {
() -> launcher.movePointer(finalDragStart, screenEdge, DEFAULT_DRAG_STEPS,
true, downTime, downTime, true,
LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER));
currentPage = Workspace.geCurrentPage(launcher);
currentPage = Workspace.getCurrentPage(launcher);
currentPosition = screenEdge;
}
return currentPosition;