testing library

Test support for DartRosa: build XForms in code and drive them.

Port of org.javarosa.test. Public so app developers can test their own forms the same way the engine is tested.

Classes

BindBuilderXFormsElement
A builder for a <bind> element, configured with cascades.
EmptyXFormsElement
A self-closing element with no content.
Scenario
Fills a form from tests: answer by XPath, navigate, add and remove repeat instances, and read answers, choices and prompts.
StringLiteralXFormsElement
An element whose content is a raw XML string.
TagXFormsElement
An element with child elements.
XFormsElement
A piece of an XForm document built in code.

Functions

bind(String nodeset) → BindBuilderXFormsElement
Starts a <bind> for nodeset; configure it with cascades.
body(List<XFormsElement> children) → XFormsElement
The <h:body> element.
data(List<XFormsElement> children) → XFormsElement
A <data> root element with a random form id.
formGroup(String ref, [List<XFormsElement> children = const []]) → XFormsElement
A <group>. Named formGroup so it doesn't clash with package:test's group.
getRef(String xpath) → TreeReference
Parses xpath into a TreeReference, turning numeric predicates into multiplicities: /data/child[2] refers to the second child (multiplicity 1), [-1] means unbound and [@template] the template.
The <h:head> element.
html(XFormsElement head, XFormsElement body, {Map<String, String> additionalNamespaces = const {}}) → XFormsElement
The <h:html> root with the standard ODK namespaces plus any additionalNamespaces (prefix → URI).
input(String ref, [List<XFormsElement> children = const []]) → XFormsElement
An <input> control.
instance(String name, List<XFormsElement> children) → XFormsElement
A secondary <instance id="name"> wrapping its items in <root>.
item(Object value, String label) → XFormsElement
A static choice <item>.
label(String innerXml) → XFormsElement
A <label> with raw XML content.
mainInstance(List<XFormsElement> children) → XFormsElement
The primary <instance> (no id).
model(List<XFormsElement> children, {Map<String, String> attributes = const {}}) → XFormsElement
The <model> element with optional extra attributes.
repeat(String nodeset, [List<XFormsElement> children = const [], String? count]) → XFormsElement
A <repeat>, optionally with a jr:count expression count.
select1(String ref, [List<XFormsElement> children = const []]) → XFormsElement
A <select1> control.
select1Dynamic(String ref, String nodeset, {String valueRef = 'value', String labelRef = 'label'}) → XFormsElement
A <select1> whose choices come from an <itemset> at nodeset.
setvalue(String event, String ref, [String? value]) → XFormsElement
A <setvalue> action; value is an XPath expression.
setvalueLiteral(String event, String ref, String innerXml) → XFormsElement
A <setvalue> action whose value is the literal innerXml.
t(String spec, [List<XFormsElement> children = const []]) → XFormsElement
Creates an element from spec (name plus inline attributes) with optional children.
title([String? text]) → XFormsElement
The <h:title> element; a random title when text is omitted.
tText(String spec, String innerXml) → XFormsElement
Creates an element from spec whose content is innerXml.

Typedefs

AnswerResult = AnswerStatus
The outcome of Scenario.answer. Port of Scenario.AnswerResult.