summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurice Lam <yukl@google.com>2018-03-16 19:19:44 -0700
committerMaurice Lam <yukl@google.com>2018-03-19 18:15:23 +0000
commit3514ad526af3d95f61383ec374ea4c384ba9b540 (patch)
treeda4b5d9fc7f41dda1834d57564ad5b66b0c7cb54
parente93708bb620727df3994c877ff6df83cc17f4088 (diff)
downloadsetupwizard-3514ad526af3d95f61383ec374ea4c384ba9b540.tar.gz
Add methods to set GLIF icon content description
Test: ./gradlew connectedAndroidTest Bug: 74435529 Change-Id: I22e3abe8dce0663a7d1e7ee3050d327abeec4ad2 (cherry picked from commit c38af2fb55868523e5ddcceb6331947501f43adf)
-rw-r--r--library/main/src/com/android/setupwizardlib/template/IconMixin.java18
-rw-r--r--library/test/instrumentation/src/com/android/setupwizardlib/template/IconMixinTest.java14
2 files changed, 32 insertions, 0 deletions
diff --git a/library/main/src/com/android/setupwizardlib/template/IconMixin.java b/library/main/src/com/android/setupwizardlib/template/IconMixin.java
index 7f5a3c9..5386c92 100644
--- a/library/main/src/com/android/setupwizardlib/template/IconMixin.java
+++ b/library/main/src/com/android/setupwizardlib/template/IconMixin.java
@@ -91,6 +91,24 @@ public class IconMixin implements Mixin {
}
/**
+ * Sets the content description of the icon view
+ */
+ public void setContentDescription(CharSequence description) {
+ final ImageView iconView = getView();
+ if (iconView != null) {
+ iconView.setContentDescription(description);
+ }
+ }
+
+ /**
+ * @return The content description of the icon view
+ */
+ public CharSequence getContentDescription() {
+ final ImageView iconView = getView();
+ return iconView != null ? iconView.getContentDescription() : null;
+ }
+
+ /**
* @return The ImageView responsible for displaying the icon.
*/
protected ImageView getView() {
diff --git a/library/test/instrumentation/src/com/android/setupwizardlib/template/IconMixinTest.java b/library/test/instrumentation/src/com/android/setupwizardlib/template/IconMixinTest.java
index 12187a2..5a36f4a 100644
--- a/library/test/instrumentation/src/com/android/setupwizardlib/template/IconMixinTest.java
+++ b/library/test/instrumentation/src/com/android/setupwizardlib/template/IconMixinTest.java
@@ -127,4 +127,18 @@ public class IconMixinTest {
assertEquals(expected.getBitmap(), actual.getBitmap());
assertEquals(View.VISIBLE, mIconView.getVisibility());
}
+
+ @Test
+ public void setContentDescription_shouldSetContentDescriptionOnIconView() {
+ IconMixin mixin = new IconMixin(mTemplateLayout, null, 0);
+ mixin.setContentDescription("hello world");
+ assertThat(mIconView.getContentDescription()).isEqualTo("hello world");
+ }
+
+ @Test
+ public void getContentDescription_shouldReturnContentDescriptionFromView() {
+ IconMixin mixin = new IconMixin(mTemplateLayout, null, 0);
+ mIconView.setContentDescription("aloha");
+ assertThat(mixin.getContentDescription()).isEqualTo("aloha");
+ }
}