use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MasterSwitchPreferenceTest method setChecked_shouldUpdateButtonCheckedState.
@Test
public void setChecked_shouldUpdateButtonCheckedState() {
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);
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 MasterSwitchPreferenceTest method setSwitchEnabled_shouldUpdateButtonEnabledState.
@Test
public void setSwitchEnabled_shouldUpdateButtonEnabledState() {
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);
preference.onBindViewHolder(holder);
preference.setSwitchEnabled(true);
assertThat(toggle.isEnabled()).isTrue();
preference.setSwitchEnabled(false);
assertThat(toggle.isEnabled()).isFalse();
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MasterSwitchPreferenceTest method setDisabledByAdmin_noEnforcedAdmin_shouldEnableButton.
@Test
public void setDisabledByAdmin_noEnforcedAdmin_shouldEnableButton() {
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);
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 MasterSwitchPreferenceTest method clickWidgetView_shouldToggleButton.
@Test
public void clickWidgetView_shouldToggleButton() {
final MasterSwitchPreference preference = new MasterSwitchPreference(mContext);
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_switch, widgetView, true);
final Switch toggle = (Switch) holder.findViewById(R.id.switchWidget);
preference.onBindViewHolder(holder);
widgetView.performClick();
assertThat(toggle.isChecked()).isTrue();
widgetView.performClick();
assertThat(toggle.isChecked()).isFalse();
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RadioButtonPreferenceWithExtraWidgetTest method setUp.
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mPreference = new RadioButtonPreferenceWithExtraWidget(mContext);
mPreference.setSummary("test summary");
View view = LayoutInflater.from(mContext).inflate(R.layout.preference_radio_with_extra_widget, null);
PreferenceViewHolder preferenceViewHolder = PreferenceViewHolder.createInstanceForTests(view);
mPreference.onBindViewHolder(preferenceViewHolder);
mSummary = view.findViewById(android.R.id.summary);
mExtraWidget = view.findViewById(R.id.radio_extra_widget);
mExtraWidgetDivider = view.findViewById(R.id.radio_extra_widget_divider);
}
Aggregations