Merge "Improving TAPL diagnostics (contains changes in Launcher)" into ub-launcher3-master

This commit is contained in:
Vadim Tryshev 2019-04-02 17:34:24 +00:00 committed by Android (Google) Code Review
commit a8bd0527ef
2 changed files with 31 additions and 2 deletions

View File

@ -33,6 +33,27 @@ public final class TestProtocol {
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";

View File

@ -30,6 +30,7 @@ import android.os.Build;
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 @@ public final class LauncherInstrumentation {
}
}
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);
@ -539,8 +546,9 @@ public final class LauncherInstrumentation {
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() {