summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorvadimt <vadimt@google.com>2019-09-04 19:02:54 -0700
committervadimt <vadimt@google.com>2019-09-04 19:02:54 -0700
commitcf61e16a2c0f793784155e4a9b1f9250c455092c (patch)
treef04e26b7a0964d860fe438febd81eb590d52f71f /tests
parente1335c235925f4169031348fc06a638929580454 (diff)
downloadandroid_packages_apps_Trebuchet-cf61e16a2c0f793784155e4a9b1f9250c455092c.tar.gz
android_packages_apps_Trebuchet-cf61e16a2c0f793784155e4a9b1f9250c455092c.tar.bz2
android_packages_apps_Trebuchet-cf61e16a2c0f793784155e4a9b1f9250c455092c.zip
Adding a test method to get a Launcher object when it becomes non-null
Change-Id: I1c56777c87827b5edf1c7f55ad9639321e598311
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index d0b2a0a28..bee3a49c6 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -24,7 +24,6 @@ import static org.junit.Assert.assertTrue;
import static java.lang.System.exit;
-import android.app.Instrumentation;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -277,6 +276,12 @@ public abstract class AbstractLauncherUiTest {
// Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
// flakiness.
+ protected <T> T getOnceNotNull(String message, Function<Launcher, T> f) {
+ return getOnceNotNull(message, f, DEFAULT_ACTIVITY_TIMEOUT);
+ }
+
+ // Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
+ // flakiness.
protected void waitForLauncherCondition(
String message, Function<Launcher, Boolean> condition, long timeout) {
if (!TestHelpers.isInLauncherProcess()) return;
@@ -285,6 +290,20 @@ public abstract class AbstractLauncherUiTest {
// Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
// flakiness.
+ protected <T> T getOnceNotNull(String message, Function<Launcher, T> f, long timeout) {
+ if (!TestHelpers.isInLauncherProcess()) return null;
+
+ final Object[] output = new Object[1];
+ Wait.atMost(message, () -> {
+ final Object fromLauncher = getFromLauncher(f);
+ output[0] = fromLauncher;
+ return fromLauncher != null;
+ }, timeout);
+ return (T) output[0];
+ }
+
+ // Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
+ // flakiness.
protected void waitForLauncherCondition(
String message,
Runnable testThreadAction, Function<Launcher, Boolean> condition,