summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVadim Tryshev <vadimt@google.com>2018-10-04 16:33:45 -0700
committerVadim Tryshev <vadimt@google.com>2018-10-04 16:33:45 -0700
commitc295098e187189d72008f8061336f8633a2e316e (patch)
tree7d42857f01d8fcf9d48cfeb1d9d549758881eaf1 /tests
parentbb24884801320d7e70528a4258bd76896f37b9b8 (diff)
downloadpackages_apps_Trebuchet-c295098e187189d72008f8061336f8633a2e316e.tar.gz
packages_apps_Trebuchet-c295098e187189d72008f8061336f8633a2e316e.tar.bz2
packages_apps_Trebuchet-c295098e187189d72008f8061336f8633a2e316e.zip
Enabling "in test harness" flag with a direct call
This allows running in-proc tests without enabling test harness on Android and restarting Launcher. Bug: 110103162 Test: TaplTests Change-Id: Ife44eff4760eb1349a10847efe2c1f27643bf146
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java4
-rw-r--r--tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java10
2 files changed, 12 insertions, 2 deletions
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index fc8e1c51e..6c44d81e3 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -49,6 +49,7 @@ import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherState;
import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.tapl.LauncherInstrumentation;
@@ -94,13 +95,14 @@ public abstract class AbstractLauncherUiTest {
private static final String TAG = "AbstractLauncherUiTest";
protected AbstractLauncherUiTest() {
- final Instrumentation instrumentation =TestHelpers.getInstrumentation();
+ final Instrumentation instrumentation = TestHelpers.getInstrumentation();
mDevice = UiDevice.getInstance(instrumentation);
try {
mDevice.setOrientationNatural();
} catch (RemoteException e) {
throw new RuntimeException(e);
}
+ if (TestHelpers.isInLauncherProcess()) Utilities.enableRunningInTestHarnessForTests();
mLauncher = new LauncherInstrumentation(instrumentation);
}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 7885e3cce..66dfe41c2 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -108,7 +108,15 @@ public final class LauncherInstrumentation {
instrumentation.getTargetContext().getContentResolver(),
SWIPE_UP_SETTING_NAME,
swipeUpEnabledDefault ? 1 : 0) == 1;
- assertTrue("Device must run in a test harness", ActivityManager.isRunningInTestHarness());
+
+ // Launcher should run in test harness so that custom accessibility protocol between
+ // Launcher and TAPL is enabled. In-process tests enable this protocol with a direct call
+ // into Launcher.
+ final boolean isInLauncherProcess =
+ instrumentation.getTargetContext().getPackageName().equals(
+ UiDevice.getInstance(instrumentation).getLauncherPackageName());
+ assertTrue("Device must run in a test harness",
+ isInLauncherProcess || ActivityManager.isRunningInTestHarness());
}
// Used only by TaplTests.