Search in sources :

Example 6 with PreferenceViewHolder

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

Example 7 with PreferenceViewHolder

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

Example 8 with PreferenceViewHolder

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

Example 9 with PreferenceViewHolder

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

Example 10 with PreferenceViewHolder

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