Search in sources :

Example 16 with FormEntryPrompt

use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.

the class PromptAutoplayerTest method whenPromptHasAutoplayAudio_andIsSelectOne_withNoButtonsAppearance_playsPromptAudio.

@Test
public void whenPromptHasAutoplayAudio_andIsSelectOne_withNoButtonsAppearance_playsPromptAudio() throws Exception {
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).withAppearance("whatever " + NO_BUTTONS).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)));
}
Also used : Clip(org.odk.collect.audioclips.Clip) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) SelectChoice(org.javarosa.core.model.SelectChoice) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) Test(org.junit.Test)

Example 17 with FormEntryPrompt

use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.

the class PromptAutoplayerTest method whenPromptHasAutoplayAudio_andIsSelectOne_withDeprecatedCompactAppearance_playsPromptAudio.

@Test
public void whenPromptHasAutoplayAudio_andIsSelectOne_withDeprecatedCompactAppearance_playsPromptAudio() throws Exception {
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).withAppearance(COMPACT).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)));
}
Also used : Clip(org.odk.collect.audioclips.Clip) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) SelectChoice(org.javarosa.core.model.SelectChoice) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) Test(org.junit.Test)

Example 18 with FormEntryPrompt

use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.

the class PromptAutoplayerTest method whenPromptHasNoAutoplay_returnsFalse.

@Test
public void whenPromptHasNoAutoplay_returnsFalse() {
    FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withAdditionalAttribute("autoplay", null).build();
    assertThat(autoplayer.autoplayIfNeeded(prompt), equalTo(false));
    verify(audioHelper, never()).playInOrder(any());
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) Test(org.junit.Test)

Example 19 with FormEntryPrompt

use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.

the class DateTimeWidgetTest method clickingSetDateButton_callsDisplayDatePickerDialogWithSelectedDate_whenPromptHasAnswer.

@Test
public void clickingSetDateButton_callsDisplayDatePickerDialogWithSelectedDate_whenPromptHasAnswer() {
    FormEntryPrompt prompt = promptWithQuestionDefAndAnswer(questionDef, new DateData(localDateTime.toDate()));
    DateTimeWidget widget = createWidget(prompt);
    widget.binding.dateWidget.dateButton.performClick();
    verify(widgetUtils).showDatePickerDialog(widgetActivity, DateTimeWidgetUtils.getDatePickerDetails(prompt.getQuestion().getAppearanceAttr()), DateTimeUtils.getSelectedDate(localDateTime, new LocalDateTime().withTime(0, 0, 0, 0)));
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) DateData(org.javarosa.core.model.data.DateData) Test(org.junit.Test)

Example 20 with FormEntryPrompt

use of org.javarosa.form.api.FormEntryPrompt in project collect by opendatakit.

the class DateTimeWidgetTest method clickingSetTimeButton_callsDisplayTimePickerDialogWithCurrentTime_whenPromptDoesNotHaveAnswer.

@Test
public void clickingSetTimeButton_callsDisplayTimePickerDialogWithCurrentTime_whenPromptDoesNotHaveAnswer() {
    FormEntryPrompt prompt = promptWithQuestionDefAndAnswer(questionDef, null);
    DateTimeWidget widget = createWidget(prompt);
    widget.binding.timeWidget.timeButton.performClick();
    verify(widgetUtils).showTimePickerDialog(widgetActivity, DateTimeUtils.getCurrentDateTime());
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) Test(org.junit.Test)

Aggregations

FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)114 Test (org.junit.Test)92 MockFormEntryPromptBuilder (org.odk.collect.android.support.MockFormEntryPromptBuilder)45 Clip (org.odk.collect.audioclips.Clip)13 FormIndex (org.javarosa.core.model.FormIndex)10 File (java.io.File)9 SelectChoice (org.javarosa.core.model.SelectChoice)7 StringData (org.javarosa.core.model.data.StringData)7 IFormElement (org.javarosa.core.model.IFormElement)5 QuestionDef (org.javarosa.core.model.QuestionDef)5 FormController (org.odk.collect.android.javarosawrapper.FormController)5 GroupDef (org.javarosa.core.model.GroupDef)4 QuestionDetails (org.odk.collect.android.formentry.questions.QuestionDetails)4 DatePickerDetails (org.odk.collect.android.logic.DatePickerDetails)4 ArrayList (java.util.ArrayList)3 DateData (org.javarosa.core.model.data.DateData)3 IAnswerData (org.javarosa.core.model.data.IAnswerData)3 TreeReference (org.javarosa.core.model.instance.TreeReference)3 LocalDateTime (org.joda.time.LocalDateTime)3 AudioControllerView (org.odk.collect.android.audio.AudioControllerView)3