summaryrefslogtreecommitdiffstats
path: root/tests/tapl
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-09-21 22:03:07 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-09-21 22:03:07 +0000
commit19e0e8ab1fd47de8455072a18b06d373495359c9 (patch)
treeaadf8031f2f4b0d42df9cde77fa46ce53705c70b /tests/tapl
parent1473b8e1025d17578b08e062427c3af46764efa6 (diff)
parent802a28946c43f4f3e4d314838d019fdf6573f2fa (diff)
downloadandroid_packages_apps_Trebuchet-19e0e8ab1fd47de8455072a18b06d373495359c9.tar.gz
android_packages_apps_Trebuchet-19e0e8ab1fd47de8455072a18b06d373495359c9.tar.bz2
android_packages_apps_Trebuchet-19e0e8ab1fd47de8455072a18b06d373495359c9.zip
Merge "Add support for testing in portrait mode" into ub-launcher3-master
Diffstat (limited to 'tests/tapl')
-rw-r--r--tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java26
1 files changed, 24 insertions, 2 deletions
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);