diff options
Diffstat (limited to 'tests')
6 files changed, 18 insertions, 18 deletions
diff --git a/tests/Android.mk b/tests/Android.mk index 0c412415c..02ead4ef4 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -27,7 +27,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ ifneq (,$(wildcard frameworks/base)) else - LOCAL_STATIC_JAVA_LIBRARIES += libSharedSystemUI + LOCAL_STATIC_JAVA_LIBRARIES += SystemUISharedLib LOCAL_SRC_FILES := $(call all-java-files-under, tapl) \ ../src/com/android/launcher3/ResourceUtils.java \ diff --git a/tests/src/com/android/launcher3/model/LoaderCursorTest.java b/tests/src/com/android/launcher3/model/LoaderCursorTest.java index 7d60ad65b..64df8e0e9 100644 --- a/tests/src/com/android/launcher3/model/LoaderCursorTest.java +++ b/tests/src/com/android/launcher3/model/LoaderCursorTest.java @@ -15,9 +15,9 @@ import com.android.launcher3.icons.IconCache; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.ItemInfo; import com.android.launcher3.LauncherAppState; -import com.android.launcher3.Utilities; import com.android.launcher3.compat.LauncherAppsCompat; import com.android.launcher3.icons.BitmapInfo; +import com.android.launcher3.util.PackageManagerHelper; import org.junit.Before; import org.junit.Test; @@ -115,7 +115,7 @@ public class LoaderCursorTest { WorkspaceItemInfo info = mLoaderCursor.getAppShortcutInfo( new Intent().setComponent(cn), false /* allowMissingTarget */, true); assertNotNull(info); - assertTrue(Utilities.isLauncherAppTarget(info.intent)); + assertTrue(PackageManagerHelper.isLauncherAppTarget(info.intent)); } @Test @@ -127,7 +127,7 @@ public class LoaderCursorTest { WorkspaceItemInfo info = mLoaderCursor.getAppShortcutInfo( new Intent().setComponent(cn), true /* allowMissingTarget */, true); assertNotNull(info); - assertTrue(Utilities.isLauncherAppTarget(info.intent)); + assertTrue(PackageManagerHelper.isLauncherAppTarget(info.intent)); } @Test diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index 1f4ba1af0..fc3118703 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -19,6 +19,7 @@ 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; @@ -47,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; @@ -55,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 +91,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")); } /** diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index da74b66f2..fe27e71f5 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -22,6 +22,7 @@ import static junit.framework.TestCase.assertTrue; import android.graphics.Point; import android.graphics.Rect; +import android.os.Bundle; import android.os.SystemClock; import android.view.KeyEvent; import android.view.MotionEvent; @@ -123,7 +124,7 @@ public final class Workspace extends Home { */ public void ensureWorkspaceIsScrollable() { final UiObject2 workspace = verifyActiveContainer(); - if (!isWorkspaceScrollable(workspace)) { + if (!isWorkspaceScrollable()) { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "dragging icon to a second page of workspace to make it scrollable")) { dragIconToWorkspace( @@ -135,12 +136,12 @@ public final class Workspace extends Home { verifyActiveContainer(); } } - assertTrue("Home screen workspace didn't become scrollable", - isWorkspaceScrollable(workspace)); + assertTrue("Home screen workspace didn't become scrollable", isWorkspaceScrollable()); } - private boolean isWorkspaceScrollable(UiObject2 workspace) { - return workspace.isScrollable(); + private boolean isWorkspaceScrollable() { + Bundle result = mLauncher.getTestInfo(TestProtocol.REQUEST_DOES_WORKSPACE_HAVE_SECOND_PAGE); + return result.getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, false); } @NonNull |