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