Merge "Improving getWorkspaceAppIcon()" into ub-launcher3-qt-qpr1-dev

This commit is contained in:
Vadim Tryshev 2019-07-31 21:13:13 +00:00 committed by Android (Google) Code Review
commit bfff1c80df
4 changed files with 11 additions and 15 deletions

View File

@ -120,7 +120,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer {
mLauncher.assertTrue("Unable to scroll to a clickable icon: " + appName,
hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector));
final UiObject2 appIcon = mLauncher.getObjectInContainer(appListRecycler,
final UiObject2 appIcon = mLauncher.waitForObjectInContainer(appListRecycler,
appIconSelector);
return new AppIcon(mLauncher, appIcon);
}

View File

@ -74,7 +74,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
flingForward();
}
mLauncher.getObjectInContainer(verifyActiveContainer(), clearAllSelector).click();
mLauncher.waitForObjectInContainer(verifyActiveContainer(), clearAllSelector).click();
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"dismissed all tasks")) {
return new Workspace(mLauncher);

View File

@ -678,13 +678,6 @@ public final class LauncherInstrumentation {
return object;
}
@NonNull
UiObject2 getObjectInContainer(UiObject2 container, BySelector selector) {
final UiObject2 object = container.findObject(selector);
assertNotNull("Can't find an object with selector: " + selector, object);
return object;
}
@NonNull
List<UiObject2> getObjectsInContainer(UiObject2 container, String resName) {
return container.findObjects(getLauncherObjectSelector(resName));

View File

@ -108,10 +108,13 @@ public final class Workspace extends Home {
*/
@NonNull
public AppIcon getWorkspaceAppIcon(String appName) {
return new AppIcon(mLauncher,
mLauncher.getObjectInContainer(
verifyActiveContainer(),
AppIcon.getAppIconSelector(appName, mLauncher)));
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to get a workspace icon")) {
return new AppIcon(mLauncher,
mLauncher.waitForObjectInContainer(
verifyActiveContainer(),
AppIcon.getAppIconSelector(appName, mLauncher)));
}
}
/**
@ -142,13 +145,13 @@ public final class Workspace extends Home {
@NonNull
public AppIcon getHotseatAppIcon(String appName) {
return new AppIcon(mLauncher, mLauncher.getObjectInContainer(
return new AppIcon(mLauncher, mLauncher.waitForObjectInContainer(
mHotseat, AppIcon.getAppIconSelector(appName, mLauncher)));
}
@NonNull
public Folder getHotseatFolder(String appName) {
return new Folder(mLauncher, mLauncher.getObjectInContainer(
return new Folder(mLauncher, mLauncher.waitForObjectInContainer(
mHotseat, Folder.getSelector(appName, mLauncher)));
}