From a734bd8d26fab7119fa29f16947e68a5cc55e3e8 Mon Sep 17 00:00:00 2001 From: vadimt Date: Mon, 1 Apr 2019 13:43:46 -0700 Subject: [PATCH] Improving TAPL diagnostics (contains changes in Launcher) Bug: 128531133 Change-Id: Ice1ffecb39cf88afb546ceefdfca21abd879f35d --- src/com/android/launcher3/TestProtocol.java | 21 +++++++++++++++++++ .../tapl/LauncherInstrumentation.java | 12 +++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/TestProtocol.java index 49a736eed5..7d3715ef10 100644 --- a/src/com/android/launcher3/TestProtocol.java +++ b/src/com/android/launcher3/TestProtocol.java @@ -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"; diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index b71f790b83..d60c79dce7 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.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); @@ -544,8 +551,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() {