Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/tree_walker_test.extjs

Issue 1948213002: Add a |skipInitialAncestry| option to tree walking. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/cvox2/background/tree_walker.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Include test fixture. 5 // Include test fixture.
6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js']); 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js']);
7 7
8 GEN_INCLUDE(['../../testing/snippets.js']); 8 GEN_INCLUDE(['../../testing/snippets.js']);
9 9
10 /** 10 /**
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 // And the reverse. 130 // And the reverse.
131 // Note that walking into a root is allowed. 131 // Note that walking into a root is allowed.
132 visited = ''; 132 visited = '';
133 var node6 = r.lastChild.lastChild; 133 var node6 = r.lastChild.lastChild;
134 assertEquals('6', node6.name); 134 assertEquals('6', node6.name);
135 walker = new AutomationTreeWalker(node6, 'backward', restrictions); 135 walker = new AutomationTreeWalker(node6, 'backward', restrictions);
136 while (walker.next().node) {} 136 while (walker.next().node) {}
137 assertEquals('532', visited); 137 assertEquals('532', visited);
138 138
139 // Test not visiting ancestors of initial node.
140 var node5 = r.firstChild.firstChild.lastChild;
141 assertEquals('5', node5.name);
142 restrictions.root = function(n) { return n.name == '1'; };
143 restrictions.leaf = function(n) { return !n.firstChild; };
144
145 visited = '';
146 restrictions.skipInitialAncestry = false;
147 walker = new AutomationTreeWalker(node5, 'backward', restrictions);
148 while (walker.next().node) {}
149 assertEquals('4321', visited);
150
151 // 2 and 1 are ancestors; check they get skipped.
152 visited = '';
153 restrictions.skipInitialAncestry = true;
154 walker = new AutomationTreeWalker(node5, 'backward', restrictions);
155 while (walker.next().node) {}
156 assertEquals('43', visited);
157
139 // We should skip node 2's subtree. 158 // We should skip node 2's subtree.
140 walker = new AutomationTreeWalker( 159 walker = new AutomationTreeWalker(
141 node2, 'forward', {skipInitialSubtree: true}); 160 node2, 'forward', {skipInitialSubtree: true});
142 assertEquals(node6, walker.next().node); 161 assertEquals(node6, walker.next().node);
143 }); 162 });
144 }); 163 });
145 164
146 TEST_F('AutomationTreeWalkerTest', 'LeafPredicateSymmetry', function() { 165 TEST_F('AutomationTreeWalkerTest', 'LeafPredicateSymmetry', function() {
147 this.runWithLoadedTree(toolbarDoc, function(r) { 166 this.runWithLoadedTree(toolbarDoc, function(r) {
148 var d = r.root.parent.root; 167 var d = r.root.parent.root;
(...skipping 22 matching lines...) Expand all
171 {root: function(node) { return node === r; }}); 190 {root: function(node) { return node === r; }});
172 assertEquals(r, backwardWalker.next().node); 191 assertEquals(r, backwardWalker.next().node);
173 assertEquals(null, backwardWalker.next().node); 192 assertEquals(null, backwardWalker.next().node);
174 193
175 var forwardWalker = 194 var forwardWalker =
176 new AutomationTreeWalker(r.firstChild.lastChild, 'forward', 195 new AutomationTreeWalker(r.firstChild.lastChild, 'forward',
177 {root: function(node) { return node === r; }}); 196 {root: function(node) { return node === r; }});
178 assertEquals(null, forwardWalker.next().node); 197 assertEquals(null, forwardWalker.next().node);
179 }); 198 });
180 }); 199 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/cvox2/background/tree_walker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698