use of org.odk.collect.android.adapters.SelectMultipleListAdapter 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.adapters.SelectMultipleListAdapter 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.adapters.SelectMultipleListAdapter in project collect by opendatakit.
the class ChoicesRecyclerViewTest method whenNoButtonsModeIsUsed_shouldViewBeLongClickableToSupportRemovingAnswers.
@Test
public void whenNoButtonsModeIsUsed_shouldViewBeLongClickableToSupportRemovingAnswers() {
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, null, 0, 1, true, mock(MediaUtils.class));
initRecyclerView(adapter, false);
assertThat(getChoiceView(0).isLongClickable(), is(true));
}
use of org.odk.collect.android.adapters.SelectMultipleListAdapter in project collect by opendatakit.
the class ChoicesRecyclerViewTest method whenChoiceSelectedInSelectMultiNoButtonsMode_shouldTryToPlayAudio.
@Test
public void whenChoiceSelectedInSelectMultiNoButtonsMode_shouldTryToPlayAudio() {
List<SelectChoice> items = getTestChoices();
setUpFormEntryPrompt(items, "no-buttons");
SelectItemClickListener listener = mock(SelectItemClickListener.class);
AudioHelper audioHelper = mock(AudioHelper.class);
SelectMultipleListAdapter adapter = spy(new SelectMultipleListAdapter(new ArrayList<>(), 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.adapters.SelectMultipleListAdapter in project collect by opendatakit.
the class ChoicesRecyclerViewTest method whenColumnsPackAppearanceIsUsed_shouldMediaElementsBeHidden.
@Test
public void whenColumnsPackAppearanceIsUsed_shouldMediaElementsBeHidden() {
List<SelectChoice> items = getTestChoices();
setUpFormEntryPrompt(items, "columns-pack");
SelectItemClickListener listener = mock(SelectItemClickListener.class);
SelectMultipleListAdapter adapter = spy(new SelectMultipleListAdapter(new ArrayList<>(), listener, activityController.get(), items, formEntryPrompt, referenceManager, null, 0, 1, false, mock(MediaUtils.class)));
initRecyclerView(adapter, true);
assertThat(getAudioVideoImageTextLabelView(0).getImageView().getVisibility(), is(View.GONE));
assertThat(getAudioVideoImageTextLabelView(0).getVideoButton().getVisibility(), is(View.GONE));
assertThat(getAudioVideoImageTextLabelView(0).getAudioButton().getVisibility(), is(View.GONE));
}
Aggregations