Search in sources :

Example 71 with PreferenceViewHolder

use of androidx.preference.PreferenceViewHolder in project android_packages_apps_Settings by omnirom.

the class PrimaryCheckBoxPreferenceTest method onBindViewHolder_checkBoxShouldHaveContentDescription.

@Test
public void onBindViewHolder_checkBoxShouldHaveContentDescription() {
    final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(LayoutInflater.from(mContext).inflate(R.layout.preference_widget_primary_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 72 with PreferenceViewHolder

use of androidx.preference.PreferenceViewHolder in project android_packages_apps_Settings by omnirom.

the class ChangeScreenLockPreferenceControllerTest method mockGearPreferenceAndViewHolder.

private void mockGearPreferenceAndViewHolder() {
    mGearPreference = new GearPreference(mContext, null);
    mGearView = new View(mContext);
    PreferenceViewHolder viewHolder = PreferenceViewHolder.createInstanceForTests(LayoutInflater.from(mContext).inflate(mGearPreference.getLayoutResource(), null, false));
    mPreferenceViewHolder = spy(viewHolder);
    doReturn(mGearView).when(mPreferenceViewHolder).findViewById(R.id.settings_button);
    when(mPreferenceScreen.findPreference(anyString())).thenReturn(mGearPreference);
}
Also used : GearPreference(com.android.settings.widget.GearPreference) View(android.view.View) PreferenceViewHolder(androidx.preference.PreferenceViewHolder)

Example 73 with PreferenceViewHolder

use of androidx.preference.PreferenceViewHolder in project android_packages_apps_Settings by omnirom.

the class GearPreferenceTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mGearPreference = new GearPreference(mContext, null);
    int layoutId = ResourcesUtils.getResourcesId(mContext, "layout", "preference_widget_gear");
    PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(LayoutInflater.from(ApplicationProvider.getApplicationContext()).inflate(layoutId, null));
    mViewHolder = spy(holder);
    mGearView = new View(mContext, null);
    int gearId = ResourcesUtils.getResourcesId(mContext, "id", "settings_button");
    when(mViewHolder.findViewById(gearId)).thenReturn(mGearView);
}
Also used : PreferenceViewHolder(androidx.preference.PreferenceViewHolder) View(android.view.View) Before(org.junit.Before)

Example 74 with PreferenceViewHolder

use of androidx.preference.PreferenceViewHolder in project android_packages_apps_Settings by omnirom.

the class ConversationPriorityPreferenceTest method onBindViewHolder_selectButtonAndText.

@Test
public void onBindViewHolder_selectButtonAndText() {
    final ConversationPriorityPreference preference = new ConversationPriorityPreference(mContext);
    final LayoutInflater inflater = LayoutInflater.from(mContext);
    final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(preference.getLayoutResource(), null));
    preference.setConfigurable(true);
    preference.setImportance(IMPORTANCE_LOW);
    preference.setPriorityConversation(true);
    preference.onBindViewHolder(holder);
    assertThat(holder.itemView.findViewById(R.id.silence).findViewById(R.id.summary).getVisibility()).isEqualTo(View.VISIBLE);
}
Also used : LayoutInflater(android.view.LayoutInflater) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) Test(org.junit.Test)

Example 75 with PreferenceViewHolder

use of androidx.preference.PreferenceViewHolder in project android_packages_apps_Settings by omnirom.

the class ConversationPriorityPreferenceTest method onBindViewHolder_nonConfigurable.

@Test
public void onBindViewHolder_nonConfigurable() {
    final ConversationPriorityPreference preference = new ConversationPriorityPreference(mContext);
    final LayoutInflater inflater = LayoutInflater.from(mContext);
    PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(preference.getLayoutResource(), null));
    preference.setConfigurable(false);
    preference.setImportance(IMPORTANCE_DEFAULT);
    preference.setPriorityConversation(true);
    preference.onBindViewHolder(holder);
    assertThat(holder.itemView.findViewById(R.id.silence).isEnabled()).isFalse();
    assertThat(holder.itemView.findViewById(R.id.priority_group).isEnabled()).isFalse();
    assertThat(holder.itemView.findViewById(R.id.alert).isEnabled()).isFalse();
}
Also used : LayoutInflater(android.view.LayoutInflater) 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