1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxtreebuilder.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,158 @@ 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 tree builder 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/birds/emu"> 1.27 + <treerow> 1.28 + <treecell label="Emu"/> 1.29 + <treecell step="-6" label="12"/> 1.30 + <treecell step="6" label="0"/> 1.31 + </treerow> 1.32 + </treeitem> 1.33 + <treeitem step="1" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx"> 1.34 + <treerow> 1.35 + <treecell label="Archaeopteryx"/> 1.36 + <treecell step="-4"/> 1.37 + <treecell step="4" label="5"/> 1.38 + </treerow> 1.39 + </treeitem> 1.40 + <treeitem step="-2" id="http://www.some-fictitious-zoo.com/birds/barnowl"> 1.41 + <treerow> 1.42 + <treecell label="Barn Owl"/> 1.43 + <treecell label="4"/> 1.44 + </treerow> 1.45 + </treeitem> 1.46 + <treeitem id="http://www.some-fictitious-zoo.com/birds/raven"> 1.47 + <treerow> 1.48 + <treecell step="-7" label="Raven"/> 1.49 + <treecell step="7" label="Crow"/> 1.50 + <treecell step="-5" label="0"/> 1.51 + <treecell step="5" label="2"/> 1.52 + </treerow> 1.53 + </treeitem> 1.54 + </treechildren> 1.55 + </data> 1.56 + 1.57 +<script src="templates_shared.js"/> 1.58 + 1.59 +<script> 1.60 +<![CDATA[ 1.61 +SimpleTest.waitForExplicitFinish(); 1.62 + 1.63 +var testid ="tree element - query syntax tree builder"; 1.64 +var queryType = "rdf"; 1.65 +var isTreeBuilder = true; 1.66 +var needsOpen = false; 1.67 +var notWorkingYet = false; 1.68 +var notWorkingYetDynamic = true; 1.69 +var expectedOutput = document.getElementById("output"); 1.70 + 1.71 +var changes = [ 1.72 + // step 1 1.73 + function(targetds, root) { 1.74 + var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'); 1.75 + targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.76 + RDF.GetLiteral('Archaeopteryx'), true); 1.77 + var container = ContainerUtils.MakeSeq(targetds, 1.78 + RDF.GetResource(ZOO_NS + 'birds')); 1.79 + container.InsertElementAt(newnode, '2', true); 1.80 + }, 1.81 + // step 2 1.82 + function(targetds, root) { 1.83 + var container = ContainerUtils.MakeSeq(targetds, 1.84 + RDF.GetResource(ZOO_NS + 'birds')); 1.85 + var removednode = container.RemoveElementAt('3', true); 1.86 + targetds.Unassert(removednode, RDF.GetResource(ZOO_NS + 'rdf#name'), 1.87 + RDF.GetLiteral('Barn Owl'), true); 1.88 + }, 1.89 + // step 3 1.90 + function(targetds, root) { 1.91 + targetds.Assert(RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'), 1.92 + RDF.GetResource(ZOO_NS + 'rdf#species'), 1.93 + RDF.GetLiteral('Archaeopteryx lithographica'), true); 1.94 + }, 1.95 + // step 4 1.96 + function(targetds, root) { 1.97 + targetds.Assert(RDF.GetResource(ZOO_NS + 'birds/archaeopteryx'), 1.98 + RDF.GetResource(ZOO_NS + 'rdf#specimens'), 1.99 + RDF.GetLiteral('5'), true); 1.100 + }, 1.101 + // step 5 1.102 + function(targetds, root) { 1.103 + var subject = RDF.GetResource(ZOO_NS + 'birds/raven'); 1.104 + var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens'); 1.105 + var oldval = targetds.GetTarget(subject, predicate, true); 1.106 + targetds.Change(RDF.GetResource(ZOO_NS + 'birds/raven'), 1.107 + RDF.GetResource(ZOO_NS + 'rdf#specimens'), 1.108 + oldval, RDF.GetLiteral('2')); 1.109 + }, 1.110 + // step 6 1.111 + function(targetds, root) { 1.112 + var subject = RDF.GetResource(ZOO_NS + 'birds/emu'); 1.113 + var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens'); 1.114 + var oldval = targetds.GetTarget(subject, predicate, true); 1.115 + targetds.Change(RDF.GetResource(ZOO_NS + 'birds/emu'), 1.116 + RDF.GetResource(ZOO_NS + 'rdf#specimens'), 1.117 + oldval, RDF.GetLiteral('0')); 1.118 + }, 1.119 + // step 7 1.120 + function(targetds, root) { 1.121 + var subject = RDF.GetResource(ZOO_NS + 'birds/raven'); 1.122 + var predicate = RDF.GetResource(ZOO_NS + 'rdf#name'); 1.123 + var oldval = targetds.GetTarget(subject, predicate, true); 1.124 + targetds.Change(RDF.GetResource(ZOO_NS + 'birds/raven'), 1.125 + RDF.GetResource(ZOO_NS + 'rdf#name'), 1.126 + oldval, RDF.GetLiteral('Crow')); 1.127 + } 1.128 +]; 1.129 +]]> 1.130 +</script> 1.131 + 1.132 +<tree xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" hidevscroll="true" hidehscroll="true" datasources="rdf:null" flags="dont-build-content" id="root" ref="http://www.some-fictitious-zoo.com/birds"> 1.133 +<treecols orient="horizontal" id="treecols"> 1.134 +<treecol id="treecol" primary="true" label="Name"/> 1.135 +<treecol label="Species"/> 1.136 +</treecols> 1.137 +<template id="template"> 1.138 +<query> 1.139 +<content uri="?uri"/> 1.140 +<member container="?uri" child="?child"/> 1.141 +<triple subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#name" object="?name"/> 1.142 +</query> 1.143 +<rule> 1.144 +<bindings> 1.145 +<binding subject="?child" predicate="http://www.some-fictitious-zoo.com/rdf#specimens" object="?specimens"/> 1.146 +</bindings> 1.147 +<action> 1.148 +<treechildren> 1.149 +<treeitem uri="?child"> 1.150 +<treerow> 1.151 +<treecell label="?name"/> 1.152 +<treecell label="?specimens"/> 1.153 +</treerow> 1.154 +</treeitem> 1.155 +</treechildren> 1.156 +</action> 1.157 +</rule> 1.158 +</template> 1.159 +</tree> 1.160 + 1.161 +</window>