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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/walkers/walker_unittest_base.js

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: Created 3 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 GEN_INCLUDE(['../testing/chromevox_unittest_base.js']); 5 GEN_INCLUDE(['../testing/chromevox_unittest_base.js']);
6 6
7 /** 7 /**
8 * Base class for walker test fixtures. 8 * Base class for walker test fixtures.
9 * @constructor 9 * @constructor
10 * @extends {ChromeVoxUnitTestBase} 10 * @extends {ChromeVoxUnitTestBase}
11 */ 11 */
12 function CvoxWalkerUnitTestBase() {} 12 function CvoxWalkerUnitTestBase() {}
13 13
14 CvoxWalkerUnitTestBase.prototype = { 14 CvoxWalkerUnitTestBase.prototype = {
15 __proto__: ChromeVoxUnitTestBase.prototype, 15 __proto__: ChromeVoxUnitTestBase.prototype,
16 16
17 /** @override */ 17 /** @override */
18 closureModuleDeps: [ 18 closureModuleDeps: ['TestMsgs', 'cvox.CursorSelection'],
19 'TestMsgs',
20 'cvox.CursorSelection'
21 ],
22 19
23 /** 20 /**
24 * Common set up for all walker test cases. 21 * Common set up for all walker test cases.
25 */ 22 */
26 setUp: function() { 23 setUp: function() {
27 // Needed for getDescription and getGranularityMsg. 24 // Needed for getDescription and getGranularityMsg.
28 Msgs = TestMsgs; 25 Msgs = TestMsgs;
29 26
30 // Delete all nodes in the body. 27 // Delete all nodes in the body.
31 while (document.body.hasChildNodes()) { 28 while (document.body.hasChildNodes()) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 * @type {Array.string} 152 * @type {Array.string}
156 * @const 153 * @const
157 */ 154 */
158 CvoxWalkerUnitTestBase.CMD_WHITELIST = ['next', 'sync', 'nextRow', 'nextCol']; 155 CvoxWalkerUnitTestBase.CMD_WHITELIST = ['next', 'sync', 'nextRow', 'nextCol'];
159 156
160 /** 157 /**
161 * Whitelist for the properties that can be asserted with go(). 158 * Whitelist for the properties that can be asserted with go().
162 * @type {Array.string} 159 * @type {Array.string}
163 * @const 160 * @const
164 */ 161 */
165 CvoxWalkerUnitTestBase.DESC_WHITELIST = ['selText', 'selNodeId', 162 CvoxWalkerUnitTestBase.DESC_WHITELIST = [
166 'selParentNodeId', 'selStartIndex', 'selEndIndex', 'selReversed', 'descText', 163 'selText', 'selNodeId', 'selParentNodeId', 'selStartIndex', 'selEndIndex',
167 'descContext', 'descAnnotation', 'descUserValue', 'descPersonality']; 164 'selReversed', 'descText', 'descContext', 'descAnnotation', 'descUserValue',
165 'descPersonality'
166 ];
168 167
169 /** 168 /**
170 * Adds common walker tests 169 * Adds common walker tests
171 * @param {string} testFixture Name of the test fixture class. 170 * @param {string} testFixture Name of the test fixture class.
172 */ 171 */
173 CvoxWalkerUnitTestBase.addCommonTests = function(testFixture) { 172 CvoxWalkerUnitTestBase.addCommonTests = function(testFixture) {
174 /** 173 /**
175 * Ensures that syncing to the beginning and ends of the page return 174 * Ensures that syncing to the beginning and ends of the page return
176 * not null. 175 * not null.
177 */ 176 */
178 TEST_F(testFixture, 'testSyncToPage', function() { 177 TEST_F(testFixture, 'testSyncToPage', function() {
179 this.loadDoc(function() {/*! 178 this.loadDoc(function() { /*!
180 <div><p id="a">a</p></div> 179 <div><p id="a">a</p></div>
181 */}); 180 */ });
182 var ret = this.walker.begin(); 181 var ret = this.walker.begin();
183 assertNotEquals(null, ret); 182 assertNotEquals(null, ret);
184 ret = this.walker.begin({reversed: true}); 183 ret = this.walker.begin({reversed: true});
185 assertNotEquals(null, ret); 184 assertNotEquals(null, ret);
186 }); 185 });
187 186
188 /** 187 /**
189 * Ensures that sync(sync(sel)) = sync(sel) 188 * Ensures that sync(sync(sel)) = sync(sel)
190 * TODO (stoarca): The interfaces are not frozen yet. In particular, 189 * TODO (stoarca): The interfaces are not frozen yet. In particular,
191 * for TableWalker, sync can return null. Override if it doesn't work yet. 190 * for TableWalker, sync can return null. Override if it doesn't work yet.
192 */ 191 */
193 TEST_F(testFixture, 'testSyncInvariant', function() { 192 TEST_F(testFixture, 'testSyncInvariant', function() {
194 this.loadDoc(function() {/*! 193 this.loadDoc(function() { /*!
195 <div id="outer"> 194 <div id="outer">
196 <p id="a">a</p> 195 <p id="a">a</p>
197 <p id="b">b</p> 196 <p id="b">b</p>
198 <p id="c">c</p> 197 <p id="c">c</p>
199 <p id="d">d</p> 198 <p id="d">d</p>
200 <h1 id="A">h1</h1> 199 <h1 id="A">h1</h1>
201 <p id="e">e</p> 200 <p id="e">e</p>
202 <h1 id="B">h1</h1> 201 <h1 id="B">h1</h1>
203 </div> 202 </div>
204 */}); 203 */ });
205 var sel = cvox.CursorSelection.fromNode( 204 var sel = cvox.CursorSelection.fromNode($('outer').firstChild);
206 $('outer').firstChild);
207 var sync = this.walker.sync(sel); 205 var sync = this.walker.sync(sel);
208 var syncsync = this.walker.sync(sync); 206 var syncsync = this.walker.sync(sync);
209 assertEquals(true, sync.equals(syncsync)); 207 assertEquals(true, sync.equals(syncsync));
210 208
211 sel = cvox.CursorSelection.fromNode($('a')); 209 sel = cvox.CursorSelection.fromNode($('a'));
212 sync = this.walker.sync(sel); 210 sync = this.walker.sync(sel);
213 syncsync = this.walker.sync(sync); 211 syncsync = this.walker.sync(sync);
214 assertEquals(true, sync.equals(syncsync)); 212 assertEquals(true, sync.equals(syncsync));
215 213
216 sel = cvox.CursorSelection.fromNode($('e')); 214 sel = cvox.CursorSelection.fromNode($('e'));
(...skipping 12 matching lines...) Expand all
229 */ 227 */
230 TEST_F(testFixture, 'testEmptyBody', function() { 228 TEST_F(testFixture, 'testEmptyBody', function() {
231 var sel = cvox.CursorSelection.fromBody(); 229 var sel = cvox.CursorSelection.fromBody();
232 230
233 // Testing for infinite loop. If one exists, this test will fail by timing 231 // Testing for infinite loop. If one exists, this test will fail by timing
234 // out. 232 // out.
235 var sync = this.walker.sync(sel); 233 var sync = this.walker.sync(sel);
236 var next = this.walker.next(sel); 234 var next = this.walker.next(sel);
237 }); 235 });
238 }; 236 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698