Search in sources :

Example 1 with SelectOneListAdapter

use of org.odk.collect.android.adapters.SelectOneListAdapter in project collect by opendatakit.

the class ChoicesRecyclerViewTest method whenNonFLexAppearanceIsUsedWithOneColumn_shouldDividersBeAdded.

@Test
public void whenNonFLexAppearanceIsUsedWithOneColumn_shouldDividersBeAdded() {
    List<SelectChoice> items = getTestChoices();
    setUpFormEntryPrompt(items, "");
    SelectOneListAdapter adapter = new SelectOneListAdapter(null, null, activityController.get(), items, formEntryPrompt, null, null, 0, 1, false, mock(MediaUtils.class));
    initRecyclerView(adapter, false);
    assertThat(recyclerView.getItemDecorationCount(), is(1));
    assertThat(recyclerView.getItemDecorationAt(0), is(instanceOf(DividerItemDecoration.class)));
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) MediaUtils(org.odk.collect.android.utilities.MediaUtils) SelectOneListAdapter(org.odk.collect.android.adapters.SelectOneListAdapter) Test(org.junit.Test)

Example 2 with SelectOneListAdapter

use of org.odk.collect.android.adapters.SelectOneListAdapter in project collect by opendatakit.

the class ChoicesRecyclerViewTest method whenClickOneOption_shouldPreviouslySelectedOptionBeUnselectedInSelectOneNoButtonsMode.

@Test
public void whenClickOneOption_shouldPreviouslySelectedOptionBeUnselectedInSelectOneNoButtonsMode() {
    List<SelectChoice> items = getTestChoices();
    setUpFormEntryPrompt(items, "no-buttons");
    SelectItemClickListener listener = mock(SelectItemClickListener.class);
    SelectOneListAdapter adapter = new SelectOneListAdapter(null, listener, activityController.get(), items, formEntryPrompt, null, audioHelper, 0, 1, true, mock(MediaUtils.class));
    initRecyclerView(adapter, false);
    // Select AAA
    clickChoice(0);
    assertThat(isItemSelected(0), is(true));
    assertThat(isItemSelected(1), is(false));
    // Select BBB
    clickChoice(1);
    assertThat(isItemSelected(0), is(false));
    assertThat(isItemSelected(1), is(true));
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) MediaUtils(org.odk.collect.android.utilities.MediaUtils) SelectItemClickListener(org.odk.collect.android.listeners.SelectItemClickListener) SelectOneListAdapter(org.odk.collect.android.adapters.SelectOneListAdapter) Test(org.junit.Test)

Example 3 with SelectOneListAdapter

use of org.odk.collect.android.adapters.SelectOneListAdapter in project collect by opendatakit.

the class ChoicesRecyclerViewTest method whenChoicesFiltered_shouldProperValuesBeReturnedInSelectOneNoButtonsMode.

@Test
public void whenChoicesFiltered_shouldProperValuesBeReturnedInSelectOneNoButtonsMode() {
    List<SelectChoice> items = getTestChoices();
    setUpFormEntryPrompt(items, "no-buttons");
    SelectOneListAdapter adapter = new SelectOneListAdapter(null, null, activityController.get(), items, formEntryPrompt, null, null, 0, 1, true, mock(MediaUtils.class));
    initRecyclerView(adapter, false);
    assertVisibleItemsInNoButtonsMode("AAA", "BBB");
    filterList(adapter, "b");
    assertVisibleItemsInNoButtonsMode("BBB");
    filterList(adapter, "bc");
    assertVisibleItemsInNoButtonsMode();
    filterList(adapter, "b");
    assertVisibleItemsInNoButtonsMode("BBB");
    filterList(adapter, "");
    assertVisibleItemsInNoButtonsMode("AAA", "BBB");
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) MediaUtils(org.odk.collect.android.utilities.MediaUtils) SelectOneListAdapter(org.odk.collect.android.adapters.SelectOneListAdapter) Test(org.junit.Test)

Example 4 with SelectOneListAdapter

use of org.odk.collect.android.adapters.SelectOneListAdapter in project collect by opendatakit.

the class ChoicesRecyclerViewTest method whenChoiceSelectedInSelectOneNoButtonsMode_shouldTryToPlayAudio.

@Test
public void whenChoiceSelectedInSelectOneNoButtonsMode_shouldTryToPlayAudio() {
    List<SelectChoice> items = getTestChoices();
    setUpFormEntryPrompt(items, "no-buttons");
    SelectItemClickListener listener = mock(SelectItemClickListener.class);
    AudioHelper audioHelper = mock(AudioHelper.class);
    SelectOneListAdapter adapter = spy(new SelectOneListAdapter(null, listener, activityController.get(), items, formEntryPrompt, null, audioHelper, 0, 1, true, mock(MediaUtils.class)));
    initRecyclerView(adapter, false);
    // Select AAA
    clickChoice(0);
    verify(adapter).playAudio(any());
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) SelectItemClickListener(org.odk.collect.android.listeners.SelectItemClickListener) SelectOneListAdapter(org.odk.collect.android.adapters.SelectOneListAdapter) AudioHelper(org.odk.collect.android.audio.AudioHelper) Test(org.junit.Test)

Example 5 with SelectOneListAdapter

use of org.odk.collect.android.adapters.SelectOneListAdapter in project collect by opendatakit.

the class ChoicesRecyclerViewTest method whenFLexAppearanceIsUsed_shouldNotDividersBeAdded.

@Test
public void whenFLexAppearanceIsUsed_shouldNotDividersBeAdded() {
    List<SelectChoice> items = getTestChoices();
    setUpFormEntryPrompt(items, "");
    SelectOneListAdapter adapter = new SelectOneListAdapter(null, null, activityController.get(), items, formEntryPrompt, null, null, 0, 2, false, mock(MediaUtils.class));
    initRecyclerView(adapter, true);
    assertThat(recyclerView.getItemDecorationCount(), is(0));
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) MediaUtils(org.odk.collect.android.utilities.MediaUtils) SelectOneListAdapter(org.odk.collect.android.adapters.SelectOneListAdapter) Test(org.junit.Test)

Aggregations

SelectOneListAdapter (org.odk.collect.android.adapters.SelectOneListAdapter)14 Test (org.junit.Test)12 MediaUtils (org.odk.collect.android.utilities.MediaUtils)11 SelectChoice (org.javarosa.core.model.SelectChoice)10 SelectItemClickListener (org.odk.collect.android.listeners.SelectItemClickListener)5 SuppressLint (android.annotation.SuppressLint)1 RadioButton (android.widget.RadioButton)1 AudioHelper (org.odk.collect.android.audio.AudioHelper)1