From e90f098d4f0f04d86e16e35e127818219c061a8f Mon Sep 17 00:00:00 2001 From: Fengjiang Li Date: Tue, 12 Mar 2024 09:36:54 -0700 Subject: [PATCH] Enable predictive back in TAPL tests With ag/26349940 we have fixed the bug where back swipe is not working Fix: 326118348 Test: this is the test Flag: NONE Change-Id: I7e826f6ba3022a04d016d4a0a2134e287d85e8be --- .../launcher3/uioverrides/QuickstepLauncher.java | 11 ++++++++++- .../src/com/android/quickstep/TaplTestsQuickstep.java | 2 -- .../src/com/android/quickstep/TaplTestsTrackpad.java | 3 --- src/com/android/launcher3/DeviceProfile.java | 1 + .../launcher3/testing/TestInformationHandler.java | 7 +++++-- .../launcher3/testing/shared/TestProtocol.java | 2 ++ .../launcher3/allapps/TaplOpenCloseAllAppsTest.java | 3 --- .../launcher3/tapl/LauncherInstrumentation.java | 8 ++++++-- 8 files changed, 24 insertions(+), 13 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 75dfe30d89..2b10bfde66 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -39,8 +39,8 @@ import static com.android.launcher3.LauncherState.OVERVIEW_SPLIT_SELECT; import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent; import static com.android.launcher3.config.FeatureFlags.enableSplitContextually; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP; -import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SPLIT_SELECTION_EXIT_INTERRUPTED; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SPLIT_SELECTION_EXIT_HOME; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SPLIT_SELECTION_EXIT_INTERRUPTED; import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID; import static com.android.launcher3.popup.QuickstepSystemShortcut.getSplitSelectShortcutByPosition; import static com.android.launcher3.popup.SystemShortcut.APP_INFO; @@ -105,6 +105,7 @@ import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Flags; import com.android.launcher3.HomeTransitionController; +import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.LauncherState; @@ -665,6 +666,14 @@ public class QuickstepLauncher extends Launcher { View.setTracedRequestLayoutClassClass(TRACE_RELAYOUT_CLASS); } + @Override + protected boolean initDeviceProfile(InvariantDeviceProfile idp) { + final boolean ret = super.initDeviceProfile(idp); + mDeviceProfile.isPredictiveBackSwipe = + getApplicationInfo().isOnBackInvokedCallbackEnabled(); + return ret; + } + @Override public void startSplitSelection(SplitSelectSource splitSelectSource) { RecentsView recentsView = getOverviewPanel(); diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index 45a95277b5..a53bb4e82d 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -35,7 +35,6 @@ import androidx.test.runner.AndroidJUnit4; import androidx.test.uiautomator.By; import androidx.test.uiautomator.Until; -import com.android.launcher3.Flags; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.tapl.LaunchedAppState; @@ -421,7 +420,6 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { READ_DEVICE_CONFIG_PERMISSION); // Debug if we need to goHome to prevent wrong previous state b/315525621 mLauncher.goHome(); - assumeFalse(Flags.enablePredictiveBackGesture()); mLauncher.getWorkspace().switchToAllApps().pressBackToWorkspace(); waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsTrackpad.java b/quickstep/tests/src/com/android/quickstep/TaplTestsTrackpad.java index aa8c7b5477..374722e694 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsTrackpad.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsTrackpad.java @@ -19,7 +19,6 @@ package com.android.quickstep; import static com.android.quickstep.NavigationModeSwitchRule.Mode.ZERO_BUTTON; import static org.junit.Assert.assertNotNull; -import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; import android.app.Instrumentation; @@ -28,7 +27,6 @@ import androidx.test.filters.LargeTest; import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.runner.AndroidJUnit4; -import com.android.launcher3.Flags; import com.android.launcher3.tapl.LauncherInstrumentation.TrackpadGestureType; import com.android.launcher3.tapl.Workspace; import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape; @@ -69,7 +67,6 @@ public class TaplTestsTrackpad extends AbstractQuickStepTest { @NavigationModeSwitch(mode = ZERO_BUTTON) public void pressBack() throws Exception { assumeTrue(mLauncher.isTablet()); - assumeFalse(Flags.enablePredictiveBackGesture()); Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); try { diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 4b4bdc2ecf..7e6835ba2f 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -101,6 +101,7 @@ public class DeviceProfile { public final boolean transposeLayoutWithOrientation; public final boolean isMultiDisplay; public final boolean isTwoPanels; + public boolean isPredictiveBackSwipe; public final boolean isQsbInline; // Device properties in current orientation diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index 07df7af97e..12cdd67515 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -19,9 +19,9 @@ import static com.android.launcher3.Flags.enableGridOnlyOverview; import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST; import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION; import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE; +import static com.android.launcher3.config.FeatureFlags.enableAppPairs; import static com.android.launcher3.config.FeatureFlags.enableSplitContextually; import static com.android.launcher3.testing.shared.TestProtocol.TEST_INFO_RESPONSE_FIELD; -import static com.android.launcher3.config.FeatureFlags.enableAppPairs; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.app.Activity; @@ -183,7 +183,10 @@ public class TestInformationHandler implements ResourceBasedOverride { case TestProtocol.REQUEST_IS_TABLET: response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, mDeviceProfile.isTablet); return response; - + case TestProtocol.REQUEST_IS_PREDICTIVE_BACK_SWIPE_ENABLED: + response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, + mDeviceProfile.isPredictiveBackSwipe); + return response; case TestProtocol.REQUEST_ENABLE_TASKBAR_NAVBAR_UNIFICATION: response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, ENABLE_TASKBAR_NAVBAR_UNIFICATION); diff --git a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java index d02ad3bba2..e0fafcc8d2 100644 --- a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java +++ b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java @@ -120,6 +120,8 @@ public final class TestProtocol { public static final String REQUEST_CLEAR_DATA = "clear-data"; public static final String REQUEST_HOTSEAT_ICON_NAMES = "get-hotseat-icon-names"; public static final String REQUEST_IS_TABLET = "is-tablet"; + public static final String REQUEST_IS_PREDICTIVE_BACK_SWIPE_ENABLED = + "is-predictive-back-swipe-enabled"; public static final String REQUEST_ENABLE_TASKBAR_NAVBAR_UNIFICATION = "enable-taskbar-navbar-unification"; public static final String REQUEST_NUM_ALL_APPS_COLUMNS = "num-all-apps-columns"; diff --git a/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllAppsTest.java b/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllAppsTest.java index 4d73f7a802..e462c4f9b1 100644 --- a/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllAppsTest.java +++ b/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllAppsTest.java @@ -20,7 +20,6 @@ import static com.android.launcher3.util.TestUtil.expectFail; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; import android.content.Intent; @@ -29,7 +28,6 @@ import android.platform.test.annotations.PlatinumTest; import androidx.test.filters.FlakyTest; import androidx.test.platform.app.InstrumentationRegistry; -import com.android.launcher3.Flags; import com.android.launcher3.LauncherState; import com.android.launcher3.tapl.AllApps; import com.android.launcher3.ui.AbstractLauncherUiTest; @@ -199,7 +197,6 @@ public class TaplOpenCloseAllAppsTest extends AbstractLauncherUiTest { public void testPressBackFromAllAppsToHome() { InstrumentationRegistry.getInstrumentation().getUiAutomation().adoptShellPermissionIdentity( READ_DEVICE_CONFIG_PERMISSION); - assumeFalse(Flags.enablePredictiveBackGesture()); mLauncher .getWorkspace() .switchToAllApps() diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 0e2735f7e1..bfff541eca 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -402,6 +402,11 @@ public final class LauncherInstrumentation { .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD); } + private boolean isPredictiveBackSwipeEnabled() { + return getTestInfo(TestProtocol.REQUEST_IS_PREDICTIVE_BACK_SWIPE_ENABLED) + .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD); + } + public boolean isTaskbarNavbarUnificationEnabled() { return getTestInfo(TestProtocol.REQUEST_ENABLE_TASKBAR_NAVBAR_UNIFICATION) .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD); @@ -1211,8 +1216,7 @@ public final class LauncherInstrumentation { waitForNavigationUiObject("back").click(); } if (launcherVisible) { - if (InstrumentationRegistry.getTargetContext().getApplicationInfo() - .isOnBackInvokedCallbackEnabled()) { + if (isPredictiveBackSwipeEnabled()) { expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_ON_BACK_INVOKED); } else { expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_KEY_BACK_UP);