Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79d8e5db authored by Doris Ling's avatar Doris Ling Committed by android-build-merger
Browse files

Merge "Add content description to the master switch toggle button." into oc-dev

am: 10158fee

Change-Id: Icc68b53cbbb93755c7ce90db1c4d2f70d5e44cd1
parents 5c5b8013 10158fee
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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);
        }
+15 −0
Original line number Diff line number Diff line
@@ -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);
    }
}