Merge "Add content description to the master switch toggle button." into oc-dev
am: 10158feecf
Change-Id: Icc68b53cbbb93755c7ce90db1c4d2f70d5e44cd1
This commit is contained in:
@@ -83,6 +83,7 @@ public class MasterSwitchPreference extends TwoTargetPreference {
|
||||
|
||||
mSwitch = (Switch) holder.findViewById(R.id.switchWidget);
|
||||
if (mSwitch != null) {
|
||||
mSwitch.setContentDescription(getTitle());
|
||||
mSwitch.setChecked(mChecked);
|
||||
mSwitch.setEnabled(mEnableSwitch);
|
||||
}
|
||||
|
@@ -183,4 +183,19 @@ public class MasterSwitchPreferenceTest {
|
||||
preference.setDisabledByAdmin(null);
|
||||
assertThat(toggle.isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onBindViewHolder_toggleButtonShouldHaveContentDescription() {
|
||||
final MasterSwitchPreference preference = new MasterSwitchPreference(mContext);
|
||||
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
|
||||
LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.preference_widget_master_switch, null));
|
||||
final Switch toggle = (Switch) holder.findViewById(R.id.switchWidget);
|
||||
final String label = "TestButton";
|
||||
preference.setTitle(label);
|
||||
|
||||
preference.onBindViewHolder(holder);
|
||||
|
||||
assertThat(toggle.getContentDescription()).isEqualTo(label);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user