summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/launcher3
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2019-08-15 14:53:41 -0700
committerSunny Goyal <sunnygoyal@google.com>2019-08-20 14:36:17 -0700
commit6fe3eec95cfb153ed7c16c6381623b7e762452c3 (patch)
treee530f240d9ce0b08d06c17e6ffe49d6c1ceab962 /tests/src/com/android/launcher3
parent4fa6f63ffd7a5ab230d17e8401d29cae3e5440b8 (diff)
downloadandroid_packages_apps_Trebuchet-6fe3eec95cfb153ed7c16c6381623b7e762452c3.tar.gz
android_packages_apps_Trebuchet-6fe3eec95cfb153ed7c16c6381623b7e762452c3.tar.bz2
android_packages_apps_Trebuchet-6fe3eec95cfb153ed7c16c6381623b7e762452c3.zip
Moving various common executors to a single location
Change-Id: I44bca49b8adb6fa22c3b48d10f674e42c28d792c
Diffstat (limited to 'tests/src/com/android/launcher3')
-rw-r--r--tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java6
-rw-r--r--tests/src/com/android/launcher3/util/Condition.java6
-rw-r--r--tests/src/com/android/launcher3/util/RaceConditionReproducer.java6
3 files changed, 8 insertions, 10 deletions
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index fc19baace..6d636cf69 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -19,12 +19,12 @@ import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static com.android.launcher3.tapl.LauncherInstrumentation.ContainerType;
import static com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName;
+import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
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;
@@ -48,7 +48,6 @@ import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager;
-import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.model.AppLaunchTracker;
@@ -56,6 +55,7 @@ import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.tapl.TestHelpers;
import com.android.launcher3.testcomponent.TestCommandReceiver;
import com.android.launcher3.testing.TestProtocol;
+import com.android.launcher3.util.LooperExecutor;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.Wait;
import com.android.launcher3.util.rule.FailureWatcher;
@@ -90,7 +90,7 @@ public abstract class AbstractLauncherUiTest {
public static final long DEFAULT_UI_TIMEOUT = 60000; // b/136278866
private static final String TAG = "AbstractLauncherUiTest";
- protected MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
+ protected LooperExecutor mMainThreadExecutor = MAIN_EXECUTOR;
protected final UiDevice mDevice = UiDevice.getInstance(getInstrumentation());
protected final LauncherInstrumentation mLauncher =
new LauncherInstrumentation(getInstrumentation());
diff --git a/tests/src/com/android/launcher3/util/Condition.java b/tests/src/com/android/launcher3/util/Condition.java
index b564a1a87..d85dd3a2d 100644
--- a/tests/src/com/android/launcher3/util/Condition.java
+++ b/tests/src/com/android/launcher3/util/Condition.java
@@ -1,8 +1,8 @@
package com.android.launcher3.util;
-import androidx.test.uiautomator.UiObject2;
+import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
-import com.android.launcher3.MainThreadExecutor;
+import androidx.test.uiautomator.UiObject2;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -16,7 +16,7 @@ public interface Condition {
* Converts the condition to be run on UI thread.
*/
static Condition runOnUiThread(final Condition condition) {
- final MainThreadExecutor executor = new MainThreadExecutor();
+ final LooperExecutor executor = MAIN_EXECUTOR;
return () -> {
final AtomicBoolean value = new AtomicBoolean(false);
final Throwable[] exceptions = new Throwable[1];
diff --git a/tests/src/com/android/launcher3/util/RaceConditionReproducer.java b/tests/src/com/android/launcher3/util/RaceConditionReproducer.java
index 0235f95d0..8f8917320 100644
--- a/tests/src/com/android/launcher3/util/RaceConditionReproducer.java
+++ b/tests/src/com/android/launcher3/util/RaceConditionReproducer.java
@@ -16,6 +16,7 @@
package com.android.launcher3.util;
+import static com.android.launcher3.util.Executors.createAndStartNewLooper;
import static com.android.launcher3.util.RaceConditionTracker.ENTER_POSTFIX;
import static com.android.launcher3.util.RaceConditionTracker.EXIT_POSTFIX;
@@ -23,7 +24,6 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import android.os.Handler;
-import android.os.HandlerThread;
import android.util.Log;
import java.util.ArrayList;
@@ -72,9 +72,7 @@ public class RaceConditionReproducer implements RaceConditionTracker.EventProces
private static final Handler POSTPONED_EVENT_RESUME_HANDLER = createEventResumeHandler();
private static Handler createEventResumeHandler() {
- final HandlerThread thread = new HandlerThread("RaceConditionEventResumer");
- thread.start();
- return new Handler(thread.getLooper());
+ return new Handler(createAndStartNewLooper("RaceConditionEventResumer"));
}
/**