use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NotificationAppPreferenceTest method setDisabledByAdmin_noEnforcedAdmin_shouldEnableButton.
@Test
public void setDisabledByAdmin_noEnforcedAdmin_shouldEnableButton() {
final NotificationAppPreference preference = new NotificationAppPreference(mContext);
final LayoutInflater inflater = LayoutInflater.from(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(R.layout.preference_app, null));
final LinearLayout widgetView = holder.itemView.findViewById(android.R.id.widget_frame);
inflater.inflate(R.layout.preference_widget_master_switch, widgetView, true);
final Switch toggle = (Switch) holder.findViewById(R.id.switchWidget);
toggle.setEnabled(false);
preference.onBindViewHolder(holder);
preference.setDisabledByAdmin(null);
assertThat(toggle.isEnabled()).isTrue();
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NotificationAppPreferenceTest method onBindViewHolder_toggleButtonShouldHaveContentDescription.
@Test
public void onBindViewHolder_toggleButtonShouldHaveContentDescription() {
final NotificationAppPreference preference = new NotificationAppPreference(mContext);
final LayoutInflater inflater = LayoutInflater.from(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(R.layout.preference_app, null));
final LinearLayout widgetView = holder.itemView.findViewById(android.R.id.widget_frame);
inflater.inflate(R.layout.preference_widget_master_switch, widgetView, true);
final Switch toggle = (Switch) holder.findViewById(R.id.switchWidget);
final String label = "TestButton";
preference.setTitle(label);
preference.onBindViewHolder(holder);
assertThat(toggle.getContentDescription()).isEqualTo(label);
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class StorageItemPreferenceTest method testProgressBarPercentageSet.
@Test
public void testProgressBarPercentageSet() {
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(LayoutInflater.from(mContext).inflate(R.layout.storage_item, null));
final ProgressBar progressBar = holder.itemView.findViewById(android.R.id.progress);
mPreference.onBindViewHolder(holder);
mPreference.setStorageSize(MEGABYTE_IN_BYTES, MEGABYTE_IN_BYTES * 10);
assertThat(progressBar).isNotNull();
assertThat(progressBar.getProgress()).isEqualTo(10);
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ZenCustomRadioButtonPreferenceTest method setChecked_shouldUpdateButtonCheckedState.
@Test
public void setChecked_shouldUpdateButtonCheckedState() {
final ZenCustomRadioButtonPreference preference = new ZenCustomRadioButtonPreference(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(LayoutInflater.from(mContext).inflate(R.layout.preference_two_target_radio, null));
final RadioButton toggle = (RadioButton) holder.findViewById(android.R.id.checkbox);
preference.onBindViewHolder(holder);
preference.setChecked(true);
assertThat(toggle.isChecked()).isTrue();
preference.setChecked(false);
assertThat(toggle.isChecked()).isFalse();
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ZenCustomRadioButtonPreferenceTest method clickWidgetView_shouldNotifyWidgetClicked.
@Test
public void clickWidgetView_shouldNotifyWidgetClicked() {
final ZenCustomRadioButtonPreference preference = new ZenCustomRadioButtonPreference(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(LayoutInflater.from(mContext).inflate(R.layout.preference_two_target_radio, null));
final View widgetView = holder.findViewById(android.R.id.widget_frame);
ZenCustomRadioButtonPreference.OnGearClickListener l = mock(ZenCustomRadioButtonPreference.OnGearClickListener.class);
preference.setOnGearClickListener(l);
preference.onBindViewHolder(holder);
widgetView.performClick();
verify(l).onGearClick(preference);
}
Aggregations