use of com.artemzin.qualitymatters.ui.adapters.DeveloperSettingsSpinnerAdapter.SelectionOption in project qualitymatters by artem-zinnatullin.
the class DeveloperSettingsSpinnerAdapterTest method getDropDownView_shouldBindDataAndReturnViewWithoutConvertView.
@SuppressLint("SetTextI18n")
@Test
public void getDropDownView_shouldBindDataAndReturnViewWithoutConvertView() {
List<SelectionOption> selectionOptions = asList(mock(SelectionOption.class), mock(SelectionOption.class), mock(SelectionOption.class));
adapter.setSelectionOptions(selectionOptions);
ViewGroup container = mock(ViewGroup.class);
for (int position = 0; position < selectionOptions.size(); position++) {
when(selectionOptions.get(position).title()).thenReturn("Title " + position);
View view = mock(View.class);
when(layoutInflater.inflate(R.layout.list_developer_settings_spinner_drop_down_item, container, false)).thenReturn(view);
TextView titleTextView = mock(TextView.class);
when(view.findViewById(R.id.list_developer_settings_spinner_item_title_text_view)).thenReturn(titleTextView);
// Notice: there is NO convertView, that what we want to check.
assertThat(adapter.getDropDownView(position, null, container)).isSameAs(view);
verify(titleTextView).setText("Title " + position);
}
}
use of com.artemzin.qualitymatters.ui.adapters.DeveloperSettingsSpinnerAdapter.SelectionOption in project qualitymatters by artem-zinnatullin.
the class DeveloperSettingsSpinnerAdapterTest method getView_shouldBindDataAndReturnViewWithConvertView.
@Test
public void getView_shouldBindDataAndReturnViewWithConvertView() {
List<SelectionOption> selectionOptions = asList(mock(SelectionOption.class), mock(SelectionOption.class), mock(SelectionOption.class));
adapter.setSelectionOptions(selectionOptions);
ViewGroup container = mock(ViewGroup.class);
for (int position = 0; position < selectionOptions.size(); position++) {
View view = mock(View.class);
when(layoutInflater.inflate(R.layout.list_developer_settings_spinner_item, container, false)).thenReturn(view);
DeveloperSettingsSpinnerAdapter.ViewHolder viewHolder = mock(DeveloperSettingsSpinnerAdapter.ViewHolder.class);
when(view.getTag()).thenReturn(viewHolder);
// Notice: there IS convertView, that what we want to check.
assertThat(adapter.getView(position, view, container)).isSameAs(view);
verify(viewHolder).bindItem(selectionOptions.get(position));
}
}
use of com.artemzin.qualitymatters.ui.adapters.DeveloperSettingsSpinnerAdapter.SelectionOption in project qualitymatters by artem-zinnatullin.
the class DeveloperSettingsSpinnerAdapterTest method getDropDownView_shouldBindDataAndReturnViewWithConvertView.
@Test
public void getDropDownView_shouldBindDataAndReturnViewWithConvertView() {
List<SelectionOption> selectionOptions = asList(mock(SelectionOption.class), mock(SelectionOption.class), mock(SelectionOption.class));
adapter.setSelectionOptions(selectionOptions);
ViewGroup container = mock(ViewGroup.class);
for (int position = 0; position < selectionOptions.size(); position++) {
View view = mock(View.class);
when(layoutInflater.inflate(R.layout.list_developer_settings_spinner_item, container, false)).thenReturn(view);
DeveloperSettingsSpinnerAdapter.ViewHolder viewHolder = mock(DeveloperSettingsSpinnerAdapter.ViewHolder.class);
when(view.getTag()).thenReturn(viewHolder);
// Notice: there IS convertView, that what we want to check.
assertThat(adapter.getDropDownView(position, view, container)).isSameAs(view);
verify(viewHolder).bindItem(selectionOptions.get(position));
}
}
use of com.artemzin.qualitymatters.ui.adapters.DeveloperSettingsSpinnerAdapter.SelectionOption in project qualitymatters by artem-zinnatullin.
the class DeveloperSettingsSpinnerAdapterTest method getView_shouldBindDataAndReturnViewWithoutConvertView.
@SuppressLint("SetTextI18n")
@Test
public void getView_shouldBindDataAndReturnViewWithoutConvertView() {
List<SelectionOption> selectionOptions = asList(mock(SelectionOption.class), mock(SelectionOption.class), mock(SelectionOption.class));
adapter.setSelectionOptions(selectionOptions);
ViewGroup container = mock(ViewGroup.class);
for (int position = 0; position < selectionOptions.size(); position++) {
when(selectionOptions.get(position).title()).thenReturn("Title " + position);
View view = mock(View.class);
when(layoutInflater.inflate(R.layout.list_developer_settings_spinner_item, container, false)).thenReturn(view);
TextView titleTextView = mock(TextView.class);
when(view.findViewById(R.id.list_developer_settings_spinner_item_title_text_view)).thenReturn(titleTextView);
// Notice: there is NO convertView, that what we want to check.
assertThat(adapter.getView(position, null, container)).isSameAs(view);
verify(titleTextView).setText("Title " + position);
}
}
Aggregations