Merge "Locking the All Apps view before asserting PS components." into main

This commit is contained in:
Treehugger Robot
2024-05-02 19:02:42 +00:00
committed by Android (Google) Code Review
3 changed files with 40 additions and 12 deletions

View File

@@ -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() {

View File

@@ -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();

View File

@@ -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();