toolkit/content/tests/chrome/test_sorttemplate.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/tests/chrome/test_sorttemplate.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,89 @@
     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 +<?xml-stylesheet href="data:text/css,window > |people { display: none }" type="text/css"?>
     1.8 +<!--
     1.9 +  XUL Widget Test for tabindex
    1.10 +  -->
    1.11 +<window title="tabindex" width="500" height="600"
    1.12 +        onfocus="runTest()"
    1.13 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.14 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>  
    1.15 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>  
    1.16 +
    1.17 +<people id="famouspeople" xmlns="">
    1.18 +    <person name="Napoleon Bonaparte" gender="male"/>
    1.19 +    <person name="Cleopatra" gender="female"/>
    1.20 +    <person name="Julius Caesar" gender="male"/>
    1.21 +    <person name="Ferdinand Magellan" gender="male"/>
    1.22 +    <person name="Laura Secord" gender="female"/>
    1.23 +</people>
    1.24 +
    1.25 +<tree id="tree" datasources="#famouspeople" ref="*" querytype="xml" flex="1">
    1.26 +  <treecols>
    1.27 +    <treecol label="Name" flex="1" sort="?name"/>
    1.28 +    <treecol label="Gender" flex="1" sort="?gender"/>
    1.29 +  </treecols>
    1.30 +  <template>
    1.31 +    <query/>
    1.32 +    <rule>
    1.33 +      <action>
    1.34 +        <treechildren id="treechildren-strings">
    1.35 +          <treeitem uri="?">
    1.36 +            <treerow>
    1.37 +              <treecell label="?name"/>
    1.38 +              <treecell label="?gender"/>
    1.39 +            </treerow>
    1.40 +          </treeitem>
    1.41 +        </treechildren>
    1.42 +      </action>
    1.43 +    </rule>
    1.44 +  </template>
    1.45 +</tree>
    1.46 +
    1.47 +<body xmlns="http://www.w3.org/1999/xhtml">
    1.48 +<p id="display"></p>
    1.49 +<div id="content" style="display: none">
    1.50 +</div>
    1.51 +<pre id="test">
    1.52 +</pre>
    1.53 +</body>
    1.54 +
    1.55 +<script>
    1.56 +<![CDATA[
    1.57 +
    1.58 +SimpleTest.waitForExplicitFinish();
    1.59 +
    1.60 +function runTest()
    1.61 +{
    1.62 +  var tree = $("tree");
    1.63 +  var col = tree.columns[0].element;
    1.64 +  synthesizeMouse(col, 12, 2, { });
    1.65 +  checkRowOrder(tree, ["Cleopatra", "Ferdinand Magellan", "Julius Caesar", "Laura Secord", "Napoleon Bonaparte"], "acsending");
    1.66 +
    1.67 +  synthesizeMouse(col, 12, 2, { });
    1.68 +  checkRowOrder(tree, ["Napoleon Bonaparte", "Laura Secord", "Julius Caesar", "Ferdinand Magellan", "Cleopatra"], "descending");
    1.69 +
    1.70 +  synthesizeMouse(col, 12, 2, { });
    1.71 +  checkRowOrder(tree, ["Napoleon Bonaparte", "Laura Secord", "Julius Caesar", "Ferdinand Magellan", "Cleopatra"], "natural");
    1.72 +
    1.73 +  SimpleTest.finish();
    1.74 +}
    1.75 +
    1.76 +function checkRowOrder(tree, expected, testid)
    1.77 +{
    1.78 +  var index = 0;
    1.79 +  var item = tree.firstChild.nextSibling.nextSibling.firstChild;
    1.80 +  while (item && index < expected.length) {
    1.81 +    if (item.firstChild.firstChild.getAttribute("label") != expected[index++])
    1.82 +      break;
    1.83 +    item = item.nextSibling;
    1.84 +  }
    1.85 +  ok(index == expected.length && !item, testid + " row order");
    1.86 +}
    1.87 +
    1.88 +]]>
    1.89 +
    1.90 +</script>
    1.91 +
    1.92 +</window>

mercurial