diff --git a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java index b59a0ad342..2e7e6e05ed 100644 --- a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java +++ b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java @@ -219,7 +219,7 @@ public class FallbackRecentsTest { OverviewTask task = overview.getCurrentTask(); assertNotNull("overview.getCurrentTask() returned null (1)", task); assertNotNull("OverviewTask.open returned null", task.open()); - assertTrue("Test activity didn't open from Overview", mDevice.wait(Until.hasObject( + assertTrue("Test activity didn't open from Overview", TestHelpers.wait(Until.hasObject( By.pkg(getAppPackageName()).text("TestActivity2")), DEFAULT_UI_TIMEOUT)); @@ -236,7 +236,7 @@ public class FallbackRecentsTest { // Test dismissing all tasks. pressHomeAndGoToOverview().dismissAllTasks(); - assertTrue("Fallback Launcher not visible", mDevice.wait(Until.hasObject(By.pkg( + assertTrue("Fallback Launcher not visible", TestHelpers.wait(Until.hasObject(By.pkg( mOtherLauncherActivity.packageName)), WAIT_TIME_MS)); } diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index 324b1337f8..b3c1240764 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -244,7 +244,7 @@ public abstract class AbstractLauncherUiTest { @Before public void setUp() throws Exception { Assert.assertTrue("Keyguard is visible", - mDevice.wait( + TestHelpers.wait( Until.gone(By.res(SYSTEMUI_PACKAGE, "keyguard_status_view")), 60000)); final String launcherPackageName = mDevice.getLauncherPackageName(); @@ -477,8 +477,7 @@ public abstract class AbstractLauncherUiTest { } getInstrumentation().getTargetContext().startActivity(intent); assertTrue("App didn't start: " + selector, - UiDevice.getInstance(getInstrumentation()) - .wait(Until.hasObject(selector), DEFAULT_UI_TIMEOUT)); + TestHelpers.wait(Until.hasObject(selector), DEFAULT_UI_TIMEOUT)); } public static ActivityInfo resolveSystemAppInfo(String category) { diff --git a/tests/tapl/com/android/launcher3/tapl/Launchable.java b/tests/tapl/com/android/launcher3/tapl/Launchable.java index 093c024732..3fc83ff926 100644 --- a/tests/tapl/com/android/launcher3/tapl/Launchable.java +++ b/tests/tapl/com/android/launcher3/tapl/Launchable.java @@ -68,8 +68,7 @@ abstract class Launchable { mLauncher.assertTrue( "App didn't start: " + label, - mLauncher.getDevice().wait(Until.hasObject(selector), - LauncherInstrumentation.WAIT_TIME_MS)); + TestHelpers.wait(Until.hasObject(selector), LauncherInstrumentation.WAIT_TIME_MS)); return new Background(mLauncher); } diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index e2a442db9b..0c8f610928 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -933,7 +933,7 @@ public final class LauncherInstrumentation { @NonNull UiObject2 waitForAndroidObject(String resId) { - final UiObject2 object = mDevice.wait( + final UiObject2 object = TestHelpers.wait( Until.findObject(By.res(ANDROID_PACKAGE, resId)), WAIT_TIME_MS); assertNotNull("Can't find a android object with id: " + resId, object); return object; diff --git a/tests/tapl/com/android/launcher3/tapl/TestHelpers.java b/tests/tapl/com/android/launcher3/tapl/TestHelpers.java index b8791e8fa8..7f6062f72a 100644 --- a/tests/tapl/com/android/launcher3/tapl/TestHelpers.java +++ b/tests/tapl/com/android/launcher3/tapl/TestHelpers.java @@ -27,6 +27,11 @@ import android.content.pm.ActivityInfo; import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.os.DropBoxManager; +import android.os.SystemClock; +import android.util.Log; + +import androidx.test.uiautomator.SearchCondition; +import androidx.test.uiautomator.UiDevice; import org.junit.Assert; @@ -35,6 +40,7 @@ import java.util.List; public class TestHelpers { + private static final String TAG = "Tapl"; private static Boolean sIsInLauncherProcess; public static boolean isInLauncherProcess() { @@ -154,4 +160,12 @@ public class TestHelpers { return null; } } + + public static R wait(SearchCondition condition, long timeout) { + Log.d(TAG, + "TestHelpers.wait, condition=" + timeout + ", time=" + SystemClock.uptimeMillis()); + final R result = UiDevice.getInstance(getInstrumentation()).wait(condition, timeout); + Log.d(TAG, "TestHelpers.wait, result=" + result + ", time=" + SystemClock.uptimeMillis()); + return result; + } }