Search in sources :

Example 1 with SelectionOption

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);
    }
}
Also used : ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) SelectionOption(com.artemzin.qualitymatters.ui.adapters.DeveloperSettingsSpinnerAdapter.SelectionOption) TextView(android.widget.TextView) View(android.view.View) SuppressLint(android.annotation.SuppressLint) Test(org.junit.Test) SuppressLint(android.annotation.SuppressLint)

Example 2 with SelectionOption

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));
    }
}
Also used : ViewGroup(android.view.ViewGroup) SelectionOption(com.artemzin.qualitymatters.ui.adapters.DeveloperSettingsSpinnerAdapter.SelectionOption) TextView(android.widget.TextView) View(android.view.View) SuppressLint(android.annotation.SuppressLint) Test(org.junit.Test)

Example 3 with SelectionOption

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));
    }
}
Also used : ViewGroup(android.view.ViewGroup) SelectionOption(com.artemzin.qualitymatters.ui.adapters.DeveloperSettingsSpinnerAdapter.SelectionOption) TextView(android.widget.TextView) View(android.view.View) SuppressLint(android.annotation.SuppressLint) Test(org.junit.Test)

Example 4 with SelectionOption

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);
    }
}
Also used : ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) SelectionOption(com.artemzin.qualitymatters.ui.adapters.DeveloperSettingsSpinnerAdapter.SelectionOption) TextView(android.widget.TextView) View(android.view.View) SuppressLint(android.annotation.SuppressLint) Test(org.junit.Test) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)4 View (android.view.View)4 ViewGroup (android.view.ViewGroup)4 TextView (android.widget.TextView)4 SelectionOption (com.artemzin.qualitymatters.ui.adapters.DeveloperSettingsSpinnerAdapter.SelectionOption)4 Test (org.junit.Test)4