Merge "[Chipbar] Don't add null icon descriptions to the main description." into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6fa4943481
@@ -156,11 +156,14 @@ open class ChipbarCoordinator @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---- Overall accessibility ----
|
// ---- Overall accessibility ----
|
||||||
currentView.requireViewById<ViewGroup>(
|
val iconDesc = newInfo.startIcon.icon.contentDescription
|
||||||
R.id.chipbar_inner
|
val loadedIconDesc = if (iconDesc != null) {
|
||||||
).contentDescription =
|
"${iconDesc.loadContentDescription(context)} "
|
||||||
"${newInfo.startIcon.icon.contentDescription.loadContentDescription(context)} " +
|
} else {
|
||||||
"${newInfo.text.loadText(context)}"
|
""
|
||||||
|
}
|
||||||
|
currentView.requireViewById<ViewGroup>(R.id.chipbar_inner).contentDescription =
|
||||||
|
"$loadedIconDesc${newInfo.text.loadText(context)}"
|
||||||
|
|
||||||
// ---- Haptics ----
|
// ---- Haptics ----
|
||||||
newInfo.vibrationEffect?.let {
|
newInfo.vibrationEffect?.let {
|
||||||
|
|||||||
@@ -109,6 +109,35 @@ class ChipbarCoordinatorTest : SysuiTestCase() {
|
|||||||
underTest.start()
|
underTest.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Test
|
||||||
fun displayView_loadedIcon_correctlyRendered() {
|
fun displayView_loadedIcon_correctlyRendered() {
|
||||||
val drawable = context.getDrawable(R.drawable.ic_celebration)!!
|
val drawable = context.getDrawable(R.drawable.ic_celebration)!!
|
||||||
|
|||||||
Reference in New Issue
Block a user