| 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 var para = root.firstChild; | 318 var para = root.firstChild; |
| 319 var webRange = new cursors.Range.fromNode(para); | 319 var webRange = new cursors.Range.fromNode(para); |
| 320 var auraRange = cursors.Range.fromNode(root.parent); | 320 var auraRange = cursors.Range.fromNode(root.parent); |
| 321 assertFalse(auraRange.isWebRange()); | 321 assertFalse(auraRange.isWebRange()); |
| 322 assertTrue(webRange.isWebRange()); | 322 assertTrue(webRange.isWebRange()); |
| 323 }); | 323 }); |
| 324 }); | 324 }); |
| 325 | 325 |
| 326 TEST_F('CursorsTest', 'DISABLED_SingleDocSelection', function() { | 326 TEST_F('CursorsTest', 'DISABLED_SingleDocSelection', function() { |
| 327 this.runWithLoadedTree(function() {/*! | 327 this.runWithLoadedTree(function() {/*! |
| 328 <span>start</span> |
| 328 <p><a href="google.com">google home page</a></p> | 329 <p><a href="google.com">google home page</a></p> |
| 329 <p>some more text</p> | 330 <p>some more text</p> |
| 330 <p>end of text</p> | 331 <p>end of text</p> |
| 331 */}, | 332 */}, |
| 332 function(root) { | 333 function(root) { |
| 333 var link = root.firstChild.firstChild; | 334 var link = root.find({role: RoleType.link}); |
| 334 var p1 = root.firstChild.nextSibling; | 335 var p1 = root.find({role: RoleType.paragraph}); |
| 335 var p2 = p1.nextSibling; | 336 var p2 = p1.nextSibling; |
| 336 | 337 |
| 337 var singleSel = new cursors.Range( | 338 var singleSel = new cursors.Range( |
| 338 new cursors.Cursor(link, 0), | 339 new cursors.Cursor(link, 0), |
| 339 new cursors.Cursor(link, 1)); | 340 new cursors.Cursor(link, 1)); |
| 340 | 341 |
| 341 var multiSel = new cursors.Range( | 342 var multiSel = new cursors.Range( |
| 342 new cursors.Cursor(p1.firstChild, 2), | 343 new cursors.Cursor(p1.firstChild, 2), |
| 343 new cursors.Cursor(p2.firstChild, 4)); | 344 new cursors.Cursor(p2.firstChild, 4)); |
| 344 | 345 |
| 345 function verifySel() { | 346 function verifySel() { |
| 346 if (root.anchorObject == link.firstChild) { | 347 if (root.anchorObject == link.firstChild) { |
| 347 assertEquals(link.firstChild, root.anchorObject); | 348 assertEquals(link.firstChild, root.anchorObject); |
| 348 assertEquals(0, root.anchorOffset); | 349 assertEquals(0, root.anchorOffset); |
| 349 assertEquals(link.firstChild, root.focusObject); | 350 assertEquals(link.firstChild, root.focusObject); |
| 350 assertEquals(1, root.focusOffset); | 351 assertEquals(1, root.focusOffset); |
| 351 this.listenOnce(root, 'textSelectionChanged', verifySel); | 352 this.listenOnce(root, 'textSelectionChanged', verifySel); |
| 352 multiSel.select(); | 353 multiSel.select(); |
| 353 } else { | 354 } else if (root.anchorObject == p1.firstChild) { |
| 354 assertEquals(p1.firstChild, root.anchorObject); | 355 assertEquals(p1.firstChild, root.anchorObject); |
| 355 assertEquals(2, root.anchorOffset); | 356 assertEquals(2, root.anchorOffset); |
| 356 assertEquals(p2.firstChild, root.focusObject); | 357 assertEquals(p2.firstChild, root.focusObject); |
| 357 assertEquals(4, root.focusOffset); | 358 assertEquals(4, root.focusOffset); |
| 358 } | 359 } |
| 359 } | 360 } |
| 360 | 361 |
| 361 this.listenOnce(root, 'textSelectionChanged', verifySel, true); | 362 this.listenOnce(root, 'textSelectionChanged', verifySel, true); |
| 362 singleSel.select(); | 363 singleSel.select(); |
| 363 }); | 364 }); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 387 assertEquals(0, cursor.selectionIndex_); | 388 assertEquals(0, cursor.selectionIndex_); |
| 388 | 389 |
| 389 cursor = new cursors.Cursor(root.firstChild.nextSibling, -1); | 390 cursor = new cursors.Cursor(root.firstChild.nextSibling, -1); |
| 390 assertEquals(root, cursor.selectionNode_); | 391 assertEquals(root, cursor.selectionNode_); |
| 391 assertEquals(1, cursor.selectionIndex_); | 392 assertEquals(1, cursor.selectionIndex_); |
| 392 }); | 393 }); |
| 393 }); | 394 }); |
| 394 | 395 |
| 395 TEST_F('CursorsTest', 'InlineElementOffset', function() { | 396 TEST_F('CursorsTest', 'InlineElementOffset', function() { |
| 396 this.runWithLoadedTree(function() {/*! | 397 this.runWithLoadedTree(function() {/*! |
| 398 <span>start</span> |
| 397 <p>This<br> is a<a href="#g">test</a>of selection</p> | 399 <p>This<br> is a<a href="#g">test</a>of selection</p> |
| 398 */}, function(root) { | 400 */}, function(root) { |
| 399 root.addEventListener('textSelectionChanged', this.newCallback(function(evt)
{ | 401 root.addEventListener('textSelectionChanged', this.newCallback(function(evt)
{ |
| 402 // Test setup moves initial focus; ensure we don't test that here. |
| 403 if (testNode != root.anchorObject) |
| 404 return; |
| 405 |
| 400 // This is a little unexpected though not really incorrect; Ctrl+C works. | 406 // This is a little unexpected though not really incorrect; Ctrl+C works. |
| 401 assertEquals(testNode, root.anchorObject); | 407 assertEquals(testNode, root.anchorObject); |
| 402 assertEquals(ofSelectionNode, root.focusObject); | 408 assertEquals(ofSelectionNode, root.focusObject); |
| 403 assertEquals(4, root.anchorOffset); | 409 assertEquals(4, root.anchorOffset); |
| 404 assertEquals(1, root.focusOffset); | 410 assertEquals(1, root.focusOffset); |
| 405 })); | 411 })); |
| 406 | 412 |
| 407 // This is the link's static text. | 413 // This is the link's static text. |
| 408 var testNode = root.lastChild.lastChild.previousSibling.firstChild; | 414 var testNode = root.lastChild.lastChild.previousSibling.firstChild; |
| 409 assertEquals(RoleType.staticText, testNode.role); | 415 assertEquals(RoleType.staticText, testNode.role); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 | 455 |
| 450 // Negative cases. | 456 // Negative cases. |
| 451 assertFalse(rootRange.contentEquals(regionRange)); | 457 assertFalse(rootRange.contentEquals(regionRange)); |
| 452 assertFalse(rootRange.contentEquals(staticTextRange)); | 458 assertFalse(rootRange.contentEquals(staticTextRange)); |
| 453 assertFalse(rootRange.contentEquals(inlineTextBoxRange)); | 459 assertFalse(rootRange.contentEquals(inlineTextBoxRange)); |
| 454 assertFalse(regionRange.contentEquals(rootRange)); | 460 assertFalse(regionRange.contentEquals(rootRange)); |
| 455 assertFalse(staticTextRange.contentEquals(rootRange)); | 461 assertFalse(staticTextRange.contentEquals(rootRange)); |
| 456 assertFalse(inlineTextBoxRange.contentEquals(rootRange)); | 462 assertFalse(inlineTextBoxRange.contentEquals(rootRange)); |
| 457 }); | 463 }); |
| 458 }); | 464 }); |
| OLD | NEW |