Moving state ordinals to TestProtocol
These checks immediately broke after recent change of ordinals.
Test: Tapl tests
Change-Id: Ie040f452d3f31c86f780e6f38c6f9afa0d0dcbf3
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index 899cdd3..471d28d 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -19,6 +19,10 @@
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS;
import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
+import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL;
+import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
+import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL;
+import static com.android.launcher3.TestProtocol.SPRING_LOADED_STATE_ORDINAL;
import static com.android.launcher3.anim.Interpolators.ACCEL_2;
import static com.android.launcher3.states.RotationHelper.REQUEST_NONE;
@@ -84,10 +88,12 @@
/**
* Various Launcher states arranged in the increasing order of UI layers
*/
- public static final LauncherState SPRING_LOADED = new SpringLoadedState(1);
- public static final LauncherState OVERVIEW = new OverviewState(2);
- public static final LauncherState ALL_APPS = new AllAppsState(3);
- public static final LauncherState BACKGROUND_APP = new BackgroundAppState(4);
+ public static final LauncherState SPRING_LOADED = new SpringLoadedState(
+ SPRING_LOADED_STATE_ORDINAL);
+ public static final LauncherState OVERVIEW = new OverviewState(OVERVIEW_STATE_ORDINAL);
+ public static final LauncherState ALL_APPS = new AllAppsState(ALL_APPS_STATE_ORDINAL);
+ public static final LauncherState BACKGROUND_APP = new BackgroundAppState(
+ BACKGROUND_APP_STATE_ORDINAL);
public final int ordinal;
diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/TestProtocol.java
index 008b624..f19b0e0 100644
--- a/src/com/android/launcher3/TestProtocol.java
+++ b/src/com/android/launcher3/TestProtocol.java
@@ -25,4 +25,8 @@
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";
+ public static final int SPRING_LOADED_STATE_ORDINAL = 1;
+ public static final int OVERVIEW_STATE_ORDINAL = 2;
+ public static final int ALL_APPS_STATE_ORDINAL = 3;
+ public static final int BACKGROUND_APP_STATE_ORDINAL = 4;
}
diff --git a/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java b/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
index 3e4b1f3..2642815 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
@@ -16,6 +16,8 @@
package com.android.launcher3.tapl;
+import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL;
+
import android.graphics.Point;
import androidx.annotation.NonNull;
@@ -45,8 +47,7 @@
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, LauncherInstrumentation.OVERVIEW_STATE_ORDINAL);
+ mLauncher.swipe(start.x, start.y, start.x, endY, 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 790e938..c54a43f 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -16,6 +16,7 @@
package com.android.launcher3.tapl;
+import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS;
import static com.android.launcher3.tapl.TestHelpers.getOverviewPackageName;
@@ -50,7 +51,7 @@
@NonNull
public BaseOverview switchToOverview() {
verifyActiveContainer();
- goToOverviewUnchecked(LauncherInstrumentation.BACKGROUND_APP_STATE_ORDINAL);
+ goToOverviewUnchecked(BACKGROUND_APP_STATE_ORDINAL);
assertTrue("Overview not visible", mLauncher.getDevice().wait(
Until.hasObject(By.pkg(getOverviewPackageName())), WAIT_TIME_MS));
return new BaseOverview(mLauncher);
diff --git a/tests/tapl/com/android/launcher3/tapl/Home.java b/tests/tapl/com/android/launcher3/tapl/Home.java
index bf857f0..f8bd85a 100644
--- a/tests/tapl/com/android/launcher3/tapl/Home.java
+++ b/tests/tapl/com/android/launcher3/tapl/Home.java
@@ -16,6 +16,8 @@
package com.android.launcher3.tapl;
+import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL;
+
import androidx.annotation.NonNull;
/**
@@ -47,7 +49,7 @@
@Override
public Overview switchToOverview() {
verifyActiveContainer();
- goToOverviewUnchecked(LauncherInstrumentation.OVERVIEW_STATE_ORDINAL);
+ goToOverviewUnchecked(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 06b9a96..1e14e27 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -54,9 +54,6 @@
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.
@@ -425,8 +422,8 @@
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",
+ 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 1f7ed29..0208144 100644
--- a/tests/tapl/com/android/launcher3/tapl/Overview.java
+++ b/tests/tapl/com/android/launcher3/tapl/Overview.java
@@ -16,6 +16,8 @@
package com.android.launcher3.tapl;
+import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL;
+
import android.graphics.Point;
import com.android.launcher3.tapl.LauncherInstrumentation.ContainerType;
@@ -51,8 +53,7 @@
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, LauncherInstrumentation.APPS_LIST_STATE_ORDINAL);
+ mLauncher.swipe(start.x, start.y, start.x, 0, ALL_APPS_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 4f86603..f597133 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -16,6 +16,8 @@
package com.android.launcher3.tapl;
+import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL;
+
import static junit.framework.TestCase.assertTrue;
import android.graphics.Point;
@@ -56,7 +58,7 @@
start.y,
start.x,
endY,
- LauncherInstrumentation.APPS_LIST_STATE_ORDINAL
+ ALL_APPS_STATE_ORDINAL
);
return new AllApps(mLauncher);