Search in sources :

Example 1 with TimeWidget

use of org.odk.collect.android.widgets.TimeWidget 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);
    IFormElement iformElementStub = mock(IFormElement.class);
    FormEntryPrompt formEntryPromptStub = mock(FormEntryPrompt.class);
    when(iformElementStub.getAdditionalAttribute(anyString(), anyString())).thenReturn(null);
    when(formEntryPromptStub.getQuestion()).thenReturn(questionDefStub);
    when(formEntryPromptStub.getFormElement()).thenReturn(iformElementStub);
    when(formEntryPromptStub.getQuestion().getAppearanceAttr()).thenReturn("no-calendar");
    DateWidget dateWidget = mock(DateWidget.class);
    when(dateWidget.getDate()).thenReturn(new LocalDateTime().withYear(year).withMonthOfYear(month).withDayOfMonth(day));
    TimeWidget timeWidget = mock(TimeWidget.class);
    when(timeWidget.getHour()).thenReturn(hour);
    when(timeWidget.getMinute()).thenReturn(minute);
    DateTimeWidget dateTimeWidget = new DateTimeWidget(RuntimeEnvironment.application, formEntryPromptStub);
    dateTimeWidget.setDateWidget(dateWidget);
    dateTimeWidget.setTimeWidget(timeWidget);
    return dateTimeWidget;
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) IFormElement(org.javarosa.core.model.IFormElement) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) DateWidget(org.odk.collect.android.widgets.DateWidget) DateTimeWidget(org.odk.collect.android.widgets.DateTimeWidget) QuestionDef(org.javarosa.core.model.QuestionDef) TimeWidget(org.odk.collect.android.widgets.TimeWidget) DateTimeWidget(org.odk.collect.android.widgets.DateTimeWidget)

Aggregations

IFormElement (org.javarosa.core.model.IFormElement)1 QuestionDef (org.javarosa.core.model.QuestionDef)1 FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)1 LocalDateTime (org.joda.time.LocalDateTime)1 DateTimeWidget (org.odk.collect.android.widgets.DateTimeWidget)1 DateWidget (org.odk.collect.android.widgets.DateWidget)1 TimeWidget (org.odk.collect.android.widgets.TimeWidget)1