| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 testInputMode(WebString("verbatim"), "input_mode_type_search_verbatim.html")
; | 503 testInputMode(WebString("verbatim"), "input_mode_type_search_verbatim.html")
; |
| 504 testInputMode(WebString(), "input_mode_type_url_verbatim.html"); | 504 testInputMode(WebString(), "input_mode_type_url_verbatim.html"); |
| 505 testInputMode(WebString("verbatim"), "input_mode_textarea_verbatim.html"); | 505 testInputMode(WebString("verbatim"), "input_mode_textarea_verbatim.html"); |
| 506 } | 506 } |
| 507 | 507 |
| 508 TEST_F(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) | 508 TEST_F(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) |
| 509 { | 509 { |
| 510 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 510 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 511 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 511 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 512 webView->setInitialFocus(false); | 512 webView->setInitialFocus(false); |
| 513 webView->setEditableSelectionOffsets(5, 13); | |
| 514 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); | 513 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); |
| 514 frame->setEditableSelectionOffsets(5, 13); |
| 515 EXPECT_EQ("56789abc", frame->selectionAsText()); | 515 EXPECT_EQ("56789abc", frame->selectionAsText()); |
| 516 WebTextInputInfo info = webView->textInputInfo(); | 516 WebTextInputInfo info = webView->textInputInfo(); |
| 517 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); | 517 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); |
| 518 EXPECT_EQ(5, info.selectionStart); | 518 EXPECT_EQ(5, info.selectionStart); |
| 519 EXPECT_EQ(13, info.selectionEnd); | 519 EXPECT_EQ(13, info.selectionEnd); |
| 520 EXPECT_EQ(-1, info.compositionStart); | 520 EXPECT_EQ(-1, info.compositionStart); |
| 521 EXPECT_EQ(-1, info.compositionEnd); | 521 EXPECT_EQ(-1, info.compositionEnd); |
| 522 | 522 |
| 523 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("content_editable_populated.html")); | 523 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("content_editable_populated.html")); |
| 524 webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_editable_po
pulated.html"); | 524 webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_editable_po
pulated.html"); |
| 525 webView->setInitialFocus(false); | 525 webView->setInitialFocus(false); |
| 526 webView->setEditableSelectionOffsets(8, 19); | |
| 527 frame = toWebFrameImpl(webView->mainFrame()); | 526 frame = toWebFrameImpl(webView->mainFrame()); |
| 527 frame->setEditableSelectionOffsets(8, 19); |
| 528 EXPECT_EQ("89abcdefghi", frame->selectionAsText()); | 528 EXPECT_EQ("89abcdefghi", frame->selectionAsText()); |
| 529 info = webView->textInputInfo(); | 529 info = webView->textInputInfo(); |
| 530 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); | 530 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); |
| 531 EXPECT_EQ(8, info.selectionStart); | 531 EXPECT_EQ(8, info.selectionStart); |
| 532 EXPECT_EQ(19, info.selectionEnd); | 532 EXPECT_EQ(19, info.selectionEnd); |
| 533 EXPECT_EQ(-1, info.compositionStart); | 533 EXPECT_EQ(-1, info.compositionStart); |
| 534 EXPECT_EQ(-1, info.compositionEnd); | 534 EXPECT_EQ(-1, info.compositionEnd); |
| 535 } | 535 } |
| 536 | 536 |
| 537 TEST_F(WebViewTest, ConfirmCompositionCursorPositionChange) | 537 TEST_F(WebViewTest, ConfirmCompositionCursorPositionChange) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 } | 577 } |
| 578 | 578 |
| 579 TEST_F(WebViewTest, InsertNewLinePlacementAfterConfirmComposition) | 579 TEST_F(WebViewTest, InsertNewLinePlacementAfterConfirmComposition) |
| 580 { | 580 { |
| 581 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); | 581 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); |
| 582 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_
populated.html"); | 582 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_
populated.html"); |
| 583 webView->setInitialFocus(false); | 583 webView->setInitialFocus(false); |
| 584 | 584 |
| 585 WebVector<WebCompositionUnderline> emptyUnderlines; | 585 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 586 | 586 |
| 587 webView->setEditableSelectionOffsets(4, 4); | 587 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); |
| 588 webView->setCompositionFromExistingText(8, 12, emptyUnderlines); | 588 frame->setEditableSelectionOffsets(4, 4); |
| 589 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
| 589 | 590 |
| 590 WebTextInputInfo info = webView->textInputInfo(); | 591 WebTextInputInfo info = webView->textInputInfo(); |
| 591 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf
8().data())); | 592 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf
8().data())); |
| 592 EXPECT_EQ(4, info.selectionStart); | 593 EXPECT_EQ(4, info.selectionStart); |
| 593 EXPECT_EQ(4, info.selectionEnd); | 594 EXPECT_EQ(4, info.selectionEnd); |
| 594 EXPECT_EQ(8, info.compositionStart); | 595 EXPECT_EQ(8, info.compositionStart); |
| 595 EXPECT_EQ(12, info.compositionEnd); | 596 EXPECT_EQ(12, info.compositionEnd); |
| 596 | 597 |
| 597 webView->confirmComposition(WebWidget::KeepSelection); | 598 webView->confirmComposition(WebWidget::KeepSelection); |
| 598 info = webView->textInputInfo(); | 599 info = webView->textInputInfo(); |
| 599 EXPECT_EQ(4, info.selectionStart); | 600 EXPECT_EQ(4, info.selectionStart); |
| 600 EXPECT_EQ(4, info.selectionEnd); | 601 EXPECT_EQ(4, info.selectionEnd); |
| 601 EXPECT_EQ(-1, info.compositionStart); | 602 EXPECT_EQ(-1, info.compositionStart); |
| 602 EXPECT_EQ(-1, info.compositionEnd); | 603 EXPECT_EQ(-1, info.compositionEnd); |
| 603 | 604 |
| 604 std::string compositionText("\n"); | 605 std::string compositionText("\n"); |
| 605 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str())); | 606 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str())); |
| 606 info = webView->textInputInfo(); | 607 info = webView->textInputInfo(); |
| 607 EXPECT_EQ(5, info.selectionStart); | 608 EXPECT_EQ(5, info.selectionStart); |
| 608 EXPECT_EQ(5, info.selectionEnd); | 609 EXPECT_EQ(5, info.selectionEnd); |
| 609 EXPECT_EQ(-1, info.compositionStart); | 610 EXPECT_EQ(-1, info.compositionStart); |
| 610 EXPECT_EQ(-1, info.compositionEnd); | 611 EXPECT_EQ(-1, info.compositionEnd); |
| 611 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u
tf8().data())); | 612 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 612 } | 613 } |
| 613 | 614 |
| 614 TEST_F(WebViewTest, ExtendSelectionAndDelete) | 615 TEST_F(WebViewTest, ExtendSelectionAndDelete) |
| 615 { | 616 { |
| 616 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 617 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 617 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 618 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 619 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); |
| 618 webView->setInitialFocus(false); | 620 webView->setInitialFocus(false); |
| 619 webView->setEditableSelectionOffsets(10, 10); | 621 frame->setEditableSelectionOffsets(10, 10); |
| 620 webView->extendSelectionAndDelete(5, 8); | 622 frame->extendSelectionAndDelete(5, 8); |
| 621 WebTextInputInfo info = webView->textInputInfo(); | 623 WebTextInputInfo info = webView->textInputInfo(); |
| 622 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); | 624 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
| 623 EXPECT_EQ(5, info.selectionStart); | 625 EXPECT_EQ(5, info.selectionStart); |
| 624 EXPECT_EQ(5, info.selectionEnd); | 626 EXPECT_EQ(5, info.selectionEnd); |
| 625 webView->extendSelectionAndDelete(10, 0); | 627 frame->extendSelectionAndDelete(10, 0); |
| 626 info = webView->textInputInfo(); | 628 info = webView->textInputInfo(); |
| 627 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); | 629 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
| 628 } | 630 } |
| 629 | 631 |
| 630 TEST_F(WebViewTest, SetCompositionFromExistingText) | 632 TEST_F(WebViewTest, SetCompositionFromExistingText) |
| 631 { | 633 { |
| 632 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 634 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 633 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 635 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 634 webView->setInitialFocus(false); | 636 webView->setInitialFocus(false); |
| 635 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 637 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 636 underlines[0] = blink::WebCompositionUnderline(0, 4, 0, false); | 638 underlines[0] = blink::WebCompositionUnderline(0, 4, 0, false); |
| 637 webView->setEditableSelectionOffsets(4, 10); | 639 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); |
| 638 webView->setCompositionFromExistingText(8, 12, underlines); | 640 frame->setEditableSelectionOffsets(4, 10); |
| 641 frame->setCompositionFromExistingText(8, 12, underlines); |
| 639 WebVector<WebCompositionUnderline> underlineResults = toWebViewImpl(webView)
->compositionUnderlines(); | 642 WebVector<WebCompositionUnderline> underlineResults = toWebViewImpl(webView)
->compositionUnderlines(); |
| 640 EXPECT_EQ(8u, underlineResults[0].startOffset); | 643 EXPECT_EQ(8u, underlineResults[0].startOffset); |
| 641 EXPECT_EQ(12u, underlineResults[0].endOffset); | 644 EXPECT_EQ(12u, underlineResults[0].endOffset); |
| 642 WebTextInputInfo info = webView->textInputInfo(); | 645 WebTextInputInfo info = webView->textInputInfo(); |
| 643 EXPECT_EQ(4, info.selectionStart); | 646 EXPECT_EQ(4, info.selectionStart); |
| 644 EXPECT_EQ(10, info.selectionEnd); | 647 EXPECT_EQ(10, info.selectionEnd); |
| 645 EXPECT_EQ(8, info.compositionStart); | 648 EXPECT_EQ(8, info.compositionStart); |
| 646 EXPECT_EQ(12, info.compositionEnd); | 649 EXPECT_EQ(12, info.compositionEnd); |
| 647 WebVector<WebCompositionUnderline> emptyUnderlines; | 650 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 648 webView->setCompositionFromExistingText(0, 0, emptyUnderlines); | 651 frame->setCompositionFromExistingText(0, 0, emptyUnderlines); |
| 649 info = webView->textInputInfo(); | 652 info = webView->textInputInfo(); |
| 650 EXPECT_EQ(4, info.selectionStart); | 653 EXPECT_EQ(4, info.selectionStart); |
| 651 EXPECT_EQ(10, info.selectionEnd); | 654 EXPECT_EQ(10, info.selectionEnd); |
| 652 EXPECT_EQ(-1, info.compositionStart); | 655 EXPECT_EQ(-1, info.compositionStart); |
| 653 EXPECT_EQ(-1, info.compositionEnd); | 656 EXPECT_EQ(-1, info.compositionEnd); |
| 654 } | 657 } |
| 655 | 658 |
| 656 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) | 659 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) |
| 657 { | 660 { |
| 658 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); | 661 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); |
| 659 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_
populated.html"); | 662 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_
populated.html"); |
| 660 webView->setInitialFocus(false); | 663 webView->setInitialFocus(false); |
| 661 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 664 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 662 underlines[0] = blink::WebCompositionUnderline(0, 4, 0, false); | 665 underlines[0] = blink::WebCompositionUnderline(0, 4, 0, false); |
| 663 webView->setEditableSelectionOffsets(27, 27); | 666 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); |
| 667 frame->setEditableSelectionOffsets(27, 27); |
| 664 std::string newLineText("\n"); | 668 std::string newLineText("\n"); |
| 665 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str())); | 669 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str())); |
| 666 WebTextInputInfo info = webView->textInputInfo(); | 670 WebTextInputInfo info = webView->textInputInfo(); |
| 667 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); | 671 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 668 | 672 |
| 669 webView->setEditableSelectionOffsets(31, 31); | 673 frame->setEditableSelectionOffsets(31, 31); |
| 670 webView->setCompositionFromExistingText(30, 34, underlines); | 674 frame->setCompositionFromExistingText(30, 34, underlines); |
| 671 WebVector<WebCompositionUnderline> underlineResults = toWebViewImpl(webView)
->compositionUnderlines(); | 675 WebVector<WebCompositionUnderline> underlineResults = toWebViewImpl(webView)
->compositionUnderlines(); |
| 672 EXPECT_EQ(2u, underlineResults[0].startOffset); | 676 EXPECT_EQ(2u, underlineResults[0].startOffset); |
| 673 EXPECT_EQ(6u, underlineResults[0].endOffset); | 677 EXPECT_EQ(6u, underlineResults[0].endOffset); |
| 674 info = webView->textInputInfo(); | 678 info = webView->textInputInfo(); |
| 675 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); | 679 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 676 EXPECT_EQ(31, info.selectionStart); | 680 EXPECT_EQ(31, info.selectionStart); |
| 677 EXPECT_EQ(31, info.selectionEnd); | 681 EXPECT_EQ(31, info.selectionEnd); |
| 678 EXPECT_EQ(30, info.compositionStart); | 682 EXPECT_EQ(30, info.compositionStart); |
| 679 EXPECT_EQ(34, info.compositionEnd); | 683 EXPECT_EQ(34, info.compositionEnd); |
| 680 | 684 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 701 webView->confirmComposition(WebString::fromUTF8(compositionTextFirst.c_str()
)); | 705 webView->confirmComposition(WebString::fromUTF8(compositionTextFirst.c_str()
)); |
| 702 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()),
emptyUnderlines, 5, 5); | 706 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()),
emptyUnderlines, 5, 5); |
| 703 | 707 |
| 704 WebTextInputInfo info = webView->textInputInfo(); | 708 WebTextInputInfo info = webView->textInputInfo(); |
| 705 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 709 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 706 EXPECT_EQ(11, info.selectionStart); | 710 EXPECT_EQ(11, info.selectionStart); |
| 707 EXPECT_EQ(11, info.selectionEnd); | 711 EXPECT_EQ(11, info.selectionEnd); |
| 708 EXPECT_EQ(6, info.compositionStart); | 712 EXPECT_EQ(6, info.compositionStart); |
| 709 EXPECT_EQ(11, info.compositionEnd); | 713 EXPECT_EQ(11, info.compositionEnd); |
| 710 | 714 |
| 711 webView->setEditableSelectionOffsets(6, 6); | 715 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); |
| 716 frame->setEditableSelectionOffsets(6, 6); |
| 712 info = webView->textInputInfo(); | 717 info = webView->textInputInfo(); |
| 713 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 718 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 714 EXPECT_EQ(6, info.selectionStart); | 719 EXPECT_EQ(6, info.selectionStart); |
| 715 EXPECT_EQ(6, info.selectionEnd); | 720 EXPECT_EQ(6, info.selectionEnd); |
| 716 EXPECT_EQ(6, info.compositionStart); | 721 EXPECT_EQ(6, info.compositionStart); |
| 717 EXPECT_EQ(11, info.compositionEnd); | 722 EXPECT_EQ(11, info.compositionEnd); |
| 718 | 723 |
| 719 webView->setEditableSelectionOffsets(8, 8); | 724 frame->setEditableSelectionOffsets(8, 8); |
| 720 info = webView->textInputInfo(); | 725 info = webView->textInputInfo(); |
| 721 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 726 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 722 EXPECT_EQ(8, info.selectionStart); | 727 EXPECT_EQ(8, info.selectionStart); |
| 723 EXPECT_EQ(8, info.selectionEnd); | 728 EXPECT_EQ(8, info.selectionEnd); |
| 724 EXPECT_EQ(6, info.compositionStart); | 729 EXPECT_EQ(6, info.compositionStart); |
| 725 EXPECT_EQ(11, info.compositionEnd); | 730 EXPECT_EQ(11, info.compositionEnd); |
| 726 | 731 |
| 727 webView->setEditableSelectionOffsets(11, 11); | 732 frame->setEditableSelectionOffsets(11, 11); |
| 728 info = webView->textInputInfo(); | 733 info = webView->textInputInfo(); |
| 729 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 734 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 730 EXPECT_EQ(11, info.selectionStart); | 735 EXPECT_EQ(11, info.selectionStart); |
| 731 EXPECT_EQ(11, info.selectionEnd); | 736 EXPECT_EQ(11, info.selectionEnd); |
| 732 EXPECT_EQ(6, info.compositionStart); | 737 EXPECT_EQ(6, info.compositionStart); |
| 733 EXPECT_EQ(11, info.compositionEnd); | 738 EXPECT_EQ(11, info.compositionEnd); |
| 734 | 739 |
| 735 webView->setEditableSelectionOffsets(6, 11); | 740 frame->setEditableSelectionOffsets(6, 11); |
| 736 info = webView->textInputInfo(); | 741 info = webView->textInputInfo(); |
| 737 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 742 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 738 EXPECT_EQ(6, info.selectionStart); | 743 EXPECT_EQ(6, info.selectionStart); |
| 739 EXPECT_EQ(11, info.selectionEnd); | 744 EXPECT_EQ(11, info.selectionEnd); |
| 740 EXPECT_EQ(6, info.compositionStart); | 745 EXPECT_EQ(6, info.compositionStart); |
| 741 EXPECT_EQ(11, info.compositionEnd); | 746 EXPECT_EQ(11, info.compositionEnd); |
| 742 | 747 |
| 743 webView->setEditableSelectionOffsets(2, 2); | 748 frame->setEditableSelectionOffsets(2, 2); |
| 744 info = webView->textInputInfo(); | 749 info = webView->textInputInfo(); |
| 745 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 750 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 746 EXPECT_EQ(2, info.selectionStart); | 751 EXPECT_EQ(2, info.selectionStart); |
| 747 EXPECT_EQ(2, info.selectionEnd); | 752 EXPECT_EQ(2, info.selectionEnd); |
| 748 EXPECT_EQ(-1, info.compositionStart); | 753 EXPECT_EQ(-1, info.compositionStart); |
| 749 EXPECT_EQ(-1, info.compositionEnd); | 754 EXPECT_EQ(-1, info.compositionEnd); |
| 750 } | 755 } |
| 751 | 756 |
| 752 TEST_F(WebViewTest, IsSelectionAnchorFirst) | 757 TEST_F(WebViewTest, IsSelectionAnchorFirst) |
| 753 { | 758 { |
| 754 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 759 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 755 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 760 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 756 WebFrame* frame = webView->mainFrame(); | 761 WebFrame* frame = webView->mainFrame(); |
| 757 | 762 |
| 758 webView->setInitialFocus(false); | 763 webView->setInitialFocus(false); |
| 759 webView->setEditableSelectionOffsets(4, 10); | 764 frame->setEditableSelectionOffsets(4, 10); |
| 760 EXPECT_TRUE(webView->isSelectionAnchorFirst()); | 765 EXPECT_TRUE(webView->isSelectionAnchorFirst()); |
| 761 WebRect anchor; | 766 WebRect anchor; |
| 762 WebRect focus; | 767 WebRect focus; |
| 763 webView->selectionBounds(anchor, focus); | 768 webView->selectionBounds(anchor, focus); |
| 764 frame->selectRange(WebPoint(focus.x, focus.y), WebPoint(anchor.x, anchor.y))
; | 769 frame->selectRange(WebPoint(focus.x, focus.y), WebPoint(anchor.x, anchor.y))
; |
| 765 EXPECT_FALSE(webView->isSelectionAnchorFirst()); | 770 EXPECT_FALSE(webView->isSelectionAnchorFirst()); |
| 766 } | 771 } |
| 767 | 772 |
| 768 TEST_F(WebViewTest, HistoryResetScrollAndScaleState) | 773 TEST_F(WebViewTest, HistoryResetScrollAndScaleState) |
| 769 { | 774 { |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 TEST_F(WebViewTest, LosingFocusDoesNotTriggerAutofillTextChange) | 1173 TEST_F(WebViewTest, LosingFocusDoesNotTriggerAutofillTextChange) |
| 1169 { | 1174 { |
| 1170 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 1175 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 1171 MockAutofillClient client; | 1176 MockAutofillClient client; |
| 1172 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 1177 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 1173 webView->setAutofillClient(&client); | 1178 webView->setAutofillClient(&client); |
| 1174 webView->setInitialFocus(false); | 1179 webView->setInitialFocus(false); |
| 1175 | 1180 |
| 1176 // Set up a composition that needs to be committed. | 1181 // Set up a composition that needs to be committed. |
| 1177 WebVector<WebCompositionUnderline> emptyUnderlines; | 1182 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1178 webView->setEditableSelectionOffsets(4, 10); | 1183 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); |
| 1179 webView->setCompositionFromExistingText(8, 12, emptyUnderlines); | 1184 frame->setEditableSelectionOffsets(4, 10); |
| 1185 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
| 1180 WebTextInputInfo info = webView->textInputInfo(); | 1186 WebTextInputInfo info = webView->textInputInfo(); |
| 1181 EXPECT_EQ(4, info.selectionStart); | 1187 EXPECT_EQ(4, info.selectionStart); |
| 1182 EXPECT_EQ(10, info.selectionEnd); | 1188 EXPECT_EQ(10, info.selectionEnd); |
| 1183 EXPECT_EQ(8, info.compositionStart); | 1189 EXPECT_EQ(8, info.compositionStart); |
| 1184 EXPECT_EQ(12, info.compositionEnd); | 1190 EXPECT_EQ(12, info.compositionEnd); |
| 1185 | 1191 |
| 1186 // Clear the focus and track that the subsequent composition commit does not
trigger a | 1192 // Clear the focus and track that the subsequent composition commit does not
trigger a |
| 1187 // text changed notification for autofill. | 1193 // text changed notification for autofill. |
| 1188 client.clearChangeCounts(); | 1194 client.clearChangeCounts(); |
| 1189 webView->setFocus(false); | 1195 webView->setFocus(false); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 { | 1231 { |
| 1226 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 1232 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 1227 MockAutofillClient client; | 1233 MockAutofillClient client; |
| 1228 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html", true); | 1234 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html", true); |
| 1229 webView->setAutofillClient(&client); | 1235 webView->setAutofillClient(&client); |
| 1230 webView->setInitialFocus(false); | 1236 webView->setInitialFocus(false); |
| 1231 | 1237 |
| 1232 WebVector<WebCompositionUnderline> emptyUnderlines; | 1238 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1233 | 1239 |
| 1234 client.clearChangeCounts(); | 1240 client.clearChangeCounts(); |
| 1235 webView->setCompositionFromExistingText(8, 12, emptyUnderlines); | 1241 WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); |
| 1242 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
| 1236 | 1243 |
| 1237 WebTextInputInfo info = webView->textInputInfo(); | 1244 WebTextInputInfo info = webView->textInputInfo(); |
| 1238 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf
8().data())); | 1245 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf
8().data())); |
| 1239 EXPECT_EQ(8, info.compositionStart); | 1246 EXPECT_EQ(8, info.compositionStart); |
| 1240 EXPECT_EQ(12, info.compositionEnd); | 1247 EXPECT_EQ(12, info.compositionEnd); |
| 1241 | 1248 |
| 1242 EXPECT_EQ(0, client.textChangesWhileIgnored()); | 1249 EXPECT_EQ(0, client.textChangesWhileIgnored()); |
| 1243 EXPECT_EQ(0, client.textChangesWhileNotIgnored()); | 1250 EXPECT_EQ(0, client.textChangesWhileNotIgnored()); |
| 1244 | 1251 |
| 1245 WebDocument document = webView->mainFrame()->document(); | 1252 WebDocument document = webView->mainFrame()->document(); |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1738 testSelectionRootBounds("select_range_iframe_textarea_overflow.html", 1.0f); | 1745 testSelectionRootBounds("select_range_iframe_textarea_overflow.html", 1.0f); |
| 1739 | 1746 |
| 1740 // Basic page with scale factor. | 1747 // Basic page with scale factor. |
| 1741 testSelectionRootBounds("select_range_basic.html", 0.0f); | 1748 testSelectionRootBounds("select_range_basic.html", 0.0f); |
| 1742 testSelectionRootBounds("select_range_basic.html", 0.1f); | 1749 testSelectionRootBounds("select_range_basic.html", 0.1f); |
| 1743 testSelectionRootBounds("select_range_basic.html", 1.5f); | 1750 testSelectionRootBounds("select_range_basic.html", 1.5f); |
| 1744 testSelectionRootBounds("select_range_basic.html", 2.0f); | 1751 testSelectionRootBounds("select_range_basic.html", 2.0f); |
| 1745 } | 1752 } |
| 1746 | 1753 |
| 1747 } // namespace | 1754 } // namespace |
| OLD | NEW |