use of org.javarosa.core.model.data.helper.Selection in project collect by opendatakit.
the class ChoicesRecyclerViewTest method whenChoiceUnselectedInSelectMultiNoButtonsMode_shouldStopPlayingAudio.
@Test
public void whenChoiceUnselectedInSelectMultiNoButtonsMode_shouldStopPlayingAudio() {
List<SelectChoice> items = getTestChoices();
setUpFormEntryPrompt(items, "no-buttons");
SelectItemClickListener listener = mock(SelectItemClickListener.class);
List<Selection> selectedItems = new ArrayList<>();
selectedItems.add(items.get(0).selection());
SelectMultipleListAdapter adapter = spy(new SelectMultipleListAdapter(selectedItems, listener, activityController.get(), items, formEntryPrompt, null, audioHelper, 0, 1, true, mock(MediaUtils.class)));
initRecyclerView(adapter, false);
// Unselect AAA
clickChoice(0);
verify(adapter.getAudioHelper()).stop();
verify(adapter, never()).playAudio(any());
}
use of org.javarosa.core.model.data.helper.Selection in project collect by opendatakit.
the class RankingWidgetTest method getNextAnswer.
@NonNull
@Override
public MultipleItemsData getNextAnswer() {
List<SelectChoice> selectChoices = getSelectChoices();
List<Selection> selections = new ArrayList<>();
for (SelectChoice selectChoice : selectChoices) {
selections.add(new Selection(selectChoice));
}
return new SelectMultiData(selections);
}
use of org.javarosa.core.model.data.helper.Selection in project collect by opendatakit.
the class SelectMultiImageMapWidgetTest method getNextAnswer.
@NonNull
@Override
public SelectMultiData getNextAnswer() {
List<SelectChoice> selectChoices = getSelectChoices();
int selectedIndex = Math.abs(random.nextInt()) % selectChoices.size();
SelectChoice selectChoice = selectChoices.get(selectedIndex);
Selection selection = new Selection(selectChoice);
return new SelectMultiData(ImmutableList.of(selection));
}
use of org.javarosa.core.model.data.helper.Selection in project collect by opendatakit.
the class SelectMultiMinimalWidgetTest method whenAnswerChanges_shouldValueChangeListenersBeCalled.
@Test
public void whenAnswerChanges_shouldValueChangeListenersBeCalled() {
WidgetValueChangedListener valueChangedListener = mockValueChangedListener(getSpyWidget());
SelectMultiData answer = getInitialAnswer();
Selection selectedChoice = ((List<Selection>) answer.getValue()).get(0);
getSpyWidget().setData(Collections.singletonList(selectedChoice));
verify(valueChangedListener).widgetValueChanged(getSpyWidget());
}
use of org.javarosa.core.model.data.helper.Selection in project collect by opendatakit.
the class SelectMultiMinimalWidgetTest method whenThereIsAnswer_shouldSelectedChoicesBeDisplayed.
@Test
public void whenThereIsAnswer_shouldSelectedChoicesBeDisplayed() {
SelectMultiData answer = getInitialAnswer();
Selection selectedChoice = ((List<Selection>) answer.getValue()).get(0);
when(formEntryPrompt.getAnswerValue()).thenReturn(answer);
when(formEntryPrompt.getSelectItemText(selectedChoice)).thenReturn(selectedChoice.getValue());
assertThat(getSpyWidget().binding.answer.getText().toString(), is(selectedChoice.getValue()));
}
Aggregations