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