use of org.javarosa.form.api.FormEntryController in project javarosa by opendatakit.
the class FormDef method validate.
public ValidateOutcome validate(boolean markCompleted) {
FormEntryModel formEntryModelToBeValidated = new FormEntryModel(this);
FormEntryController formEntryControllerToBeValidated = new FormEntryController(formEntryModelToBeValidated);
return dagImpl.validate(formEntryControllerToBeValidated, markCompleted);
}
use of org.javarosa.form.api.FormEntryController in project javarosa by opendatakit.
the class FormDefTest method testAnswerConstraint.
public void testAnswerConstraint() {
IntegerData ans = new IntegerData(13);
FormEntryController fec = fpi.getFormEntryController();
fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());
do {
QuestionDef q = fpi.getCurrentQuestion();
if (q == null || q.getTextID() == null || q.getTextID().length() == 0)
continue;
if (q.getTextID().equals("constraint-test")) {
int response = fec.answerQuestion(ans, true);
if (response == FormEntryController.ANSWER_CONSTRAINT_VIOLATED) {
fail("Answer Constraint test failed.");
} else if (response == FormEntryController.ANSWER_OK) {
break;
} else {
fail("Bad response from fec.answerQuestion()");
}
}
} while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);
}
use of org.javarosa.form.api.FormEntryController in project javarosa by opendatakit.
the class TextFormTests method testTextForms.
/**
* Test that the long and short text forms work as expected
* (fallback to default for example).
* Test being able to retrieve other exotic forms
*/
public void testTextForms() {
FormEntryController fec = fpi.getFormEntryController();
fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());
boolean foundFlag = false;
Localizer l = fpi.getFormDef().getLocalizer();
l.setDefaultLocale(l.getAvailableLocales()[0]);
l.setLocale(l.getAvailableLocales()[0]);
int state = -99;
while (state != FormEntryController.EVENT_QUESTION) {
state = fec.stepToNextEvent();
}
fep = fec.getModel().getQuestionPrompt();
if (!fep.getLongText().equals("Patient ID"))
fail("getLongText() not returning correct value");
if (!fep.getShortText().equals("ID"))
fail("getShortText() not returning correct value");
if (!fep.getAudioText().equals("jr://audio/hah.mp3"))
fail("getAudioText() not returning correct value");
state = -99;
while (state != FormEntryController.EVENT_QUESTION) {
state = fec.stepToNextEvent();
}
fep = fec.getModel().getQuestionPrompt();
if (!fep.getShortText().equals("Name"))
fail("getShortText() not returning correct value");
if (!fep.getLongText().equals("Full Name"))
fail("getLongText() not falling back to default text form correctly");
String v = fep.getSpecialFormQuestionText("long");
if (fep.getSpecialFormQuestionText("long") != null)
fail("getSpecialFormQuestionText() returning incorrect value");
}
use of org.javarosa.form.api.FormEntryController in project javarosa by opendatakit.
the class FormIndexSerializationTest method testOnFormController.
@Test
public void testOnFormController() throws IOException, ClassNotFoundException {
FormParseInit formParseInit = new FormParseInit();
formParseInit.setFormToParse(Paths.get(PathConst.getTestResourcePath().getAbsolutePath(), "formindex-serialization.xml").toString());
FormEntryController formEntryController = formParseInit.getFormEntryController();
FormIndex formIndex = formEntryController.getModel().getFormIndex();
assertFormIndex(formIndex, deserializeFormIndex(serializeObject(formIndex)));
do {
formIndex = formEntryController.getModel().incrementIndex(formIndex);
assertFormIndex(formIndex, deserializeFormIndex(serializeObject(formIndex)));
} while (!formIndex.isEndOfFormIndex());
}
Aggregations