| 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 16 matching lines...) Expand all Loading... |
| 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.DOM_NODE = cursors.Unit.DOM_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 window.RoleType = chrome.automation.RoleType; |
| 37 }, | 38 }, |
| 38 | 39 |
| 39 /** | 40 /** |
| 40 * Performs a series of operations on a cursor and asserts the result. | 41 * Performs a series of operations on a cursor and asserts the result. |
| 41 * @param {cursors.Cursor} cursor The starting cursor. | 42 * @param {cursors.Cursor} cursor The starting cursor. |
| 42 * @param {!Array<Array< | 43 * @param {!Array<Array< |
| 43 * cursors.Unit| | 44 * cursors.Unit| |
| 44 * cursors.Movement| | 45 * cursors.Movement| |
| 45 * constants.Dir| | 46 * constants.Dir| |
| 46 * Object>>} | 47 * Object>>} |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 // Now, try selecting via node offsets. | 383 // Now, try selecting via node offsets. |
| 383 var cursor = new cursors.Cursor(root.firstChild, -1); | 384 var cursor = new cursors.Cursor(root.firstChild, -1); |
| 384 assertEquals(root, cursor.selectionNode_); | 385 assertEquals(root, cursor.selectionNode_); |
| 385 assertEquals(0, cursor.selectionIndex_); | 386 assertEquals(0, cursor.selectionIndex_); |
| 386 | 387 |
| 387 cursor = new cursors.Cursor(root.firstChild.nextSibling, -1); | 388 cursor = new cursors.Cursor(root.firstChild.nextSibling, -1); |
| 388 assertEquals(root, cursor.selectionNode_); | 389 assertEquals(root, cursor.selectionNode_); |
| 389 assertEquals(1, cursor.selectionIndex_); | 390 assertEquals(1, cursor.selectionIndex_); |
| 390 }); | 391 }); |
| 391 }); | 392 }); |
| 393 |
| 394 TEST_F('CursorsTest', 'InlineElementOffset', function() { |
| 395 this.runWithLoadedTree(function() {/*! |
| 396 <p>This<br> is a<a href="#g">test</a>of selection</p> |
| 397 */}, function(root) { |
| 398 root.addEventListener('textSelectionChanged', this.newCallback(function(evt)
{ |
| 399 // This is a little unexpected though not really incorrect; Ctrl+C works. |
| 400 assertEquals(testNode, root.anchorObject); |
| 401 assertEquals(ofSelectionNode, root.focusObject); |
| 402 assertEquals(4, root.anchorOffset); |
| 403 assertEquals(1, root.focusOffset); |
| 404 })); |
| 405 |
| 406 // This is the link's static text. |
| 407 var testNode = root.lastChild.lastChild.previousSibling.firstChild; |
| 408 assertEquals(RoleType.staticText, testNode.role); |
| 409 assertEquals('test', testNode.name); |
| 410 |
| 411 var ofSelectionNode = root.lastChild.lastChild; |
| 412 var cur = new cursors.Cursor(ofSelectionNode, 0); |
| 413 assertEquals('of selection', cur.selectionNode_.name); |
| 414 assertEquals(RoleType.staticText, cur.selectionNode_.role); |
| 415 assertEquals(13, cur.selectionIndex_); |
| 416 |
| 417 var curIntoO = new cursors.Cursor(ofSelectionNode, 1); |
| 418 assertEquals('of selection', curIntoO.selectionNode_.name); |
| 419 assertEquals(RoleType.staticText, curIntoO.selectionNode_.role); |
| 420 assertEquals(14, curIntoO.selectionIndex_); |
| 421 |
| 422 var oRange = new cursors.Range(cur, curIntoO); |
| 423 oRange.select(); |
| 424 }); |
| 425 }); |
| OLD | NEW |