Fix toolbar announce wrong text.
This is a regression during refactor toolbar code, we don't intent
to announce the toolbar popup window so we should not set content
description for the container.
Bug: 239563674
Test: manual. Turn on talkback and make sure the announce is correct
and the behavior is the same
Test: atest TextViewIntegrationTest pass for local/remote
Test: atest TextViewActivityTest pass for local/remote
Test: atest SuggestionsPopupWindowTest pass for local/remote
Change-Id: I6e30d2f6d9a2c4905b702c25655fe5e4eb7de5d5
diff --git a/core/java/android/service/selectiontoolbar/RemoteSelectionToolbar.java b/core/java/android/service/selectiontoolbar/RemoteSelectionToolbar.java
index 95bcda5..9292e96 100644
--- a/core/java/android/service/selectiontoolbar/RemoteSelectionToolbar.java
+++ b/core/java/android/service/selectiontoolbar/RemoteSelectionToolbar.java
@@ -1317,7 +1317,6 @@
contentContainer.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
contentContainer.setTag(FloatingToolbar.FLOATING_TOOLBAR_TAG);
- contentContainer.setContentDescription(FloatingToolbar.FLOATING_TOOLBAR_TAG);
contentContainer.setClipToOutline(true);
return contentContainer;
}
diff --git a/core/java/com/android/internal/widget/floatingtoolbar/LocalFloatingToolbarPopup.java b/core/java/com/android/internal/widget/floatingtoolbar/LocalFloatingToolbarPopup.java
index 8c61a12..80d8bd7 100644
--- a/core/java/com/android/internal/widget/floatingtoolbar/LocalFloatingToolbarPopup.java
+++ b/core/java/com/android/internal/widget/floatingtoolbar/LocalFloatingToolbarPopup.java
@@ -1475,7 +1475,6 @@
contentContainer.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
contentContainer.setTag(FloatingToolbar.FLOATING_TOOLBAR_TAG);
- contentContainer.setContentDescription(FloatingToolbar.FLOATING_TOOLBAR_TAG);
contentContainer.setClipToOutline(true);
return contentContainer;
}
diff --git a/core/res/res/layout/floating_popup_container.xml b/core/res/res/layout/floating_popup_container.xml
index ca03737..776a35d 100644
--- a/core/res/res/layout/floating_popup_container.xml
+++ b/core/res/res/layout/floating_popup_container.xml
@@ -16,6 +16,7 @@
*/
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/floating_popup_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="0dp"
diff --git a/core/tests/coretests/src/android/widget/FloatingToolbarUtils.java b/core/tests/coretests/src/android/widget/FloatingToolbarUtils.java
index c6f5924..2d3ed95 100644
--- a/core/tests/coretests/src/android/widget/FloatingToolbarUtils.java
+++ b/core/tests/coretests/src/android/widget/FloatingToolbarUtils.java
@@ -16,13 +16,12 @@
package android.widget;
-import static com.android.internal.widget.floatingtoolbar.FloatingToolbar.FLOATING_TOOLBAR_TAG;
-
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import android.content.res.Resources;
import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.BySelector;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.Until;
@@ -33,25 +32,27 @@
final class FloatingToolbarUtils {
private final UiDevice mDevice;
+ private static final BySelector TOOLBAR_CONTAINER_SELECTOR =
+ By.res("android", "floating_popup_container");
FloatingToolbarUtils() {
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
}
void waitForFloatingToolbarPopup() {
- mDevice.wait(Until.findObject(By.desc(FLOATING_TOOLBAR_TAG)), 500);
+ mDevice.wait(Until.findObject(TOOLBAR_CONTAINER_SELECTOR), 500);
}
void assertFloatingToolbarIsDisplayed() {
waitForFloatingToolbarPopup();
- assertThat(mDevice.hasObject(By.desc(FLOATING_TOOLBAR_TAG))).isTrue();
+ assertThat(mDevice.hasObject(TOOLBAR_CONTAINER_SELECTOR)).isTrue();
}
void assertFloatingToolbarContainsItem(String itemLabel) {
waitForFloatingToolbarPopup();
assertWithMessage("Expected to find item labelled [" + itemLabel + "]")
.that(mDevice.hasObject(
- By.desc(FLOATING_TOOLBAR_TAG).hasDescendant(By.text(itemLabel))))
+ TOOLBAR_CONTAINER_SELECTOR.hasDescendant(By.text(itemLabel))))
.isTrue();
}
@@ -59,14 +60,14 @@
waitForFloatingToolbarPopup();
assertWithMessage("Expected to not find item labelled [" + itemLabel + "]")
.that(mDevice.hasObject(
- By.desc(FLOATING_TOOLBAR_TAG).hasDescendant(By.text(itemLabel))))
+ TOOLBAR_CONTAINER_SELECTOR.hasDescendant(By.text(itemLabel))))
.isFalse();
}
void assertFloatingToolbarContainsItemAtIndex(String itemLabel, int index) {
waitForFloatingToolbarPopup();
assertWithMessage("Expected to find item labelled [" + itemLabel + "] at index " + index)
- .that(mDevice.findObject(By.desc(FLOATING_TOOLBAR_TAG))
+ .that(mDevice.findObject(TOOLBAR_CONTAINER_SELECTOR)
.findObjects(By.clickable(true))
.get(index)
.getChildren()
@@ -77,7 +78,7 @@
void clickFloatingToolbarItem(String label) {
waitForFloatingToolbarPopup();
- mDevice.findObject(By.desc(FLOATING_TOOLBAR_TAG))
+ mDevice.findObject(TOOLBAR_CONTAINER_SELECTOR)
.findObject(By.text(label))
.click();
}
@@ -85,13 +86,13 @@
void clickFloatingToolbarOverflowItem(String label) {
// TODO: There might be a benefit to combining this with "clickFloatingToolbarItem" method.
waitForFloatingToolbarPopup();
- mDevice.findObject(By.desc(FLOATING_TOOLBAR_TAG))
+ mDevice.findObject(TOOLBAR_CONTAINER_SELECTOR)
.findObject(By.desc(str(R.string.floating_toolbar_open_overflow_description)))
.click();
mDevice.wait(
- Until.findObject(By.desc(FLOATING_TOOLBAR_TAG).hasDescendant(By.text(label))),
+ Until.findObject(TOOLBAR_CONTAINER_SELECTOR.hasDescendant(By.text(label))),
1000);
- mDevice.findObject(By.desc(FLOATING_TOOLBAR_TAG))
+ mDevice.findObject(TOOLBAR_CONTAINER_SELECTOR)
.findObject(By.text(label))
.click();
}