use of org.odk.collect.android.listeners.SelectItemClickListener in project collect by opendatakit.
the class ChoicesRecyclerViewTest method whenChangingAnswer_shouldHasAnswerChangedReturnCorrectValue.
@Test
public void whenChangingAnswer_shouldHasAnswerChangedReturnCorrectValue() {
List<SelectChoice> items = getTestChoices();
setUpFormEntryPrompt(items, "");
SelectItemClickListener listener = mock(SelectItemClickListener.class);
List<Selection> selectedItems = new ArrayList<>();
selectedItems.add(items.get(0).selection());
SelectMultipleListAdapter adapter = new SelectMultipleListAdapter(selectedItems, listener, activityController.get(), items, formEntryPrompt, null, null, 0, 1, false, mock(MediaUtils.class));
initRecyclerView(adapter, false);
// Select BBB
clickChoice(1);
assertThat(adapter.hasAnswerChanged(), is(true));
// Unselect AAA
clickChoice(0);
assertThat(adapter.hasAnswerChanged(), is(true));
// Unselect BBB
clickChoice(1);
assertThat(adapter.hasAnswerChanged(), is(true));
// Select AAA
clickChoice(0);
assertThat(adapter.hasAnswerChanged(), is(false));
}
use of org.odk.collect.android.listeners.SelectItemClickListener in project collect by opendatakit.
the class ChoicesRecyclerViewTest method whenClickOneOption_shouldPreviouslySelectedOptionRemainSelectedInSelectMultiNoButtonsMode.
@Test
public void whenClickOneOption_shouldPreviouslySelectedOptionRemainSelectedInSelectMultiNoButtonsMode() {
List<SelectChoice> items = getTestChoices();
setUpFormEntryPrompt(items, "no-buttons");
SelectItemClickListener listener = mock(SelectItemClickListener.class);
SelectMultipleListAdapter adapter = new SelectMultipleListAdapter(new ArrayList<>(), 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(true));
assertThat(isItemSelected(1), is(true));
}
use of org.odk.collect.android.listeners.SelectItemClickListener 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));
}
use of org.odk.collect.android.listeners.SelectItemClickListener 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());
}
use of org.odk.collect.android.listeners.SelectItemClickListener 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));
}
Aggregations