use of org.javarosa.core.model.QuestionDef 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;
}
use of org.javarosa.core.model.QuestionDef in project collect by opendatakit.
the class DaylightSavingTest method prepareDateWidget.
private DateWidget prepareDateWidget(int year, int month, int day) {
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");
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);
DateWidget dateWidget = new DateWidget(RuntimeEnvironment.application, formEntryPromptStub);
dateWidget.setDatePickerDialog(datePickerDialog);
return dateWidget;
}
use of org.javarosa.core.model.QuestionDef in project javarosa by opendatakit.
the class FormDefConstructionUtils method createSimpleGroupReference.
public static FormDef createSimpleGroupReference() {
FormDef theform = new FormDef();
QuestionDef question1 = new QuestionDef();
GroupDef group1 = new GroupDef();
QuestionDef question11 = new QuestionDef();
QuestionDef question12 = new QuestionDef();
group1.addChild(question11);
group1.addChild(question12);
QuestionDef question2 = new QuestionDef();
theform.addChild(question1);
theform.addChild(group1);
theform.addChild(question2);
return theform;
}
use of org.javarosa.core.model.QuestionDef in project javarosa by opendatakit.
the class SelectOneDataTests method setUp.
/* (non-Javadoc)
* @see j2meunit.framework.TestCase#setUp()
*/
public void setUp() throws Exception {
super.setUp();
question = new QuestionDef();
question.setID(57);
for (int i = 0; i < 3; i++) {
question.addSelectChoice(new SelectChoice("", "Selection" + i, "Selection" + i, false));
}
one = new Selection("Selection1");
one.attachChoice(question);
two = new Selection("Selection2");
two.attachChoice(question);
}
use of org.javarosa.core.model.QuestionDef in project javarosa by opendatakit.
the class QuestionDefTest method testFlagObservers.
@Test
public void testFlagObservers() {
QuestionDef q = new QuestionDef();
QuestionObserver qo = new QuestionObserver();
q.registerStateObserver(qo);
if (qo.flag || qo.q != null || qo.flags != 0) {
fail("Improper state in question observer");
}
q.unregisterStateObserver(qo);
if (qo.flag) {
fail("Localization observer updated after unregistered");
}
}
Aggregations