Search in sources :

Example 46 with PreferenceViewHolder

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

Example 47 with PreferenceViewHolder

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

Example 48 with PreferenceViewHolder

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

Example 49 with PreferenceViewHolder

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

Example 50 with PreferenceViewHolder

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

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