Merge "Waiting for the recycler to populate when opening all apps" into ub-launcher3-qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5d7dbd914a
@@ -20,8 +20,10 @@ import static com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.test.uiautomator.By;
|
||||
import androidx.test.uiautomator.BySelector;
|
||||
import androidx.test.uiautomator.Direction;
|
||||
import androidx.test.uiautomator.UiObject2;
|
||||
@@ -42,6 +44,10 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer {
|
||||
super(launcher);
|
||||
final UiObject2 allAppsContainer = verifyActiveContainer();
|
||||
mHeight = allAppsContainer.getVisibleBounds().height();
|
||||
final UiObject2 appListRecycler = mLauncher.waitForObjectInContainer(allAppsContainer,
|
||||
"apps_list_view");
|
||||
// Wait for the recycler to populate.
|
||||
mLauncher.waitForObjectInContainer(appListRecycler, By.clazz(TextView.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,7 +121,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer {
|
||||
verifyActiveContainer();
|
||||
}
|
||||
|
||||
final UiObject2 appIcon = mLauncher.getObjectInContainer(allAppsContainer,
|
||||
final UiObject2 appIcon = mLauncher.getObjectInContainer(appListRecycler,
|
||||
appIconSelector);
|
||||
ensureIconVisible(appIcon, allAppsContainer, appListRecycler);
|
||||
return new AppIcon(mLauncher, appIcon);
|
||||
|
||||
@@ -21,9 +21,9 @@ import static android.content.pm.PackageManager.DONT_KILL_APP;
|
||||
import static android.content.pm.PackageManager.MATCH_ALL;
|
||||
import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
|
||||
|
||||
import static com.android.launcher3.tapl.TestHelpers.getOverviewPackageName;
|
||||
import static com.android.launcher3.testing.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.TestProtocol.NORMAL_STATE_ORDINAL;
|
||||
import static com.android.launcher3.tapl.TestHelpers.getOverviewPackageName;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Instrumentation;
|
||||
@@ -570,6 +570,16 @@ public final class LauncherInstrumentation {
|
||||
return object;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
UiObject2 waitForObjectInContainer(UiObject2 container, BySelector selector) {
|
||||
final UiObject2 object = container.wait(
|
||||
Until.findObject(selector),
|
||||
WAIT_TIME_MS);
|
||||
assertNotNull("Can't find a launcher object id: " + selector + " in container: " +
|
||||
container.getResourceName(), object);
|
||||
return object;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private boolean hasLauncherObject(String resId) {
|
||||
return mDevice.hasObject(getLauncherObjectSelector(resId));
|
||||
@@ -580,11 +590,6 @@ public final class LauncherInstrumentation {
|
||||
return waitForObjectBySelector(getLauncherObjectSelector(resName));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
UiObject2 waitForLauncherObjectByClass(String clazz) {
|
||||
return waitForObjectBySelector(getLauncherObjectSelectorByClass(clazz));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
UiObject2 waitForFallbackLauncherObject(String resName) {
|
||||
return waitForObjectBySelector(getFallbackLauncherObjectSelector(resName));
|
||||
@@ -600,10 +605,6 @@ public final class LauncherInstrumentation {
|
||||
return By.res(getLauncherPackageName(), resName);
|
||||
}
|
||||
|
||||
BySelector getLauncherObjectSelectorByClass(String clazz) {
|
||||
return By.pkg(getLauncherPackageName()).clazz(clazz);
|
||||
}
|
||||
|
||||
BySelector getFallbackLauncherObjectSelector(String resName) {
|
||||
return By.res(getOverviewPackageName(), resName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user