summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVadim Tryshev <vadimt@google.com>2018-09-21 14:31:21 -0700
committerVadim Tryshev <vadimt@google.com>2018-09-21 14:53:11 -0700
commit802a28946c43f4f3e4d314838d019fdf6573f2fa (patch)
tree7f2a992743984387b0297b7c62bff4efc048a44a /tests
parente583a064fadb17ca1a3630654651c7ff1a008f6d (diff)
downloadandroid_packages_apps_Trebuchet-802a28946c43f4f3e4d314838d019fdf6573f2fa.tar.gz
android_packages_apps_Trebuchet-802a28946c43f4f3e4d314838d019fdf6573f2fa.tar.bz2
android_packages_apps_Trebuchet-802a28946c43f4f3e4d314838d019fdf6573f2fa.zip
Add support for testing in portrait mode
Bug: 110103162 Test: TaplTests Change-Id: I7f633405c04984ea8f04acdc6dd4ad21019d3409
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java19
-rw-r--r--tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java26
2 files changed, 32 insertions, 13 deletions
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index 5a3d36d6d..ba7d9c523 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -52,7 +52,6 @@ import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.testcomponent.AppWidgetNoConfig;
import com.android.launcher3.testcomponent.AppWidgetWithConfig;
-import com.android.launcher3.util.Condition;
import com.android.launcher3.util.Wait;
import com.android.launcher3.util.rule.LauncherActivityRule;
@@ -79,20 +78,23 @@ public abstract class AbstractLauncherUiTest {
public static final long DEFAULT_WORKER_TIMEOUT_SECS = 5;
protected MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
- protected UiDevice mDevice;
- protected LauncherInstrumentation mLauncher;
+ protected final UiDevice mDevice;
+ protected final LauncherInstrumentation mLauncher;
protected Context mTargetContext;
protected String mTargetPackage;
private static final String TAG = "AbstractLauncherUiTest";
+ protected AbstractLauncherUiTest() {
+ mDevice = UiDevice.getInstance(getInstrumentation());
+ mLauncher = new LauncherInstrumentation(getInstrumentation());
+ }
+
@Rule
public LauncherActivityRule mActivityMonitor = new LauncherActivityRule();
@Before
public void setUp() throws Exception {
- mDevice = UiDevice.getInstance(getInstrumentation());
- mLauncher = new LauncherInstrumentation(getInstrumentation());
mTargetContext = InstrumentationRegistry.getTargetContext();
mTargetPackage = mTargetContext.getPackageName();
mDevice.executeShellCommand("settings put global heads_up_notifications_enabled 0");
@@ -285,12 +287,7 @@ public abstract class AbstractLauncherUiTest {
// flakiness.
protected boolean waitForLauncherCondition(
Function<Launcher, Boolean> condition, long timeout) {
- return Wait.atMost(new Condition() {
- @Override
- public boolean isTrue() {
- return getFromLauncher(condition);
- }
- }, timeout);
+ return Wait.atMost(() -> getFromLauncher(condition), timeout);
}
/**
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 9e4a61530..7885e3cce 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -25,6 +25,7 @@ import android.os.Bundle;
import android.os.Parcelable;
import android.provider.Settings;
import android.util.Log;
+import android.view.Surface;
import android.view.accessibility.AccessibilityEvent;
import androidx.annotation.NonNull;
@@ -92,6 +93,7 @@ public final class LauncherInstrumentation {
private final boolean mSwipeUpEnabled;
private Boolean mSwipeUpEnabledOverride = null;
private final Instrumentation mInstrumentation;
+ private int mExpectedRotation = Surface.ROTATION_0;
/**
* Constructs the root of TAPL hierarchy. You get all other objects from it.
@@ -109,7 +111,7 @@ public final class LauncherInstrumentation {
assertTrue("Device must run in a test harness", ActivityManager.isRunningInTestHarness());
}
- // Used only by tests.
+ // Used only by TaplTests.
public void overrideSwipeUpEnabled(Boolean swipeUpEnabledOverride) {
mSwipeUpEnabledOverride = swipeUpEnabledOverride;
}
@@ -144,14 +146,30 @@ public final class LauncherInstrumentation {
fail(message + ". " + "Actual: " + actual);
}
+ static public void assertEquals(String message, int expected, int actual) {
+ if (expected != actual) {
+ fail(message + " expected: " + expected + " but was: " + actual);
+ }
+ }
+
static void assertNotEquals(String message, int unexpected, int actual) {
if (unexpected == actual) {
failEquals(message, actual);
}
}
+ public void setExpectedRotation(int expectedRotation) {
+ mExpectedRotation = expectedRotation;
+ }
+
private UiObject2 verifyContainerType(ContainerType containerType) {
+ assertEquals("Unexpected display rotation",
+ mExpectedRotation, mDevice.getDisplayRotation());
+ assertTrue("Presence of recents button doesn't match isSwipeUpEnabled()",
+ isSwipeUpEnabled() ==
+ (mDevice.findObject(By.res(SYSTEMUI_PACKAGE, "recent_apps")) == null));
log("verifyContainerType: " + containerType);
+
switch (containerType) {
case WORKSPACE: {
waitUntilGone(APPS_RES_ID);
@@ -172,7 +190,11 @@ public final class LauncherInstrumentation {
return waitForLauncherObject(APPS_RES_ID);
}
case OVERVIEW: {
- waitForLauncherObject(APPS_RES_ID);
+ if (mDevice.isNaturalOrientation()) {
+ waitForLauncherObject(APPS_RES_ID);
+ } else {
+ waitUntilGone(APPS_RES_ID);
+ }
waitUntilGone(WORKSPACE_RES_ID);
waitUntilGone(WIDGETS_RES_ID);
return waitForLauncherObject(OVERVIEW_RES_ID);