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

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

Issue 2385343002: Make ChromeVox use child-index based offsets again for selection. (Closed)
Patch Set: Fix test Created 4 years, 2 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/cursors.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 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 340
341 var multiSel = new cursors.Range( 341 var multiSel = new cursors.Range(
342 new cursors.Cursor(p1.firstChild, 2), 342 new cursors.Cursor(p1.firstChild, 2),
343 new cursors.Cursor(p2.firstChild, 4)); 343 new cursors.Cursor(p2.firstChild, 4));
344 344
345 function verifySel() { 345 function verifySel() {
346 if (root.anchorObject == link.firstChild) { 346 if (root.anchorObject == link.firstChild) {
347 assertEquals(link.firstChild, root.anchorObject); 347 assertEquals(link.firstChild, root.anchorObject);
348 assertEquals(0, root.anchorOffset); 348 assertEquals(0, root.anchorOffset);
349 assertEquals(link.firstChild, root.focusObject); 349 assertEquals(link.firstChild, root.focusObject);
350 assertEquals(16, root.focusOffset); 350 assertEquals(1, root.focusOffset);
351 this.listenOnce(root, 'textSelectionChanged', verifySel); 351 this.listenOnce(root, 'textSelectionChanged', verifySel);
352 multiSel.select(); 352 multiSel.select();
353 } else { 353 } else {
354 assertEquals(p1.firstChild, root.anchorObject); 354 assertEquals(p1.firstChild, root.anchorObject);
355 assertEquals(2, root.anchorOffset); 355 assertEquals(2, root.anchorOffset);
356 assertEquals(p2.firstChild, root.focusObject); 356 assertEquals(p2.firstChild, root.focusObject);
357 assertEquals(4, root.focusOffset); 357 assertEquals(4, root.focusOffset);
358 } 358 }
359 } 359 }
360 360
(...skipping 13 matching lines...) Expand all
374 assertEquals(secondLineCursor.node.parent, 374 assertEquals(secondLineCursor.node.parent,
375 secondLineCursor.selectionNode_); 375 secondLineCursor.selectionNode_);
376 376
377 // This selects the entire node via a character offset. 377 // This selects the entire node via a character offset.
378 assertEquals(6, secondLineCursor.selectionIndex_); 378 assertEquals(6, secondLineCursor.selectionIndex_);
379 379
380 // Index into the characters. 380 // Index into the characters.
381 secondLineCursor = new cursors.Cursor(secondLine, 1); 381 secondLineCursor = new cursors.Cursor(secondLine, 1);
382 assertEquals(7, secondLineCursor.selectionIndex_); 382 assertEquals(7, secondLineCursor.selectionIndex_);
383 383
384 // Now, try selecting via node offsets. This defaults to index 0 and not 384 // Now, try selecting via node offsets.
385 // index in parent because Blink accessibility selection doesn't always
386 // work.
387 var cursor = new cursors.Cursor(root.firstChild, -1); 385 var cursor = new cursors.Cursor(root.firstChild, -1);
388 assertEquals(root.firstChild, cursor.selectionNode_); 386 assertEquals(root, cursor.selectionNode_);
389 assertEquals(0, cursor.selectionIndex_); 387 assertEquals(0, cursor.selectionIndex_);
390 388
391 cursor = new cursors.Cursor(root.firstChild.nextSibling, -1); 389 cursor = new cursors.Cursor(root.firstChild.nextSibling, -1);
392 assertEquals(root.firstChild.nextSibling, cursor.selectionNode_); 390 assertEquals(root, cursor.selectionNode_);
393 assertEquals(0, cursor.selectionIndex_); 391 assertEquals(1, cursor.selectionIndex_);
394 }); 392 });
395 }); 393 });
396 394
397 TEST_F('CursorsTest', 'InlineElementOffset', function() { 395 TEST_F('CursorsTest', 'InlineElementOffset', function() {
398 this.runWithLoadedTree(function() {/*! 396 this.runWithLoadedTree(function() {/*!
399 <p>This<br> is a<a href="#g">test</a>of selection</p> 397 <p>This<br> is a<a href="#g">test</a>of selection</p>
400 */}, function(root) { 398 */}, function(root) {
401 root.addEventListener('textSelectionChanged', this.newCallback(function(evt) { 399 root.addEventListener('textSelectionChanged', this.newCallback(function(evt) {
402 // This is a little unexpected though not really incorrect; Ctrl+C works. 400 // This is a little unexpected though not really incorrect; Ctrl+C works.
403 assertEquals(testNode, root.anchorObject); 401 assertEquals(testNode, root.anchorObject);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 449
452 // Negative cases. 450 // Negative cases.
453 assertFalse(rootRange.contentEquals(regionRange)); 451 assertFalse(rootRange.contentEquals(regionRange));
454 assertFalse(rootRange.contentEquals(staticTextRange)); 452 assertFalse(rootRange.contentEquals(staticTextRange));
455 assertFalse(rootRange.contentEquals(inlineTextBoxRange)); 453 assertFalse(rootRange.contentEquals(inlineTextBoxRange));
456 assertFalse(regionRange.contentEquals(rootRange)); 454 assertFalse(regionRange.contentEquals(rootRange));
457 assertFalse(staticTextRange.contentEquals(rootRange)); 455 assertFalse(staticTextRange.contentEquals(rootRange));
458 assertFalse(inlineTextBoxRange.contentEquals(rootRange)); 456 assertFalse(inlineTextBoxRange.contentEquals(rootRange));
459 }); 457 });
460 }); 458 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698