content/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivemultiplerulestreebuilder.xul

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:979b834ea2d4
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
4
5 <!--
6 tree element - query syntax recursive multiple rules tree builder
7 -->
8
9 <window title="XUL Template Tests" width="500" height="600"
10 onload="test_template();"
11 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
12 <script type="application/javascript"
13 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
14
15 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
16
17 <data id="output">
18 <treecols id="treecols" orient="horizontal">
19 <treecol id="treecol" primary="true" label="Name" ordinal="1"/>
20 <treecol label="Species" ordinal="3"/>
21 </treecols>
22 <treechildren>
23 <treeitem id="http://www.some-fictitious-zoo.com/humans/sarah">
24 <treerow>
25 <treecell label="Sarah"/>
26 <treecell/>
27 </treerow>
28 </treeitem>
29 <treeitem step="-1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
30 <treerow>
31 <treecell/>
32 <treecell label="Is this cool: Mammals?"/>
33 </treerow>
34 </treeitem>
35 <treeitem step="1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" open="true">
36 <treerow>
37 <treecell/>
38 <treecell label="Is this cool: Mammals?"/>
39 </treerow>
40 <treechildren>
41 <treeitem id="http://www.some-fictitious-zoo.com/mammals/lion">
42 <treerow>
43 <treecell/>
44 <treecell label="Is this cool: Lion?"/>
45 </treerow>
46 </treeitem>
47 <treeitem id="http://www.some-fictitious-zoo.com/mammals/hippopotamus">
48 <treerow>
49 <treecell label="HIPPOPOTAMUS"/>
50 <treecell/>
51 </treerow>
52 </treeitem>
53 <treeitem id="http://www.some-fictitious-zoo.com/mammals/africanelephant">
54 <treerow>
55 <treecell/>
56 <treecell label="Is this cool: African Elephant?"/>
57 </treerow>
58 </treeitem>
59 <treeitem step="2" id="http://www.some-fictitious-zoo.com/mammals/koala">
60 <treerow>
61 <treecell/>
62 <treecell label="Is this cool: Koala?"/>
63 </treerow>
64 </treeitem>
65 <treeitem id="http://www.some-fictitious-zoo.com/mammals/llama">
66 <treerow>
67 <treecell/>
68 <treecell label="Is this cool: LLAMA?"/>
69 </treerow>
70 </treeitem>
71 <treeitem id="http://www.some-fictitious-zoo.com/mammals/polarbear">
72 <treerow>
73 <treecell/>
74 <treecell label="Is this cool: Polar Bear?"/>
75 </treerow>
76 </treeitem>
77 <treeitem id="http://www.some-fictitious-zoo.com/mammals/aardvark">
78 <treerow>
79 <treecell label="aardvark"/>
80 <treecell/>
81 </treerow>
82 </treeitem>
83 <treeitem id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
84 <treerow>
85 <treecell/>
86 <treecell label="Is this cool: Nine-banded Armadillo?"/>
87 </treerow>
88 </treeitem>
89 <treeitem id="http://www.some-fictitious-zoo.com/mammals/gorilla">
90 <treerow>
91 <treecell/>
92 <treecell label="Is this cool: Gorilla?"/>
93 </treerow>
94 </treeitem>
95 </treechildren>
96 </treeitem>
97 <treeitem step="-3" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
98 <treerow>
99 <treecell label="Crustaceans"/>
100 <treecell/>
101 </treerow>
102 </treeitem>
103 <treeitem step="3,-4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false">
104 <treerow>
105 <treecell label="Crustaceans"/>
106 <treecell/>
107 </treerow>
108 </treeitem>
109 <treeitem step="4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false" open="true">
110 <treerow>
111 <treecell label="Crustaceans"/>
112 <treecell/>
113 </treerow>
114 <treechildren>
115 <treeitem id="http://www.some-fictitious-zoo.com/crustaceans/lobster">
116 <treerow>
117 <treecell/>
118 <treecell label="Is this cool: Lobster?"/>
119 </treerow>
120 </treeitem>
121 </treechildren>
122 </treeitem>
123 <treeitem id="http://www.some-fictitious-zoo.com/birds/emu">
124 <treerow>
125 <treecell label="Emu"/>
126 <treecell/>
127 </treerow>
128 </treeitem>
129 </treechildren>
130 </data>
131
132 <script src="templates_shared.js"/>
133
134 <script>
135 <![CDATA[
136 SimpleTest.waitForExplicitFinish();
137
138 var testid ="tree element - query syntax recursive multiple rules tree builder";
139 var queryType = "rdf";
140 var isTreeBuilder = true;
141 var needsOpen = false;
142 var notWorkingYet = false;
143 var notWorkingYetDynamic = true;
144 var expectedOutput = document.getElementById("output");
145
146 var changes = [
147 // step 1
148 function(targetds, root) {
149 if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
150 root.view.toggleOpenState(1);
151 },
152 // step 2
153 function(targetds, root) {
154 var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala');
155 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
156 RDF.GetLiteral('Koala'), true);
157 var container = ContainerUtils.MakeSeq(targetds,
158 RDF.GetResource(ZOO_NS + 'mammals'));
159 container.InsertElementAt(newnode, '4', true);
160 },
161 // step 3
162 function(targetds, root) {
163 var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/lobster');
164 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
165 RDF.GetLiteral('Lobster'), true);
166 var container = ContainerUtils.MakeSeq(targetds,
167 RDF.GetResource(ZOO_NS + 'crustaceans'));
168 container.AppendElement(newnode);
169 },
170 // step 4
171 function(targetds, root) {
172 if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
173 root.view.toggleOpenState(11);
174 },
175 // step 5
176 function(targetds, root) {
177 if (root.view && 11 < root.view.rowCount && root.view.isContainer(11))
178 root.view.toggleOpenState(11);
179 },
180 // step 6
181 function(targetds, root) {
182 if (root.view && 1 < root.view.rowCount && root.view.isContainer(1))
183 root.view.toggleOpenState(1);
184 }
185 ];
186 ]]>
187 </script>
188
189 <tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/marked" flags=" dont-build-content" id="root">
190 <treecols orient="horizontal" id="treecols">
191 <treecol id="treecol" primary="true" label="Name"/>
192 <treecol label="Species"/>
193 </treecols>
194 <template id="template">
195 <query>
196 <content uri="?uri"/>
197 <member container="?uri" child="?child"/>
198 <triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/>
199 </query>
200 <rule>
201 <conditions>
202 <where subject="?name" rel="contains" value="l" ignorecase="true"/>
203 </conditions>
204 <action>
205 <treechildren>
206 <treeitem uri="?child">
207 <treerow>
208 <treecell/>
209 <treecell label="Is this cool: ?name^??"/>
210 </treerow>
211 </treeitem>
212 </treechildren>
213 </action>
214 </rule>
215 <rule>
216 <action>
217 <treechildren>
218 <treeitem uri="?child">
219 <treerow>
220 <treecell label="?name"/>
221 <treecell/>
222 </treerow>
223 </treeitem>
224 </treechildren>
225 </action>
226 </rule>
227 </template>
228 </tree>
229
230 </window>

mercurial