Sending state ordinals from Launcher to TAPL
This improves diagnostics.
Test: TAPL tests
Change-Id: I0ebb533513405372ea7c58a36910160cfb6d8368
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
index a3c942e..b50c381 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
@@ -210,8 +210,7 @@
// Optimization, hide the all apps view to prevent layout while initializing
activity.getAppsView().getContentView().setVisibility(View.GONE);
- AccessibilityManagerCompat.sendEventToTest(
- activity, TestProtocol.SWITCHED_TO_STATE_MESSAGE);
+ AccessibilityManagerCompat.sendStateEventToTest(activity, fromState.ordinal);
} else {
fromState = startState;
}
diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/TestProtocol.java
index 0a3b86d..008b624 100644
--- a/src/com/android/launcher3/TestProtocol.java
+++ b/src/com/android/launcher3/TestProtocol.java
@@ -22,6 +22,7 @@
public final class TestProtocol {
public static final String GET_SCROLL_MESSAGE = "TAPL_GET_SCROLL";
public static final String SCROLL_Y_FIELD = "scrollY";
+ public static final String STATE_FIELD = "state";
public static final String SWITCHED_TO_STATE_MESSAGE = "TAPL_SWITCHED_TO_STATE";
public static final String RESPONSE_MESSAGE_POSTFIX = "_RESPONSE";
}
diff --git a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
index 6feb1e9..51e914c 100644
--- a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
+++ b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
@@ -52,11 +52,14 @@
return (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
}
- public static void sendEventToTest(Context context, String eventTag) {
+ public static void sendStateEventToTest(Context context, int stateOrdinal) {
final AccessibilityManager accessibilityManager = getAccessibilityManagerForTest(context);
if (accessibilityManager == null) return;
- sendEventToTest(accessibilityManager, eventTag, null);
+ final Bundle parcel = new Bundle();
+ parcel.putInt(TestProtocol.STATE_FIELD, stateOrdinal);
+
+ sendEventToTest(accessibilityManager, TestProtocol.SWITCHED_TO_STATE_MESSAGE, parcel);
}
private static void sendEventToTest(
diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
index 0e2ed6c..c125c10 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -522,8 +522,7 @@
}
mLauncher.getStateManager().goToState(targetState, false /* animated */);
- AccessibilityManagerCompat.sendEventToTest(
- mLauncher, TestProtocol.SWITCHED_TO_STATE_MESSAGE);
+ AccessibilityManagerCompat.sendStateEventToTest(mLauncher, targetState.ordinal);
}
}
diff --git a/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java b/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
index 42817c1..3e4b1f3 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
@@ -45,7 +45,8 @@
final Point start = qsb.getVisibleCenter();
final int endY = (int) (mLauncher.getDevice().getDisplayHeight() * 0.6);
LauncherInstrumentation.log("AllAppsFromOverview.switchBackToOverview before swipe");
- mLauncher.swipe(start.x, start.y, start.x, endY);
+ mLauncher.swipe(
+ start.x, start.y, start.x, endY, LauncherInstrumentation.OVERVIEW_STATE_ORDINAL);
return new Overview(mLauncher);
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index 08d2889..790e938 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -50,21 +50,22 @@
@NonNull
public BaseOverview switchToOverview() {
verifyActiveContainer();
- goToOverviewUnchecked();
+ goToOverviewUnchecked(LauncherInstrumentation.BACKGROUND_APP_STATE_ORDINAL);
assertTrue("Overview not visible", mLauncher.getDevice().wait(
Until.hasObject(By.pkg(getOverviewPackageName())), WAIT_TIME_MS));
return new BaseOverview(mLauncher);
}
- protected void goToOverviewUnchecked() {
+ protected void goToOverviewUnchecked(int expectedState) {
if (mLauncher.isSwipeUpEnabled()) {
final int height = mLauncher.getDevice().getDisplayHeight();
final UiObject2 navBar = mLauncher.getSystemUiObject("navigation_bar_frame");
mLauncher.swipe(
navBar.getVisibleBounds().centerX(), navBar.getVisibleBounds().centerY(),
- navBar.getVisibleBounds().centerX(), height - 400);
+ navBar.getVisibleBounds().centerX(), height - 400,
+ expectedState);
} else {
mLauncher.getSystemUiObject("recent_apps").click();
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Home.java b/tests/tapl/com/android/launcher3/tapl/Home.java
index 522ce14..bf857f0 100644
--- a/tests/tapl/com/android/launcher3/tapl/Home.java
+++ b/tests/tapl/com/android/launcher3/tapl/Home.java
@@ -47,7 +47,7 @@
@Override
public Overview switchToOverview() {
verifyActiveContainer();
- goToOverviewUnchecked();
+ goToOverviewUnchecked(LauncherInstrumentation.OVERVIEW_STATE_ORDINAL);
return new Overview(mLauncher);
}
}
\ No newline at end of file
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 6b76012..6aa18d3 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -54,6 +54,9 @@
public final class LauncherInstrumentation {
private static final String TAG = "Tapl";
+ static final int OVERVIEW_STATE_ORDINAL = 2;
+ static final int APPS_LIST_STATE_ORDINAL = 4;
+ static final int BACKGROUND_APP_STATE_ORDINAL = 5;
// Types for launcher containers that the user is interacting with. "Background" is a
// pseudo-container corresponding to inactive launcher covered by another app.
@@ -154,7 +157,7 @@
fail(message + ". " + "Actual: " + actual);
}
- static public void assertEquals(String message, int expected, int actual) {
+ static private void assertEquals(String message, int expected, int actual) {
if (expected != actual) {
fail(message + " expected: " + expected + " but was: " + actual);
}
@@ -416,12 +419,14 @@
return mDevice;
}
- void swipe(int startX, int startY, int endX, int endY) {
- executeAndWaitForEvent(
+ void swipe(int startX, int startY, int endX, int endY, int expectedState) {
+ final Bundle parcel = (Bundle) executeAndWaitForEvent(
() -> mDevice.swipe(startX, startY, endX, endY, 60),
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));
}
void waitForIdle() {
diff --git a/tests/tapl/com/android/launcher3/tapl/Overview.java b/tests/tapl/com/android/launcher3/tapl/Overview.java
index 9e0c07f..1f7ed29 100644
--- a/tests/tapl/com/android/launcher3/tapl/Overview.java
+++ b/tests/tapl/com/android/launcher3/tapl/Overview.java
@@ -51,7 +51,8 @@
final UiObject2 navBar = mLauncher.getSystemUiObject("navigation_bar_frame");
final Point start = navBar.getVisibleCenter();
LauncherInstrumentation.log("Overview.switchToAllApps before swipe");
- mLauncher.swipe(start.x, start.y, start.x, 0);
+ mLauncher.swipe(
+ start.x, start.y, start.x, 0, LauncherInstrumentation.APPS_LIST_STATE_ORDINAL);
return new AllAppsFromOverview(mLauncher);
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index e10c4fb..4f86603 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -55,7 +55,8 @@
start.x,
start.y,
start.x,
- endY
+ endY,
+ LauncherInstrumentation.APPS_LIST_STATE_ORDINAL
);
return new AllApps(mLauncher);