From 4d4f62ac77dff74a6c3d57da7eff8d8dad9bf923 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Thu, 15 Sep 2022 09:36:45 +0800 Subject: [PATCH] TAPL: add setIgnoreTaskbarVisibility in LauncherInstrumentation As now FlickerTests is leveraging TAPL to interact devices CUJs, we realized in LauncherInstrumentation will verify task bar visibility automatically to expect it always visible when quick-switch, which is not always reliable since the task bar may be hidden by manual or when the activity requests to show IME. Add setIgnoreTaskbarVisibility in LauncherInstrumentation for the caller to ignore taskbar visibility if the test does not need to verify it. Bug: 228012334 Bug: 240306344 Test: atest FlickerTests:SwitchImeWindowsFromGestureNavTest in tablet device Test: atest NexusLauncherOutOfProcTests:com.android.quickstep.\ TaplTestsQuickstep#testQuickSwitchToPreviousAppForTablet Change-Id: Id0a35561523d733b8434acb702ec7dcaa466a1c2 --- .../android/quickstep/TaplTestsQuickstep.java | 22 +++++++++++++++ tests/Android.bp | 1 + tests/AndroidManifest-common.xml | 10 +++++++ .../testcomponent/BaseTestingActivity.java | 16 +++++++++++ .../testcomponent/ImeTestActivity.java | 27 +++++++++++++++++++ .../launcher3/ui/AbstractLauncherUiTest.java | 10 +++++++ .../android/launcher3/tapl/Background.java | 19 +++++++++---- .../launcher3/tapl/LaunchedAppState.java | 10 +++++++ .../tapl/LauncherInstrumentation.java | 18 ++++++++++++- 9 files changed, 127 insertions(+), 6 deletions(-) create mode 100644 tests/src/com/android/launcher3/testcomponent/ImeTestActivity.java diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index 42e9be32e3..cc561c6c23 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -309,6 +309,28 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { launchedAppState.switchToOverview(); } + @Test + @ScreenRecord // b/242163205 + public void testQuickSwitchToPreviousAppForTablet() throws Exception { + assumeTrue(mLauncher.isTablet()); + startTestActivity(2); + startImeTestActivity(); + + // Set ignoreTaskbarVisibility to true to verify the task bar visibility explicitly. + mLauncher.setIgnoreTaskbarVisibility(true); + + // Expect task bar invisible when the launched app was the IME activity. + LaunchedAppState launchedAppState = getAndAssertLaunchedApp(); + launchedAppState.assertTaskbarHidden(); + + // Quick-switch to the test app with swiping to right. + launchedAppState.quickSwitchToPreviousApp(); + + // Expect task bar visible when the launched app was the test activity. + launchedAppState = getAndAssertLaunchedApp(); + launchedAppState.assertTaskbarVisible(); + } + private boolean isTestActivityRunning(int activityNumber) { return mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()) .text("TestActivity" + activityNumber)), diff --git a/tests/Android.bp b/tests/Android.bp index 1584308091..39bd3074a3 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -60,6 +60,7 @@ filegroup { "src/com/android/launcher3/testcomponent/CustomShortcutConfigActivity.java", "src/com/android/launcher3/testcomponent/TestCommandReceiver.java", "src/com/android/launcher3/testcomponent/TestLauncherActivity.java", + "src/com/android/launcher3/testcomponent/ImeTestActivity.java", ], } diff --git a/tests/AndroidManifest-common.xml b/tests/AndroidManifest-common.xml index 9cc3aeda1f..ae1060ec92 100644 --- a/tests/AndroidManifest-common.xml +++ b/tests/AndroidManifest-common.xml @@ -277,6 +277,16 @@ + + + + + + + mDiagnosticContext = new LinkedList<>(); private Function mSystemHealthSupplier; + private boolean mIgnoreTaskbarVisibility = false; + private Consumer mOnSettledStateAction; private LogEventChecker mEventChecker; private boolean mCheckEventsForSuccessfulGestures = false; private Runnable mOnLauncherCrashed; - private static Pattern getTouchEventPattern(String prefix, String action) { // The pattern includes checks that we don't get a multi-touch events or other surprises. return Pattern.compile( @@ -680,6 +681,18 @@ public final class LauncherInstrumentation { } } + /** + * Whether to ignore verifying the task bar visibility during instrumenting. + * + * @param ignoreTaskbarVisibility {@code true} will ignore the instrumentation implicitly + * verifying the task bar visibility with + * {@link VisibleContainer#verifyActiveContainer}. + * {@code false} otherwise. + */ + public void setIgnoreTaskbarVisibility(boolean ignoreTaskbarVisibility) { + mIgnoreTaskbarVisibility = ignoreTaskbarVisibility; + } + public void setExpectedRotation(int expectedRotation) { mExpectedRotation = expectedRotation; } @@ -798,6 +811,9 @@ public final class LauncherInstrumentation { waitUntilLauncherObjectGone(WIDGETS_RES_ID); waitUntilLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID); + if (mIgnoreTaskbarVisibility) { + return null; + } if (isTablet() && !isFallbackOverview()) { waitForLauncherObject(TASKBAR_RES_ID); } else {