diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 9264b8a4eb..7c73f2b471 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -1033,6 +1033,15 @@ public final class LauncherInstrumentation { } } + List getChildren(UiObject2 container) { + try { + return container.getChildren(); + } catch (StaleObjectException e) { + fail("The container disappeared from screen"); + return null; + } + } + private boolean hasLauncherObject(String resId) { return mDevice.hasObject(getLauncherObjectSelector(resId)); } diff --git a/tests/tapl/com/android/launcher3/tapl/Widgets.java b/tests/tapl/com/android/launcher3/tapl/Widgets.java index 99d988926a..6e7264ac0b 100644 --- a/tests/tapl/com/android/launcher3/tapl/Widgets.java +++ b/tests/tapl/com/android/launcher3/tapl/Widgets.java @@ -116,9 +116,9 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer { "widget_preview"); int i = 0; for (; ; ) { - final Collection tableRows = widgetsContainer.getChildren(); + final Collection tableRows = mLauncher.getChildren(widgetsContainer); for (UiObject2 row : tableRows) { - final Collection widgetCells = row.getChildren(); + final Collection widgetCells = mLauncher.getChildren(row); for (UiObject2 widget : widgetCells) { final UiObject2 label = mLauncher.findObjectInContainer(widget, labelSelector);