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/cvox2/background/editing_test.extjs

Issue 2966273002: Provide complete, smart, spoken feedback for editable selection (Closed)
Patch Set: Rename. Created 3 years, 5 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/editing.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 '../../testing/assert_additions.js']); 7 '../../testing/assert_additions.js']);
8 8
9 GEN_INCLUDE(['../../testing/mock_feedback.js']); 9 GEN_INCLUDE(['../../testing/mock_feedback.js']);
10 10
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 // Unfortunately, the node offset being wrong here means there's no 533 // Unfortunately, the node offset being wrong here means there's no
534 // output for the next character move. Fix Once node offsets get fixed 534 // output for the next character move. Fix Once node offsets get fixed
535 // in Blink. 535 // in Blink.
536 536
537 .replay(); 537 .replay();
538 }); 538 });
539 input.focus(); 539 input.focus();
540 }); 540 });
541 }); 541 });
542 542
543 TEST_F('EditingTest', 'RichTextSelectByLine', function() {
544 var mockFeedback = this.createMockFeedback();
545 this.runWithLoadedTree(function() {/*!
546 <p id="go" contenteditable>
547 first line<br>
548 second line<br>
549 third line<br>
550 </p>
551 <script>
552 var commands = [
553 ['extend', 'forward', 'character'],
554 ['extend', 'forward', 'character'],
555
556 ['extend', 'forward', 'line'],
557 ['extend', 'forward', 'line'],
558
559 ['extend', 'backward', 'line'],
560 ['extend', 'backward', 'line'],
561
562 ['extend', 'forward', 'documentBoundary'],
563
564 ['move', 'forward', 'character'],
565 ['move', 'backward', 'character'],
566 ['move', 'backward', 'character'],
567
568 ['extend', 'backward', 'line'],
569 ['extend', 'backward', 'line'],
570
571 ['extend', 'forward', 'line'],
572 ];
573 document.getElementById('go').addEventListener('click', function() {
574 var sel = getSelection();
575 sel.modify.apply(sel, commands.shift());
576 }, true);
577 </script>
578 */}, function(root) {
579 var input = root.find({role: RoleType.PARAGRAPH});
580 var move = input.doDefault.bind(input);
581
582 this.listenOnce(input, 'focus', function() {
583
584 // By character.
585 mockFeedback.call(move)
586 .expectSpeech('f', 'selected')
587 .expectBraille('first line\n', {startIndex: 0, endIndex: 1})
588 .call(move)
589 .expectSpeech('i', 'added to selection')
590 .expectBraille('first line\n', {startIndex: 0, endIndex: 2})
591
592 // Forward selection.
593
594 // Growing.
595
596 // By line (notice the partial selections from the first and second
597 // lines).
598 .call(move)
599 .expectSpeech('rst line \n se', 'selected')
600 .expectBraille('second line\n', {startIndex: 0, endIndex: 2})
601
602 .call(move)
603 .expectSpeech('cond line \n th', 'selected')
604 .expectBraille('third line\n', {startIndex: 0, endIndex: 2})
605
606 // Shrinking.
607 .call(move)
608 .expectSpeech('cond line \n th', 'unselected')
609 .expectBraille('second line\n', {startIndex: 0, endIndex: 2})
610
611 .call(move)
612 .expectSpeech('fi', 'selected')
613 .expectBraille('first line\n', {startIndex: 0, endIndex: 2})
614
615 // Document boundary.
616 .call(move)
617 .expectSpeech('rst line \n second line \n third line \n \n',
618 'selected')
619 .expectBraille('third line\n', {startIndex: 0, endIndex: 10})
620
621 // The script repositions the caret to the 'n' of the third line.
622 .call(move)
623 .expectSpeech('third line')
624 .expectBraille('third line\n', {startIndex: 10, endIndex: 10})
625 .call(move)
626 .expectSpeech('e')
627 .expectBraille('third line\n', {startIndex: 9, endIndex: 9})
628 .call(move)
629 .expectSpeech('n')
630 .expectBraille('third line\n', {startIndex: 8, endIndex: 8})
631
632 // Backward selection.
633
634 // Growing.
635 .call(move)
636 .expectSpeech(' line \n third li', 'selected')
637 .expectBraille('second line\n', {startIndex: 6, endIndex: 12})
638
639 .call(move)
640 .expectSpeech('e \n second', 'selected')
641 .expectBraille('first line\n', {startIndex: 9, endIndex: 11})
642
643 // Shrinking.
644 .call(move)
645 .expectSpeech('e \n second', 'unselected')
646 .expectBraille('second line\n', {startIndex: 6, endIndex: 12})
647
648 .replay();
649 });
650 input.focus();
651 });
652 });
653
543 TEST_F('EditingTest', 'EditableLineOneStaticText', function() { 654 TEST_F('EditingTest', 'EditableLineOneStaticText', function() {
544 this.runWithLoadedTree(function() {/*! 655 this.runWithLoadedTree(function() {/*!
545 <p contenteditable style="word-spacing:100000px">this is a test</p> 656 <p contenteditable style="word-spacing:100000px">this is a test</p>
546 */}, function(root) { 657 */}, function(root) {
547 var staticText = root.find({role: RoleType.STATIC_TEXT}); 658 var staticText = root.find({role: RoleType.STATIC_TEXT});
548 659
549 var e = new editing.EditableLine(staticText, 0, staticText, 0); 660 var e = new editing.EditableLine(staticText, 0, staticText, 0);
550 assertEquals('this ', e.text); 661 assertEquals('this ', e.text);
551 662
552 assertEquals(0, e.startOffset); 663 assertEquals(0, e.startOffset);
(...skipping 13 matching lines...) Expand all
566 assertEquals(1, e.localEndOffset); 677 assertEquals(1, e.localEndOffset);
567 678
568 assertEquals(0, e.containerStartOffset); 679 assertEquals(0, e.containerStartOffset);
569 assertEquals(4, e.containerEndOffset); 680 assertEquals(4, e.containerEndOffset);
570 681
571 e = new editing.EditableLine(staticText, 5, staticText, 5); 682 e = new editing.EditableLine(staticText, 5, staticText, 5);
572 assertEquals('is ', e.text); 683 assertEquals('is ', e.text);
573 684
574 assertEquals(0, e.startOffset); 685 assertEquals(0, e.startOffset);
575 assertEquals(0, e.endOffset); 686 assertEquals(0, e.endOffset);
576 assertEquals(0, e.localStartOffset); 687 assertEquals(5, e.localStartOffset);
577 assertEquals(0, e.localEndOffset); 688 assertEquals(5, e.localEndOffset);
578 689
579 assertEquals(0, e.containerStartOffset); 690 assertEquals(0, e.containerStartOffset);
580 assertEquals(2, e.containerEndOffset); 691 assertEquals(2, e.containerEndOffset);
581 692
582 e = new editing.EditableLine(staticText, 7, staticText, 7); 693 e = new editing.EditableLine(staticText, 7, staticText, 7);
583 assertEquals('is ', e.text); 694 assertEquals('is ', e.text);
584 695
585 assertEquals(2, e.startOffset); 696 assertEquals(2, e.startOffset);
586 assertEquals(2, e.endOffset); 697 assertEquals(2, e.endOffset);
587 assertEquals(2, e.localStartOffset); 698 assertEquals(7, e.localStartOffset);
588 assertEquals(2, e.localEndOffset); 699 assertEquals(7, e.localEndOffset);
589 700
590 assertEquals(0, e.containerStartOffset); 701 assertEquals(0, e.containerStartOffset);
591 assertEquals(2, e.containerEndOffset); 702 assertEquals(2, e.containerEndOffset);
592 }); 703 });
593 }); 704 });
594 705
595 TEST_F('EditingTest', 'EditableLineTwoStaticTexts', function() { 706 TEST_F('EditingTest', 'EditableLineTwoStaticTexts', function() {
596 this.runWithLoadedTree(function() {/*! 707 this.runWithLoadedTree(function() {/*!
597 <p contenteditable>hello <b>world</b></p> 708 <p contenteditable>hello <b>world</b></p>
598 */}, function(root) { 709 */}, function(root) {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 assertEquals(0, e1.startOffset); 924 assertEquals(0, e1.startOffset);
814 assertEquals(2, e1.endOffset); 925 assertEquals(2, e1.endOffset);
815 926
816 // Across paragraph selection with base line on anchor. 927 // Across paragraph selection with base line on anchor.
817 e1 = new editing.EditableLine(thisIsATest, 5, hello, 2, true); 928 e1 = new editing.EditableLine(thisIsATest, 5, hello, 2, true);
818 assertEquals('is ', e1.text); 929 assertEquals('is ', e1.text);
819 assertEquals(0, e1.startOffset); 930 assertEquals(0, e1.startOffset);
820 assertEquals(3, e1.endOffset); 931 assertEquals(3, e1.endOffset);
821 }) 932 })
822 }); 933 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698