From 295027d0d1524b5d37613755731ac3ef9a5b28e9 Mon Sep 17 00:00:00 2001 From: Jagrut Desai Date: Mon, 18 Dec 2023 13:14:37 -0800 Subject: [PATCH] Adding Support for Tapl Workspace Tests into PlatformScenario Test: Presubmit, manual Bug: 303258153 Flag: NONE Change-Id: Ic7d2cd3dc24bbe4b252ef490c1e6d3cf0e3e217a --- .../ui/workspace/TaplWorkspaceTest.java | 5 ---- .../com/android/launcher3/tapl/Workspace.java | 25 ++++++++++++++----- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java b/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java index 59c82a7b2f..4edeb42fc1 100644 --- a/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java +++ b/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java @@ -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(); diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index f8fa00c365..75d6ed1306 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -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;