use of org.javarosa.core.model.QuestionDef in project javarosa by opendatakit.
the class TextFormTests method testPromptsNoLocalizer.
public void testPromptsNoLocalizer() {
QuestionDef q = new QuestionDef();
q.setLabelInnerText("labelInnerText");
if (!"labelInnerText".equals(q.getLabelInnerText())) {
fail("LabelInnerText getter/setter broken");
}
q.setHelpText("help text");
if (!"help text".equals(q.getHelpText())) {
fail("Help text getter/setter broken");
}
}
use of org.javarosa.core.model.QuestionDef in project javarosa by opendatakit.
the class TextFormTests method testConstructors.
public void testConstructors() {
QuestionDef q;
q = new QuestionDef();
if (q.getID() != -1) {
fail("QuestionDef not initialized properly (default constructor)");
}
q = new QuestionDef(17, Constants.CONTROL_RANGE);
if (q.getID() != 17) {
fail("QuestionDef not initialized properly");
}
if (q.getControlType() != Constants.CONTROL_RANGE) {
fail("QuestionDef not initialized properly");
}
}
use of org.javarosa.core.model.QuestionDef in project javarosa by opendatakit.
the class TextFormTests method testPromptsWithLocalizer.
public void testPromptsWithLocalizer() {
Localizer l = new Localizer();
TableLocaleSource table = new TableLocaleSource();
l.addAvailableLocale("locale");
l.setDefaultLocale("locale");
table.setLocaleMapping("prompt;long", "loc: long text");
table.setLocaleMapping("prompt;short", "loc: short text");
table.setLocaleMapping("help", "loc: help text");
l.registerLocaleResource("locale", table);
l.setLocale("locale");
QuestionDef q = new QuestionDef();
q.setHelpTextID("help");
FormEntryPrompt fep = new DummyFormEntryPrompt(l, "prompt", q);
if (!"loc: long text".equals(fep.getLongText())) {
fail("Long text did not localize properly");
}
if (!"loc: short text".equals(fep.getShortText())) {
fail("Short text did not localize properly");
}
}
use of org.javarosa.core.model.QuestionDef in project javarosa by opendatakit.
the class SelectMultiDataTests method setUp.
/* (non-Javadoc)
* @see j2meunit.framework.TestCase#setUp()
*/
public void setUp() throws Exception {
super.setUp();
question = new QuestionDef();
for (int i = 0; i < 4; i++) {
question.addSelectChoice(new SelectChoice("", "Selection" + i, "Selection " + i, false));
}
one = new Selection("Selection 1");
one.attachChoice(question);
two = new Selection("Selection 2");
two.attachChoice(question);
three = new Selection("Selection 3");
three.attachChoice(question);
firstTwo = new ArrayList<Selection>();
firstTwo.add(one);
firstTwo.add(two);
lastTwo = new ArrayList<Selection>();
lastTwo.add(two);
lastTwo.add(three);
invalid = new ArrayList<Object>();
invalid.add(three);
invalid.add(new Integer(12));
invalid.add(one);
}
use of org.javarosa.core.model.QuestionDef in project javarosa by opendatakit.
the class FormParseInit method printStuff.
/*
* Makes an 'extremely basic' print out of the xform model.
*/
public String printStuff() {
String stuff = "";
// go to the beginning of the form
fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());
do {
FormEntryCaption fep = femodel.getCaptionPrompt();
boolean choiceFlag = false;
if (fep.getFormElement() instanceof QuestionDef) {
stuff += "\t[Type:QuestionDef, ";
List<SelectChoice> s = ((QuestionDef) fep.getFormElement()).getChoices();
stuff += "ContainsChoices: " + ((s != null && s.size() > 0) ? "true " : "false") + ", ";
if (s != null && s.size() > 0)
choiceFlag = true;
} else if (fep.getFormElement() instanceof FormDef) {
stuff += "\t[Type:FormDef, ";
} else if (fep.getFormElement() instanceof GroupDef) {
stuff += "\t[Type:GroupDef, ";
} else {
stuff += "\t[Type:Unknown]\n";
continue;
}
stuff += "ID:" + fep.getFormElement().getID() + ", TextID:" + fep.getFormElement().getTextID() + ",InnerText:" + fep.getFormElement().getLabelInnerText();
if (choiceFlag) {
stuff += "] \n\t\t---Choices:" + ((QuestionDef) fep.getFormElement()).getChoices().toString() + "\n";
} else {
stuff += "]\n";
}
} while (fec.stepToNextEvent() != fec.EVENT_END_OF_FORM);
return stuff;
}
Aggregations