use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MasterCheckBoxPreferenceTest method setChecked_shouldUpdateCheckBoxCheckedState.
@Test
public void setChecked_shouldUpdateCheckBoxCheckedState() {
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(LayoutInflater.from(mContext).inflate(R.layout.preference_widget_master_checkbox, null));
final CheckBox checkBox = (CheckBox) holder.findViewById(R.id.checkboxWidget);
mPreference.onBindViewHolder(holder);
mPreference.setChecked(true);
assertThat(checkBox.isChecked()).isTrue();
mPreference.setChecked(false);
assertThat(checkBox.isChecked()).isFalse();
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MasterCheckBoxPreferenceTest method clickWidgetView_shouldNotifyPreferenceChanged.
@Test
public void clickWidgetView_shouldNotifyPreferenceChanged() {
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(LayoutInflater.from(mContext).inflate(R.layout.preference_two_target, null));
final View widgetView = holder.findViewById(android.R.id.widget_frame);
final OnPreferenceChangeListener listener = mock(OnPreferenceChangeListener.class);
mPreference.setOnPreferenceChangeListener(listener);
mPreference.onBindViewHolder(holder);
mPreference.setChecked(false);
widgetView.performClick();
verify(listener).onPreferenceChange(mPreference, true);
mPreference.setChecked(true);
widgetView.performClick();
verify(listener).onPreferenceChange(mPreference, false);
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MasterCheckBoxPreferenceTest method setCheckboxEnabled_shouldOnlyUpdateCheckBoxEnabledState.
@Test
public void setCheckboxEnabled_shouldOnlyUpdateCheckBoxEnabledState() {
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(LayoutInflater.from(mContext).inflate(R.layout.preference_widget_master_checkbox, null));
final CheckBox checkBox = (CheckBox) holder.findViewById(R.id.checkboxWidget);
mPreference.onBindViewHolder(holder);
mPreference.setCheckBoxEnabled(false);
assertThat(mPreference.isEnabled()).isTrue();
assertThat(checkBox.isEnabled()).isFalse();
mPreference.setCheckBoxEnabled(true);
assertThat(mPreference.isEnabled()).isTrue();
assertThat(checkBox.isEnabled()).isTrue();
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MasterCheckBoxPreferenceTest method onBindViewHolder_checkBoxShouldHaveContentDescription.
@Test
public void onBindViewHolder_checkBoxShouldHaveContentDescription() {
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(LayoutInflater.from(mContext).inflate(R.layout.preference_widget_master_checkbox, null));
final CheckBox checkBox = (CheckBox) holder.findViewById(R.id.checkboxWidget);
final String label = "TestButton";
mPreference.setTitle(label);
mPreference.onBindViewHolder(holder);
assertThat(checkBox.getContentDescription()).isEqualTo(label);
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RadioButtonPreferenceTest method hideAppendix_shouldBeGone.
@Test
public void hideAppendix_shouldBeGone() {
mPreference.setAppendixVisibility(View.GONE);
View view = LayoutInflater.from(mContext).inflate(R.layout.preference_radio, null);
PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(view);
mPreference.onBindViewHolder(holder);
assertThat(holder.findViewById(R.id.appendix).getVisibility()).isEqualTo(View.GONE);
}
Aggregations