Search in sources :

Example 1 with QuestionDef

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;
}
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)

Example 2 with QuestionDef

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;
}
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) DatePicker(android.widget.DatePicker) QuestionDef(org.javarosa.core.model.QuestionDef)

Example 3 with QuestionDef

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;
}
Also used : FormDef(org.javarosa.core.model.FormDef) QuestionDef(org.javarosa.core.model.QuestionDef) GroupDef(org.javarosa.core.model.GroupDef)

Example 4 with QuestionDef

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);
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) Selection(org.javarosa.core.model.data.helper.Selection) QuestionDef(org.javarosa.core.model.QuestionDef)

Example 5 with QuestionDef

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");
    }
}
Also used : QuestionDef(org.javarosa.core.model.QuestionDef) Test(org.junit.Test)

Aggregations

QuestionDef (org.javarosa.core.model.QuestionDef)30 IFormElement (org.javarosa.core.model.IFormElement)8 SelectChoice (org.javarosa.core.model.SelectChoice)7 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 GroupDef (org.javarosa.core.model.GroupDef)5 IDataReference (org.javarosa.core.model.IDataReference)4 Selection (org.javarosa.core.model.data.helper.Selection)4 TreeElement (org.javarosa.core.model.instance.TreeElement)4 FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)4 TreeReference (org.javarosa.core.model.instance.TreeReference)3 Localizer (org.javarosa.core.services.locale.Localizer)3 List (java.util.List)2 FormDef (org.javarosa.core.model.FormDef)2 ItemsetBinding (org.javarosa.core.model.ItemsetBinding)2 Constraint (org.javarosa.core.model.condition.Constraint)2 EvaluationContext (org.javarosa.core.model.condition.EvaluationContext)2 SelectMultiData (org.javarosa.core.model.data.SelectMultiData)2 SelectOneData (org.javarosa.core.model.data.SelectOneData)2 AbstractTreeElement (org.javarosa.core.model.instance.AbstractTreeElement)2