Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 | 547 |
| 548 // On different node, with multi-static text line. | 548 // On different node, with multi-static text line. |
| 549 e1 = new editing.EditableLine(world, 1, world, 1); | 549 e1 = new editing.EditableLine(world, 1, world, 1); |
| 550 assertTrue(e1.equals(e2)); | 550 assertTrue(e1.equals(e2)); |
| 551 | 551 |
| 552 // Another mix of lines. | 552 // Another mix of lines. |
| 553 e2 = new editing.EditableLine(thisIsATest, 9, thisIsATest, 9); | 553 e2 = new editing.EditableLine(thisIsATest, 9, thisIsATest, 9); |
| 554 assertFalse(e1.equals(e2)); | 554 assertFalse(e1.equals(e2)); |
| 555 }); | 555 }); |
| 556 }); | 556 }); |
| 557 | |
| 558 TEST_F('EditingTest', 'EditableLineStrictEquality', function() { | |
| 559 this.runWithLoadedTree(function() {/*! | |
| 560 <div contenteditable role="textbox"> | |
| 561 <p style="word-spacing:100000px">this is a test</p> | |
| 562 <p>hello <b>world</b></p> | |
| 563 </div> | |
| 564 */}, function(root) { | |
| 565 var thisIsATest = root.findAll({role: RoleType.PARAGRAPH})[0].firstChild; | |
| 566 var hello = root.findAll({role: RoleType.PARAGRAPH})[1].firstChild; | |
| 567 var world = root.findAll({role: RoleType.PARAGRAPH})[1].lastChild; | |
| 568 | |
| 569 // The same position -- sanity check. | |
| 570 var e1 = new editing.EditableLine(thisIsATest, 0, thisIsATest, 0); | |
| 571 assertEquals('this ', e1.text); | |
| 572 assertTrue(e1.equalsStrict(e1)); | |
| 573 | |
| 574 // Offset into the same soft line. | |
| 575 var e2 = new editing.EditableLine(thisIsATest, 1, thisIsATest, 1); | |
| 576 assertFalse(e1.equalsStrict(e2)); | |
| 577 | |
| 578 // Boundary. | |
| 579 e2 = new editing.EditableLine(thisIsATest, 4, thisIsATest, 4); | |
| 580 assertFalse(e1.equalsStrict(e2)); | |
| 581 | |
| 582 // Offsets into different soft lines. | |
| 583 e2 = new editing.EditableLine(thisIsATest, 5, thisIsATest, 5); | |
| 584 assertEquals('is ', e2.text); | |
| 585 assertFalse(e1.equalsStrict(e2)); | |
| 586 | |
| 587 // Sanity check; second soft line. | |
| 588 assertTrue(e2.equalsStrict(e2)); | |
| 589 | |
| 590 // Different offsets into second soft line. | |
| 591 e1 = new editing.EditableLine(thisIsATest, 6, thisIsATest, 6); | |
| 592 assertFalse(e1.equalsStrict(e2)); | |
| 593 | |
| 594 // Boundary. | |
| 595 e1 = new editing.EditableLine(thisIsATest, 7, thisIsATest, 7); | |
| 596 assertFalse(e1.equalsStrict(e2)); | |
| 597 | |
| 598 // Cross into new paragraph. | |
| 599 e2 = new editing.EditableLine(hello, 0, hello, 0); | |
| 600 assertEquals('hello world', e2.text); | |
| 601 assertFalse(e1.equalsStrict(e2)); | |
| 602 | |
| 603 // On same node, with multi-static text line. | |
| 604 e1 = new editing.EditableLine(hello, 1, hello, 1); | |
| 605 assertFalse(e1.equalsStrict(e2)); | |
| 606 | |
| 607 // On same node, with multi-static text line; boundary. | |
| 608 e1 = new editing.EditableLine(hello, 5, hello, 5); | |
| 609 assertFalse(e1.equalsStrict(e2)); | |
| 610 }); | |
| 611 }); | |
| 612 | |
| 613 TEST_F('EditingTest', 'EditableLineBaseLineAnchorOrFocus', function() { | |
| 614 this.runWithLoadedTree(function() {/*! | |
| 615 <div contenteditable role="textbox"> | |
| 616 <p style="word-spacing:100000px">this is a test</p> | |
| 617 <p>hello <b>world</b></p> | |
| 618 </div> | |
| 619 */}, function(root) { | |
| 620 var thisIsATest = root.findAll({role: RoleType.PARAGRAPH})[0].firstChild; | |
| 621 var hello = root.findAll({role: RoleType.PARAGRAPH})[1].firstChild; | |
| 622 var world = root.findAll({role: RoleType.PARAGRAPH})[1].lastChild; | |
| 623 | |
| 624 // The same position -- sanity check. | |
| 625 var e1 = new editing.EditableLine(thisIsATest, 0, thisIsATest, 0, true); | |
| 626 assertEquals('this ', e1.text); | |
| 627 | |
| 628 // Offsets into different soft lines; base on focus (default). | |
| 629 e1 = new editing.EditableLine(thisIsATest, 0, thisIsATest, 6); | |
| 630 assertEquals('is ', e1.text); | |
| 631 // Notice that the offset is truncated at the beginning of the line. | |
| 632 assertEquals(0, e1.startOffset); | |
| 633 // Notice that the end offset is properly retained. | |
|
dmazzoni
2017/06/21 06:22:08
nit: indent
David Tseng
2017/06/21 16:58:28
Done.
| |
| 634 assertEquals(1, e1.endOffset); | |
| 635 | |
| 636 // Offsets into different soft lines; base on anchor. | |
| 637 e1 = new editing.EditableLine(thisIsATest, 0, thisIsATest, 6, true); | |
| 638 assertEquals('this ', e1.text); | |
| 639 assertEquals(0, e1.startOffset); | |
| 640 // Notice that the end offset is truncated up to the end of line. | |
|
dmazzoni
2017/06/21 06:22:08
nit: indent
David Tseng
2017/06/21 16:58:28
Done (hmm git cl format didn't catch this).
| |
| 641 assertEquals(5, e1.endOffset); | |
| 642 | |
| 643 // Across paragraph dselection with base line on focus. | |
|
dmazzoni
2017/06/21 06:22:08
nit: dselection -> selection, and again below
David Tseng
2017/06/21 16:58:28
Done.
| |
| 644 e1 = new editing.EditableLine(thisIsATest, 5, hello, 2); | |
| 645 assertEquals('hello world', e1.text); | |
| 646 assertEquals(0, e1.startOffset); | |
| 647 assertEquals(2, e1.endOffset); | |
| 648 | |
| 649 // Across paragraph dselection with base line on anchor. | |
| 650 e1 = new editing.EditableLine(thisIsATest, 5, hello, 2, true); | |
| 651 assertEquals('is ', e1.text); | |
| 652 assertEquals(0, e1.startOffset); | |
| 653 assertEquals(3, e1.endOffset); | |
| 654 }) | |
| 655 }); | |
| OLD | NEW |