diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index 2facd4436c..4e85eb4ced 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -30,6 +30,7 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_I import android.animation.ObjectAnimator; import android.annotation.DrawableRes; +import android.annotation.IdRes; import android.graphics.Rect; import android.graphics.Region; import android.graphics.Region.Op; @@ -123,7 +124,8 @@ public class NavbarButtonsViewController { flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0, MultiValueAlpha.VALUE, 1, 0)); // Rotation button - RotationButton rotationButton = new RotationButtonImpl(addButton(mEndContainer)); + RotationButton rotationButton = new RotationButtonImpl( + addButton(mEndContainer, R.id.rotate_suggestion)); rotationButton.hide(); mControllers.rotationButtonController.setRotationButton(rotationButton); } else { @@ -138,7 +140,7 @@ public class NavbarButtonsViewController { TaskbarNavButtonController navButtonController) { View backButton = addButton(R.drawable.ic_sysbar_back, BUTTON_BACK, - startContainer, navButtonController); + startContainer, navButtonController, R.id.back); // Rotate when Ime visible mPropertyHolders.add(new StatePropertyHolder(backButton, flags -> (flags & FLAG_IME_VISIBLE) == 0, View.ROTATION, 0, @@ -149,19 +151,19 @@ public class NavbarButtonsViewController { // home and recents buttons View homeButton = addButton(R.drawable.ic_sysbar_home, BUTTON_HOME, startContainer, - navButtonController); + navButtonController, R.id.home); mPropertyHolders.add(new StatePropertyHolder(homeButton, flags -> (flags & FLAG_IME_VISIBLE) == 0 && (flags & FLAG_KEYGUARD_VISIBLE) == 0)); View recentsButton = addButton(R.drawable.ic_sysbar_recent, BUTTON_RECENTS, - startContainer, navButtonController); + startContainer, navButtonController, R.id.recent_apps); mPropertyHolders.add(new StatePropertyHolder(recentsButton, flags -> (flags & FLAG_IME_VISIBLE) == 0 && (flags & FLAG_KEYGUARD_VISIBLE) == 0)); // IME switcher View imeSwitcherButton = addButton(R.drawable.ic_ime_switcher, BUTTON_IME_SWITCH, - endContainer, navButtonController); + endContainer, navButtonController, R.id.ime_switcher); mPropertyHolders.add(new StatePropertyHolder(imeSwitcherButton, flags -> ((flags & MASK_IME_SWITCHER_VISIBLE) == MASK_IME_SWITCHER_VISIBLE) && ((flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0) @@ -169,7 +171,7 @@ public class NavbarButtonsViewController { // A11y button mA11yButton = addButton(R.drawable.ic_sysbar_accessibility_button, BUTTON_A11Y, - endContainer, navButtonController); + endContainer, navButtonController, R.id.accessibility_button); mPropertyHolders.add(new StatePropertyHolder(mA11yButton, flags -> (flags & FLAG_A11Y_VISIBLE) != 0 && (flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0)); @@ -251,16 +253,17 @@ public class NavbarButtonsViewController { } private ImageView addButton(@DrawableRes int drawableId, @TaskbarButton int buttonType, - ViewGroup parent, TaskbarNavButtonController navButtonController) { - ImageView buttonView = addButton(parent); + ViewGroup parent, TaskbarNavButtonController navButtonController, @IdRes int id) { + ImageView buttonView = addButton(parent, id); buttonView.setImageResource(drawableId); buttonView.setOnClickListener(view -> navButtonController.onButtonClick(buttonType)); return buttonView; } - private ImageView addButton(ViewGroup parent) { + private ImageView addButton(ViewGroup parent, int id) { ImageView buttonView = (ImageView) mContext.getLayoutInflater() .inflate(R.layout.taskbar_nav_button, parent, false); + buttonView.setId(id); parent.addView(buttonView); mAllButtons.add(buttonView); return buttonView; diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java index 8b0f426699..dd7c403d65 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java @@ -23,6 +23,8 @@ import android.view.inputmethod.InputMethodManager; import androidx.annotation.IntDef; +import com.android.launcher3.testing.TestLogging; +import com.android.launcher3.testing.TestProtocol; import com.android.quickstep.OverviewCommandHelper; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.TouchInteractionService; @@ -94,6 +96,7 @@ public class TaskbarNavButtonController { } private void navigateToOverview() { + TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "onOverviewToggle"); mService.getOverviewCommandHelper().addCommand(OverviewCommandHelper.TYPE_TOGGLE); } diff --git a/res/values/id.xml b/res/values/id.xml index 1bd40cec4a..d941716f0a 100644 --- a/res/values/id.xml +++ b/res/values/id.xml @@ -19,4 +19,13 @@ + + + + + + + + + diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index 4261d080d9..5cd36825fc 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -117,6 +117,10 @@ public class TestInformationHandler implements ResourceBasedOverride { TestProtocol.sDisableSensorRotation = true; return response; + case TestProtocol.REQUEST_IS_TABLET: + response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, mDeviceProfile.isTablet); + return response; + default: return null; } diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index b6da7fcd37..2f1f82d9f7 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -94,6 +94,7 @@ public final class TestProtocol { public static final String REQUEST_GET_TEST_EVENTS = "get-test-events"; public static final String REQUEST_STOP_EVENT_LOGGING = "stop-event-logging"; public static final String REQUEST_CLEAR_DATA = "clear-data"; + public static final String REQUEST_IS_TABLET = "is-tablet"; public static boolean sDebugTracing = false; public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing"; diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java index e86be2af1e..55be593fb4 100644 --- a/tests/tapl/com/android/launcher3/tapl/Background.java +++ b/tests/tapl/com/android/launcher3/tapl/Background.java @@ -136,7 +136,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer { case THREE_BUTTON: mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); mLauncher.runToState( - () -> mLauncher.waitForSystemUiObject("recent_apps").click(), + () -> mLauncher.waitForNavigationUiObject("recent_apps").click(), OVERVIEW_STATE_ORDINAL); break; } @@ -224,7 +224,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer { case THREE_BUTTON: // Double press the recents button. - UiObject2 recentsButton = mLauncher.waitForSystemUiObject("recent_apps"); + UiObject2 recentsButton = mLauncher.waitForNavigationUiObject("recent_apps"); mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL); mLauncher.getOverview(); diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 96e82224b1..95a15c0162 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -283,6 +283,11 @@ public final class LauncherInstrumentation { .getParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD); } + public boolean isTablet() { + return getTestInfo(TestProtocol.REQUEST_IS_TABLET) + .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD); + } + void setActiveContainer(VisibleContainer container) { sActiveContainer = new WeakReference<>(container); } @@ -554,29 +559,35 @@ public final class LauncherInstrumentation { public String getNavigationModeMismatchError(boolean waitForCorrectState) { final int waitTime = waitForCorrectState ? WAIT_TIME_MS : 0; final NavigationModel navigationModel = getNavigationModel(); - + String resPackage = getNavigationButtonResPackage(); if (navigationModel == NavigationModel.THREE_BUTTON) { - if (!mDevice.wait(Until.hasObject(By.res(SYSTEMUI_PACKAGE, "recent_apps")), waitTime)) { + if (!mDevice.wait(Until.hasObject(By.res(resPackage, "recent_apps")), waitTime)) { return "Recents button not present in 3-button mode"; } } else { - if (!mDevice.wait(Until.gone(By.res(SYSTEMUI_PACKAGE, "recent_apps")), waitTime)) { + if (!mDevice.wait(Until.gone(By.res(resPackage, "recent_apps")), waitTime)) { return "Recents button is present in non-3-button mode"; } } if (navigationModel == NavigationModel.ZERO_BUTTON) { - if (!mDevice.wait(Until.gone(By.res(SYSTEMUI_PACKAGE, "home")), waitTime)) { + if (!mDevice.wait(Until.gone(By.res(resPackage, "home")), waitTime)) { return "Home button is present in gestural mode"; } } else { - if (!mDevice.wait(Until.hasObject(By.res(SYSTEMUI_PACKAGE, "home")), waitTime)) { + if (!mDevice.wait(Until.hasObject(By.res(resPackage, "home")), waitTime)) { return "Home button not present in non-gestural mode"; } } return null; } + private String getNavigationButtonResPackage() { + return isTablet() && getNavigationModel() == NavigationModel.THREE_BUTTON ? + getLauncherPackageName() : + SYSTEMUI_PACKAGE; + } + private UiObject2 verifyContainerType(ContainerType containerType) { waitForLauncherInitialized(); @@ -741,7 +752,7 @@ public final class LauncherInstrumentation { } runToState( - waitForSystemUiObject("home")::click, + waitForNavigationUiObject("home")::click, NORMAL_STATE_ORDINAL, !hasLauncherObject(WORKSPACE_RES_ID) && (hasLauncherObject(APPS_RES_ID) @@ -891,6 +902,15 @@ public final class LauncherInstrumentation { return object; } + @NonNull + UiObject2 waitForNavigationUiObject(String resId) { + String resPackage = getNavigationButtonResPackage(); + final UiObject2 object = mDevice.wait( + Until.findObject(By.res(resPackage, resId)), WAIT_TIME_MS); + assertNotNull("Can't find a navigation UI object with id: " + resId, object); + return object; + } + @Nullable UiObject2 findObjectInContainer(UiObject2 container, BySelector selector) { try { diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index 1ea0922029..f4fe49db8b 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -63,7 +63,7 @@ public final class Workspace extends Home { /** * Swipes up to All Apps. * - * @return the App Apps object. + * @return the All Apps object. */ @NonNull public AllApps switchToAllApps() {