Search in sources :

Example 31 with FormEntryPrompt

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

the class AudioWidgetTest method whenRecordingInProgress_updatesWaveform.

@Test
public void whenRecordingInProgress_updatesWaveform() {
    FormEntryPrompt prompt = promptWithAnswer(null);
    AudioWidget widget = createWidget(prompt);
    recordingRequester.setAmplitude(prompt.getIndex().toString(), 5);
    assertThat(widget.binding.audioPlayer.waveform.getLatestAmplitude(), is(5));
    recordingRequester.setAmplitude(prompt.getIndex().toString(), 67);
    assertThat(widget.binding.audioPlayer.waveform.getLatestAmplitude(), is(67));
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) Test(org.junit.Test)

Example 32 with FormEntryPrompt

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

the class BearingWidgetTest method clickingBearingButton_whenSensorIsAvailable_setsWidgetWaitingForData.

@Test
public void clickingBearingButton_whenSensorIsAvailable_setsWidgetWaitingForData() {
    FormEntryPrompt prompt = promptWithAnswer(null);
    FormIndex formIndex = mock(FormIndex.class);
    when(prompt.getIndex()).thenReturn(formIndex);
    BearingWidget widget = createWidget(prompt);
    widget.binding.bearingButton.performClick();
    assertThat(fakeWaitingForDataRegistry.waiting.contains(formIndex), is(true));
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) FormIndex(org.javarosa.core.model.FormIndex) Test(org.junit.Test)

Example 33 with FormEntryPrompt

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

the class DateWidgetTest method clickingButton_callsDisplayDatePickerDialogWithCurrentDate_whenPromptDoesNotHaveAnswer.

@Test
public void clickingButton_callsDisplayDatePickerDialogWithCurrentDate_whenPromptDoesNotHaveAnswer() {
    FormEntryPrompt prompt = promptWithQuestionDefAndAnswer(questionDef, null);
    DateWidget widget = createWidget(prompt);
    widget.binding.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 34 with FormEntryPrompt

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

the class DateWidgetTest method whenPromptHasAnswer_answerTextViewShowsCorrectDate.

@Test
public void whenPromptHasAnswer_answerTextViewShowsCorrectDate() {
    FormEntryPrompt prompt = promptWithQuestionDefAndAnswer(questionDef, new DateData(dateAnswer.toDate()));
    DatePickerDetails datePickerDetails = DateTimeWidgetUtils.getDatePickerDetails(prompt.getQuestion().getAppearanceAttr());
    DateWidget widget = createWidget(prompt);
    assertEquals(widget.binding.dateAnswerText.getText(), DateTimeWidgetUtils.getDateTimeLabel(dateAnswer.toDate(), datePickerDetails, false, widget.getContext()));
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) DateData(org.javarosa.core.model.data.DateData) DatePickerDetails(org.odk.collect.android.logic.DatePickerDetails) Test(org.junit.Test)

Example 35 with FormEntryPrompt

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

the class GeoPointWidgetTest method buttonClick_requestsGeoPoint_whenAnswerIsUpdated.

@Test
public void buttonClick_requestsGeoPoint_whenAnswerIsUpdated() {
    FormEntryPrompt prompt = promptWithAnswer(null);
    GeoPointWidget widget = createWidget(prompt);
    widget.setData(answer);
    widget.binding.simpleButton.performClick();
    verify(geoDataRequester).requestGeoPoint(prompt, answer.getDisplayText(), waitingForDataRegistry);
}
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