Search in sources :

Example 16 with PreferenceViewHolder

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();
}
Also used : CheckBox(android.widget.CheckBox) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) Test(org.junit.Test)

Example 17 with PreferenceViewHolder

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);
}
Also used : OnPreferenceChangeListener(androidx.preference.Preference.OnPreferenceChangeListener) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) View(android.view.View) Test(org.junit.Test)

Example 18 with PreferenceViewHolder

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();
}
Also used : CheckBox(android.widget.CheckBox) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) Test(org.junit.Test)

Example 19 with PreferenceViewHolder

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);
}
Also used : CheckBox(android.widget.CheckBox) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) Test(org.junit.Test)

Example 20 with PreferenceViewHolder

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);
}
Also used : View(android.view.View) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) Test(org.junit.Test)

Aggregations

PreferenceViewHolder (androidx.preference.PreferenceViewHolder)79 Test (org.junit.Test)61 View (android.view.View)33 LayoutInflater (android.view.LayoutInflater)29 LinearLayout (android.widget.LinearLayout)17 Switch (android.widget.Switch)16 TextView (android.widget.TextView)16 CheckBox (android.widget.CheckBox)14 Preference (androidx.preference.Preference)12 PreferenceCategory (androidx.preference.PreferenceCategory)7 Drawable (android.graphics.drawable.Drawable)6 ProgressBar (android.widget.ProgressBar)5 OnPreferenceChangeListener (androidx.preference.Preference.OnPreferenceChangeListener)5 ImportancePreference (com.android.settings.notification.app.ImportancePreference)5 Before (org.junit.Before)5 ImageView (android.widget.ImageView)4 Context (android.content.Context)3 Button (android.widget.Button)3 ListPreference (androidx.preference.ListPreference)3 PreferenceGroupAdapter (androidx.preference.PreferenceGroupAdapter)3