Search in sources :

Example 21 with FormEntryPrompt

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

the class DateTimeWidgetTest method clickingSetTimeButton_callsDisplayTimePickerDialogWithSelectedTime_whenPromptHasAnswer.

@Test
public void clickingSetTimeButton_callsDisplayTimePickerDialogWithSelectedTime_whenPromptHasAnswer() {
    FormEntryPrompt prompt = promptWithQuestionDefAndAnswer(questionDef, new TimeData(localDateTime.toDateTime().toDate()));
    DateTimeWidget widget = createWidget(prompt);
    widget.binding.timeWidget.timeButton.performClick();
    verify(widgetUtils).showTimePickerDialog(widgetActivity, localDateTime);
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) DateTimeData(org.javarosa.core.model.data.DateTimeData) TimeData(org.javarosa.core.model.data.TimeData) Test(org.junit.Test)

Example 22 with FormEntryPrompt

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

the class DateTimeWidgetTest method clickingSetDateButton_callsDisplayDatePickerDialogWithCurrentDate_whenPromptDoesNotHaveAnswer.

@Test
public void clickingSetDateButton_callsDisplayDatePickerDialogWithCurrentDate_whenPromptDoesNotHaveAnswer() {
    FormEntryPrompt prompt = promptWithQuestionDefAndAnswer(questionDef, null);
    DateTimeWidget widget = createWidget(prompt);
    widget.binding.dateWidget.dateButton.performClick();
    verify(widgetUtils).showDatePickerDialog(widgetActivity, DateTimeWidgetUtils.getDatePickerDetails(prompt.getQuestion().getAppearanceAttr()), DateTimeUtils.getCurrentDateTime());
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) Test(org.junit.Test)

Example 23 with FormEntryPrompt

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

the class DateTimeWidgetTest method setDateData_updatesValueShownInDateAnswerTextView.

@Test
public void setDateData_updatesValueShownInDateAnswerTextView() {
    FormEntryPrompt prompt = promptWithQuestionDefAndAnswer(questionDef, null);
    DatePickerDetails datePickerDetails = DateTimeWidgetUtils.getDatePickerDetails(prompt.getQuestion().getAppearanceAttr());
    DateTimeWidget widget = createWidget(prompt);
    widget.setData(new LocalDateTime().withDate(2010, 5, 12));
    assertEquals(widget.binding.dateWidget.dateAnswerText.getText(), DateTimeWidgetUtils.getDateTimeLabel(localDateTime.toDate(), datePickerDetails, false, widget.getContext()));
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) DatePickerDetails(org.odk.collect.android.logic.DatePickerDetails) Test(org.junit.Test)

Example 24 with FormEntryPrompt

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

the class AudioWidgetTest method whenRecordingFinished_showsButtons.

@Test
public void whenRecordingFinished_showsButtons() {
    FormEntryPrompt prompt = promptWithAnswer(null);
    AudioWidget widget = createWidget(prompt);
    recordingRequester.setDuration(prompt.getIndex().toString(), 5);
    recordingRequester.reset();
    assertThat(widget.binding.audioPlayer.audioController.getVisibility(), is(GONE));
    assertThat(widget.binding.audioPlayer.recordingDuration.getVisibility(), is(GONE));
    assertThat(widget.binding.audioPlayer.waveform.getVisibility(), is(GONE));
    assertThat(widget.binding.captureButton.getVisibility(), is(VISIBLE));
    assertThat(widget.binding.chooseButton.getVisibility(), is(VISIBLE));
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) Test(org.junit.Test)

Example 25 with FormEntryPrompt

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

the class AudioWidgetTest method afterSetBinaryData_showsDurationOfAudio.

@Test
public void afterSetBinaryData_showsDurationOfAudio() throws Exception {
    FormEntryPrompt prompt = promptWithAnswer(null);
    File answerFile = questionMediaManager.addAnswerFile(File.createTempFile("blah", ".mp3"));
    Clip expectedClip = getExpectedClip(prompt, answerFile.getName());
    setupMediaPlayerDataSource(expectedClip.getURI(), 322450);
    AudioWidget widget = createWidget(prompt);
    widget.setData(answerFile);
    AudioControllerView audioController = widget.binding.audioPlayer.audioController;
    assertThat(audioController.binding.totalDuration.getText().toString(), is("05:22"));
}
Also used : Clip(org.odk.collect.audioclips.Clip) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) AudioControllerView(org.odk.collect.android.audio.AudioControllerView) File(java.io.File) 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