use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.
the class PromptAutoplayerTest method whenPromptHasAutoplayAudio_andIsSelectOne_withMinimalAppearance_playsPromptAudio.
@Test
public void whenPromptHasAutoplayAudio_andIsSelectOne_withMinimalAppearance_playsPromptAudio() throws Exception {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).withAppearance(MINIMAL).withAudioURI(REFERENCES.get(0).first).withAdditionalAttribute("autoplay", "audio").withSelectChoices(asList(new SelectChoice("1", "1"), new SelectChoice("2", "2"))).withSpecialFormSelectChoiceText(asList(new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(1).first), new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(2).first))).build();
assertThat(autoplayer.autoplayIfNeeded(prompt), equalTo(true));
verify(audioHelper).playInOrder(asList(new Clip(prompt.getIndex().toString(), REFERENCES.get(0).second)));
}
use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.
the class BarcodeWidgetTest method clickingBarcodeButton_whenPermissionIsGranted_setsWidgetWaitingForData.
@Test
public void clickingBarcodeButton_whenPermissionIsGranted_setsWidgetWaitingForData() {
FormEntryPrompt prompt = promptWithAnswer(null);
when(prompt.getIndex()).thenReturn(formIndex);
BarcodeWidget widget = createWidget(prompt);
widget.setPermissionsProvider(permissionsProvider);
widget.binding.barcodeButton.performClick();
assertThat(waitingForDataRegistry.waiting.contains(formIndex), is(true));
}
use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.
the class DateTimeWidgetTest method whenPromptHasAnswer_answerTextViewShowsCorrectDateAndTime.
@Test
public void whenPromptHasAnswer_answerTextViewShowsCorrectDateAndTime() {
FormEntryPrompt prompt = promptWithQuestionDefAndAnswer(questionDef, new DateTimeData(localDateTime.toDate()));
DatePickerDetails datePickerDetails = DateTimeWidgetUtils.getDatePickerDetails(prompt.getQuestion().getAppearanceAttr());
DateTimeWidget widget = createWidget(prompt);
assertEquals(widget.binding.dateWidget.dateAnswerText.getText(), DateTimeWidgetUtils.getDateTimeLabel(localDateTime.toDate(), datePickerDetails, false, widget.getContext()));
assertEquals(widget.binding.timeWidget.timeAnswerText.getText(), DateTimeUtils.getTimeData(localDateTime.toDateTime()).getDisplayText());
}
use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.
the class GeoTraceWidgetTest method buttonClick_requestsGeoTrace_whenAnswerIsUpdated.
@Test
public void buttonClick_requestsGeoTrace_whenAnswerIsUpdated() {
FormEntryPrompt prompt = promptWithAnswer(null);
GeoTraceWidget widget = createWidget(prompt);
widget.setData(answer);
widget.binding.simpleButton.performClick();
verify(geoDataRequester).requestGeoTrace(prompt, answer, waitingForDataRegistry);
}
use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.
the class GeoTraceWidgetTest method buttonClick_whenMapConfiguratorIsAvailable_requestsGeoTrace.
@Test
public void buttonClick_whenMapConfiguratorIsAvailable_requestsGeoTrace() {
FormEntryPrompt prompt = promptWithAnswer(null);
GeoTraceWidget widget = createWidget(prompt);
widget.binding.simpleButton.performClick();
verify(geoDataRequester).requestGeoTrace(prompt, "", waitingForDataRegistry);
}
Aggregations