1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivemultiplerules.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,268 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 + 1.8 +<!-- 1.9 + tree element - query syntax recursive multiple rules 1.10 +--> 1.11 + 1.12 +<window title="XUL Template Tests" width="500" height="600" 1.13 + onload="test_template();" 1.14 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.15 + <script type="application/javascript" 1.16 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.17 + 1.18 + <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/> 1.19 + 1.20 + <data id="output"> 1.21 + <treecols id="treecols" orient="horizontal"> 1.22 + <treecol id="treecol" primary="true" label="Name" ordinal="1"/> 1.23 + <treecol label="Species" ordinal="3"/> 1.24 + </treecols> 1.25 + <treechildren> 1.26 + <treeitem id="http://www.some-fictitious-zoo.com/humans/sarah"> 1.27 + <treerow> 1.28 + <treecell label="Sarah"/> 1.29 + <treecell/> 1.30 + </treerow> 1.31 + </treeitem> 1.32 + <treeitem step="-1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false"> 1.33 + <treerow> 1.34 + <treecell/> 1.35 + <treecell label="Is this cool: Mammals?"/> 1.36 + </treerow> 1.37 + </treeitem> 1.38 + <treeitem step="1" id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" open="true"> 1.39 + <treerow> 1.40 + <treecell/> 1.41 + <treecell label="Is this cool: Mammals?"/> 1.42 + </treerow> 1.43 + <treechildren> 1.44 + <treeitem id="http://www.some-fictitious-zoo.com/mammals/lion"> 1.45 + <treerow> 1.46 + <treecell/> 1.47 + <treecell label="Is this cool: Lion?"/> 1.48 + </treerow> 1.49 + </treeitem> 1.50 + <treeitem id="http://www.some-fictitious-zoo.com/mammals/hippopotamus"> 1.51 + <treerow> 1.52 + <treecell label="HIPPOPOTAMUS"/> 1.53 + <treecell/> 1.54 + </treerow> 1.55 + </treeitem> 1.56 + <treeitem id="http://www.some-fictitious-zoo.com/mammals/africanelephant"> 1.57 + <treerow> 1.58 + <treecell/> 1.59 + <treecell label="Is this cool: African Elephant?"/> 1.60 + </treerow> 1.61 + </treeitem> 1.62 + <treeitem step="2" id="http://www.some-fictitious-zoo.com/mammals/koala"> 1.63 + <treerow> 1.64 + <treecell/> 1.65 + <treecell label="Is this cool: Koala?"/> 1.66 + </treerow> 1.67 + </treeitem> 1.68 + <treeitem id="http://www.some-fictitious-zoo.com/mammals/llama"> 1.69 + <treerow> 1.70 + <treecell/> 1.71 + <treecell label="Is this cool: LLAMA?"/> 1.72 + </treerow> 1.73 + </treeitem> 1.74 + <treeitem id="http://www.some-fictitious-zoo.com/mammals/polarbear"> 1.75 + <treerow> 1.76 + <treecell/> 1.77 + <treecell label="Is this cool: Polar Bear?"/> 1.78 + </treerow> 1.79 + </treeitem> 1.80 + <treeitem id="http://www.some-fictitious-zoo.com/mammals/aardvark"> 1.81 + <treerow> 1.82 + <treecell label="aardvark"/> 1.83 + <treecell/> 1.84 + </treerow> 1.85 + </treeitem> 1.86 + <treeitem id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo"> 1.87 + <treerow> 1.88 + <treecell/> 1.89 + <treecell label="Is this cool: Nine-banded Armadillo?"/> 1.90 + </treerow> 1.91 + </treeitem> 1.92 + <treeitem id="http://www.some-fictitious-zoo.com/mammals/gorilla"> 1.93 + <treerow> 1.94 + <treecell/> 1.95 + <treecell label="Is this cool: Gorilla?"/> 1.96 + </treerow> 1.97 + </treeitem> 1.98 + </treechildren> 1.99 + </treeitem> 1.100 + <treeitem step="-3" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true"> 1.101 + <treerow> 1.102 + <treecell label="Crustaceans"/> 1.103 + <treecell/> 1.104 + </treerow> 1.105 + </treeitem> 1.106 + <treeitem step="3,-4" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false"> 1.107 + <treerow> 1.108 + <treecell label="Crustaceans"/> 1.109 + <treecell/> 1.110 + </treerow> 1.111 + </treeitem> 1.112 + <treeitem step="5" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="false" open="true"> 1.113 + <treerow> 1.114 + <treecell label="Crustaceans"/> 1.115 + <treecell/> 1.116 + </treerow> 1.117 + <treechildren> 1.118 + <treeitem id="http://www.some-fictitious-zoo.com/crustaceans/lobster"> 1.119 + <treerow> 1.120 + <treecell/> 1.121 + <treecell label="Is this cool: Lobster?"/> 1.122 + </treerow> 1.123 + </treeitem> 1.124 + <treeitem id="http://www.some-fictitious-zoo.com/crustaceans/crayfish"> 1.125 + <treerow> 1.126 + <treecell label="Crayfish"/> 1.127 + <treecell/> 1.128 + </treerow> 1.129 + </treeitem> 1.130 + </treechildren> 1.131 + </treeitem> 1.132 + <treeitem id="http://www.some-fictitious-zoo.com/birds/emu"> 1.133 + <treerow> 1.134 + <treecell label="Emu"/> 1.135 + <treecell/> 1.136 + </treerow> 1.137 + </treeitem> 1.138 + </treechildren> 1.139 + </data> 1.140 + 1.141 +<script src="templates_shared.js"/> 1.142 + 1.143 +<script> 1.144 +<![CDATA[ 1.145 +SimpleTest.waitForExplicitFinish(); 1.146 + 1.147 +var testid ="tree element - query syntax recursive multiple rules"; 1.148 +var queryType = "rdf"; 1.149 +var isTreeBuilder = false; 1.150 +var needsOpen = false; 1.151 +var notWorkingYet = false; 1.152 +var notWorkingYetDynamic = true; 1.153 +var expectedOutput = document.getElementById("output"); 1.154 + 1.155 +var changes = [ 1.156 + // step 1 1.157 + function(targetds, root) { 1.158 + if (root.view && 1 < root.view.rowCount && root.view.isContainer(1)) 1.159 + root.view.toggleOpenState(1); 1.160 + expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/lion', true, true, 1.161 + '1 matching rule 1'); 1.162 + expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/hippopotamus', true, true, 1.163 + '1 matching rule 2'); 1.164 + expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/africanelephant', true, true, 1.165 + '1 matching rule 1'); 1.166 + expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/llama', true, true, 1.167 + '1 matching rule 1'); 1.168 + expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/polarbear', true, true, 1.169 + '1 matching rule 1'); 1.170 + expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/aardvark', true, true, 1.171 + '1 matching rule 2'); 1.172 + expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/ninebandedarmadillo', true, true, 1.173 + '1 matching rule 1'); 1.174 + expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/gorilla', true, true, 1.175 + '1 matching rule 1'); 1.176 + }, 1.177 + // step 2 1.178 + function(targetds, root) { 1.179 + var newnode = RDF.GetResource(ZOO_NS + 'mammals/koala'); 1.180 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.181 + RDF.GetLiteral('Koala'), true); 1.182 + var container = ContainerUtils.MakeSeq(targetds, 1.183 + RDF.GetResource(ZOO_NS + 'mammals')); 1.184 + container.InsertElementAt(newnode, '4', true); 1.185 + expectConsoleMessage(ZOO_NS + 'mammals', ZOO_NS + 'mammals/koala', true, true, 1.186 + '1 matching rule 1'); 1.187 + }, 1.188 + // step 3 1.189 + function(targetds, root) { 1.190 + var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/lobster'); 1.191 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.192 + RDF.GetLiteral('Lobster'), true); 1.193 + var container = ContainerUtils.MakeSeq(targetds, 1.194 + RDF.GetResource(ZOO_NS + 'crustaceans')); 1.195 + container.AppendElement(newnode); 1.196 + }, 1.197 + // step 4 1.198 + function(targetds, root) { 1.199 + var newnode = RDF.GetResource(ZOO_NS + 'crustaceans/crayfish'); 1.200 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.201 + RDF.GetLiteral('Crayfish'), true); 1.202 + var container = ContainerUtils.MakeSeq(targetds, 1.203 + RDF.GetResource(ZOO_NS + 'crustaceans')); 1.204 + container.AppendElement(newnode); 1.205 + }, 1.206 + // step 5 1.207 + function(targetds, root) { 1.208 + if (root.view && 11 < root.view.rowCount && root.view.isContainer(11)) 1.209 + root.view.toggleOpenState(11); 1.210 + expectConsoleMessage(ZOO_NS + 'crustaceans', ZOO_NS + 'crustaceans/lobster', true, true, 1.211 + '1 matching rule 1'); 1.212 + expectConsoleMessage(ZOO_NS + 'crustaceans', ZOO_NS + 'crustaceans/crayfish', true, true, 1.213 + '1 matching rule 2'); 1.214 + }, 1.215 + // step 6 1.216 + function(targetds, root) { 1.217 + if (root.view && 11 < root.view.rowCount && root.view.isContainer(11)) 1.218 + root.view.toggleOpenState(11); 1.219 + }, 1.220 + // step 7 1.221 + function(targetds, root) { 1.222 + if (root.view && 1 < root.view.rowCount && root.view.isContainer(1)) 1.223 + root.view.toggleOpenState(1); 1.224 + } 1.225 +]; 1.226 +]]> 1.227 +</script> 1.228 + 1.229 +<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" 1.230 + flags="logging" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/marked" id="root"> 1.231 +<treecols orient="horizontal" id="treecols"> 1.232 +<treecol id="treecol" primary="true" label="Name"/> 1.233 +<treecol label="Species"/> 1.234 +</treecols> 1.235 +<template id="template"> 1.236 +<query> 1.237 +<content uri="?uri"/> 1.238 +<member container="?uri" child="?child"/> 1.239 +<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/> 1.240 +</query> 1.241 +<rule> 1.242 +<conditions> 1.243 +<where subject="?name" rel="contains" value="l" ignorecase="true"/> 1.244 +</conditions> 1.245 +<action> 1.246 +<treechildren> 1.247 +<treeitem uri="?child"> 1.248 +<treerow> 1.249 +<treecell/> 1.250 +<treecell label="Is this cool: ?name^??"/> 1.251 +</treerow> 1.252 +</treeitem> 1.253 +</treechildren> 1.254 +</action> 1.255 +</rule> 1.256 +<rule> 1.257 +<action> 1.258 +<treechildren> 1.259 +<treeitem uri="?child"> 1.260 +<treerow> 1.261 +<treecell label="?name"/> 1.262 +<treecell/> 1.263 +</treerow> 1.264 +</treeitem> 1.265 +</treechildren> 1.266 +</action> 1.267 +</rule> 1.268 +</template> 1.269 +</tree> 1.270 + 1.271 +</window>