Search in sources :

Example 36 with FormEntryPrompt

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

the class DaylightSavingTest method prepareDateTimeWidget.

private DateTimeWidget prepareDateTimeWidget(int year, int month, int day, int hour, int minute) {
    QuestionDef questionDefStub = mock(QuestionDef.class);
    FormEntryPrompt formEntryPromptStub = new MockFormEntryPromptBuilder().withIndex("index").build();
    IFormElement iformElementStub = formEntryPromptStub.getFormElement();
    when(iformElementStub.getAdditionalAttribute(anyString(), anyString())).thenReturn(null);
    when(formEntryPromptStub.getQuestion()).thenReturn(questionDefStub);
    when(formEntryPromptStub.getFormElement()).thenReturn(iformElementStub);
    when(formEntryPromptStub.getQuestion().getAppearanceAttr()).thenReturn("no-calendar");
    DateTimeWidget dateTimeWidget = new DateTimeWidget(widgetActivity, new QuestionDetails(formEntryPromptStub), widgetUtils);
    dateTimeWidget.setData(new LocalDateTime().withDate(year, month, day));
    dateTimeWidget.setData(new DateTime().withTime(hour, minute, 0, 0));
    return dateTimeWidget;
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) IFormElement(org.javarosa.core.model.IFormElement) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) DateTimeWidget(org.odk.collect.android.widgets.DateTimeWidget) QuestionDetails(org.odk.collect.android.formentry.questions.QuestionDetails) QuestionDef(org.javarosa.core.model.QuestionDef) DateTime(org.joda.time.DateTime) LocalDateTime(org.joda.time.LocalDateTime)

Example 37 with FormEntryPrompt

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

the class DaylightSavingTest method prepareDateWidget.

private DateWidget prepareDateWidget(int year, int month, int day) {
    QuestionDef questionDefStub = mock(QuestionDef.class);
    FormEntryPrompt formEntryPromptStub = new MockFormEntryPromptBuilder().withIndex("index").build();
    IFormElement iformElementStub = formEntryPromptStub.getFormElement();
    when(iformElementStub.getAdditionalAttribute(anyString(), anyString())).thenReturn(null);
    when(formEntryPromptStub.getQuestion()).thenReturn(questionDefStub);
    when(formEntryPromptStub.getFormElement()).thenReturn(iformElementStub);
    when(formEntryPromptStub.getQuestion().getAppearanceAttr()).thenReturn("no-calendar");
    DatePickerDialog datePickerDialog = mock(DatePickerDialog.class);
    DatePicker datePicker = mock(DatePicker.class);
    when(datePickerDialog.getDatePicker()).thenReturn(datePicker);
    when(datePickerDialog.getDatePicker().getYear()).thenReturn(year);
    when(datePickerDialog.getDatePicker().getMonth()).thenReturn(month);
    when(datePickerDialog.getDatePicker().getDayOfMonth()).thenReturn(day);
    return new DateWidget(widgetActivity, new QuestionDetails(formEntryPromptStub), widgetUtils);
}
Also used : IFormElement(org.javarosa.core.model.IFormElement) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) DatePickerDialog(android.app.DatePickerDialog) DateWidget(org.odk.collect.android.widgets.DateWidget) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) DatePicker(android.widget.DatePicker) QuestionDetails(org.odk.collect.android.formentry.questions.QuestionDetails) QuestionDef(org.javarosa.core.model.QuestionDef)

Example 38 with FormEntryPrompt

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

the class GeoPointMapWidgetTest method buttonClick_requestsGeoPoint.

@Test
public void buttonClick_requestsGeoPoint() {
    FormEntryPrompt prompt = promptWithAnswer(answer);
    GeoPointMapWidget widget = createWidget(prompt);
    widget.binding.simpleButton.performClick();
    verify(geoDataRequester).requestGeoPoint(prompt, answer.getDisplayText(), waitingForDataRegistry);
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) Test(org.junit.Test)

Example 39 with FormEntryPrompt

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

the class GeoShapeWidgetTest method buttonClick_requestsGeoShape.

@Test
public void buttonClick_requestsGeoShape() {
    FormEntryPrompt prompt = promptWithAnswer(new StringData(answer));
    GeoShapeWidget widget = createWidget(prompt);
    widget.binding.simpleButton.performClick();
    verify(geoDataRequester).requestGeoShape(prompt, answer, waitingForDataRegistry);
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) StringData(org.javarosa.core.model.data.StringData) Test(org.junit.Test)

Example 40 with FormEntryPrompt

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

the class GeoShapeWidgetTest method buttonClick_requestsGeoShape_whenAnswerIsCleared.

@Test
public void buttonClick_requestsGeoShape_whenAnswerIsCleared() {
    FormEntryPrompt prompt = promptWithAnswer(new StringData(answer));
    GeoShapeWidget widget = createWidget(prompt);
    widget.clearAnswer();
    widget.binding.simpleButton.performClick();
    verify(geoDataRequester).requestGeoShape(prompt, "", waitingForDataRegistry);
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) StringData(org.javarosa.core.model.data.StringData) 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