Search in sources :

Example 6 with SelectOneListAdapter

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

the class ChoicesRecyclerViewTest method whenClickOneOption_shouldPreviouslySelectedOptionBeUnselectedInSelectOneButtonsMode.

@Test
public void whenClickOneOption_shouldPreviouslySelectedOptionBeUnselectedInSelectOneButtonsMode() {
    List<SelectChoice> items = getTestChoices();
    setUpFormEntryPrompt(items, "");
    SelectItemClickListener listener = mock(SelectItemClickListener.class);
    SelectOneListAdapter adapter = new SelectOneListAdapter(null, listener, activityController.get(), items, formEntryPrompt, null, null, 0, 1, false, 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 7 with SelectOneListAdapter

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

the class ChoicesRecyclerViewTest method whenClickOneElementTwice_shouldThatElementRemainSelectedInSelectOneButtonsMode.

@Test
public void whenClickOneElementTwice_shouldThatElementRemainSelectedInSelectOneButtonsMode() {
    List<SelectChoice> items = getTestChoices();
    setUpFormEntryPrompt(items, "");
    SelectItemClickListener listener = mock(SelectItemClickListener.class);
    SelectOneListAdapter adapter = new SelectOneListAdapter(null, listener, activityController.get(), items, formEntryPrompt, null, null, 0, 1, false, mock(MediaUtils.class));
    initRecyclerView(adapter, false);
    // Select AAA
    clickChoice(0);
    assertThat(isItemSelected(0), is(true));
    assertThat(isItemSelected(1), is(false));
    // Select AAA again
    clickChoice(0);
    assertThat(isItemSelected(0), is(true));
    assertThat(isItemSelected(1), is(false));
}
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 8 with SelectOneListAdapter

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

the class ChoicesRecyclerViewTest method whenClickOneElementTwice_shouldThatElementRemainSelectedInSelectOneNoButtonsMode.

@Test
public void whenClickOneElementTwice_shouldThatElementRemainSelectedInSelectOneNoButtonsMode() {
    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 AAA again
    clickChoice(0);
    assertThat(isItemSelected(0), is(true));
    assertThat(isItemSelected(1), is(false));
}
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 9 with SelectOneListAdapter

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

the class ChoicesRecyclerViewTest method whenChoicesFiltered_shouldProperValuesBeReturnedInSelectOneButtonsMode.

@Test
public void whenChoicesFiltered_shouldProperValuesBeReturnedInSelectOneButtonsMode() {
    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);
    assertVisibleItemsInButtonsMode("AAA", "BBB");
    filterList(adapter, "b");
    assertVisibleItemsInButtonsMode("BBB");
    filterList(adapter, "bc");
    assertVisibleItemsInButtonsMode();
    filterList(adapter, "b");
    assertVisibleItemsInButtonsMode("BBB");
    filterList(adapter, "");
    assertVisibleItemsInButtonsMode("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 10 with SelectOneListAdapter

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

the class ChoicesRecyclerViewTest method whenNonFLexAppearanceIsUsed_shouldGridLayoutManagerBeUsed.

@Test
public void whenNonFLexAppearanceIsUsed_shouldGridLayoutManagerBeUsed() {
    SelectOneListAdapter adapter = new SelectOneListAdapter(null, null, null, new ArrayList<>(), null, null, null, 0, 1, false, mock(MediaUtils.class));
    initRecyclerView(adapter, false);
    assertThat(recyclerView.getLayoutManager().getClass().getName(), equalTo(GridLayoutManager.class.getName()));
}
Also used : 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