use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MasterCheckBoxPreferenceTest method setEnabled_shouldUpdateCheckBoxEnabledState.
@Test
public void setEnabled_shouldUpdateCheckBoxEnabledState() {
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.setEnabled(true);
assertThat(checkBox.isEnabled()).isTrue();
mPreference.setEnabled(false);
assertThat(checkBox.isEnabled()).isFalse();
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MasterCheckBoxPreferenceTest method clickWidgetView_shouldNotToggleCheckBoxIfDisabled.
@Test
public void clickWidgetView_shouldNotToggleCheckBoxIfDisabled() {
final LayoutInflater inflater = LayoutInflater.from(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(R.layout.preference_two_target, null));
final LinearLayout widgetView = holder.itemView.findViewById(android.R.id.widget_frame);
assertThat(widgetView).isNotNull();
inflater.inflate(R.layout.preference_widget_master_checkbox, widgetView, true);
final CheckBox checkBox = (CheckBox) holder.findViewById(R.id.checkboxWidget);
mPreference.onBindViewHolder(holder);
mPreference.setEnabled(false);
widgetView.performClick();
assertThat(checkBox.isChecked()).isFalse();
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RadioButtonPreferenceTest method nullSummary_containerShouldBeGone.
@Test
public void nullSummary_containerShouldBeGone() {
mPreference.setSummary(null);
View summaryContainer = new View(mContext);
View view = mock(View.class);
when(view.findViewById(R.id.summary_container)).thenReturn(summaryContainer);
PreferenceViewHolder preferenceViewHolder = PreferenceViewHolder.createInstanceForTests(view);
mPreference.onBindViewHolder(preferenceViewHolder);
assertEquals(View.GONE, summaryContainer.getVisibility());
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RadioButtonPreferenceTest method summary_containerShouldBeVisible.
@Test
public void summary_containerShouldBeVisible() {
mPreference.setSummary("some summary");
View summaryContainer = new View(mContext);
View view = mock(View.class);
when(view.findViewById(R.id.summary_container)).thenReturn(summaryContainer);
PreferenceViewHolder preferenceViewHolder = PreferenceViewHolder.createInstanceForTests(view);
mPreference.onBindViewHolder(preferenceViewHolder);
assertEquals(View.VISIBLE, summaryContainer.getVisibility());
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RadioButtonPreferenceTest method emptySummary_containerShouldBeGone.
@Test
public void emptySummary_containerShouldBeGone() {
mPreference.setSummary("");
View summaryContainer = new View(mContext);
View view = mock(View.class);
when(view.findViewById(R.id.summary_container)).thenReturn(summaryContainer);
PreferenceViewHolder preferenceViewHolder = PreferenceViewHolder.createInstanceForTests(view);
mPreference.onBindViewHolder(preferenceViewHolder);
assertEquals(View.GONE, summaryContainer.getVisibility());
}
Aggregations