1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/selectable/test_tree.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,189 @@ 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" 1.7 + type="text/css"?> 1.8 +<?xml-stylesheet href="../treeview.css" 1.9 + type="text/css"?> 1.10 + 1.11 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.12 + title="XUL tree selectable tests"> 1.13 + 1.14 + <script type="application/javascript" 1.15 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> 1.16 + 1.17 + <script type="application/javascript" 1.18 + src="../treeview.js" /> 1.19 + 1.20 + <script type="application/javascript" 1.21 + src="../common.js" /> 1.22 + <script type="application/javascript" 1.23 + src="../events.js" /> 1.24 + <script type="application/javascript" 1.25 + src="../role.js" /> 1.26 + <script type="application/javascript" 1.27 + src="../states.js" /> 1.28 + <script type="application/javascript" 1.29 + src="../selectable.js" /> 1.30 + 1.31 + <script type="application/javascript"> 1.32 + <![CDATA[ 1.33 + //////////////////////////////////////////////////////////////////////////// 1.34 + // Test 1.35 + 1.36 + // gA11yEventDumpID = "debug"; 1.37 + 1.38 + /** 1.39 + * Event queue invoker object to test accessible states for XUL tree 1.40 + * accessible. 1.41 + */ 1.42 + function statesChecker(aTreeID, aView) 1.43 + { 1.44 + this.DOMNode = getNode(aTreeID); 1.45 + 1.46 + this.invoke = function invoke() 1.47 + { 1.48 + this.DOMNode.treeBoxObject.view = aView; 1.49 + } 1.50 + this.check = function check() 1.51 + { 1.52 + var tree = getAccessible(this.DOMNode); 1.53 + 1.54 + var isTreeMultiSelectable = false; 1.55 + var seltype = this.DOMNode.getAttribute("seltype"); 1.56 + if (seltype != "single" && seltype != "cell" && seltype != "text") 1.57 + isTreeMultiSelectable = true; 1.58 + 1.59 + // selectAll 1.60 + var accSelectable = getAccessible(this.DOMNode, 1.61 + [nsIAccessibleSelectable]); 1.62 + ok(accSelectable, "tree is not selectable!"); 1.63 + if (accSelectable) { 1.64 + is(accSelectable.selectAll(), isTreeMultiSelectable, 1.65 + "SelectAll is not correct for seltype: " + seltype); 1.66 + } 1.67 + 1.68 + var selectedChildren = []; 1.69 + if (isTreeMultiSelectable) { 1.70 + var rows = tree.children; 1.71 + for (var i = 0; i < rows.length; i++) { 1.72 + var row = rows.queryElementAt(i, nsIAccessible); 1.73 + if (getRole(row) == ROLE_OUTLINEITEM || getRole(row) == ROLE_ROW) 1.74 + selectedChildren.push(row); 1.75 + } 1.76 + } 1.77 + testSelectableSelection(accSelectable, selectedChildren, 1.78 + "selectAll test. "); 1.79 + 1.80 + // unselectAll 1.81 + accSelectable.unselectAll(); 1.82 + testSelectableSelection(accSelectable, [], "unselectAll test. "); 1.83 + 1.84 + // addItemToSelection 1.85 + accSelectable.addItemToSelection(1); 1.86 + accSelectable.addItemToSelection(3); 1.87 + 1.88 + selectedChildren = isTreeMultiSelectable ? 1.89 + [ accSelectable.getChildAt(2), accSelectable.getChildAt(4) ] : 1.90 + [ accSelectable.getChildAt(2) ]; 1.91 + testSelectableSelection(accSelectable, selectedChildren, 1.92 + "addItemToSelection test. "); 1.93 + 1.94 + // removeItemFromSelection 1.95 + accSelectable.removeItemFromSelection(1); 1.96 + 1.97 + selectedChildren = isTreeMultiSelectable ? 1.98 + [ accSelectable.getChildAt(4) ] : [ ]; 1.99 + testSelectableSelection(accSelectable, selectedChildren, 1.100 + "removeItemFromSelection test. "); 1.101 + } 1.102 + 1.103 + this.getID = function getID() 1.104 + { 1.105 + "tree processor for " + prettyName(aTreeID); 1.106 + } 1.107 + } 1.108 + 1.109 + var gQueue = null; 1.110 + 1.111 + function doTest() 1.112 + { 1.113 + gQueue = new eventQueue(EVENT_REORDER); 1.114 + gQueue.push(new statesChecker("tree", new nsTreeTreeView())); 1.115 + gQueue.push(new statesChecker("treesingle", new nsTreeTreeView())); 1.116 + gQueue.push(new statesChecker("treecell", new nsTreeTreeView())); 1.117 + gQueue.push(new statesChecker("treetext", new nsTreeTreeView())); 1.118 + gQueue.push(new statesChecker("tabletree", new nsTreeTreeView())); 1.119 + 1.120 + gQueue.invoke(); // Will call SimpleTest.finish(); 1.121 + } 1.122 + 1.123 + SimpleTest.waitForExplicitFinish(); 1.124 + addA11yLoadEvent(doTest); 1.125 + ]]> 1.126 + </script> 1.127 + 1.128 + <hbox flex="1" style="overflow: auto;"> 1.129 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.130 + <a target="_blank" 1.131 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=523118" 1.132 + title="we mistake 'cell' and text' xul tree seltypes for multiselects"> 1.133 + Mozilla Bug 523118 1.134 + </a> 1.135 + <a target="_blank" 1.136 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=624977" 1.137 + title="Optimize nsXulTreeAccessible selectedItems()"> 1.138 + Mozilla Bug 624977 1.139 + </a><br/> 1.140 + <p id="display"></p> 1.141 + <div id="content" style="display: none"> 1.142 + </div> 1.143 + <pre id="test"> 1.144 + </pre> 1.145 + </body> 1.146 + 1.147 + <vbox flex="1"> 1.148 + <tree id="tree" flex="1"> 1.149 + <treecols> 1.150 + <treecol id="col" flex="1" primary="true" label="column"/> 1.151 + </treecols> 1.152 + <treechildren/> 1.153 + </tree> 1.154 + 1.155 + <tree id="treesingle" flex="1" seltype="single"> 1.156 + <treecols> 1.157 + <treecol id="col_single" flex="1" primary="true" label="column"/> 1.158 + </treecols> 1.159 + <treechildren/> 1.160 + </tree> 1.161 + 1.162 + <tree id="treecell" flex="1" seltype="cell"> 1.163 + <treecols> 1.164 + <treecol id="col_cell" flex="1" primary="true" label="column"/> 1.165 + </treecols> 1.166 + <treechildren/> 1.167 + </tree> 1.168 + 1.169 + <tree id="treetext" flex="1" seltype="text"> 1.170 + <treecols> 1.171 + <treecol id="col_text" flex="1" primary="true" label="column"/> 1.172 + </treecols> 1.173 + <treechildren/> 1.174 + </tree> 1.175 + 1.176 + <tree id="tabletree" flex="1" editable="true"> 1.177 + <treecols> 1.178 + <treecol id="tabletree_col1" cycler="true" label="cycler"/> 1.179 + <treecol id="tabletree_col2" flex="1" primary="true" label="column1"/> 1.180 + <treecol id="tabletree_col3" flex="1" label="column2"/> 1.181 + <treecol id="tabletree_col4" flex="1" label="checker" 1.182 + type="checkbox" editable="true"/> 1.183 + </treecols> 1.184 + <treechildren/> 1.185 + </tree> 1.186 + 1.187 + <vbox id="debug"/> 1.188 + </vbox> 1.189 + </hbox> 1.190 + 1.191 +</window> 1.192 +