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