Search in sources :

Example 41 with PreferenceViewHolder

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

Example 42 with PreferenceViewHolder

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

Example 43 with PreferenceViewHolder

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

Example 44 with PreferenceViewHolder

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

Example 45 with PreferenceViewHolder

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());
}
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