| 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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 testAutoResize(minAutoResize, maxAutoResize, pageWidth, pageHeight, | 746 testAutoResize(minAutoResize, maxAutoResize, pageWidth, pageHeight, |
| 747 expectedWidth, expectedHeight, NoHorizontalScrollbar, | 747 expectedWidth, expectedHeight, NoHorizontalScrollbar, |
| 748 NoVerticalScrollbar); | 748 NoVerticalScrollbar); |
| 749 } | 749 } |
| 750 | 750 |
| 751 void WebViewTest::testTextInputType(WebTextInputType expectedType, | 751 void WebViewTest::testTextInputType(WebTextInputType expectedType, |
| 752 const std::string& htmlFile) { | 752 const std::string& htmlFile) { |
| 753 URLTestHelpers::registerMockedURLFromBaseURL( | 753 URLTestHelpers::registerMockedURLFromBaseURL( |
| 754 WebString::fromUTF8(m_baseURL.c_str()), | 754 WebString::fromUTF8(m_baseURL.c_str()), |
| 755 WebString::fromUTF8(htmlFile.c_str())); | 755 WebString::fromUTF8(htmlFile.c_str())); |
| 756 WebViewImpl* webView = | 756 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile); |
| 757 m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile); | 757 EXPECT_EQ(WebTextInputTypeNone, webView->textInputType()); |
| 758 WebInputMethodControllerImpl* controller = | 758 EXPECT_EQ(WebTextInputTypeNone, webView->textInputInfo().type); |
| 759 webView->mainFrameImpl()->inputMethodController(); | |
| 760 EXPECT_EQ(WebTextInputTypeNone, controller->textInputType()); | |
| 761 EXPECT_EQ(WebTextInputTypeNone, controller->textInputInfo().type); | |
| 762 webView->setInitialFocus(false); | 759 webView->setInitialFocus(false); |
| 763 EXPECT_EQ(expectedType, controller->textInputType()); | 760 EXPECT_EQ(expectedType, webView->textInputType()); |
| 764 EXPECT_EQ(expectedType, controller->textInputInfo().type); | 761 EXPECT_EQ(expectedType, webView->textInputInfo().type); |
| 765 webView->clearFocusedElement(); | 762 webView->clearFocusedElement(); |
| 766 EXPECT_EQ(WebTextInputTypeNone, controller->textInputType()); | 763 EXPECT_EQ(WebTextInputTypeNone, webView->textInputType()); |
| 767 EXPECT_EQ(WebTextInputTypeNone, controller->textInputInfo().type); | 764 EXPECT_EQ(WebTextInputTypeNone, webView->textInputInfo().type); |
| 768 } | 765 } |
| 769 | 766 |
| 770 TEST_P(WebViewTest, TextInputType) { | 767 TEST_P(WebViewTest, TextInputType) { |
| 771 testTextInputType(WebTextInputTypeText, "input_field_default.html"); | 768 testTextInputType(WebTextInputTypeText, "input_field_default.html"); |
| 772 testTextInputType(WebTextInputTypePassword, "input_field_password.html"); | 769 testTextInputType(WebTextInputTypePassword, "input_field_password.html"); |
| 773 testTextInputType(WebTextInputTypeEmail, "input_field_email.html"); | 770 testTextInputType(WebTextInputTypeEmail, "input_field_email.html"); |
| 774 testTextInputType(WebTextInputTypeSearch, "input_field_search.html"); | 771 testTextInputType(WebTextInputTypeSearch, "input_field_search.html"); |
| 775 testTextInputType(WebTextInputTypeNumber, "input_field_number.html"); | 772 testTextInputType(WebTextInputTypeNumber, "input_field_number.html"); |
| 776 testTextInputType(WebTextInputTypeTelephone, "input_field_tel.html"); | 773 testTextInputType(WebTextInputTypeTelephone, "input_field_tel.html"); |
| 777 testTextInputType(WebTextInputTypeURL, "input_field_url.html"); | 774 testTextInputType(WebTextInputTypeURL, "input_field_url.html"); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 799 baseURL); | 796 baseURL); |
| 800 webViewImpl->setInitialFocus(false); | 797 webViewImpl->setInitialFocus(false); |
| 801 | 798 |
| 802 // Add id="foo" to <path>, thus triggering the condition described above. | 799 // Add id="foo" to <path>, thus triggering the condition described above. |
| 803 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); | 800 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); |
| 804 document->body() | 801 document->body() |
| 805 ->querySelector("path", ASSERT_NO_EXCEPTION) | 802 ->querySelector("path", ASSERT_NO_EXCEPTION) |
| 806 ->setIdAttribute("foo"); | 803 ->setIdAttribute("foo"); |
| 807 | 804 |
| 808 // This should not DCHECK. | 805 // This should not DCHECK. |
| 809 EXPECT_EQ(WebTextInputTypeText, webViewImpl->mainFrameImpl() | 806 EXPECT_EQ(WebTextInputTypeText, webViewImpl->textInputInfo().type); |
| 810 ->inputMethodController() | |
| 811 ->textInputInfo() | |
| 812 .type); | |
| 813 } | 807 } |
| 814 | 808 |
| 815 void WebViewTest::testInputMode(WebTextInputMode expectedInputMode, | 809 void WebViewTest::testInputMode(WebTextInputMode expectedInputMode, |
| 816 const std::string& htmlFile) { | 810 const std::string& htmlFile) { |
| 817 URLTestHelpers::registerMockedURLFromBaseURL( | 811 URLTestHelpers::registerMockedURLFromBaseURL( |
| 818 WebString::fromUTF8(m_baseURL.c_str()), | 812 WebString::fromUTF8(m_baseURL.c_str()), |
| 819 WebString::fromUTF8(htmlFile.c_str())); | 813 WebString::fromUTF8(htmlFile.c_str())); |
| 820 WebViewImpl* webViewImpl = | 814 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile); |
| 821 m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile); | 815 webView->setInitialFocus(false); |
| 822 webViewImpl->setInitialFocus(false); | 816 EXPECT_EQ(expectedInputMode, webView->textInputInfo().inputMode); |
| 823 EXPECT_EQ(expectedInputMode, webViewImpl->mainFrameImpl() | |
| 824 ->inputMethodController() | |
| 825 ->textInputInfo() | |
| 826 .inputMode); | |
| 827 } | 817 } |
| 828 | 818 |
| 829 TEST_P(WebViewTest, InputMode) { | 819 TEST_P(WebViewTest, InputMode) { |
| 830 testInputMode(WebTextInputMode::kWebTextInputModeDefault, | 820 testInputMode(WebTextInputMode::kWebTextInputModeDefault, |
| 831 "input_mode_default.html"); | 821 "input_mode_default.html"); |
| 832 testInputMode(WebTextInputMode::kWebTextInputModeDefault, | 822 testInputMode(WebTextInputMode::kWebTextInputModeDefault, |
| 833 "input_mode_default_unknown.html"); | 823 "input_mode_default_unknown.html"); |
| 834 testInputMode(WebTextInputMode::kWebTextInputModeVerbatim, | 824 testInputMode(WebTextInputMode::kWebTextInputModeVerbatim, |
| 835 "input_mode_default_verbatim.html"); | 825 "input_mode_default_verbatim.html"); |
| 836 testInputMode(WebTextInputMode::kWebTextInputModeVerbatim, | 826 testInputMode(WebTextInputMode::kWebTextInputModeVerbatim, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 861 "input_mode_type_email.html"); | 851 "input_mode_type_email.html"); |
| 862 testInputMode(WebTextInputMode::kWebTextInputModeUrl, | 852 testInputMode(WebTextInputMode::kWebTextInputModeUrl, |
| 863 "input_mode_type_url.html"); | 853 "input_mode_type_url.html"); |
| 864 } | 854 } |
| 865 | 855 |
| 866 TEST_P(WebViewTest, TextInputInfoWithReplacedElements) { | 856 TEST_P(WebViewTest, TextInputInfoWithReplacedElements) { |
| 867 std::string url = m_baseURL + "div_with_image.html"; | 857 std::string url = m_baseURL + "div_with_image.html"; |
| 868 URLTestHelpers::registerMockedURLLoad(toKURL(url), "div_with_image.html"); | 858 URLTestHelpers::registerMockedURLLoad(toKURL(url), "div_with_image.html"); |
| 869 URLTestHelpers::registerMockedURLLoad(toKURL("http://www.test.com/foo.png"), | 859 URLTestHelpers::registerMockedURLLoad(toKURL("http://www.test.com/foo.png"), |
| 870 "white-1x1.png"); | 860 "white-1x1.png"); |
| 871 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url); | 861 WebView* webView = m_webViewHelper.initializeAndLoad(url); |
| 872 webViewImpl->setInitialFocus(false); | 862 webView->setInitialFocus(false); |
| 873 WebTextInputInfo info = | 863 WebTextInputInfo info = webView->textInputInfo(); |
| 874 webViewImpl->mainFrameImpl()->inputMethodController()->textInputInfo(); | |
| 875 | 864 |
| 876 EXPECT_EQ("foo\xef\xbf\xbc", info.value.utf8()); | 865 EXPECT_EQ("foo\xef\xbf\xbc", info.value.utf8()); |
| 877 } | 866 } |
| 878 | 867 |
| 879 TEST_P(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) { | 868 TEST_P(WebViewTest, SetEditableSelectionOffsetsAndTextInputInfo) { |
| 880 URLTestHelpers::registerMockedURLFromBaseURL( | 869 URLTestHelpers::registerMockedURLFromBaseURL( |
| 881 WebString::fromUTF8(m_baseURL.c_str()), | 870 WebString::fromUTF8(m_baseURL.c_str()), |
| 882 WebString::fromUTF8("input_field_populated.html")); | 871 WebString::fromUTF8("input_field_populated.html")); |
| 883 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 872 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
| 884 m_baseURL + "input_field_populated.html"); | 873 m_baseURL + "input_field_populated.html"); |
| 885 webView->setInitialFocus(false); | 874 webView->setInitialFocus(false); |
| 886 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 875 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 887 WebInputMethodControllerImpl* activeInputMethodController = | |
| 888 frame->inputMethodController(); | |
| 889 frame->setEditableSelectionOffsets(5, 13); | 876 frame->setEditableSelectionOffsets(5, 13); |
| 890 EXPECT_EQ("56789abc", frame->selectionAsText()); | 877 EXPECT_EQ("56789abc", frame->selectionAsText()); |
| 891 WebTextInputInfo info = activeInputMethodController->textInputInfo(); | 878 WebTextInputInfo info = webView->textInputInfo(); |
| 892 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); | 879 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); |
| 893 EXPECT_EQ(5, info.selectionStart); | 880 EXPECT_EQ(5, info.selectionStart); |
| 894 EXPECT_EQ(13, info.selectionEnd); | 881 EXPECT_EQ(13, info.selectionEnd); |
| 895 EXPECT_EQ(-1, info.compositionStart); | 882 EXPECT_EQ(-1, info.compositionStart); |
| 896 EXPECT_EQ(-1, info.compositionEnd); | 883 EXPECT_EQ(-1, info.compositionEnd); |
| 897 | 884 |
| 898 URLTestHelpers::registerMockedURLFromBaseURL( | 885 URLTestHelpers::registerMockedURLFromBaseURL( |
| 899 WebString::fromUTF8(m_baseURL.c_str()), | 886 WebString::fromUTF8(m_baseURL.c_str()), |
| 900 WebString::fromUTF8("content_editable_populated.html")); | 887 WebString::fromUTF8("content_editable_populated.html")); |
| 901 webView = m_webViewHelper.initializeAndLoad( | 888 webView = m_webViewHelper.initializeAndLoad( |
| 902 m_baseURL + "content_editable_populated.html"); | 889 m_baseURL + "content_editable_populated.html"); |
| 903 webView->setInitialFocus(false); | 890 webView->setInitialFocus(false); |
| 904 frame = webView->mainFrameImpl(); | 891 frame = webView->mainFrameImpl(); |
| 905 activeInputMethodController = frame->inputMethodController(); | |
| 906 frame->setEditableSelectionOffsets(8, 19); | 892 frame->setEditableSelectionOffsets(8, 19); |
| 907 EXPECT_EQ("89abcdefghi", frame->selectionAsText()); | 893 EXPECT_EQ("89abcdefghi", frame->selectionAsText()); |
| 908 info = activeInputMethodController->textInputInfo(); | 894 info = webView->textInputInfo(); |
| 909 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); | 895 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); |
| 910 EXPECT_EQ(8, info.selectionStart); | 896 EXPECT_EQ(8, info.selectionStart); |
| 911 EXPECT_EQ(19, info.selectionEnd); | 897 EXPECT_EQ(19, info.selectionEnd); |
| 912 EXPECT_EQ(-1, info.compositionStart); | 898 EXPECT_EQ(-1, info.compositionStart); |
| 913 EXPECT_EQ(-1, info.compositionEnd); | 899 EXPECT_EQ(-1, info.compositionEnd); |
| 914 } | 900 } |
| 915 | 901 |
| 916 // Regression test for crbug.com/663645 | 902 // Regression test for crbug.com/663645 |
| 917 TEST_P(WebViewTest, FinishComposingTextDoesNotAssert) { | 903 TEST_P(WebViewTest, FinishComposingTextDoesNotAssert) { |
| 918 URLTestHelpers::registerMockedURLFromBaseURL( | 904 URLTestHelpers::registerMockedURLFromBaseURL( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 std::string compositionText("hello"); | 943 std::string compositionText("hello"); |
| 958 | 944 |
| 959 WebInputMethodController* activeInputMethodController = | 945 WebInputMethodController* activeInputMethodController = |
| 960 webView->mainFrameImpl() | 946 webView->mainFrameImpl() |
| 961 ->frameWidget() | 947 ->frameWidget() |
| 962 ->getActiveWebInputMethodController(); | 948 ->getActiveWebInputMethodController(); |
| 963 WebVector<WebCompositionUnderline> emptyUnderlines; | 949 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 964 activeInputMethodController->setComposition( | 950 activeInputMethodController->setComposition( |
| 965 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3); | 951 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3); |
| 966 | 952 |
| 967 WebTextInputInfo info = activeInputMethodController->textInputInfo(); | 953 WebTextInputInfo info = webView->textInputInfo(); |
| 968 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 954 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 969 EXPECT_EQ(3, info.selectionStart); | 955 EXPECT_EQ(3, info.selectionStart); |
| 970 EXPECT_EQ(3, info.selectionEnd); | 956 EXPECT_EQ(3, info.selectionEnd); |
| 971 EXPECT_EQ(0, info.compositionStart); | 957 EXPECT_EQ(0, info.compositionStart); |
| 972 EXPECT_EQ(5, info.compositionEnd); | 958 EXPECT_EQ(5, info.compositionEnd); |
| 973 | 959 |
| 974 activeInputMethodController->finishComposingText( | 960 activeInputMethodController->finishComposingText( |
| 975 WebInputMethodController::KeepSelection); | 961 WebInputMethodController::KeepSelection); |
| 976 info = activeInputMethodController->textInputInfo(); | 962 info = webView->textInputInfo(); |
| 977 EXPECT_EQ(3, info.selectionStart); | 963 EXPECT_EQ(3, info.selectionStart); |
| 978 EXPECT_EQ(3, info.selectionEnd); | 964 EXPECT_EQ(3, info.selectionEnd); |
| 979 EXPECT_EQ(-1, info.compositionStart); | 965 EXPECT_EQ(-1, info.compositionStart); |
| 980 EXPECT_EQ(-1, info.compositionEnd); | 966 EXPECT_EQ(-1, info.compositionEnd); |
| 981 | 967 |
| 982 activeInputMethodController->setComposition( | 968 activeInputMethodController->setComposition( |
| 983 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3); | 969 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3); |
| 984 info = activeInputMethodController->textInputInfo(); | 970 info = webView->textInputInfo(); |
| 985 EXPECT_EQ("helhellolo", std::string(info.value.utf8().data())); | 971 EXPECT_EQ("helhellolo", std::string(info.value.utf8().data())); |
| 986 EXPECT_EQ(6, info.selectionStart); | 972 EXPECT_EQ(6, info.selectionStart); |
| 987 EXPECT_EQ(6, info.selectionEnd); | 973 EXPECT_EQ(6, info.selectionEnd); |
| 988 EXPECT_EQ(3, info.compositionStart); | 974 EXPECT_EQ(3, info.compositionStart); |
| 989 EXPECT_EQ(8, info.compositionEnd); | 975 EXPECT_EQ(8, info.compositionEnd); |
| 990 | 976 |
| 991 activeInputMethodController->finishComposingText( | 977 activeInputMethodController->finishComposingText( |
| 992 WebInputMethodController::DoNotKeepSelection); | 978 WebInputMethodController::DoNotKeepSelection); |
| 993 info = activeInputMethodController->textInputInfo(); | 979 info = webView->textInputInfo(); |
| 994 EXPECT_EQ(8, info.selectionStart); | 980 EXPECT_EQ(8, info.selectionStart); |
| 995 EXPECT_EQ(8, info.selectionEnd); | 981 EXPECT_EQ(8, info.selectionEnd); |
| 996 EXPECT_EQ(-1, info.compositionStart); | 982 EXPECT_EQ(-1, info.compositionStart); |
| 997 EXPECT_EQ(-1, info.compositionEnd); | 983 EXPECT_EQ(-1, info.compositionEnd); |
| 998 } | 984 } |
| 999 | 985 |
| 1000 TEST_P(WebViewTest, SetCompositionForNewCaretPositions) { | 986 TEST_P(WebViewTest, SetCompositionForNewCaretPositions) { |
| 1001 URLTestHelpers::registerMockedURLFromBaseURL( | 987 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1002 WebString::fromUTF8(m_baseURL.c_str()), | 988 WebString::fromUTF8(m_baseURL.c_str()), |
| 1003 WebString::fromUTF8("input_field_populated.html")); | 989 WebString::fromUTF8("input_field_populated.html")); |
| 1004 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 990 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
| 1005 m_baseURL + "input_field_populated.html"); | 991 m_baseURL + "input_field_populated.html"); |
| 1006 webView->setInitialFocus(false); | 992 webView->setInitialFocus(false); |
| 1007 WebInputMethodController* activeInputMethodController = | 993 WebInputMethodController* activeInputMethodController = |
| 1008 webView->mainFrameImpl() | 994 webView->mainFrameImpl() |
| 1009 ->frameWidget() | 995 ->frameWidget() |
| 1010 ->getActiveWebInputMethodController(); | 996 ->getActiveWebInputMethodController(); |
| 1011 | 997 |
| 1012 activeInputMethodController->commitText("hello", 0); | 998 activeInputMethodController->commitText("hello", 0); |
| 1013 activeInputMethodController->commitText("world", -5); | 999 activeInputMethodController->commitText("world", -5); |
| 1014 WebTextInputInfo info = activeInputMethodController->textInputInfo(); | 1000 WebTextInputInfo info = webView->textInputInfo(); |
| 1015 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 1001 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
| 1016 EXPECT_EQ(5, info.selectionStart); | 1002 EXPECT_EQ(5, info.selectionStart); |
| 1017 EXPECT_EQ(5, info.selectionEnd); | 1003 EXPECT_EQ(5, info.selectionEnd); |
| 1018 EXPECT_EQ(-1, info.compositionStart); | 1004 EXPECT_EQ(-1, info.compositionStart); |
| 1019 EXPECT_EQ(-1, info.compositionEnd); | 1005 EXPECT_EQ(-1, info.compositionEnd); |
| 1020 | 1006 |
| 1021 WebVector<WebCompositionUnderline> emptyUnderlines; | 1007 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1022 // Set up a composition that needs to be committed. | 1008 // Set up a composition that needs to be committed. |
| 1023 std::string compositionText("ABC"); | 1009 std::string compositionText("ABC"); |
| 1024 | 1010 |
| 1025 // Caret is on the left of composing text. | 1011 // Caret is on the left of composing text. |
| 1026 activeInputMethodController->setComposition( | 1012 activeInputMethodController->setComposition( |
| 1027 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0, 0); | 1013 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0, 0); |
| 1028 info = activeInputMethodController->textInputInfo(); | 1014 info = webView->textInputInfo(); |
| 1029 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1015 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 1030 EXPECT_EQ(5, info.selectionStart); | 1016 EXPECT_EQ(5, info.selectionStart); |
| 1031 EXPECT_EQ(5, info.selectionEnd); | 1017 EXPECT_EQ(5, info.selectionEnd); |
| 1032 EXPECT_EQ(5, info.compositionStart); | 1018 EXPECT_EQ(5, info.compositionStart); |
| 1033 EXPECT_EQ(8, info.compositionEnd); | 1019 EXPECT_EQ(8, info.compositionEnd); |
| 1034 | 1020 |
| 1035 // Caret is on the right of composing text. | 1021 // Caret is on the right of composing text. |
| 1036 activeInputMethodController->setComposition( | 1022 activeInputMethodController->setComposition( |
| 1037 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3); | 1023 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3); |
| 1038 info = activeInputMethodController->textInputInfo(); | 1024 info = webView->textInputInfo(); |
| 1039 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1025 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 1040 EXPECT_EQ(8, info.selectionStart); | 1026 EXPECT_EQ(8, info.selectionStart); |
| 1041 EXPECT_EQ(8, info.selectionEnd); | 1027 EXPECT_EQ(8, info.selectionEnd); |
| 1042 EXPECT_EQ(5, info.compositionStart); | 1028 EXPECT_EQ(5, info.compositionStart); |
| 1043 EXPECT_EQ(8, info.compositionEnd); | 1029 EXPECT_EQ(8, info.compositionEnd); |
| 1044 | 1030 |
| 1045 // Caret is between composing text and left boundary. | 1031 // Caret is between composing text and left boundary. |
| 1046 activeInputMethodController->setComposition( | 1032 activeInputMethodController->setComposition( |
| 1047 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -2, -2); | 1033 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -2, -2); |
| 1048 info = activeInputMethodController->textInputInfo(); | 1034 info = webView->textInputInfo(); |
| 1049 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1035 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 1050 EXPECT_EQ(3, info.selectionStart); | 1036 EXPECT_EQ(3, info.selectionStart); |
| 1051 EXPECT_EQ(3, info.selectionEnd); | 1037 EXPECT_EQ(3, info.selectionEnd); |
| 1052 EXPECT_EQ(5, info.compositionStart); | 1038 EXPECT_EQ(5, info.compositionStart); |
| 1053 EXPECT_EQ(8, info.compositionEnd); | 1039 EXPECT_EQ(8, info.compositionEnd); |
| 1054 | 1040 |
| 1055 // Caret is between composing text and right boundary. | 1041 // Caret is between composing text and right boundary. |
| 1056 activeInputMethodController->setComposition( | 1042 activeInputMethodController->setComposition( |
| 1057 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 5, 5); | 1043 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 5, 5); |
| 1058 info = activeInputMethodController->textInputInfo(); | 1044 info = webView->textInputInfo(); |
| 1059 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1045 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 1060 EXPECT_EQ(10, info.selectionStart); | 1046 EXPECT_EQ(10, info.selectionStart); |
| 1061 EXPECT_EQ(10, info.selectionEnd); | 1047 EXPECT_EQ(10, info.selectionEnd); |
| 1062 EXPECT_EQ(5, info.compositionStart); | 1048 EXPECT_EQ(5, info.compositionStart); |
| 1063 EXPECT_EQ(8, info.compositionEnd); | 1049 EXPECT_EQ(8, info.compositionEnd); |
| 1064 | 1050 |
| 1065 // Caret is on the left boundary. | 1051 // Caret is on the left boundary. |
| 1066 activeInputMethodController->setComposition( | 1052 activeInputMethodController->setComposition( |
| 1067 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -5, -5); | 1053 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -5, -5); |
| 1068 info = activeInputMethodController->textInputInfo(); | 1054 info = webView->textInputInfo(); |
| 1069 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1055 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 1070 EXPECT_EQ(0, info.selectionStart); | 1056 EXPECT_EQ(0, info.selectionStart); |
| 1071 EXPECT_EQ(0, info.selectionEnd); | 1057 EXPECT_EQ(0, info.selectionEnd); |
| 1072 EXPECT_EQ(5, info.compositionStart); | 1058 EXPECT_EQ(5, info.compositionStart); |
| 1073 EXPECT_EQ(8, info.compositionEnd); | 1059 EXPECT_EQ(8, info.compositionEnd); |
| 1074 | 1060 |
| 1075 // Caret is on the right boundary. | 1061 // Caret is on the right boundary. |
| 1076 activeInputMethodController->setComposition( | 1062 activeInputMethodController->setComposition( |
| 1077 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 8, 8); | 1063 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 8, 8); |
| 1078 info = activeInputMethodController->textInputInfo(); | 1064 info = webView->textInputInfo(); |
| 1079 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1065 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 1080 EXPECT_EQ(13, info.selectionStart); | 1066 EXPECT_EQ(13, info.selectionStart); |
| 1081 EXPECT_EQ(13, info.selectionEnd); | 1067 EXPECT_EQ(13, info.selectionEnd); |
| 1082 EXPECT_EQ(5, info.compositionStart); | 1068 EXPECT_EQ(5, info.compositionStart); |
| 1083 EXPECT_EQ(8, info.compositionEnd); | 1069 EXPECT_EQ(8, info.compositionEnd); |
| 1084 | 1070 |
| 1085 // Caret exceeds the left boundary. | 1071 // Caret exceeds the left boundary. |
| 1086 activeInputMethodController->setComposition( | 1072 activeInputMethodController->setComposition( |
| 1087 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -100, | 1073 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -100, |
| 1088 -100); | 1074 -100); |
| 1089 info = activeInputMethodController->textInputInfo(); | 1075 info = webView->textInputInfo(); |
| 1090 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1076 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 1091 EXPECT_EQ(0, info.selectionStart); | 1077 EXPECT_EQ(0, info.selectionStart); |
| 1092 EXPECT_EQ(0, info.selectionEnd); | 1078 EXPECT_EQ(0, info.selectionEnd); |
| 1093 EXPECT_EQ(5, info.compositionStart); | 1079 EXPECT_EQ(5, info.compositionStart); |
| 1094 EXPECT_EQ(8, info.compositionEnd); | 1080 EXPECT_EQ(8, info.compositionEnd); |
| 1095 | 1081 |
| 1096 // Caret exceeds the right boundary. | 1082 // Caret exceeds the right boundary. |
| 1097 activeInputMethodController->setComposition( | 1083 activeInputMethodController->setComposition( |
| 1098 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 100, 100); | 1084 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 100, 100); |
| 1099 info = activeInputMethodController->textInputInfo(); | 1085 info = webView->textInputInfo(); |
| 1100 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1086 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 1101 EXPECT_EQ(13, info.selectionStart); | 1087 EXPECT_EQ(13, info.selectionStart); |
| 1102 EXPECT_EQ(13, info.selectionEnd); | 1088 EXPECT_EQ(13, info.selectionEnd); |
| 1103 EXPECT_EQ(5, info.compositionStart); | 1089 EXPECT_EQ(5, info.compositionStart); |
| 1104 EXPECT_EQ(8, info.compositionEnd); | 1090 EXPECT_EQ(8, info.compositionEnd); |
| 1105 } | 1091 } |
| 1106 | 1092 |
| 1107 TEST_P(WebViewTest, SetCompositionWithEmptyText) { | 1093 TEST_P(WebViewTest, SetCompositionWithEmptyText) { |
| 1108 URLTestHelpers::registerMockedURLFromBaseURL( | 1094 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1109 WebString::fromUTF8(m_baseURL.c_str()), | 1095 WebString::fromUTF8(m_baseURL.c_str()), |
| 1110 WebString::fromUTF8("input_field_populated.html")); | 1096 WebString::fromUTF8("input_field_populated.html")); |
| 1111 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 1097 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
| 1112 m_baseURL + "input_field_populated.html"); | 1098 m_baseURL + "input_field_populated.html"); |
| 1113 webView->setInitialFocus(false); | 1099 webView->setInitialFocus(false); |
| 1114 WebInputMethodController* activeInputMethodController = | 1100 WebInputMethodController* activeInputMethodController = |
| 1115 webView->mainFrameImpl() | 1101 webView->mainFrameImpl() |
| 1116 ->frameWidget() | 1102 ->frameWidget() |
| 1117 ->getActiveWebInputMethodController(); | 1103 ->getActiveWebInputMethodController(); |
| 1118 | 1104 |
| 1119 activeInputMethodController->commitText("hello", 0); | 1105 activeInputMethodController->commitText("hello", 0); |
| 1120 WebTextInputInfo info = activeInputMethodController->textInputInfo(); | 1106 WebTextInputInfo info = webView->textInputInfo(); |
| 1121 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1107 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 1122 EXPECT_EQ(5, info.selectionStart); | 1108 EXPECT_EQ(5, info.selectionStart); |
| 1123 EXPECT_EQ(5, info.selectionEnd); | 1109 EXPECT_EQ(5, info.selectionEnd); |
| 1124 EXPECT_EQ(-1, info.compositionStart); | 1110 EXPECT_EQ(-1, info.compositionStart); |
| 1125 EXPECT_EQ(-1, info.compositionEnd); | 1111 EXPECT_EQ(-1, info.compositionEnd); |
| 1126 | 1112 |
| 1127 WebVector<WebCompositionUnderline> emptyUnderlines; | 1113 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1128 | 1114 |
| 1129 activeInputMethodController->setComposition(WebString::fromUTF8(""), | 1115 activeInputMethodController->setComposition(WebString::fromUTF8(""), |
| 1130 emptyUnderlines, 0, 0); | 1116 emptyUnderlines, 0, 0); |
| 1131 info = activeInputMethodController->textInputInfo(); | 1117 info = webView->textInputInfo(); |
| 1132 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1118 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 1133 EXPECT_EQ(5, info.selectionStart); | 1119 EXPECT_EQ(5, info.selectionStart); |
| 1134 EXPECT_EQ(5, info.selectionEnd); | 1120 EXPECT_EQ(5, info.selectionEnd); |
| 1135 EXPECT_EQ(-1, info.compositionStart); | 1121 EXPECT_EQ(-1, info.compositionStart); |
| 1136 EXPECT_EQ(-1, info.compositionEnd); | 1122 EXPECT_EQ(-1, info.compositionEnd); |
| 1137 | 1123 |
| 1138 activeInputMethodController->setComposition(WebString::fromUTF8(""), | 1124 activeInputMethodController->setComposition(WebString::fromUTF8(""), |
| 1139 emptyUnderlines, -2, -2); | 1125 emptyUnderlines, -2, -2); |
| 1140 info = activeInputMethodController->textInputInfo(); | 1126 info = webView->textInputInfo(); |
| 1141 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1127 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 1142 EXPECT_EQ(3, info.selectionStart); | 1128 EXPECT_EQ(3, info.selectionStart); |
| 1143 EXPECT_EQ(3, info.selectionEnd); | 1129 EXPECT_EQ(3, info.selectionEnd); |
| 1144 EXPECT_EQ(-1, info.compositionStart); | 1130 EXPECT_EQ(-1, info.compositionStart); |
| 1145 EXPECT_EQ(-1, info.compositionEnd); | 1131 EXPECT_EQ(-1, info.compositionEnd); |
| 1146 } | 1132 } |
| 1147 | 1133 |
| 1148 TEST_P(WebViewTest, CommitTextForNewCaretPositions) { | 1134 TEST_P(WebViewTest, CommitTextForNewCaretPositions) { |
| 1149 URLTestHelpers::registerMockedURLFromBaseURL( | 1135 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1150 WebString::fromUTF8(m_baseURL.c_str()), | 1136 WebString::fromUTF8(m_baseURL.c_str()), |
| 1151 WebString::fromUTF8("input_field_populated.html")); | 1137 WebString::fromUTF8("input_field_populated.html")); |
| 1152 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 1138 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
| 1153 m_baseURL + "input_field_populated.html"); | 1139 m_baseURL + "input_field_populated.html"); |
| 1154 webView->setInitialFocus(false); | 1140 webView->setInitialFocus(false); |
| 1155 WebInputMethodController* activeInputMethodController = | 1141 WebInputMethodController* activeInputMethodController = |
| 1156 webView->mainFrameImpl() | 1142 webView->mainFrameImpl() |
| 1157 ->frameWidget() | 1143 ->frameWidget() |
| 1158 ->getActiveWebInputMethodController(); | 1144 ->getActiveWebInputMethodController(); |
| 1159 | 1145 |
| 1160 // Caret is on the left of composing text. | 1146 // Caret is on the left of composing text. |
| 1161 activeInputMethodController->commitText("ab", -2); | 1147 activeInputMethodController->commitText("ab", -2); |
| 1162 WebTextInputInfo info = activeInputMethodController->textInputInfo(); | 1148 WebTextInputInfo info = webView->textInputInfo(); |
| 1163 EXPECT_EQ("ab", std::string(info.value.utf8().data())); | 1149 EXPECT_EQ("ab", std::string(info.value.utf8().data())); |
| 1164 EXPECT_EQ(0, info.selectionStart); | 1150 EXPECT_EQ(0, info.selectionStart); |
| 1165 EXPECT_EQ(0, info.selectionEnd); | 1151 EXPECT_EQ(0, info.selectionEnd); |
| 1166 EXPECT_EQ(-1, info.compositionStart); | 1152 EXPECT_EQ(-1, info.compositionStart); |
| 1167 EXPECT_EQ(-1, info.compositionEnd); | 1153 EXPECT_EQ(-1, info.compositionEnd); |
| 1168 | 1154 |
| 1169 // Caret is on the right of composing text. | 1155 // Caret is on the right of composing text. |
| 1170 activeInputMethodController->commitText("c", 1); | 1156 activeInputMethodController->commitText("c", 1); |
| 1171 info = activeInputMethodController->textInputInfo(); | 1157 info = webView->textInputInfo(); |
| 1172 EXPECT_EQ("cab", std::string(info.value.utf8().data())); | 1158 EXPECT_EQ("cab", std::string(info.value.utf8().data())); |
| 1173 EXPECT_EQ(2, info.selectionStart); | 1159 EXPECT_EQ(2, info.selectionStart); |
| 1174 EXPECT_EQ(2, info.selectionEnd); | 1160 EXPECT_EQ(2, info.selectionEnd); |
| 1175 EXPECT_EQ(-1, info.compositionStart); | 1161 EXPECT_EQ(-1, info.compositionStart); |
| 1176 EXPECT_EQ(-1, info.compositionEnd); | 1162 EXPECT_EQ(-1, info.compositionEnd); |
| 1177 | 1163 |
| 1178 // Caret is on the left boundary. | 1164 // Caret is on the left boundary. |
| 1179 activeInputMethodController->commitText("def", -5); | 1165 activeInputMethodController->commitText("def", -5); |
| 1180 info = activeInputMethodController->textInputInfo(); | 1166 info = webView->textInputInfo(); |
| 1181 EXPECT_EQ("cadefb", std::string(info.value.utf8().data())); | 1167 EXPECT_EQ("cadefb", std::string(info.value.utf8().data())); |
| 1182 EXPECT_EQ(0, info.selectionStart); | 1168 EXPECT_EQ(0, info.selectionStart); |
| 1183 EXPECT_EQ(0, info.selectionEnd); | 1169 EXPECT_EQ(0, info.selectionEnd); |
| 1184 EXPECT_EQ(-1, info.compositionStart); | 1170 EXPECT_EQ(-1, info.compositionStart); |
| 1185 EXPECT_EQ(-1, info.compositionEnd); | 1171 EXPECT_EQ(-1, info.compositionEnd); |
| 1186 | 1172 |
| 1187 // Caret is on the right boundary. | 1173 // Caret is on the right boundary. |
| 1188 activeInputMethodController->commitText("g", 6); | 1174 activeInputMethodController->commitText("g", 6); |
| 1189 info = activeInputMethodController->textInputInfo(); | 1175 info = webView->textInputInfo(); |
| 1190 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data())); | 1176 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data())); |
| 1191 EXPECT_EQ(7, info.selectionStart); | 1177 EXPECT_EQ(7, info.selectionStart); |
| 1192 EXPECT_EQ(7, info.selectionEnd); | 1178 EXPECT_EQ(7, info.selectionEnd); |
| 1193 EXPECT_EQ(-1, info.compositionStart); | 1179 EXPECT_EQ(-1, info.compositionStart); |
| 1194 EXPECT_EQ(-1, info.compositionEnd); | 1180 EXPECT_EQ(-1, info.compositionEnd); |
| 1195 | 1181 |
| 1196 // Caret exceeds the left boundary. | 1182 // Caret exceeds the left boundary. |
| 1197 activeInputMethodController->commitText("hi", -100); | 1183 activeInputMethodController->commitText("hi", -100); |
| 1198 info = activeInputMethodController->textInputInfo(); | 1184 info = webView->textInputInfo(); |
| 1199 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data())); | 1185 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data())); |
| 1200 EXPECT_EQ(0, info.selectionStart); | 1186 EXPECT_EQ(0, info.selectionStart); |
| 1201 EXPECT_EQ(0, info.selectionEnd); | 1187 EXPECT_EQ(0, info.selectionEnd); |
| 1202 EXPECT_EQ(-1, info.compositionStart); | 1188 EXPECT_EQ(-1, info.compositionStart); |
| 1203 EXPECT_EQ(-1, info.compositionEnd); | 1189 EXPECT_EQ(-1, info.compositionEnd); |
| 1204 | 1190 |
| 1205 // Caret exceeds the right boundary. | 1191 // Caret exceeds the right boundary. |
| 1206 activeInputMethodController->commitText("jk", 100); | 1192 activeInputMethodController->commitText("jk", 100); |
| 1207 info = activeInputMethodController->textInputInfo(); | 1193 info = webView->textInputInfo(); |
| 1208 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); | 1194 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); |
| 1209 EXPECT_EQ(11, info.selectionStart); | 1195 EXPECT_EQ(11, info.selectionStart); |
| 1210 EXPECT_EQ(11, info.selectionEnd); | 1196 EXPECT_EQ(11, info.selectionEnd); |
| 1211 EXPECT_EQ(-1, info.compositionStart); | 1197 EXPECT_EQ(-1, info.compositionStart); |
| 1212 EXPECT_EQ(-1, info.compositionEnd); | 1198 EXPECT_EQ(-1, info.compositionEnd); |
| 1213 } | 1199 } |
| 1214 | 1200 |
| 1215 TEST_P(WebViewTest, CommitTextWhileComposing) { | 1201 TEST_P(WebViewTest, CommitTextWhileComposing) { |
| 1216 URLTestHelpers::registerMockedURLFromBaseURL( | 1202 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1217 WebString::fromUTF8(m_baseURL.c_str()), | 1203 WebString::fromUTF8(m_baseURL.c_str()), |
| 1218 WebString::fromUTF8("input_field_populated.html")); | 1204 WebString::fromUTF8("input_field_populated.html")); |
| 1219 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 1205 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
| 1220 m_baseURL + "input_field_populated.html"); | 1206 m_baseURL + "input_field_populated.html"); |
| 1221 webView->setInitialFocus(false); | 1207 webView->setInitialFocus(false); |
| 1222 WebInputMethodController* activeInputMethodController = | 1208 WebInputMethodController* activeInputMethodController = |
| 1223 webView->mainFrameImpl() | 1209 webView->mainFrameImpl() |
| 1224 ->frameWidget() | 1210 ->frameWidget() |
| 1225 ->getActiveWebInputMethodController(); | 1211 ->getActiveWebInputMethodController(); |
| 1226 | 1212 |
| 1227 WebVector<WebCompositionUnderline> emptyUnderlines; | 1213 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1228 activeInputMethodController->setComposition(WebString::fromUTF8("abc"), | 1214 activeInputMethodController->setComposition(WebString::fromUTF8("abc"), |
| 1229 emptyUnderlines, 0, 0); | 1215 emptyUnderlines, 0, 0); |
| 1230 WebTextInputInfo info = activeInputMethodController->textInputInfo(); | 1216 WebTextInputInfo info = webView->textInputInfo(); |
| 1231 EXPECT_EQ("abc", std::string(info.value.utf8().data())); | 1217 EXPECT_EQ("abc", std::string(info.value.utf8().data())); |
| 1232 EXPECT_EQ(0, info.selectionStart); | 1218 EXPECT_EQ(0, info.selectionStart); |
| 1233 EXPECT_EQ(0, info.selectionEnd); | 1219 EXPECT_EQ(0, info.selectionEnd); |
| 1234 EXPECT_EQ(0, info.compositionStart); | 1220 EXPECT_EQ(0, info.compositionStart); |
| 1235 EXPECT_EQ(3, info.compositionEnd); | 1221 EXPECT_EQ(3, info.compositionEnd); |
| 1236 | 1222 |
| 1237 // Deletes ongoing composition, inserts the specified text and moves the | 1223 // Deletes ongoing composition, inserts the specified text and moves the |
| 1238 // caret. | 1224 // caret. |
| 1239 activeInputMethodController->commitText("hello", -2); | 1225 activeInputMethodController->commitText("hello", -2); |
| 1240 info = activeInputMethodController->textInputInfo(); | 1226 info = webView->textInputInfo(); |
| 1241 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1227 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 1242 EXPECT_EQ(3, info.selectionStart); | 1228 EXPECT_EQ(3, info.selectionStart); |
| 1243 EXPECT_EQ(3, info.selectionEnd); | 1229 EXPECT_EQ(3, info.selectionEnd); |
| 1244 EXPECT_EQ(-1, info.compositionStart); | 1230 EXPECT_EQ(-1, info.compositionStart); |
| 1245 EXPECT_EQ(-1, info.compositionEnd); | 1231 EXPECT_EQ(-1, info.compositionEnd); |
| 1246 | 1232 |
| 1247 activeInputMethodController->setComposition(WebString::fromUTF8("abc"), | 1233 activeInputMethodController->setComposition(WebString::fromUTF8("abc"), |
| 1248 emptyUnderlines, 0, 0); | 1234 emptyUnderlines, 0, 0); |
| 1249 info = activeInputMethodController->textInputInfo(); | 1235 info = webView->textInputInfo(); |
| 1250 EXPECT_EQ("helabclo", std::string(info.value.utf8().data())); | 1236 EXPECT_EQ("helabclo", std::string(info.value.utf8().data())); |
| 1251 EXPECT_EQ(3, info.selectionStart); | 1237 EXPECT_EQ(3, info.selectionStart); |
| 1252 EXPECT_EQ(3, info.selectionEnd); | 1238 EXPECT_EQ(3, info.selectionEnd); |
| 1253 EXPECT_EQ(3, info.compositionStart); | 1239 EXPECT_EQ(3, info.compositionStart); |
| 1254 EXPECT_EQ(6, info.compositionEnd); | 1240 EXPECT_EQ(6, info.compositionEnd); |
| 1255 | 1241 |
| 1256 // Deletes ongoing composition and moves the caret. | 1242 // Deletes ongoing composition and moves the caret. |
| 1257 activeInputMethodController->commitText("", 2); | 1243 activeInputMethodController->commitText("", 2); |
| 1258 info = activeInputMethodController->textInputInfo(); | 1244 info = webView->textInputInfo(); |
| 1259 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1245 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 1260 EXPECT_EQ(5, info.selectionStart); | 1246 EXPECT_EQ(5, info.selectionStart); |
| 1261 EXPECT_EQ(5, info.selectionEnd); | 1247 EXPECT_EQ(5, info.selectionEnd); |
| 1262 EXPECT_EQ(-1, info.compositionStart); | 1248 EXPECT_EQ(-1, info.compositionStart); |
| 1263 EXPECT_EQ(-1, info.compositionEnd); | 1249 EXPECT_EQ(-1, info.compositionEnd); |
| 1264 | 1250 |
| 1265 // Inserts the specified text and moves the caret. | 1251 // Inserts the specified text and moves the caret. |
| 1266 activeInputMethodController->commitText("world", -5); | 1252 activeInputMethodController->commitText("world", -5); |
| 1267 info = activeInputMethodController->textInputInfo(); | 1253 info = webView->textInputInfo(); |
| 1268 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 1254 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
| 1269 EXPECT_EQ(5, info.selectionStart); | 1255 EXPECT_EQ(5, info.selectionStart); |
| 1270 EXPECT_EQ(5, info.selectionEnd); | 1256 EXPECT_EQ(5, info.selectionEnd); |
| 1271 EXPECT_EQ(-1, info.compositionStart); | 1257 EXPECT_EQ(-1, info.compositionStart); |
| 1272 EXPECT_EQ(-1, info.compositionEnd); | 1258 EXPECT_EQ(-1, info.compositionEnd); |
| 1273 | 1259 |
| 1274 // Only moves the caret. | 1260 // Only moves the caret. |
| 1275 activeInputMethodController->commitText("", 5); | 1261 activeInputMethodController->commitText("", 5); |
| 1276 info = activeInputMethodController->textInputInfo(); | 1262 info = webView->textInputInfo(); |
| 1277 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 1263 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
| 1278 EXPECT_EQ(10, info.selectionStart); | 1264 EXPECT_EQ(10, info.selectionStart); |
| 1279 EXPECT_EQ(10, info.selectionEnd); | 1265 EXPECT_EQ(10, info.selectionEnd); |
| 1280 EXPECT_EQ(-1, info.compositionStart); | 1266 EXPECT_EQ(-1, info.compositionStart); |
| 1281 EXPECT_EQ(-1, info.compositionEnd); | 1267 EXPECT_EQ(-1, info.compositionEnd); |
| 1282 } | 1268 } |
| 1283 | 1269 |
| 1284 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) { | 1270 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) { |
| 1285 URLTestHelpers::registerMockedURLFromBaseURL( | 1271 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1286 WebString::fromUTF8(m_baseURL.c_str()), | 1272 WebString::fromUTF8(m_baseURL.c_str()), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1299 emptyUnderlines, 0, 3); | 1285 emptyUnderlines, 0, 3); |
| 1300 | 1286 |
| 1301 // Scroll the input field out of the viewport. | 1287 // Scroll the input field out of the viewport. |
| 1302 Element* element = static_cast<Element*>( | 1288 Element* element = static_cast<Element*>( |
| 1303 webView->mainFrame()->document().getElementById("btn")); | 1289 webView->mainFrame()->document().getElementById("btn")); |
| 1304 element->scrollIntoView(); | 1290 element->scrollIntoView(); |
| 1305 float offsetHeight = webView->mainFrame()->getScrollOffset().height; | 1291 float offsetHeight = webView->mainFrame()->getScrollOffset().height; |
| 1306 EXPECT_EQ(0, webView->mainFrame()->getScrollOffset().width); | 1292 EXPECT_EQ(0, webView->mainFrame()->getScrollOffset().width); |
| 1307 EXPECT_LT(0, offsetHeight); | 1293 EXPECT_LT(0, offsetHeight); |
| 1308 | 1294 |
| 1309 WebTextInputInfo info = frame->inputMethodController()->textInputInfo(); | 1295 WebTextInputInfo info = webView->textInputInfo(); |
| 1310 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1296 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 1311 | 1297 |
| 1312 // Verify that the input field is not scrolled back into the viewport. | 1298 // Verify that the input field is not scrolled back into the viewport. |
| 1313 frame->frameWidget() | 1299 frame->frameWidget() |
| 1314 ->getActiveWebInputMethodController() | 1300 ->getActiveWebInputMethodController() |
| 1315 ->finishComposingText(WebInputMethodController::DoNotKeepSelection); | 1301 ->finishComposingText(WebInputMethodController::DoNotKeepSelection); |
| 1316 EXPECT_EQ(0, webView->mainFrame()->getScrollOffset().width); | 1302 EXPECT_EQ(0, webView->mainFrame()->getScrollOffset().width); |
| 1317 EXPECT_EQ(offsetHeight, webView->mainFrame()->getScrollOffset().height); | 1303 EXPECT_EQ(offsetHeight, webView->mainFrame()->getScrollOffset().height); |
| 1318 } | 1304 } |
| 1319 | 1305 |
| 1320 TEST_P(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) { | 1306 TEST_P(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) { |
| 1321 URLTestHelpers::registerMockedURLFromBaseURL( | 1307 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1322 WebString::fromUTF8(m_baseURL.c_str()), | 1308 WebString::fromUTF8(m_baseURL.c_str()), |
| 1323 WebString::fromUTF8("text_area_populated.html")); | 1309 WebString::fromUTF8("text_area_populated.html")); |
| 1324 WebViewImpl* webView = | 1310 WebViewImpl* webView = |
| 1325 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); | 1311 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); |
| 1326 webView->setInitialFocus(false); | 1312 webView->setInitialFocus(false); |
| 1327 | 1313 |
| 1328 WebVector<WebCompositionUnderline> emptyUnderlines; | 1314 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1329 | 1315 |
| 1330 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1316 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1331 WebInputMethodController* activeInputMethodController = | |
| 1332 frame->inputMethodController(); | |
| 1333 frame->setEditableSelectionOffsets(4, 4); | 1317 frame->setEditableSelectionOffsets(4, 4); |
| 1334 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); | 1318 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
| 1335 | 1319 |
| 1336 WebTextInputInfo info = activeInputMethodController->textInputInfo(); | 1320 WebTextInputInfo info = webView->textInputInfo(); |
| 1337 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", | 1321 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", |
| 1338 std::string(info.value.utf8().data())); | 1322 std::string(info.value.utf8().data())); |
| 1339 EXPECT_EQ(4, info.selectionStart); | 1323 EXPECT_EQ(4, info.selectionStart); |
| 1340 EXPECT_EQ(4, info.selectionEnd); | 1324 EXPECT_EQ(4, info.selectionEnd); |
| 1341 EXPECT_EQ(8, info.compositionStart); | 1325 EXPECT_EQ(8, info.compositionStart); |
| 1342 EXPECT_EQ(12, info.compositionEnd); | 1326 EXPECT_EQ(12, info.compositionEnd); |
| 1343 | 1327 |
| 1328 WebInputMethodController* activeInputMethodController = |
| 1329 frame->frameWidget()->getActiveWebInputMethodController(); |
| 1344 activeInputMethodController->finishComposingText( | 1330 activeInputMethodController->finishComposingText( |
| 1345 WebInputMethodController::KeepSelection); | 1331 WebInputMethodController::KeepSelection); |
| 1346 info = activeInputMethodController->textInputInfo(); | 1332 info = webView->textInputInfo(); |
| 1347 EXPECT_EQ(4, info.selectionStart); | 1333 EXPECT_EQ(4, info.selectionStart); |
| 1348 EXPECT_EQ(4, info.selectionEnd); | 1334 EXPECT_EQ(4, info.selectionEnd); |
| 1349 EXPECT_EQ(-1, info.compositionStart); | 1335 EXPECT_EQ(-1, info.compositionStart); |
| 1350 EXPECT_EQ(-1, info.compositionEnd); | 1336 EXPECT_EQ(-1, info.compositionEnd); |
| 1351 | 1337 |
| 1352 std::string compositionText("\n"); | 1338 std::string compositionText("\n"); |
| 1353 activeInputMethodController->commitText( | 1339 activeInputMethodController->commitText( |
| 1354 WebString::fromUTF8(compositionText.c_str()), 0); | 1340 WebString::fromUTF8(compositionText.c_str()), 0); |
| 1355 info = activeInputMethodController->textInputInfo(); | 1341 info = webView->textInputInfo(); |
| 1356 EXPECT_EQ(5, info.selectionStart); | 1342 EXPECT_EQ(5, info.selectionStart); |
| 1357 EXPECT_EQ(5, info.selectionEnd); | 1343 EXPECT_EQ(5, info.selectionEnd); |
| 1358 EXPECT_EQ(-1, info.compositionStart); | 1344 EXPECT_EQ(-1, info.compositionStart); |
| 1359 EXPECT_EQ(-1, info.compositionEnd); | 1345 EXPECT_EQ(-1, info.compositionEnd); |
| 1360 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", | 1346 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", |
| 1361 std::string(info.value.utf8().data())); | 1347 std::string(info.value.utf8().data())); |
| 1362 } | 1348 } |
| 1363 | 1349 |
| 1364 TEST_P(WebViewTest, ExtendSelectionAndDelete) { | 1350 TEST_P(WebViewTest, ExtendSelectionAndDelete) { |
| 1365 URLTestHelpers::registerMockedURLFromBaseURL( | 1351 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1366 WebString::fromUTF8(m_baseURL.c_str()), | 1352 WebString::fromUTF8(m_baseURL.c_str()), |
| 1367 WebString::fromUTF8("input_field_populated.html")); | 1353 WebString::fromUTF8("input_field_populated.html")); |
| 1368 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 1354 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
| 1369 m_baseURL + "input_field_populated.html"); | 1355 m_baseURL + "input_field_populated.html"); |
| 1370 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1356 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1371 webView->setInitialFocus(false); | 1357 webView->setInitialFocus(false); |
| 1372 frame->setEditableSelectionOffsets(10, 10); | 1358 frame->setEditableSelectionOffsets(10, 10); |
| 1373 frame->extendSelectionAndDelete(5, 8); | 1359 frame->extendSelectionAndDelete(5, 8); |
| 1374 WebInputMethodController* activeInputMethodController = | 1360 WebTextInputInfo info = webView->textInputInfo(); |
| 1375 frame->inputMethodController(); | |
| 1376 WebTextInputInfo info = activeInputMethodController->textInputInfo(); | |
| 1377 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); | 1361 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
| 1378 EXPECT_EQ(5, info.selectionStart); | 1362 EXPECT_EQ(5, info.selectionStart); |
| 1379 EXPECT_EQ(5, info.selectionEnd); | 1363 EXPECT_EQ(5, info.selectionEnd); |
| 1380 frame->extendSelectionAndDelete(10, 0); | 1364 frame->extendSelectionAndDelete(10, 0); |
| 1381 info = activeInputMethodController->textInputInfo(); | 1365 info = webView->textInputInfo(); |
| 1382 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); | 1366 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
| 1383 } | 1367 } |
| 1384 | 1368 |
| 1385 TEST_P(WebViewTest, DeleteSurroundingText) { | 1369 TEST_P(WebViewTest, DeleteSurroundingText) { |
| 1386 URLTestHelpers::registerMockedURLFromBaseURL( | 1370 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1387 WebString::fromUTF8(m_baseURL.c_str()), | 1371 WebString::fromUTF8(m_baseURL.c_str()), |
| 1388 WebString::fromUTF8("input_field_populated.html")); | 1372 WebString::fromUTF8("input_field_populated.html")); |
| 1389 WebView* webView = m_webViewHelper.initializeAndLoad( | 1373 WebView* webView = m_webViewHelper.initializeAndLoad( |
| 1390 m_baseURL + "input_field_populated.html"); | 1374 m_baseURL + "input_field_populated.html"); |
| 1391 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 1375 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); |
| 1392 WebInputMethodController* activeInputMethodController = | |
| 1393 frame->inputMethodController(); | |
| 1394 webView->setInitialFocus(false); | 1376 webView->setInitialFocus(false); |
| 1395 | 1377 |
| 1396 frame->setEditableSelectionOffsets(10, 10); | 1378 frame->setEditableSelectionOffsets(10, 10); |
| 1397 frame->deleteSurroundingText(5, 8); | 1379 frame->deleteSurroundingText(5, 8); |
| 1398 WebTextInputInfo info = activeInputMethodController->textInputInfo(); | 1380 WebTextInputInfo info = webView->textInputInfo(); |
| 1399 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); | 1381 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
| 1400 EXPECT_EQ(5, info.selectionStart); | 1382 EXPECT_EQ(5, info.selectionStart); |
| 1401 EXPECT_EQ(5, info.selectionEnd); | 1383 EXPECT_EQ(5, info.selectionEnd); |
| 1402 | 1384 |
| 1403 frame->setEditableSelectionOffsets(5, 10); | 1385 frame->setEditableSelectionOffsets(5, 10); |
| 1404 frame->deleteSurroundingText(3, 5); | 1386 frame->deleteSurroundingText(3, 5); |
| 1405 info = activeInputMethodController->textInputInfo(); | 1387 info = webView->textInputInfo(); |
| 1406 EXPECT_EQ("01ijklmstuvwxyz", std::string(info.value.utf8().data())); | 1388 EXPECT_EQ("01ijklmstuvwxyz", std::string(info.value.utf8().data())); |
| 1407 EXPECT_EQ(2, info.selectionStart); | 1389 EXPECT_EQ(2, info.selectionStart); |
| 1408 EXPECT_EQ(7, info.selectionEnd); | 1390 EXPECT_EQ(7, info.selectionEnd); |
| 1409 | 1391 |
| 1410 frame->setEditableSelectionOffsets(5, 5); | 1392 frame->setEditableSelectionOffsets(5, 5); |
| 1411 frame->deleteSurroundingText(10, 0); | 1393 frame->deleteSurroundingText(10, 0); |
| 1412 info = activeInputMethodController->textInputInfo(); | 1394 info = webView->textInputInfo(); |
| 1413 EXPECT_EQ("lmstuvwxyz", std::string(info.value.utf8().data())); | 1395 EXPECT_EQ("lmstuvwxyz", std::string(info.value.utf8().data())); |
| 1414 EXPECT_EQ(0, info.selectionStart); | 1396 EXPECT_EQ(0, info.selectionStart); |
| 1415 EXPECT_EQ(0, info.selectionEnd); | 1397 EXPECT_EQ(0, info.selectionEnd); |
| 1416 | 1398 |
| 1417 frame->deleteSurroundingText(0, 20); | 1399 frame->deleteSurroundingText(0, 20); |
| 1418 info = activeInputMethodController->textInputInfo(); | 1400 info = webView->textInputInfo(); |
| 1419 EXPECT_EQ("", std::string(info.value.utf8().data())); | 1401 EXPECT_EQ("", std::string(info.value.utf8().data())); |
| 1420 EXPECT_EQ(0, info.selectionStart); | 1402 EXPECT_EQ(0, info.selectionStart); |
| 1421 EXPECT_EQ(0, info.selectionEnd); | 1403 EXPECT_EQ(0, info.selectionEnd); |
| 1422 | 1404 |
| 1423 frame->deleteSurroundingText(10, 10); | 1405 frame->deleteSurroundingText(10, 10); |
| 1424 info = activeInputMethodController->textInputInfo(); | 1406 info = webView->textInputInfo(); |
| 1425 EXPECT_EQ("", std::string(info.value.utf8().data())); | 1407 EXPECT_EQ("", std::string(info.value.utf8().data())); |
| 1426 EXPECT_EQ(0, info.selectionStart); | 1408 EXPECT_EQ(0, info.selectionStart); |
| 1427 EXPECT_EQ(0, info.selectionEnd); | 1409 EXPECT_EQ(0, info.selectionEnd); |
| 1428 } | 1410 } |
| 1429 | 1411 |
| 1430 TEST_P(WebViewTest, SetCompositionFromExistingText) { | 1412 TEST_P(WebViewTest, SetCompositionFromExistingText) { |
| 1431 URLTestHelpers::registerMockedURLFromBaseURL( | 1413 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1432 WebString::fromUTF8(m_baseURL.c_str()), | 1414 WebString::fromUTF8(m_baseURL.c_str()), |
| 1433 WebString::fromUTF8("input_field_populated.html")); | 1415 WebString::fromUTF8("input_field_populated.html")); |
| 1434 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 1416 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
| 1435 m_baseURL + "input_field_populated.html"); | 1417 m_baseURL + "input_field_populated.html"); |
| 1436 webView->setInitialFocus(false); | 1418 webView->setInitialFocus(false); |
| 1437 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 1419 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 1438 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 1420 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
| 1439 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1421 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1440 WebInputMethodController* activeInputMethodController = | |
| 1441 frame->inputMethodController(); | |
| 1442 frame->setEditableSelectionOffsets(4, 10); | 1422 frame->setEditableSelectionOffsets(4, 10); |
| 1443 frame->setCompositionFromExistingText(8, 12, underlines); | 1423 frame->setCompositionFromExistingText(8, 12, underlines); |
| 1444 WebTextInputInfo info = activeInputMethodController->textInputInfo(); | 1424 WebTextInputInfo info = webView->textInputInfo(); |
| 1445 EXPECT_EQ(4, info.selectionStart); | 1425 EXPECT_EQ(4, info.selectionStart); |
| 1446 EXPECT_EQ(10, info.selectionEnd); | 1426 EXPECT_EQ(10, info.selectionEnd); |
| 1447 EXPECT_EQ(8, info.compositionStart); | 1427 EXPECT_EQ(8, info.compositionStart); |
| 1448 EXPECT_EQ(12, info.compositionEnd); | 1428 EXPECT_EQ(12, info.compositionEnd); |
| 1449 WebVector<WebCompositionUnderline> emptyUnderlines; | 1429 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1450 frame->setCompositionFromExistingText(0, 0, emptyUnderlines); | 1430 frame->setCompositionFromExistingText(0, 0, emptyUnderlines); |
| 1451 info = activeInputMethodController->textInputInfo(); | 1431 info = webView->textInputInfo(); |
| 1452 EXPECT_EQ(4, info.selectionStart); | 1432 EXPECT_EQ(4, info.selectionStart); |
| 1453 EXPECT_EQ(10, info.selectionEnd); | 1433 EXPECT_EQ(10, info.selectionEnd); |
| 1454 EXPECT_EQ(-1, info.compositionStart); | 1434 EXPECT_EQ(-1, info.compositionStart); |
| 1455 EXPECT_EQ(-1, info.compositionEnd); | 1435 EXPECT_EQ(-1, info.compositionEnd); |
| 1456 } | 1436 } |
| 1457 | 1437 |
| 1458 TEST_P(WebViewTest, SetCompositionFromExistingTextInTextArea) { | 1438 TEST_P(WebViewTest, SetCompositionFromExistingTextInTextArea) { |
| 1459 URLTestHelpers::registerMockedURLFromBaseURL( | 1439 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1460 WebString::fromUTF8(m_baseURL.c_str()), | 1440 WebString::fromUTF8(m_baseURL.c_str()), |
| 1461 WebString::fromUTF8("text_area_populated.html")); | 1441 WebString::fromUTF8("text_area_populated.html")); |
| 1462 WebViewImpl* webView = | 1442 WebViewImpl* webView = |
| 1463 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); | 1443 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); |
| 1464 webView->setInitialFocus(false); | 1444 webView->setInitialFocus(false); |
| 1465 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 1445 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 1466 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 1446 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
| 1467 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1447 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1468 WebInputMethodController* activeInputMethodController = | 1448 WebInputMethodController* activeInputMethodController = |
| 1469 frame->frameWidget()->getActiveWebInputMethodController(); | 1449 frame->frameWidget()->getActiveWebInputMethodController(); |
| 1470 frame->setEditableSelectionOffsets(27, 27); | 1450 frame->setEditableSelectionOffsets(27, 27); |
| 1471 std::string newLineText("\n"); | 1451 std::string newLineText("\n"); |
| 1472 activeInputMethodController->commitText( | 1452 activeInputMethodController->commitText( |
| 1473 WebString::fromUTF8(newLineText.c_str()), 0); | 1453 WebString::fromUTF8(newLineText.c_str()), 0); |
| 1474 WebTextInputInfo info = activeInputMethodController->textInputInfo(); | 1454 WebTextInputInfo info = webView->textInputInfo(); |
| 1475 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", | 1455 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", |
| 1476 std::string(info.value.utf8().data())); | 1456 std::string(info.value.utf8().data())); |
| 1477 | 1457 |
| 1478 frame->setEditableSelectionOffsets(31, 31); | 1458 frame->setEditableSelectionOffsets(31, 31); |
| 1479 frame->setCompositionFromExistingText(30, 34, underlines); | 1459 frame->setCompositionFromExistingText(30, 34, underlines); |
| 1480 info = activeInputMethodController->textInputInfo(); | 1460 info = webView->textInputInfo(); |
| 1481 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", | 1461 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", |
| 1482 std::string(info.value.utf8().data())); | 1462 std::string(info.value.utf8().data())); |
| 1483 EXPECT_EQ(31, info.selectionStart); | 1463 EXPECT_EQ(31, info.selectionStart); |
| 1484 EXPECT_EQ(31, info.selectionEnd); | 1464 EXPECT_EQ(31, info.selectionEnd); |
| 1485 EXPECT_EQ(30, info.compositionStart); | 1465 EXPECT_EQ(30, info.compositionStart); |
| 1486 EXPECT_EQ(34, info.compositionEnd); | 1466 EXPECT_EQ(34, info.compositionEnd); |
| 1487 | 1467 |
| 1488 std::string compositionText("yolo"); | 1468 std::string compositionText("yolo"); |
| 1489 activeInputMethodController->commitText( | 1469 activeInputMethodController->commitText( |
| 1490 WebString::fromUTF8(compositionText.c_str()), 0); | 1470 WebString::fromUTF8(compositionText.c_str()), 0); |
| 1491 info = activeInputMethodController->textInputInfo(); | 1471 info = webView->textInputInfo(); |
| 1492 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", | 1472 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", |
| 1493 std::string(info.value.utf8().data())); | 1473 std::string(info.value.utf8().data())); |
| 1494 EXPECT_EQ(34, info.selectionStart); | 1474 EXPECT_EQ(34, info.selectionStart); |
| 1495 EXPECT_EQ(34, info.selectionEnd); | 1475 EXPECT_EQ(34, info.selectionEnd); |
| 1496 EXPECT_EQ(-1, info.compositionStart); | 1476 EXPECT_EQ(-1, info.compositionStart); |
| 1497 EXPECT_EQ(-1, info.compositionEnd); | 1477 EXPECT_EQ(-1, info.compositionEnd); |
| 1498 } | 1478 } |
| 1499 | 1479 |
| 1500 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) { | 1480 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) { |
| 1501 URLTestHelpers::registerMockedURLFromBaseURL( | 1481 URLTestHelpers::registerMockedURLFromBaseURL( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1528 WebInputMethodController* activeInputMethodController = | 1508 WebInputMethodController* activeInputMethodController = |
| 1529 webView->mainFrameImpl() | 1509 webView->mainFrameImpl() |
| 1530 ->frameWidget() | 1510 ->frameWidget() |
| 1531 ->getActiveWebInputMethodController(); | 1511 ->getActiveWebInputMethodController(); |
| 1532 activeInputMethodController->commitText( | 1512 activeInputMethodController->commitText( |
| 1533 WebString::fromUTF8(compositionTextFirst.c_str()), 0); | 1513 WebString::fromUTF8(compositionTextFirst.c_str()), 0); |
| 1534 activeInputMethodController->setComposition( | 1514 activeInputMethodController->setComposition( |
| 1535 WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5, | 1515 WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5, |
| 1536 5); | 1516 5); |
| 1537 | 1517 |
| 1538 WebTextInputInfo info = activeInputMethodController->textInputInfo(); | 1518 WebTextInputInfo info = webView->textInputInfo(); |
| 1539 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1519 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 1540 EXPECT_EQ(11, info.selectionStart); | 1520 EXPECT_EQ(11, info.selectionStart); |
| 1541 EXPECT_EQ(11, info.selectionEnd); | 1521 EXPECT_EQ(11, info.selectionEnd); |
| 1542 EXPECT_EQ(6, info.compositionStart); | 1522 EXPECT_EQ(6, info.compositionStart); |
| 1543 EXPECT_EQ(11, info.compositionEnd); | 1523 EXPECT_EQ(11, info.compositionEnd); |
| 1544 | 1524 |
| 1545 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1525 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1546 frame->setEditableSelectionOffsets(6, 6); | 1526 frame->setEditableSelectionOffsets(6, 6); |
| 1547 info = activeInputMethodController->textInputInfo(); | 1527 info = webView->textInputInfo(); |
| 1548 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1528 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 1549 EXPECT_EQ(6, info.selectionStart); | 1529 EXPECT_EQ(6, info.selectionStart); |
| 1550 EXPECT_EQ(6, info.selectionEnd); | 1530 EXPECT_EQ(6, info.selectionEnd); |
| 1551 EXPECT_EQ(6, info.compositionStart); | 1531 EXPECT_EQ(6, info.compositionStart); |
| 1552 EXPECT_EQ(11, info.compositionEnd); | 1532 EXPECT_EQ(11, info.compositionEnd); |
| 1553 | 1533 |
| 1554 frame->setEditableSelectionOffsets(8, 8); | 1534 frame->setEditableSelectionOffsets(8, 8); |
| 1555 info = activeInputMethodController->textInputInfo(); | 1535 info = webView->textInputInfo(); |
| 1556 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1536 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 1557 EXPECT_EQ(8, info.selectionStart); | 1537 EXPECT_EQ(8, info.selectionStart); |
| 1558 EXPECT_EQ(8, info.selectionEnd); | 1538 EXPECT_EQ(8, info.selectionEnd); |
| 1559 EXPECT_EQ(6, info.compositionStart); | 1539 EXPECT_EQ(6, info.compositionStart); |
| 1560 EXPECT_EQ(11, info.compositionEnd); | 1540 EXPECT_EQ(11, info.compositionEnd); |
| 1561 | 1541 |
| 1562 frame->setEditableSelectionOffsets(11, 11); | 1542 frame->setEditableSelectionOffsets(11, 11); |
| 1563 info = activeInputMethodController->textInputInfo(); | 1543 info = webView->textInputInfo(); |
| 1564 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1544 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 1565 EXPECT_EQ(11, info.selectionStart); | 1545 EXPECT_EQ(11, info.selectionStart); |
| 1566 EXPECT_EQ(11, info.selectionEnd); | 1546 EXPECT_EQ(11, info.selectionEnd); |
| 1567 EXPECT_EQ(6, info.compositionStart); | 1547 EXPECT_EQ(6, info.compositionStart); |
| 1568 EXPECT_EQ(11, info.compositionEnd); | 1548 EXPECT_EQ(11, info.compositionEnd); |
| 1569 | 1549 |
| 1570 frame->setEditableSelectionOffsets(6, 11); | 1550 frame->setEditableSelectionOffsets(6, 11); |
| 1571 info = activeInputMethodController->textInputInfo(); | 1551 info = webView->textInputInfo(); |
| 1572 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1552 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 1573 EXPECT_EQ(6, info.selectionStart); | 1553 EXPECT_EQ(6, info.selectionStart); |
| 1574 EXPECT_EQ(11, info.selectionEnd); | 1554 EXPECT_EQ(11, info.selectionEnd); |
| 1575 EXPECT_EQ(6, info.compositionStart); | 1555 EXPECT_EQ(6, info.compositionStart); |
| 1576 EXPECT_EQ(11, info.compositionEnd); | 1556 EXPECT_EQ(11, info.compositionEnd); |
| 1577 | 1557 |
| 1578 frame->setEditableSelectionOffsets(2, 2); | 1558 frame->setEditableSelectionOffsets(2, 2); |
| 1579 info = activeInputMethodController->textInputInfo(); | 1559 info = webView->textInputInfo(); |
| 1580 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1560 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 1581 EXPECT_EQ(2, info.selectionStart); | 1561 EXPECT_EQ(2, info.selectionStart); |
| 1582 EXPECT_EQ(2, info.selectionEnd); | 1562 EXPECT_EQ(2, info.selectionEnd); |
| 1583 EXPECT_EQ(-1, info.compositionStart); | 1563 EXPECT_EQ(-1, info.compositionStart); |
| 1584 EXPECT_EQ(-1, info.compositionEnd); | 1564 EXPECT_EQ(-1, info.compositionEnd); |
| 1585 } | 1565 } |
| 1586 | 1566 |
| 1587 TEST_P(WebViewTest, IsSelectionAnchorFirst) { | 1567 TEST_P(WebViewTest, IsSelectionAnchorFirst) { |
| 1588 URLTestHelpers::registerMockedURLFromBaseURL( | 1568 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1589 WebString::fromUTF8(m_baseURL.c_str()), | 1569 WebString::fromUTF8(m_baseURL.c_str()), |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2738 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 2718 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
| 2739 m_baseURL + "input_field_populated.html"); | 2719 m_baseURL + "input_field_populated.html"); |
| 2740 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 2720 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 2741 frame->setAutofillClient(&client); | 2721 frame->setAutofillClient(&client); |
| 2742 webView->setInitialFocus(false); | 2722 webView->setInitialFocus(false); |
| 2743 | 2723 |
| 2744 // Set up a composition that needs to be committed. | 2724 // Set up a composition that needs to be committed. |
| 2745 WebVector<WebCompositionUnderline> emptyUnderlines; | 2725 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 2746 frame->setEditableSelectionOffsets(4, 10); | 2726 frame->setEditableSelectionOffsets(4, 10); |
| 2747 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); | 2727 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
| 2748 WebTextInputInfo info = frame->inputMethodController()->textInputInfo(); | 2728 WebTextInputInfo info = webView->textInputInfo(); |
| 2749 EXPECT_EQ(4, info.selectionStart); | 2729 EXPECT_EQ(4, info.selectionStart); |
| 2750 EXPECT_EQ(10, info.selectionEnd); | 2730 EXPECT_EQ(10, info.selectionEnd); |
| 2751 EXPECT_EQ(8, info.compositionStart); | 2731 EXPECT_EQ(8, info.compositionStart); |
| 2752 EXPECT_EQ(12, info.compositionEnd); | 2732 EXPECT_EQ(12, info.compositionEnd); |
| 2753 | 2733 |
| 2754 // Clear the focus and track that the subsequent composition commit does not | 2734 // Clear the focus and track that the subsequent composition commit does not |
| 2755 // trigger a text changed notification for autofill. | 2735 // trigger a text changed notification for autofill. |
| 2756 client.clearChangeCounts(); | 2736 client.clearChangeCounts(); |
| 2757 webView->setFocus(false); | 2737 webView->setFocus(false); |
| 2758 EXPECT_EQ(0, client.textChangesWhileNotIgnored()); | 2738 EXPECT_EQ(0, client.textChangesWhileNotIgnored()); |
| 2759 | 2739 |
| 2760 frame->setAutofillClient(0); | 2740 frame->setAutofillClient(0); |
| 2761 } | 2741 } |
| 2762 | 2742 |
| 2763 static void verifySelectionAndComposition(WebViewImpl* webView, | 2743 static void verifySelectionAndComposition(WebView* webView, |
| 2764 int selectionStart, | 2744 int selectionStart, |
| 2765 int selectionEnd, | 2745 int selectionEnd, |
| 2766 int compositionStart, | 2746 int compositionStart, |
| 2767 int compositionEnd, | 2747 int compositionEnd, |
| 2768 const char* failMessage) { | 2748 const char* failMessage) { |
| 2769 WebTextInputInfo info = | 2749 WebTextInputInfo info = webView->textInputInfo(); |
| 2770 webView->mainFrameImpl()->inputMethodController()->textInputInfo(); | |
| 2771 EXPECT_EQ(selectionStart, info.selectionStart) << failMessage; | 2750 EXPECT_EQ(selectionStart, info.selectionStart) << failMessage; |
| 2772 EXPECT_EQ(selectionEnd, info.selectionEnd) << failMessage; | 2751 EXPECT_EQ(selectionEnd, info.selectionEnd) << failMessage; |
| 2773 EXPECT_EQ(compositionStart, info.compositionStart) << failMessage; | 2752 EXPECT_EQ(compositionStart, info.compositionStart) << failMessage; |
| 2774 EXPECT_EQ(compositionEnd, info.compositionEnd) << failMessage; | 2753 EXPECT_EQ(compositionEnd, info.compositionEnd) << failMessage; |
| 2775 } | 2754 } |
| 2776 | 2755 |
| 2777 TEST_P(WebViewTest, CompositionNotCancelledByBackspace) { | 2756 TEST_P(WebViewTest, CompositionNotCancelledByBackspace) { |
| 2778 URLTestHelpers::registerMockedURLFromBaseURL( | 2757 URLTestHelpers::registerMockedURLFromBaseURL( |
| 2779 WebString::fromUTF8(m_baseURL.c_str()), | 2758 WebString::fromUTF8(m_baseURL.c_str()), |
| 2780 WebString::fromUTF8("composition_not_cancelled_by_backspace.html")); | 2759 WebString::fromUTF8("composition_not_cancelled_by_backspace.html")); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2834 WebInputMethodController* activeInputMethodController = | 2813 WebInputMethodController* activeInputMethodController = |
| 2835 frame->frameWidget()->getActiveWebInputMethodController(); | 2814 frame->frameWidget()->getActiveWebInputMethodController(); |
| 2836 // Set up a composition that needs to be committed. | 2815 // Set up a composition that needs to be committed. |
| 2837 std::string compositionText("testingtext"); | 2816 std::string compositionText("testingtext"); |
| 2838 | 2817 |
| 2839 WebVector<WebCompositionUnderline> emptyUnderlines; | 2818 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 2840 activeInputMethodController->setComposition( | 2819 activeInputMethodController->setComposition( |
| 2841 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0, | 2820 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0, |
| 2842 compositionText.length()); | 2821 compositionText.length()); |
| 2843 | 2822 |
| 2844 WebTextInputInfo info = activeInputMethodController->textInputInfo(); | 2823 WebTextInputInfo info = webView->textInputInfo(); |
| 2845 EXPECT_EQ(0, info.selectionStart); | 2824 EXPECT_EQ(0, info.selectionStart); |
| 2846 EXPECT_EQ((int)compositionText.length(), info.selectionEnd); | 2825 EXPECT_EQ((int)compositionText.length(), info.selectionEnd); |
| 2847 EXPECT_EQ(0, info.compositionStart); | 2826 EXPECT_EQ(0, info.compositionStart); |
| 2848 EXPECT_EQ((int)compositionText.length(), info.compositionEnd); | 2827 EXPECT_EQ((int)compositionText.length(), info.compositionEnd); |
| 2849 | 2828 |
| 2850 client.clearChangeCounts(); | 2829 client.clearChangeCounts(); |
| 2851 activeInputMethodController->finishComposingText( | 2830 activeInputMethodController->finishComposingText( |
| 2852 WebInputMethodController::KeepSelection); | 2831 WebInputMethodController::KeepSelection); |
| 2853 EXPECT_EQ(0, client.textChangesWhileIgnored()); | 2832 EXPECT_EQ(0, client.textChangesWhileIgnored()); |
| 2854 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); | 2833 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2865 m_baseURL + "input_field_populated.html", true); | 2844 m_baseURL + "input_field_populated.html", true); |
| 2866 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 2845 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 2867 frame->setAutofillClient(&client); | 2846 frame->setAutofillClient(&client); |
| 2868 webView->setInitialFocus(false); | 2847 webView->setInitialFocus(false); |
| 2869 | 2848 |
| 2870 WebVector<WebCompositionUnderline> emptyUnderlines; | 2849 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 2871 | 2850 |
| 2872 client.clearChangeCounts(); | 2851 client.clearChangeCounts(); |
| 2873 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); | 2852 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
| 2874 | 2853 |
| 2875 WebTextInputInfo info = frame->inputMethodController()->textInputInfo(); | 2854 WebTextInputInfo info = webView->textInputInfo(); |
| 2876 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", | 2855 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", |
| 2877 std::string(info.value.utf8().data())); | 2856 std::string(info.value.utf8().data())); |
| 2878 EXPECT_EQ(8, info.compositionStart); | 2857 EXPECT_EQ(8, info.compositionStart); |
| 2879 EXPECT_EQ(12, info.compositionEnd); | 2858 EXPECT_EQ(12, info.compositionEnd); |
| 2880 | 2859 |
| 2881 EXPECT_EQ(0, client.textChangesWhileIgnored()); | 2860 EXPECT_EQ(0, client.textChangesWhileIgnored()); |
| 2882 EXPECT_EQ(0, client.textChangesWhileNotIgnored()); | 2861 EXPECT_EQ(0, client.textChangesWhileNotIgnored()); |
| 2883 | 2862 |
| 2884 WebDocument document = webView->mainFrame()->document(); | 2863 WebDocument document = webView->mainFrame()->document(); |
| 2885 EXPECT_EQ(WebString::fromUTF8("none"), | 2864 EXPECT_EQ(WebString::fromUTF8("none"), |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3514 } | 3493 } |
| 3515 | 3494 |
| 3516 // This test verifies the text input flags are correctly exposed to script. | 3495 // This test verifies the text input flags are correctly exposed to script. |
| 3517 TEST_P(WebViewTest, TextInputFlags) { | 3496 TEST_P(WebViewTest, TextInputFlags) { |
| 3518 std::string url = m_baseURL + "text_input_flags.html"; | 3497 std::string url = m_baseURL + "text_input_flags.html"; |
| 3519 URLTestHelpers::registerMockedURLLoad(toKURL(url), "text_input_flags.html"); | 3498 URLTestHelpers::registerMockedURLLoad(toKURL(url), "text_input_flags.html"); |
| 3520 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true); | 3499 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true); |
| 3521 webViewImpl->setInitialFocus(false); | 3500 webViewImpl->setInitialFocus(false); |
| 3522 | 3501 |
| 3523 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); | 3502 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); |
| 3524 WebInputMethodControllerImpl* activeInputMethodController = | |
| 3525 frame->inputMethodController(); | |
| 3526 Document* document = frame->frame()->document(); | 3503 Document* document = frame->frame()->document(); |
| 3527 | 3504 |
| 3528 // (A) <input> | 3505 // (A) <input> |
| 3529 // (A.1) Verifies autocorrect/autocomplete/spellcheck flags are Off and | 3506 // (A.1) Verifies autocorrect/autocomplete/spellcheck flags are Off and |
| 3530 // autocapitalize is set to none. | 3507 // autocapitalize is set to none. |
| 3531 HTMLInputElement* inputElement = | 3508 HTMLInputElement* inputElement = |
| 3532 toHTMLInputElement(document->getElementById("input")); | 3509 toHTMLInputElement(document->getElementById("input")); |
| 3533 document->setFocusedElement( | 3510 document->setFocusedElement( |
| 3534 inputElement, | 3511 inputElement, |
| 3535 FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); | 3512 FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); |
| 3536 webViewImpl->setFocus(true); | 3513 webViewImpl->setFocus(true); |
| 3537 WebTextInputInfo info1 = activeInputMethodController->textInputInfo(); | 3514 WebTextInputInfo info1 = webViewImpl->textInputInfo(); |
| 3538 EXPECT_EQ(WebTextInputFlagAutocompleteOff | WebTextInputFlagAutocorrectOff | | 3515 EXPECT_EQ(WebTextInputFlagAutocompleteOff | WebTextInputFlagAutocorrectOff | |
| 3539 WebTextInputFlagSpellcheckOff | | 3516 WebTextInputFlagSpellcheckOff | |
| 3540 WebTextInputFlagAutocapitalizeNone, | 3517 WebTextInputFlagAutocapitalizeNone, |
| 3541 info1.flags); | 3518 info1.flags); |
| 3542 | 3519 |
| 3543 // (A.2) Verifies autocorrect/autocomplete/spellcheck flags are On and | 3520 // (A.2) Verifies autocorrect/autocomplete/spellcheck flags are On and |
| 3544 // autocapitalize is set to sentences. | 3521 // autocapitalize is set to sentences. |
| 3545 inputElement = toHTMLInputElement(document->getElementById("input2")); | 3522 inputElement = toHTMLInputElement(document->getElementById("input2")); |
| 3546 document->setFocusedElement( | 3523 document->setFocusedElement( |
| 3547 inputElement, | 3524 inputElement, |
| 3548 FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); | 3525 FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); |
| 3549 webViewImpl->setFocus(true); | 3526 webViewImpl->setFocus(true); |
| 3550 WebTextInputInfo info2 = activeInputMethodController->textInputInfo(); | 3527 WebTextInputInfo info2 = webViewImpl->textInputInfo(); |
| 3551 EXPECT_EQ(WebTextInputFlagAutocompleteOn | WebTextInputFlagAutocorrectOn | | 3528 EXPECT_EQ(WebTextInputFlagAutocompleteOn | WebTextInputFlagAutocorrectOn | |
| 3552 WebTextInputFlagSpellcheckOn | | 3529 WebTextInputFlagSpellcheckOn | |
| 3553 WebTextInputFlagAutocapitalizeSentences, | 3530 WebTextInputFlagAutocapitalizeSentences, |
| 3554 info2.flags); | 3531 info2.flags); |
| 3555 | 3532 |
| 3556 // (B) <textarea> Verifies the default text input flags are | 3533 // (B) <textarea> Verifies the default text input flags are |
| 3557 // WebTextInputFlagAutocapitalizeSentences. | 3534 // WebTextInputFlagAutocapitalizeSentences. |
| 3558 HTMLTextAreaElement* textAreaElement = | 3535 HTMLTextAreaElement* textAreaElement = |
| 3559 toHTMLTextAreaElement(document->getElementById("textarea")); | 3536 toHTMLTextAreaElement(document->getElementById("textarea")); |
| 3560 document->setFocusedElement( | 3537 document->setFocusedElement( |
| 3561 textAreaElement, | 3538 textAreaElement, |
| 3562 FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); | 3539 FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); |
| 3563 webViewImpl->setFocus(true); | 3540 webViewImpl->setFocus(true); |
| 3564 WebTextInputInfo info3 = activeInputMethodController->textInputInfo(); | 3541 WebTextInputInfo info3 = webViewImpl->textInputInfo(); |
| 3565 EXPECT_EQ(WebTextInputFlagAutocapitalizeSentences, info3.flags); | 3542 EXPECT_EQ(WebTextInputFlagAutocapitalizeSentences, info3.flags); |
| 3566 | 3543 |
| 3567 // (C) Verifies the WebTextInputInfo's don't equal. | 3544 // (C) Verifies the WebTextInputInfo's don't equal. |
| 3568 EXPECT_FALSE(info1.equals(info2)); | 3545 EXPECT_FALSE(info1.equals(info2)); |
| 3569 EXPECT_FALSE(info2.equals(info3)); | 3546 EXPECT_FALSE(info2.equals(info3)); |
| 3570 | 3547 |
| 3571 // Free the webView before freeing the NonUserInputTextUpdateWebViewClient. | 3548 // Free the webView before freeing the NonUserInputTextUpdateWebViewClient. |
| 3572 m_webViewHelper.reset(); | 3549 m_webViewHelper.reset(); |
| 3573 } | 3550 } |
| 3574 | 3551 |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4277 .translate(50, 55) | 4254 .translate(50, 55) |
| 4278 .scale(1. / 2.f); | 4255 .scale(1. / 2.f); |
| 4279 EXPECT_EQ(expectedMatrix, | 4256 EXPECT_EQ(expectedMatrix, |
| 4280 webViewImpl->getDeviceEmulationTransformForTesting()); | 4257 webViewImpl->getDeviceEmulationTransformForTesting()); |
| 4281 // visibleContentRect doesn't change. | 4258 // visibleContentRect doesn't change. |
| 4282 EXPECT_EQ(IntRect(50, 55, 50, 75), | 4259 EXPECT_EQ(IntRect(50, 55, 50, 75), |
| 4283 *devToolsEmulator->visibleContentRectForPainting()); | 4260 *devToolsEmulator->visibleContentRectForPainting()); |
| 4284 } | 4261 } |
| 4285 | 4262 |
| 4286 } // namespace blink | 4263 } // namespace blink |
| OLD | NEW |