OLD | NEW |
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 // 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 /** | 8 /** |
9 * Test fixture for cvox2.cursors. | 9 * Test fixture for cvox2.cursors. |
10 * @constructor | 10 * @constructor |
(...skipping 13 matching lines...) Expand all Loading... |
24 RANGE: 'range', | 24 RANGE: 'range', |
25 | 25 |
26 /** @override */ | 26 /** @override */ |
27 setUp: function() { | 27 setUp: function() { |
28 // Various aliases. | 28 // Various aliases. |
29 window.BACKWARD = constants.Dir.BACKWARD; | 29 window.BACKWARD = constants.Dir.BACKWARD; |
30 window.FORWARD = constants.Dir.FORWARD; | 30 window.FORWARD = constants.Dir.FORWARD; |
31 window.CHARACTER = cursors.Unit.CHARACTER; | 31 window.CHARACTER = cursors.Unit.CHARACTER; |
32 window.WORD = cursors.Unit.WORD; | 32 window.WORD = cursors.Unit.WORD; |
33 window.LINE = cursors.Unit.LINE; | 33 window.LINE = cursors.Unit.LINE; |
34 window.DOM_NODE = cursors.Unit.DOM_NODE; | 34 window.NODE = cursors.Unit.NODE; |
35 window.BOUND = cursors.Movement.BOUND; | 35 window.BOUND = cursors.Movement.BOUND; |
36 window.DIRECTIONAL = cursors.Movement.DIRECTIONAL; | 36 window.DIRECTIONAL = cursors.Movement.DIRECTIONAL; |
37 }, | 37 }, |
38 | 38 |
39 /** | 39 /** |
40 * Performs a series of operations on a cursor and asserts the result. | 40 * Performs a series of operations on a cursor and asserts the result. |
41 * @param {cursors.Cursor} cursor The starting cursor. | 41 * @param {cursors.Cursor} cursor The starting cursor. |
42 * @param {!Array<Array< | 42 * @param {!Array<Array< |
43 * cursors.Unit| | 43 * cursors.Unit| |
44 * cursors.Movement| | 44 * cursors.Movement| |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 [LINE, BACKWARD, | 274 [LINE, BACKWARD, |
275 {value: 'start ', index: 0}, {value: 'same line', index: 9}] | 275 {value: 'start ', index: 0}, {value: 'same line', index: 9}] |
276 ], this.RANGE); | 276 ], this.RANGE); |
277 }); | 277 }); |
278 | 278 |
279 TEST_F('CursorsTest', 'DontSplitOnNodeNavigation', function() { | 279 TEST_F('CursorsTest', 'DontSplitOnNodeNavigation', function() { |
280 this.runWithLoadedTree(this.multiInlineDoc, function(root) { | 280 this.runWithLoadedTree(this.multiInlineDoc, function(root) { |
281 var para = root.firstChild; | 281 var para = root.firstChild; |
282 assertEquals('paragraph', para.role); | 282 assertEquals('paragraph', para.role); |
283 var cursor = new cursors.Cursor(para.firstChild, 0); | 283 var cursor = new cursors.Cursor(para.firstChild, 0); |
284 cursor = cursor.move(DOM_NODE, DIRECTIONAL, FORWARD); | 284 cursor = cursor.move(NODE, DIRECTIONAL, FORWARD); |
285 assertEquals('staticText', cursor.node.role); | 285 assertEquals('staticText', cursor.node.role); |
286 assertEquals('end', cursor.node.name); | 286 assertEquals('end', cursor.node.name); |
287 | 287 |
288 cursor = cursor.move(DOM_NODE, DIRECTIONAL, BACKWARD); | 288 cursor = cursor.move(NODE, DIRECTIONAL, BACKWARD); |
289 assertEquals('staticText', cursor.node.role); | 289 assertEquals('staticText', cursor.node.role); |
290 assertEquals('start diff line', cursor.node.name); | 290 assertEquals('start diff line', cursor.node.name); |
291 | 291 |
292 assertEquals('inlineTextBox', cursor.node.firstChild.role); | 292 assertEquals('inlineTextBox', cursor.node.firstChild.role); |
293 assertEquals('start ', cursor.node.firstChild.name); | 293 assertEquals('start ', cursor.node.firstChild.name); |
294 assertEquals('diff ', cursor.node.firstChild.nextSibling.name); | 294 assertEquals('diff ', cursor.node.firstChild.nextSibling.name); |
295 assertEquals('line', cursor.node.lastChild.name); | 295 assertEquals('line', cursor.node.lastChild.name); |
296 }); | 296 }); |
297 }); | 297 }); |
298 | 298 |
299 TEST_F('CursorsTest', 'WrappingCursors', function() { | 299 TEST_F('CursorsTest', 'WrappingCursors', function() { |
300 this.runWithLoadedTree(this.multiInlineDoc, function(root) { | 300 this.runWithLoadedTree(this.multiInlineDoc, function(root) { |
301 var first = root; | 301 var first = root; |
302 var last = root.lastChild.firstChild; | 302 var last = root.lastChild.firstChild; |
303 var cursor = new cursors.WrappingCursor(first, -1); | 303 var cursor = new cursors.WrappingCursor(first, -1); |
304 | 304 |
305 // Wrap from first node to last node. | 305 // Wrap from first node to last node. |
306 cursor = cursor.move(DOM_NODE, DIRECTIONAL, BACKWARD); | 306 cursor = cursor.move(NODE, DIRECTIONAL, BACKWARD); |
307 assertEquals(last, cursor.node); | 307 assertEquals(last, cursor.node); |
308 | 308 |
309 // Wrap from last node to first node. | 309 // Wrap from last node to first node. |
310 cursor = cursor.move(DOM_NODE, DIRECTIONAL, FORWARD); | 310 cursor = cursor.move(NODE, DIRECTIONAL, FORWARD); |
311 assertEquals(first, cursor.node); | 311 assertEquals(first, cursor.node); |
312 }); | 312 }); |
313 }); | 313 }); |
314 | 314 |
315 TEST_F('CursorsTest', 'IsInWebRange', function() { | 315 TEST_F('CursorsTest', 'IsInWebRange', function() { |
316 this.runWithLoadedTree(this.simpleDoc, function(root) { | 316 this.runWithLoadedTree(this.simpleDoc, function(root) { |
317 var para = root.firstChild; | 317 var para = root.firstChild; |
318 var webRange = new cursors.Range.fromNode(para); | 318 var webRange = new cursors.Range.fromNode(para); |
319 var auraRange = cursors.Range.fromNode(root.parent); | 319 var auraRange = cursors.Range.fromNode(root.parent); |
320 assertFalse(auraRange.isWebRange()); | 320 assertFalse(auraRange.isWebRange()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 // Now, try selecting via node offsets. | 382 // Now, try selecting via node offsets. |
383 var cursor = new cursors.Cursor(root.firstChild, -1); | 383 var cursor = new cursors.Cursor(root.firstChild, -1); |
384 assertEquals(root, cursor.selectionNode_); | 384 assertEquals(root, cursor.selectionNode_); |
385 assertEquals(0, cursor.selectionIndex_); | 385 assertEquals(0, cursor.selectionIndex_); |
386 | 386 |
387 cursor = new cursors.Cursor(root.firstChild.nextSibling, -1); | 387 cursor = new cursors.Cursor(root.firstChild.nextSibling, -1); |
388 assertEquals(root, cursor.selectionNode_); | 388 assertEquals(root, cursor.selectionNode_); |
389 assertEquals(1, cursor.selectionIndex_); | 389 assertEquals(1, cursor.selectionIndex_); |
390 }); | 390 }); |
391 }); | 391 }); |
OLD | NEW |