|
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 queryset - two |
|
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 <button step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/> |
|
19 <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/> |
|
20 <checkbox step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/> |
|
21 <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/> |
|
22 <button step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/> |
|
23 <button step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/> |
|
24 </data> |
|
25 |
|
26 <script src="templates_shared.js"/> |
|
27 |
|
28 <script> |
|
29 <![CDATA[ |
|
30 SimpleTest.waitForExplicitFinish(); |
|
31 |
|
32 var testid ="queryset - two"; |
|
33 var queryType = "rdf"; |
|
34 var isTreeBuilder = false; |
|
35 var needsOpen = false; |
|
36 var notWorkingYet = false; |
|
37 var notWorkingYetDynamic = false; |
|
38 var expectedOutput = document.getElementById("output"); |
|
39 |
|
40 var changes = [ |
|
41 // step 1 |
|
42 function(targetds, root) { |
|
43 var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin'); |
|
44 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
45 RDF.GetLiteral('Emperor Penguin'), true); |
|
46 var container = ContainerUtils.MakeSeq(targetds, |
|
47 RDF.GetResource(ZOO_NS + 'birds')); |
|
48 container.AppendElement(newnode); |
|
49 expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/emperorpenguin', true, true, |
|
50 '2 matching rule 1'); |
|
51 }, |
|
52 // step 2 |
|
53 function(targetds, root) { |
|
54 var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'); |
|
55 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
56 RDF.GetLiteral('Archaeopteryx'), true); |
|
57 var container = ContainerUtils.MakeSeq(targetds, |
|
58 RDF.GetResource(ZOO_NS + 'birds')); |
|
59 container.InsertElementAt(newnode, '4', true); |
|
60 expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/archaeopteryx', true, true, |
|
61 '2 matching rule 1'); |
|
62 }, |
|
63 // step 3 |
|
64 function(targetds, root) { |
|
65 var newnode = RDF.GetResource(ZOO_NS + 'birds/wren'); |
|
66 targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
67 RDF.GetLiteral('Wren'), true); |
|
68 var container = ContainerUtils.MakeSeq(targetds, |
|
69 RDF.GetResource(ZOO_NS + 'birds')); |
|
70 container.InsertElementAt(newnode, '1', true); |
|
71 expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/wren', true, true, |
|
72 '2 matching rule 1'); |
|
73 }, |
|
74 // step 4 |
|
75 function(targetds, root) { |
|
76 var container = ContainerUtils.MakeSeq(targetds, |
|
77 RDF.GetResource(ZOO_NS + 'birds')); |
|
78 var removednode = container.RemoveElementAt('3', true); |
|
79 targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'), |
|
80 RDF.GetLiteral('Barn Owl'), true); |
|
81 expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/barnowl', false, false, |
|
82 '2 (active query is 1)'); |
|
83 expectConsoleMessage(ZOO_NS + 'birds', ZOO_NS + 'birds/barnowl', false, true, |
|
84 '1 (no new active query)'); |
|
85 } |
|
86 ]; |
|
87 ]]> |
|
88 </script> |
|
89 |
|
90 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" flags="logging" |
|
91 datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds"> |
|
92 <template> |
|
93 <queryset> |
|
94 <query> |
|
95 <content uri="?uri"/> |
|
96 <member container="?uri" child="?animal"/> |
|
97 <triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="Barn Owl"/> |
|
98 <triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/> |
|
99 </query> |
|
100 <action> |
|
101 <checkbox uri="?animal" label="?name"/> |
|
102 </action> |
|
103 </queryset> |
|
104 <queryset> |
|
105 <query> |
|
106 <content uri="?uri"/> |
|
107 <member container="?uri" child="?animal"/> |
|
108 <triple subject="?animal" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/> |
|
109 </query> |
|
110 <action> |
|
111 <button uri="?animal" label="?name"/> |
|
112 </action> |
|
113 </queryset> |
|
114 </template> |
|
115 </vbox> |
|
116 |
|
117 </window> |