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

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

Issue 2966973002: Reland: Expand EditableLine to include non-inline text box leafs (Closed)
Patch Set: 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
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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 .expectSpeech('s', 'selected') 477 .expectSpeech('s', 'selected')
478 .call(moveByChar) 478 .call(moveByChar)
479 .expectSpeech('t', 'added to selection') 479 .expectSpeech('t', 'added to selection')
480 480
481 .replay(); 481 .replay();
482 }); 482 });
483 input.focus(); 483 input.focus();
484 }); 484 });
485 }); 485 });
486 486
487 TEST_F('EditingTest', 'RichTextImageByCharacter', function() {
488 var mockFeedback = this.createMockFeedback();
489 this.runWithLoadedTree(function() {/*!
490 <p id="go" contenteditable>
491 <img alt="dog"></img> is a <img alt="cat"</img> test
492 </p>
493 <script>
494 document.getElementById('go').addEventListener('click', function() {
495 var sel = getSelection();
496 sel.modify('move', 'forward', 'character');
497 }, true);
498 </script>
499 */}, function(root) {
500 var input = root.find({role: RoleType.PARAGRAPH});
501 var moveByChar = input.doDefault.bind(input);
502
503 this.listenOnce(input, 'focus', function() {
504 var lineText = 'dog is a cat test';
505 mockFeedback.call(moveByChar)
506 // Note that this isn't quite correct. This should be the second
507 // character which is a space ' '.
508 .expectSpeech('dog', 'Image')
509 // Ditto.
510 .expectBraille(lineText, {startIndex: 0, endIndex: 0})
511 .call(moveByChar)
512 .expectSpeech('i')
513 .expectBraille(lineText, {startIndex: 4, endIndex: 4})
514 .call(moveByChar)
515 .expectSpeech('s')
516 .expectBraille(lineText, {startIndex: 5, endIndex: 5})
517 .call(moveByChar)
518 .expectSpeech(' ')
519 .expectBraille(lineText, {startIndex: 6, endIndex: 6})
520 .call(moveByChar)
521 .expectSpeech('a')
522 .expectBraille(lineText, {startIndex: 7, endIndex: 7})
523 .call(moveByChar)
524 .expectSpeech(' ')
525 .expectBraille(lineText, {startIndex: 8, endIndex: 8})
526 .call(moveByChar)
527
528 // This is technically wrong because we're actually over the entire
529 // image. This is broken because of bad node offsets.
530 .expectSpeech('c')
531 .expectBraille(lineText, {startIndex: 9, endIndex: 9})
532
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
535 // in Blink.
536
537 .replay();
538 });
539 input.focus();
540 });
541 });
542
487 TEST_F('EditingTest', 'EditableLineOneStaticText', function() { 543 TEST_F('EditingTest', 'EditableLineOneStaticText', function() {
488 this.runWithLoadedTree(function() {/*! 544 this.runWithLoadedTree(function() {/*!
489 <p contenteditable style="word-spacing:100000px">this is a test</p> 545 <p contenteditable style="word-spacing:100000px">this is a test</p>
490 */}, function(root) { 546 */}, function(root) {
491 var staticText = root.find({role: RoleType.STATIC_TEXT}); 547 var staticText = root.find({role: RoleType.STATIC_TEXT});
492 548
493 var e = new editing.EditableLine(staticText, 0, staticText, 0); 549 var e = new editing.EditableLine(staticText, 0, staticText, 0);
494 assertEquals('this ', e.text); 550 assertEquals('this ', e.text);
495 551
496 assertEquals(0, e.startOffset); 552 assertEquals(0, e.startOffset);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 assertEquals(0, e1.startOffset); 813 assertEquals(0, e1.startOffset);
758 assertEquals(2, e1.endOffset); 814 assertEquals(2, e1.endOffset);
759 815
760 // Across paragraph selection with base line on anchor. 816 // Across paragraph selection with base line on anchor.
761 e1 = new editing.EditableLine(thisIsATest, 5, hello, 2, true); 817 e1 = new editing.EditableLine(thisIsATest, 5, hello, 2, true);
762 assertEquals('is ', e1.text); 818 assertEquals('is ', e1.text);
763 assertEquals(0, e1.startOffset); 819 assertEquals(0, e1.startOffset);
764 assertEquals(3, e1.endOffset); 820 assertEquals(3, e1.endOffset);
765 }) 821 })
766 }); 822 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698