use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.
the class PromptAutoplayerTest method whenPromptHasAutoplayAudio_playsAudio.
@Test
public void whenPromptHasAutoplayAudio_playsAudio() {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withAudioURI(REFERENCES.get(0).first).withAdditionalAttribute("autoplay", "audio").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 AudioWidgetTest method setData_whenPromptHasDifferentAudioFile_deletesOriginalAnswer.
@Test
public void setData_whenPromptHasDifferentAudioFile_deletesOriginalAnswer() throws Exception {
File originalFile = questionMediaManager.addAnswerFile(File.createTempFile("blah1", ".mp3"));
FormEntryPrompt prompt = promptWithAnswer(new StringData(originalFile.getName()));
when(prompt.getIndex()).thenReturn(formIndex);
AudioWidget widget = createWidget(prompt);
File newFile = questionMediaManager.addAnswerFile(File.createTempFile("blah2", ".mp3"));
widget.setData(newFile);
assertThat(questionMediaManager.originalFiles.get("questionIndex"), equalTo(originalFile.getAbsolutePath()));
}
use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.
the class AudioWidgetTest method setData_whenFileExists_replacesOriginalFileWithNewFile.
@Test
public void setData_whenFileExists_replacesOriginalFileWithNewFile() throws Exception {
File answerFile = questionMediaManager.addAnswerFile(File.createTempFile("blah1", ".mp3"));
FormEntryPrompt prompt = promptWithAnswer(new StringData(answerFile.getName()));
when(prompt.getIndex()).thenReturn(formIndex);
AudioWidget widget = createWidget(prompt);
File newFile = questionMediaManager.addAnswerFile(File.createTempFile("blah2", ".mp3"));
widget.setData(newFile);
assertThat(questionMediaManager.recentFiles.get("questionIndex"), equalTo(newFile.getAbsolutePath()));
}
use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.
the class DateWidgetTest method clickingButton_callsDisplayDatePickerDialogWithSelectedDate_whenPromptHasAnswer.
@Test
public void clickingButton_callsDisplayDatePickerDialogWithSelectedDate_whenPromptHasAnswer() {
FormEntryPrompt prompt = promptWithQuestionDefAndAnswer(questionDef, new DateData(dateAnswer.toDate()));
DateWidget widget = createWidget(prompt);
widget.binding.dateButton.performClick();
verify(widgetUtils).showDatePickerDialog(widgetActivity, DateTimeWidgetUtils.getDatePickerDetails(prompt.getQuestion().getAppearanceAttr()), dateAnswer);
}
use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.
the class DateWidgetTest method setData_updatesValueDisplayedInAnswerTextView.
@Test
public void setData_updatesValueDisplayedInAnswerTextView() {
FormEntryPrompt prompt = promptWithQuestionDefAndAnswer(questionDef, null);
DatePickerDetails datePickerDetails = DateTimeWidgetUtils.getDatePickerDetails(prompt.getQuestion().getAppearanceAttr());
DateWidget widget = createWidget(prompt);
widget.setData(dateAnswer);
assertEquals(widget.binding.dateAnswerText.getText(), DateTimeWidgetUtils.getDateTimeLabel(dateAnswer.toDate(), datePickerDetails, false, widget.getContext()));
}
Aggregations