From 2a648aa894dd029fa2981929c3b937d68f733d78 Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 14 Feb 2019 17:47:11 -0800 Subject: [PATCH] Moving state ordinals to TestProtocol These checks immediately broke after recent change of ordinals. Test: Tapl tests Change-Id: Ie040f452d3f31c86f780e6f38c6f9afa0d0dcbf3 --- src/com/android/launcher3/LauncherState.java | 14 ++++++++++---- src/com/android/launcher3/TestProtocol.java | 4 ++++ .../launcher3/tapl/AllAppsFromOverview.java | 5 +++-- .../com/android/launcher3/tapl/Background.java | 3 ++- tests/tapl/com/android/launcher3/tapl/Home.java | 4 +++- .../launcher3/tapl/LauncherInstrumentation.java | 7 ++----- .../tapl/com/android/launcher3/tapl/Overview.java | 5 +++-- .../tapl/com/android/launcher3/tapl/Workspace.java | 4 +++- 8 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index 899cdd3878..471d28d3f4 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_AUTO; 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 @@ public class LauncherState { /** * 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 008b624d11..f19b0e0076 100644 --- a/src/com/android/launcher3/TestProtocol.java +++ b/src/com/android/launcher3/TestProtocol.java @@ -25,4 +25,8 @@ public final class TestProtocol { 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 3e4b1f3caa..264281502b 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 @@ public final class AllAppsFromOverview extends AllApps { 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 790e938f86..c54a43f237 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 @@ public class Background extends LauncherInstrumentation.VisibleContainer { @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 bf857f0c39..f8bd85accc 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 @@ public abstract class Home extends Background { @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 06b9a96fc7..1e14e27818 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -54,9 +54,6 @@ import java.util.concurrent.TimeoutException; 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 @@ 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", + 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 1f7ed29086..02081449b1 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 @@ public final class Overview extends BaseOverview { 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 4f86603dcd..f597133ed8 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 @@ public final class Workspace extends Home { start.y, start.x, endY, - LauncherInstrumentation.APPS_LIST_STATE_ORDINAL + ALL_APPS_STATE_ORDINAL ); return new AllApps(mLauncher);