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

Commit ab5b6e73 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

am: 79d8e5db

Change-Id: Ied594a8096175ad340f246af3d467629df687bc1
parents 1e583e5d 79d8e5db
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);
    }
}