From 264d9a67deabec812f79b12b63e13879929c335c Mon Sep 17 00:00:00 2001 From: Benno Lin Date: Wed, 19 Jan 2022 03:45:46 +0000 Subject: [PATCH] Enable pressback tests Bug: 205027405 Test: Manual Change-Id: I5bb41fc27db17e95d7a7c91cec2bbf85f33d6dad (cherry picked from commit b5b70930e983fe2d2c7ebd64a2408e0061d060e5) --- .../android/quickstep/TaplTestsQuickstep.java | 16 ++---------- .../launcher3/ui/TaplTestsLauncher3.java | 12 ++------- .../tapl/LauncherInstrumentation.java | 25 +++++++++++++------ 3 files changed, 21 insertions(+), 32 deletions(-) diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index 399cd10855..4d38822f26 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -32,7 +32,6 @@ import androidx.test.uiautomator.Until; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; -import com.android.launcher3.tapl.HomeAllApps; import com.android.launcher3.tapl.LaunchedAppState; import com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel; import com.android.launcher3.tapl.Overview; @@ -45,7 +44,6 @@ import com.android.quickstep.views.RecentsView; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -295,26 +293,16 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { getAndAssertLaunchedApp(); } - // TODO(b/204830798): test with all navigation modes(add @NavigationModeSwitch annotation) - // after the bug resolved. - @Ignore("b/205027405") @Test @PortraitLandscape - @ScreenRecord + @NavigationModeSwitch public void testPressBack() throws Exception { mLauncher.getWorkspace().switchToAllApps(); mLauncher.pressBack(); mLauncher.getWorkspace(); waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); - HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps(); - allApps.freeze(); - try { - allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false); - } finally { - allApps.unfreeze(); - } - mLauncher.getWorkspace().getWorkspaceAppIcon(APP_NAME).launch(getAppPackageName()); + startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); mLauncher.pressBack(); mLauncher.getWorkspace(); waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java index 73e9823229..f0bef2477f 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java @@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import android.content.Intent; import android.graphics.Point; import androidx.test.filters.LargeTest; @@ -50,7 +51,6 @@ import com.android.launcher3.widget.picker.WidgetsFullSheet; import com.android.launcher3.widget.picker.WidgetsRecyclerView; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -391,7 +391,6 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { folder.close(); } - @Ignore("b/205027405") @Test @PortraitLandscape public void testPressBack() throws Exception { @@ -400,14 +399,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { mLauncher.getWorkspace(); waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); - HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps(); - allApps.freeze(); - try { - allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false); - } finally { - allApps.unfreeze(); - } - mLauncher.getWorkspace().getWorkspaceAppIcon(APP_NAME).launch(getAppPackageName()); + startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); mLauncher.pressBack(); mLauncher.getWorkspace(); waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 8e0eb7b071..9f0d9720da 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -113,6 +113,7 @@ public final class LauncherInstrumentation { static final Pattern EVENT_TOUCH_DOWN_TIS = getTouchEventPatternTIS("ACTION_DOWN"); static final Pattern EVENT_TOUCH_UP_TIS = getTouchEventPatternTIS("ACTION_UP"); + static final Pattern EVENT_TOUCH_CANCEL_TIS = getTouchEventPatternTIS("ACTION_CANCEL"); static final Pattern EVENT_KEY_BACK_DOWN = getKeyEventPattern("ACTION_DOWN", "KEYCODE_BACK"); static final Pattern EVENT_KEY_BACK_UP = getKeyEventPattern("ACTION_UP", "KEYCODE_BACK"); @@ -135,6 +136,8 @@ public final class LauncherInstrumentation { public enum GestureScope { OUTSIDE_WITHOUT_PILFER, OUTSIDE_WITH_PILFER, INSIDE, INSIDE_TO_OUTSIDE, INSIDE_TO_OUTSIDE_WITHOUT_PILFER, + INSIDE_TO_OUTSIDE_WITH_KEYCODE, // For gestures that will trigger a keycode from TIS. + OUTSIDE_WITH_KEYCODE, } // Base class for launcher containers. @@ -877,10 +880,9 @@ public final class LauncherInstrumentation { } /** + * @return the Workspace object. * @deprecated use goHome(). * Presses nav bar home button. - * - * @return the Workspace object. */ @Deprecated public Workspace pressHome() { @@ -968,9 +970,11 @@ public final class LauncherInstrumentation { if (getNavigationModel() == NavigationModel.ZERO_BUTTON) { final Point displaySize = getRealDisplaySize(); final GestureScope gestureScope = - launcherVisible ? GestureScope.INSIDE_TO_OUTSIDE_WITHOUT_PILFER - : GestureScope.OUTSIDE_WITHOUT_PILFER; - linearGesture(0, displaySize.y / 2, displaySize.x / 2, displaySize.y / 2, + launcherVisible ? GestureScope.INSIDE_TO_OUTSIDE_WITH_KEYCODE + : GestureScope.OUTSIDE_WITH_KEYCODE; + // TODO(b/225505986): change startY and endY back to displaySize.y / 2 once the + // issue is solved. + linearGesture(0, displaySize.y / 4, displaySize.x / 2, displaySize.y / 4, 10, false, gestureScope); } else { waitForNavigationUiObject("back").click(); @@ -1506,7 +1510,8 @@ public final class LauncherInstrumentation { switch (action) { case MotionEvent.ACTION_DOWN: if (gestureScope != GestureScope.OUTSIDE_WITH_PILFER - && gestureScope != GestureScope.OUTSIDE_WITHOUT_PILFER) { + && gestureScope != GestureScope.OUTSIDE_WITHOUT_PILFER + && gestureScope != GestureScope.OUTSIDE_WITH_KEYCODE) { expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_DOWN); } if (notLauncher3 && getNavigationModel() != NavigationModel.THREE_BUTTON) { @@ -1521,14 +1526,18 @@ public final class LauncherInstrumentation { expectEvent(TestProtocol.SEQUENCE_PILFER, EVENT_PILFER_POINTERS); } if (gestureScope != GestureScope.OUTSIDE_WITH_PILFER - && gestureScope != GestureScope.OUTSIDE_WITHOUT_PILFER) { + && gestureScope != GestureScope.OUTSIDE_WITHOUT_PILFER + && gestureScope != GestureScope.OUTSIDE_WITH_KEYCODE) { expectEvent(TestProtocol.SEQUENCE_MAIN, gestureScope == GestureScope.INSIDE || gestureScope == GestureScope.OUTSIDE_WITHOUT_PILFER ? EVENT_TOUCH_UP : EVENT_TOUCH_CANCEL); } if (notLauncher3 && getNavigationModel() != NavigationModel.THREE_BUTTON) { - expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_UP_TIS); + expectEvent(TestProtocol.SEQUENCE_TIS, + gestureScope == GestureScope.INSIDE_TO_OUTSIDE_WITH_KEYCODE + || gestureScope == GestureScope.OUTSIDE_WITH_KEYCODE + ? EVENT_TOUCH_CANCEL_TIS : EVENT_TOUCH_UP_TIS); } break; }