From eb7afb09e825e5322979c554370a9dc293fcb1fd Mon Sep 17 00:00:00 2001 From: Clayton Sims Date: Mon, 17 Jul 2017 10:11:26 -0400 Subject: [PATCH] Realized we had no basic form tests that itemsets aren't broken --- .../javarosa/core/model/test/FormDefTest.java | 27 ++++++++ .../xform_tests/itemset_population_test.xhtml | 65 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 src/test/resources/xform_tests/itemset_population_test.xhtml diff --git a/src/test/java/org/javarosa/core/model/test/FormDefTest.java b/src/test/java/org/javarosa/core/model/test/FormDefTest.java index c947250de0..eaa09dd35f 100644 --- a/src/test/java/org/javarosa/core/model/test/FormDefTest.java +++ b/src/test/java/org/javarosa/core/model/test/FormDefTest.java @@ -614,4 +614,31 @@ public boolean rawArgs() { fec.answerQuestion(new SelectOneData(new Selection("yes"))); } while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM); } + + @Test + public void testItemsetPopulationAndFilter() { + FormParseInit fpi = new FormParseInit("/xform_tests/itemset_population_test.xhtml"); + + FormEntryController fec = fpi.getFormEntryController(); + + do { + QuestionDef q = fpi.getCurrentQuestion(); + if (q == null) { + continue; + } + TreeReference currentRef = fec.getModel().getFormIndex().getReference(); + if(currentRef == null) { continue; } + + if(currentRef.genericize().toString().equals("/data/filter")) { + fec.answerQuestion(new SelectOneData(new Selection("a"))); + } + + if(currentRef.genericize().toString().equals("/data/question")) { + assertEquals("Itemset Filter returned the wrong size", + fec.getModel().getQuestionPrompt().getSelectChoices().size(), + 3); + } + + } while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM); + } } diff --git a/src/test/resources/xform_tests/itemset_population_test.xhtml b/src/test/resources/xform_tests/itemset_population_test.xhtml new file mode 100644 index 0000000000..2fab7676a0 --- /dev/null +++ b/src/test/resources/xform_tests/itemset_population_test.xhtml @@ -0,0 +1,65 @@ + + + Itemset Test + + + + + + + + + + + + + 1_a + + + + 2_a + + + + 3_a + + + + + 1_b + + + + 2_b + + + + + + + + + + + a + + + + b + + + + + + + + +