Improving TAPL diagnostics (contains changes in Launcher)
Bug: 128531133
Change-Id: Ice1ffecb39cf88afb546ceefdfca21abd879f35d
diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/TestProtocol.java
index 49a736e..7d3715e 100644
--- a/src/com/android/launcher3/TestProtocol.java
+++ b/src/com/android/launcher3/TestProtocol.java
@@ -33,6 +33,27 @@
public static final int ALL_APPS_STATE_ORDINAL = 5;
public static final int BACKGROUND_APP_STATE_ORDINAL = 6;
+ public static String stateOrdinalToString(int ordinal) {
+ switch (ordinal) {
+ case NORMAL_STATE_ORDINAL:
+ return "Normal";
+ case SPRING_LOADED_STATE_ORDINAL:
+ return "SpringLoaded";
+ case OVERVIEW_STATE_ORDINAL:
+ return "Overview";
+ case OVERVIEW_PEEK_STATE_ORDINAL:
+ return "OverviewPeek";
+ case QUICK_SWITCH_STATE_ORDINAL:
+ return "QuickSwitch";
+ case ALL_APPS_STATE_ORDINAL:
+ return "AllApps";
+ case BACKGROUND_APP_STATE_ORDINAL:
+ return "Background";
+ default:
+ return null;
+ }
+ }
+
public static final String TEST_INFO_RESPONSE_FIELD = "response";
public static final String REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT =
"home-to-overview-swipe-height";
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index b71f790..d60c79d 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -30,6 +30,7 @@
import android.os.Bundle;
import android.os.Parcelable;
import android.os.SystemClock;
+import android.text.TextUtils;
import android.util.Log;
import android.view.InputDevice;
import android.view.MotionEvent;
@@ -225,6 +226,12 @@
}
}
+ private void assertEquals(String message, String expected, String actual) {
+ if (!TextUtils.equals(expected, actual)) {
+ fail(message + " expected: '" + expected + "' but was: '" + actual + "'");
+ }
+ }
+
void assertNotEquals(String message, int unexpected, int actual) {
if (unexpected == actual) {
failEquals(message, actual);
@@ -544,8 +551,9 @@
event -> TestProtocol.SWITCHED_TO_STATE_MESSAGE.equals(event.getClassName()),
"Swipe failed to receive an event for the swipe end: " + startX + ", " + startY
+ ", " + endX + ", " + endY);
- assertEquals("Swipe switched launcher to a wrong state",
- expectedState, parcel.getInt(TestProtocol.STATE_FIELD));
+ assertEquals("Swipe switched launcher to a wrong state;",
+ TestProtocol.stateOrdinalToString(expectedState),
+ TestProtocol.stateOrdinalToString(parcel.getInt(TestProtocol.STATE_FIELD)));
}
void waitForIdle() {