summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Caitlin Shkuratov <caitlinshk@google.com> 2022-12-06 18:25:30 +0000
committer Caitlin Shkuratov <caitlinshk@google.com> 2022-12-06 18:26:15 +0000
commit8d86871d01acc9e4ed58d001dd040ab9a9b965ea (patch)
treed7fd03ba09d0f0d23cc694b1e3c1eca9a3e0c3cc
parent83382685821ba74752d1694ea7888c10d6c68811 (diff)
[Chipbar] Don't add null icon descriptions to the main description.
Fixes: 260951134 Test: verify active unlock chipbar doesn't contain "null" in its content description Test: atest ChipbarCoordinatorTest Change-Id: I2de3de5cd9146825e9ec706a7f1d7a6b1bacc737
-rw-r--r--packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt13
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt29
2 files changed, 37 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt b/packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt
index 3b8b1e3a5933..4d91e35856dc 100644
--- a/packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt
+++ b/packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt
@@ -156,11 +156,14 @@ open class ChipbarCoordinator @Inject constructor(
}
// ---- Overall accessibility ----
- currentView.requireViewById<ViewGroup>(
- R.id.chipbar_inner
- ).contentDescription =
- "${newInfo.startIcon.icon.contentDescription.loadContentDescription(context)} " +
- "${newInfo.text.loadText(context)}"
+ val iconDesc = newInfo.startIcon.icon.contentDescription
+ val loadedIconDesc = if (iconDesc != null) {
+ "${iconDesc.loadContentDescription(context)} "
+ } else {
+ ""
+ }
+ currentView.requireViewById<ViewGroup>(R.id.chipbar_inner).contentDescription =
+ "$loadedIconDesc${newInfo.text.loadText(context)}"
// ---- Haptics ----
newInfo.vibrationEffect?.let {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt
index 5343ad8340a7..7014f93fba4a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt
@@ -110,6 +110,35 @@ class ChipbarCoordinatorTest : SysuiTestCase() {
}
@Test
+ fun displayView_contentDescription_iconHasDescription() {
+ underTest.displayView(
+ createChipbarInfo(
+ Icon.Resource(R.drawable.ic_cake, ContentDescription.Loaded("loadedCD")),
+ Text.Loaded("text"),
+ endItem = null,
+ )
+ )
+
+ val contentDescView = getChipbarView().requireViewById<ViewGroup>(R.id.chipbar_inner)
+ assertThat(contentDescView.contentDescription.toString()).contains("loadedCD")
+ assertThat(contentDescView.contentDescription.toString()).contains("text")
+ }
+
+ @Test
+ fun displayView_contentDescription_iconHasNoDescription() {
+ underTest.displayView(
+ createChipbarInfo(
+ Icon.Resource(R.drawable.ic_cake, contentDescription = null),
+ Text.Loaded("text"),
+ endItem = null,
+ )
+ )
+
+ val contentDescView = getChipbarView().requireViewById<ViewGroup>(R.id.chipbar_inner)
+ assertThat(contentDescView.contentDescription.toString()).isEqualTo("text")
+ }
+
+ @Test
fun displayView_loadedIcon_correctlyRendered() {
val drawable = context.getDrawable(R.drawable.ic_celebration)!!