diff --git a/quickstep/tests/src/com/android/quickstep/TaplPrivateSpaceTest.java b/quickstep/tests/src/com/android/quickstep/TaplPrivateSpaceTest.java index 7708233e0a..efe773b578 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplPrivateSpaceTest.java +++ b/quickstep/tests/src/com/android/quickstep/TaplPrivateSpaceTest.java @@ -27,6 +27,7 @@ import android.util.Log; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; +import com.android.launcher3.tapl.HomeAllApps; import com.android.launcher3.tapl.LauncherInstrumentation; import com.android.launcher3.tapl.PrivateSpaceContainer; import com.android.launcher3.util.TestUtil; @@ -100,10 +101,18 @@ public class TaplPrivateSpaceTest extends AbstractQuickStepTest { public void testPrivateSpaceContainerIsPresent() { // Scroll to the bottom of All Apps executeOnLauncher(launcher -> launcher.getAppsView().resetAndScrollToPrivateSpaceHeader()); + // Freeze All Apps + HomeAllApps homeAllApps = mLauncher.getAllApps(); + homeAllApps.freeze(); - // Verify Unlocked View elements are present. - assertNotNull("Private Space Unlocked View not found, or is not correct", - mLauncher.getAllApps().getPrivateSpaceUnlockedView()); + try { + // Verify Unlocked View elements are present. + assertNotNull("Private Space Unlocked View not found, or is not correct", + homeAllApps.getPrivateSpaceUnlockedView()); + } finally { + // UnFreeze + homeAllApps.unfreeze(); + } } @Test @@ -117,10 +126,18 @@ public class TaplPrivateSpaceTest extends AbstractQuickStepTest { waitForLauncherUIUpdate(); // Scroll to the bottom of All Apps executeOnLauncher(launcher -> launcher.getAppsView().resetAndScrollToPrivateSpaceHeader()); + // Freeze All Apps + HomeAllApps homeAllApps = mLauncher.getAllApps(); + homeAllApps.freeze(); - // Verify the Installed App is displayed in correct position. - PrivateSpaceContainer psContainer = mLauncher.getAllApps().getPrivateSpaceUnlockedView(); - psContainer.verifyInstalledAppIsPresent(INSTALLED_APP_NAME); + try { + // Verify the Installed App is displayed in correct position. + PrivateSpaceContainer psContainer = homeAllApps.getPrivateSpaceUnlockedView(); + psContainer.verifyInstalledAppIsPresent(INSTALLED_APP_NAME); + } finally { + // UnFreeze + homeAllApps.unfreeze(); + } } @Test @@ -134,8 +151,17 @@ public class TaplPrivateSpaceTest extends AbstractQuickStepTest { waitForLauncherUIUpdate(); // Scroll to the bottom of All Apps executeOnLauncher(launcher -> launcher.getAppsView().resetAndScrollToPrivateSpaceHeader()); - // Get the "uninstall" menu item. - mLauncher.getAllApps().getAppIcon(INSTALLED_APP_NAME).openMenu().getMenuItem("Uninstall"); + // Freeze All Apps + HomeAllApps homeAllApps = mLauncher.getAllApps(); + homeAllApps.freeze(); + + try { + // Get the "uninstall" menu item. + homeAllApps.getAppIcon(INSTALLED_APP_NAME).openMenu().getMenuItem("Uninstall"); + } finally { + // UnFreeze + homeAllApps.unfreeze(); + } } private void waitForPrivateSpaceSetup() { diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java index b4901244f5..f3ec852c6c 100644 --- a/tests/tapl/com/android/launcher3/tapl/AllApps.java +++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java @@ -433,7 +433,7 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer public PrivateSpaceContainer getPrivateSpaceUnlockedView() { final UiObject2 allAppsContainer = verifyActiveContainer(); final UiObject2 appListRecycler = getAppListRecycler(allAppsContainer); - return new PrivateSpaceContainer(mLauncher, appListRecycler); + return new PrivateSpaceContainer(mLauncher, appListRecycler, this); } protected abstract void verifyVisibleContainerOnDismiss(); diff --git a/tests/tapl/com/android/launcher3/tapl/PrivateSpaceContainer.java b/tests/tapl/com/android/launcher3/tapl/PrivateSpaceContainer.java index daddd2f84b..0e65ffb477 100644 --- a/tests/tapl/com/android/launcher3/tapl/PrivateSpaceContainer.java +++ b/tests/tapl/com/android/launcher3/tapl/PrivateSpaceContainer.java @@ -30,11 +30,13 @@ public class PrivateSpaceContainer { private final LauncherInstrumentation mLauncher; private final UiObject2 mAppListRecycler; + private final AllApps mAppList; PrivateSpaceContainer(LauncherInstrumentation launcherInstrumentation, - UiObject2 appListRecycler) { + UiObject2 appListRecycler, AllApps appList) { mLauncher = launcherInstrumentation; mAppListRecycler = appListRecycler; + mAppList = appList; verifyHeaderIsPresent(); verifyInstallAppButtonIsPresent(); @@ -52,7 +54,7 @@ public class PrivateSpaceContainer { // Assert Install App Item is present in view. private void verifyInstallAppButtonIsPresent() { - mLauncher.getAllApps().getAppIcon(INSTALL_APP_TITLE); + mAppList.getAppIcon(INSTALL_APP_TITLE); } // Assert Sys App Divider is present in view. @@ -64,7 +66,7 @@ public class PrivateSpaceContainer { * Verifies that a user installed app is present above the divider. */ public void verifyInstalledAppIsPresent(String appName) { - HomeAppIcon appIcon = mLauncher.getAllApps().getAppIcon(appName); + AppIcon appIcon = mAppList.getAppIcon(appName); final Point iconCenter = appIcon.mObject.getVisibleCenter(); UiObject2 divider = mLauncher.waitForObjectInContainer(mAppListRecycler, DIVIDER_RES_ID); final Point dividerCenter = divider.getVisibleCenter();