Merge "Add IDs to buttons in 3 button nav for Taskbar" into sc-v2-dev am: 3fcc02b8dc am: 7107268df9
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15027506
Change-Id: I7fc65aa447ab6ca63b3e5b0ff1802ad056ab4b56
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index 2facd44..4e85eb4 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -30,6 +30,7 @@
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 @@
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 @@
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 @@
// 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 @@
// 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 @@
}
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 8b0f426..dd7c403 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java
@@ -23,6 +23,8 @@
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 @@
}
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 1bd40ce..d941716 100644
--- a/res/values/id.xml
+++ b/res/values/id.xml
@@ -19,4 +19,13 @@
<item type="id" name="view_type_widgets_list" />
<item type="id" name="view_type_widgets_header" />
<item type="id" name="view_type_widgets_search_header" />
+
+ <!-- Do not change, must be kept in sync with sysui navbar button IDs for tests! -->
+ <item type="id" name="home" />
+ <item type="id" name="recent_apps" />
+ <item type="id" name="back" />
+ <item type="id" name="ime_switcher" />
+ <item type="id" name="accessibility_button" />
+ <item type="id" name="rotate_suggestion" />
+ <!-- /Do not change, must be kept in sync with sysui navbar button IDs for tests! -->
</resources>
diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java
index 4261d08..5cd3682 100644
--- a/src/com/android/launcher3/testing/TestInformationHandler.java
+++ b/src/com/android/launcher3/testing/TestInformationHandler.java
@@ -117,6 +117,10 @@
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 b6da7fc..2f1f82d 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -94,6 +94,7 @@
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 e86be2a..55be593 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -136,7 +136,7 @@
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 @@
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 96e8222..95a15c0 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -283,6 +283,11 @@
.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 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 @@
}
runToState(
- waitForSystemUiObject("home")::click,
+ waitForNavigationUiObject("home")::click,
NORMAL_STATE_ORDINAL,
!hasLauncherObject(WORKSPACE_RES_ID)
&& (hasLauncherObject(APPS_RES_ID)
@@ -891,6 +902,15 @@
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 1ea0922..f4fe49d 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -63,7 +63,7 @@
/**
* Swipes up to All Apps.
*
- * @return the App Apps object.
+ * @return the All Apps object.
*/
@NonNull
public AllApps switchToAllApps() {