use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class FingerprintPreferenceTest method bindAndClickDeleteButton_shouldInvokeOnDeleteListener.
@Test
public void bindAndClickDeleteButton_shouldInvokeOnDeleteListener() {
final FrameLayout layout = new FrameLayout(mContext);
LayoutInflater.from(mContext).inflate(mPreference.getSecondTargetResId(), layout, true);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(layout);
mPreference.onBindViewHolder(holder);
final View view = layout.findViewById(R.id.delete_button);
assertThat(view).isNotNull();
view.performClick();
verify(mOnDeleteClickListener).onDeleteClick(mPreference);
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NotificationAppPreferenceTest method setSwitchEnabled_shouldUpdateButtonEnabledState.
@Test
public void setSwitchEnabled_shouldUpdateButtonEnabledState() {
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);
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 NotificationAppPreferenceTest method clickWidgetView_shouldNotifyPreferenceChanged.
@Test
public void clickWidgetView_shouldNotifyPreferenceChanged() {
final NotificationAppPreference preference = new NotificationAppPreference(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(LayoutInflater.from(mContext).inflate(R.layout.preference_app, null));
final View widgetView = holder.findViewById(android.R.id.widget_frame);
final Preference.OnPreferenceChangeListener listener = mock(Preference.OnPreferenceChangeListener.class);
preference.setOnPreferenceChangeListener(listener);
preference.onBindViewHolder(holder);
preference.setChecked(false);
widgetView.performClick();
verify(listener).onPreferenceChange(preference, true);
preference.setChecked(true);
widgetView.performClick();
verify(listener).onPreferenceChange(preference, false);
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NotificationAppPreferenceTest method clickWidgetView_shouldToggleButton.
@Test
public void clickWidgetView_shouldToggleButton() {
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);
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 NotificationAppPreferenceTest method clickWidgetView_shouldNotToggleButtonIfDisabled.
@Test
public void clickWidgetView_shouldNotToggleButtonIfDisabled() {
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);
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);
toggle.setEnabled(false);
widgetView.performClick();
assertThat(toggle.isChecked()).isFalse();
}
Aggregations