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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 #include "public/web/WebCache.h" | 75 #include "public/web/WebCache.h" |
76 #include "public/web/WebDateTimeChooserCompletion.h" | 76 #include "public/web/WebDateTimeChooserCompletion.h" |
77 #include "public/web/WebDeviceEmulationParams.h" | 77 #include "public/web/WebDeviceEmulationParams.h" |
78 #include "public/web/WebDocument.h" | 78 #include "public/web/WebDocument.h" |
79 #include "public/web/WebElement.h" | 79 #include "public/web/WebElement.h" |
80 #include "public/web/WebFrame.h" | 80 #include "public/web/WebFrame.h" |
81 #include "public/web/WebFrameClient.h" | 81 #include "public/web/WebFrameClient.h" |
82 #include "public/web/WebFrameContentDumper.h" | 82 #include "public/web/WebFrameContentDumper.h" |
83 #include "public/web/WebHitTestResult.h" | 83 #include "public/web/WebHitTestResult.h" |
84 #include "public/web/WebInputEvent.h" | 84 #include "public/web/WebInputEvent.h" |
85 #include "public/web/WebInputMethodController.h" | |
85 #include "public/web/WebScriptSource.h" | 86 #include "public/web/WebScriptSource.h" |
86 #include "public/web/WebSettings.h" | 87 #include "public/web/WebSettings.h" |
87 #include "public/web/WebTreeScopeType.h" | 88 #include "public/web/WebTreeScopeType.h" |
88 #include "public/web/WebViewClient.h" | 89 #include "public/web/WebViewClient.h" |
89 #include "public/web/WebWidget.h" | 90 #include "public/web/WebWidget.h" |
90 #include "public/web/WebWidgetClient.h" | 91 #include "public/web/WebWidgetClient.h" |
91 #include "testing/gtest/include/gtest/gtest.h" | 92 #include "testing/gtest/include/gtest/gtest.h" |
92 #include "third_party/skia/include/core/SkBitmap.h" | 93 #include "third_party/skia/include/core/SkBitmap.h" |
93 #include "third_party/skia/include/core/SkCanvas.h" | 94 #include "third_party/skia/include/core/SkCanvas.h" |
95 #include "web/WebInputMethodControllerImpl.h" | |
94 #include "web/WebLocalFrameImpl.h" | 96 #include "web/WebLocalFrameImpl.h" |
95 #include "web/WebSettingsImpl.h" | 97 #include "web/WebSettingsImpl.h" |
96 #include "web/WebViewImpl.h" | 98 #include "web/WebViewImpl.h" |
97 #include "web/tests/FrameTestHelpers.h" | 99 #include "web/tests/FrameTestHelpers.h" |
98 #include "wtf/PtrUtil.h" | 100 #include "wtf/PtrUtil.h" |
99 #include <memory> | 101 #include <memory> |
100 | 102 |
101 #if OS(MACOSX) | 103 #if OS(MACOSX) |
102 #include "public/web/mac/WebSubstringUtil.h" | 104 #include "public/web/mac/WebSubstringUtil.h" |
103 #endif | 105 #endif |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 | 232 |
231 void testAutoResize(const WebSize& minAutoResize, const WebSize& maxAutoResi ze, | 233 void testAutoResize(const WebSize& minAutoResize, const WebSize& maxAutoResi ze, |
232 const std::string& pageWidth, const std::string& pageHei ght, | 234 const std::string& pageWidth, const std::string& pageHei ght, |
233 int expectedWidth, int expectedHeight, | 235 int expectedWidth, int expectedHeight, |
234 HorizontalScrollbarState expectedHorizontalState, Vertic alScrollbarState expectedVerticalState); | 236 HorizontalScrollbarState expectedHorizontalState, Vertic alScrollbarState expectedVerticalState); |
235 | 237 |
236 void testTextInputType(WebTextInputType expectedType, const std::string& htm lFile); | 238 void testTextInputType(WebTextInputType expectedType, const std::string& htm lFile); |
237 void testInputMode(const WebString& expectedInputMode, const std::string& ht mlFile); | 239 void testInputMode(const WebString& expectedInputMode, const std::string& ht mlFile); |
238 bool tapElement(WebInputEvent::Type, Element*); | 240 bool tapElement(WebInputEvent::Type, Element*); |
239 bool tapElementById(WebInputEvent::Type, const WebString& id); | 241 bool tapElementById(WebInputEvent::Type, const WebString& id); |
242 WebInputMethodController* inputMethodController() const; | |
240 | 243 |
241 std::string m_baseURL; | 244 std::string m_baseURL; |
242 FrameTestHelpers::WebViewHelper m_webViewHelper; | 245 FrameTestHelpers::WebViewHelper m_webViewHelper; |
243 }; | 246 }; |
244 | 247 |
245 static bool hitTestIsContentEditable(WebView* view, int x, int y) | 248 static bool hitTestIsContentEditable(WebView* view, int x, int y) |
246 { | 249 { |
247 WebPoint hitPoint(x, y); | 250 WebPoint hitPoint(x, y); |
248 WebHitTestResult hitTestResult = view->hitTestResultAt(hitPoint); | 251 WebHitTestResult hitTestResult = view->hitTestResultAt(hitPoint); |
249 return hitTestResult.isContentEditable(); | 252 return hitTestResult.isContentEditable(); |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
823 TEST_F(WebViewTest, FinishComposingTextCursorPositionChange) | 826 TEST_F(WebViewTest, FinishComposingTextCursorPositionChange) |
824 { | 827 { |
825 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); | 828 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); |
826 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html"); | 829 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html"); |
827 webView->setInitialFocus(false); | 830 webView->setInitialFocus(false); |
828 | 831 |
829 // Set up a composition that needs to be committed. | 832 // Set up a composition that needs to be committed. |
830 std::string compositionText("hello"); | 833 std::string compositionText("hello"); |
831 | 834 |
832 WebVector<WebCompositionUnderline> emptyUnderlines; | 835 WebVector<WebCompositionUnderline> emptyUnderlines; |
833 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, 3, 3); | 836 inputMethodController()->setComposition(WebString::fromUTF8(compositionText. c_str()), emptyUnderlines, 3, 3); |
834 | 837 |
835 WebTextInputInfo info = webView->textInputInfo(); | 838 WebTextInputInfo info = webView->textInputInfo(); |
836 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 839 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
837 EXPECT_EQ(3, info.selectionStart); | 840 EXPECT_EQ(3, info.selectionStart); |
838 EXPECT_EQ(3, info.selectionEnd); | 841 EXPECT_EQ(3, info.selectionEnd); |
839 EXPECT_EQ(0, info.compositionStart); | 842 EXPECT_EQ(0, info.compositionStart); |
840 EXPECT_EQ(5, info.compositionEnd); | 843 EXPECT_EQ(5, info.compositionEnd); |
841 | 844 |
842 webView->finishComposingText(WebWidget::KeepSelection); | 845 inputMethodController()->finishComposingText(WebInputMethodController::KeepS election); |
843 info = webView->textInputInfo(); | 846 info = webView->textInputInfo(); |
844 EXPECT_EQ(3, info.selectionStart); | 847 EXPECT_EQ(3, info.selectionStart); |
845 EXPECT_EQ(3, info.selectionEnd); | 848 EXPECT_EQ(3, info.selectionEnd); |
846 EXPECT_EQ(-1, info.compositionStart); | 849 EXPECT_EQ(-1, info.compositionStart); |
847 EXPECT_EQ(-1, info.compositionEnd); | 850 EXPECT_EQ(-1, info.compositionEnd); |
848 | 851 |
849 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, 3, 3); | 852 inputMethodController()->setComposition(WebString::fromUTF8(compositionText. c_str()), emptyUnderlines, 3, 3); |
850 info = webView->textInputInfo(); | 853 info = webView->textInputInfo(); |
851 EXPECT_EQ("helhellolo", std::string(info.value.utf8().data())); | 854 EXPECT_EQ("helhellolo", std::string(info.value.utf8().data())); |
852 EXPECT_EQ(6, info.selectionStart); | 855 EXPECT_EQ(6, info.selectionStart); |
853 EXPECT_EQ(6, info.selectionEnd); | 856 EXPECT_EQ(6, info.selectionEnd); |
854 EXPECT_EQ(3, info.compositionStart); | 857 EXPECT_EQ(3, info.compositionStart); |
855 EXPECT_EQ(8, info.compositionEnd); | 858 EXPECT_EQ(8, info.compositionEnd); |
856 | 859 |
857 webView->finishComposingText(WebWidget::DoNotKeepSelection); | 860 inputMethodController()->finishComposingText(WebInputMethodController::DoNot KeepSelection); |
858 info = webView->textInputInfo(); | 861 info = webView->textInputInfo(); |
859 EXPECT_EQ(8, info.selectionStart); | 862 EXPECT_EQ(8, info.selectionStart); |
860 EXPECT_EQ(8, info.selectionEnd); | 863 EXPECT_EQ(8, info.selectionEnd); |
861 EXPECT_EQ(-1, info.compositionStart); | 864 EXPECT_EQ(-1, info.compositionStart); |
862 EXPECT_EQ(-1, info.compositionEnd); | 865 EXPECT_EQ(-1, info.compositionEnd); |
863 } | 866 } |
864 | 867 |
865 TEST_F(WebViewTest, SetCompositionForNewCaretPositions) | 868 TEST_F(WebViewTest, SetCompositionForNewCaretPositions) |
866 { | 869 { |
867 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); | 870 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); |
868 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html"); | 871 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html"); |
869 webView->setInitialFocus(false); | 872 webView->setInitialFocus(false); |
870 | 873 |
871 webView->commitText("hello", 0); | 874 inputMethodController()->commitText("hello", 0); |
872 webView->commitText("world", -5); | 875 inputMethodController()->commitText("world", -5); |
873 WebTextInputInfo info = webView->textInputInfo(); | 876 WebTextInputInfo info = webView->textInputInfo(); |
874 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 877 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
875 EXPECT_EQ(5, info.selectionStart); | 878 EXPECT_EQ(5, info.selectionStart); |
876 EXPECT_EQ(5, info.selectionEnd); | 879 EXPECT_EQ(5, info.selectionEnd); |
877 EXPECT_EQ(-1, info.compositionStart); | 880 EXPECT_EQ(-1, info.compositionStart); |
878 EXPECT_EQ(-1, info.compositionEnd); | 881 EXPECT_EQ(-1, info.compositionEnd); |
879 | 882 |
880 WebVector<WebCompositionUnderline> emptyUnderlines; | 883 WebVector<WebCompositionUnderline> emptyUnderlines; |
881 // Set up a composition that needs to be committed. | 884 // Set up a composition that needs to be committed. |
882 std::string compositionText("ABC"); | 885 std::string compositionText("ABC"); |
883 | 886 |
884 // Caret is on the left of composing text. | 887 // Caret is on the left of composing text. |
885 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, 0, 0); | 888 inputMethodController()->setComposition(WebString::fromUTF8(compositionText. c_str()), emptyUnderlines, 0, 0); |
886 info = webView->textInputInfo(); | 889 info = webView->textInputInfo(); |
887 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 890 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
888 EXPECT_EQ(5, info.selectionStart); | 891 EXPECT_EQ(5, info.selectionStart); |
889 EXPECT_EQ(5, info.selectionEnd); | 892 EXPECT_EQ(5, info.selectionEnd); |
890 EXPECT_EQ(5, info.compositionStart); | 893 EXPECT_EQ(5, info.compositionStart); |
891 EXPECT_EQ(8, info.compositionEnd); | 894 EXPECT_EQ(8, info.compositionEnd); |
892 | 895 |
893 // Caret is on the right of composing text. | 896 // Caret is on the right of composing text. |
894 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, 3, 3); | 897 inputMethodController()->setComposition(WebString::fromUTF8(compositionText. c_str()), emptyUnderlines, 3, 3); |
895 info = webView->textInputInfo(); | 898 info = webView->textInputInfo(); |
896 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 899 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
897 EXPECT_EQ(8, info.selectionStart); | 900 EXPECT_EQ(8, info.selectionStart); |
898 EXPECT_EQ(8, info.selectionEnd); | 901 EXPECT_EQ(8, info.selectionEnd); |
899 EXPECT_EQ(5, info.compositionStart); | 902 EXPECT_EQ(5, info.compositionStart); |
900 EXPECT_EQ(8, info.compositionEnd); | 903 EXPECT_EQ(8, info.compositionEnd); |
901 | 904 |
902 // Caret is between composing text and left boundary. | 905 // Caret is between composing text and left boundary. |
903 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, -2, -2); | 906 inputMethodController()->setComposition(WebString::fromUTF8(compositionText. c_str()), emptyUnderlines, -2, -2); |
904 info = webView->textInputInfo(); | 907 info = webView->textInputInfo(); |
905 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 908 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
906 EXPECT_EQ(3, info.selectionStart); | 909 EXPECT_EQ(3, info.selectionStart); |
907 EXPECT_EQ(3, info.selectionEnd); | 910 EXPECT_EQ(3, info.selectionEnd); |
908 EXPECT_EQ(5, info.compositionStart); | 911 EXPECT_EQ(5, info.compositionStart); |
909 EXPECT_EQ(8, info.compositionEnd); | 912 EXPECT_EQ(8, info.compositionEnd); |
910 | 913 |
911 // Caret is between composing text and right boundary. | 914 // Caret is between composing text and right boundary. |
912 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, 5, 5); | 915 inputMethodController()->setComposition(WebString::fromUTF8(compositionText. c_str()), emptyUnderlines, 5, 5); |
913 info = webView->textInputInfo(); | 916 info = webView->textInputInfo(); |
914 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 917 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
915 EXPECT_EQ(10, info.selectionStart); | 918 EXPECT_EQ(10, info.selectionStart); |
916 EXPECT_EQ(10, info.selectionEnd); | 919 EXPECT_EQ(10, info.selectionEnd); |
917 EXPECT_EQ(5, info.compositionStart); | 920 EXPECT_EQ(5, info.compositionStart); |
918 EXPECT_EQ(8, info.compositionEnd); | 921 EXPECT_EQ(8, info.compositionEnd); |
919 | 922 |
920 // Caret is on the left boundary. | 923 // Caret is on the left boundary. |
921 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, -5, -5); | 924 inputMethodController()->setComposition(WebString::fromUTF8(compositionText. c_str()), emptyUnderlines, -5, -5); |
922 info = webView->textInputInfo(); | 925 info = webView->textInputInfo(); |
923 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 926 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
924 EXPECT_EQ(0, info.selectionStart); | 927 EXPECT_EQ(0, info.selectionStart); |
925 EXPECT_EQ(0, info.selectionEnd); | 928 EXPECT_EQ(0, info.selectionEnd); |
926 EXPECT_EQ(5, info.compositionStart); | 929 EXPECT_EQ(5, info.compositionStart); |
927 EXPECT_EQ(8, info.compositionEnd); | 930 EXPECT_EQ(8, info.compositionEnd); |
928 | 931 |
929 // Caret is on the right boundary. | 932 // Caret is on the right boundary. |
930 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, 8, 8); | 933 inputMethodController()->setComposition(WebString::fromUTF8(compositionText. c_str()), emptyUnderlines, 8, 8); |
931 info = webView->textInputInfo(); | 934 info = webView->textInputInfo(); |
932 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 935 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
933 EXPECT_EQ(13, info.selectionStart); | 936 EXPECT_EQ(13, info.selectionStart); |
934 EXPECT_EQ(13, info.selectionEnd); | 937 EXPECT_EQ(13, info.selectionEnd); |
935 EXPECT_EQ(5, info.compositionStart); | 938 EXPECT_EQ(5, info.compositionStart); |
936 EXPECT_EQ(8, info.compositionEnd); | 939 EXPECT_EQ(8, info.compositionEnd); |
937 | 940 |
938 // Caret exceeds the left boundary. | 941 // Caret exceeds the left boundary. |
939 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, -100, -100); | 942 inputMethodController()->setComposition(WebString::fromUTF8(compositionText. c_str()), emptyUnderlines, -100, -100); |
940 info = webView->textInputInfo(); | 943 info = webView->textInputInfo(); |
941 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 944 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
942 EXPECT_EQ(0, info.selectionStart); | 945 EXPECT_EQ(0, info.selectionStart); |
943 EXPECT_EQ(0, info.selectionEnd); | 946 EXPECT_EQ(0, info.selectionEnd); |
944 EXPECT_EQ(5, info.compositionStart); | 947 EXPECT_EQ(5, info.compositionStart); |
945 EXPECT_EQ(8, info.compositionEnd); | 948 EXPECT_EQ(8, info.compositionEnd); |
946 | 949 |
947 // Caret exceeds the right boundary. | 950 // Caret exceeds the right boundary. |
948 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, 100, 100); | 951 inputMethodController()->setComposition(WebString::fromUTF8(compositionText. c_str()), emptyUnderlines, 100, 100); |
949 info = webView->textInputInfo(); | 952 info = webView->textInputInfo(); |
950 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 953 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
951 EXPECT_EQ(13, info.selectionStart); | 954 EXPECT_EQ(13, info.selectionStart); |
952 EXPECT_EQ(13, info.selectionEnd); | 955 EXPECT_EQ(13, info.selectionEnd); |
953 EXPECT_EQ(5, info.compositionStart); | 956 EXPECT_EQ(5, info.compositionStart); |
954 EXPECT_EQ(8, info.compositionEnd); | 957 EXPECT_EQ(8, info.compositionEnd); |
955 } | 958 } |
956 | 959 |
957 TEST_F(WebViewTest, SetCompositionWithEmptyText) | 960 TEST_F(WebViewTest, SetCompositionWithEmptyText) |
958 { | 961 { |
959 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); | 962 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); |
960 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html"); | 963 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html"); |
961 webView->setInitialFocus(false); | 964 webView->setInitialFocus(false); |
962 | 965 |
963 webView->commitText("hello", 0); | 966 inputMethodController()->commitText("hello", 0); |
964 WebTextInputInfo info = webView->textInputInfo(); | 967 WebTextInputInfo info = webView->textInputInfo(); |
965 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 968 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
966 EXPECT_EQ(5, info.selectionStart); | 969 EXPECT_EQ(5, info.selectionStart); |
967 EXPECT_EQ(5, info.selectionEnd); | 970 EXPECT_EQ(5, info.selectionEnd); |
968 EXPECT_EQ(-1, info.compositionStart); | 971 EXPECT_EQ(-1, info.compositionStart); |
969 EXPECT_EQ(-1, info.compositionEnd); | 972 EXPECT_EQ(-1, info.compositionEnd); |
970 | 973 |
971 WebVector<WebCompositionUnderline> emptyUnderlines; | 974 WebVector<WebCompositionUnderline> emptyUnderlines; |
972 | 975 |
973 webView->setComposition(WebString::fromUTF8(""), emptyUnderlines, 0, 0); | 976 inputMethodController()->setComposition(WebString::fromUTF8(""), emptyUnderl ines, 0, 0); |
974 info = webView->textInputInfo(); | 977 info = webView->textInputInfo(); |
975 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 978 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
976 EXPECT_EQ(5, info.selectionStart); | 979 EXPECT_EQ(5, info.selectionStart); |
977 EXPECT_EQ(5, info.selectionEnd); | 980 EXPECT_EQ(5, info.selectionEnd); |
978 EXPECT_EQ(-1, info.compositionStart); | 981 EXPECT_EQ(-1, info.compositionStart); |
979 EXPECT_EQ(-1, info.compositionEnd); | 982 EXPECT_EQ(-1, info.compositionEnd); |
980 | 983 |
981 webView->setComposition(WebString::fromUTF8(""), emptyUnderlines, -2, -2); | 984 inputMethodController()->setComposition(WebString::fromUTF8(""), emptyUnderl ines, -2, -2); |
982 info = webView->textInputInfo(); | 985 info = webView->textInputInfo(); |
983 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 986 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
984 EXPECT_EQ(3, info.selectionStart); | 987 EXPECT_EQ(3, info.selectionStart); |
985 EXPECT_EQ(3, info.selectionEnd); | 988 EXPECT_EQ(3, info.selectionEnd); |
986 EXPECT_EQ(-1, info.compositionStart); | 989 EXPECT_EQ(-1, info.compositionStart); |
987 EXPECT_EQ(-1, info.compositionEnd); | 990 EXPECT_EQ(-1, info.compositionEnd); |
988 } | 991 } |
989 | 992 |
990 TEST_F(WebViewTest, CommitTextForNewCaretPositions) | 993 TEST_F(WebViewTest, CommitTextForNewCaretPositions) |
991 { | 994 { |
992 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); | 995 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); |
993 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html"); | 996 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html"); |
994 webView->setInitialFocus(false); | 997 webView->setInitialFocus(false); |
995 | 998 |
996 // Caret is on the left of composing text. | 999 // Caret is on the left of composing text. |
997 webView->commitText("ab", -2); | 1000 inputMethodController()->commitText("ab", -2); |
998 WebTextInputInfo info = webView->textInputInfo(); | 1001 WebTextInputInfo info = webView->textInputInfo(); |
999 EXPECT_EQ("ab", std::string(info.value.utf8().data())); | 1002 EXPECT_EQ("ab", std::string(info.value.utf8().data())); |
1000 EXPECT_EQ(0, info.selectionStart); | 1003 EXPECT_EQ(0, info.selectionStart); |
1001 EXPECT_EQ(0, info.selectionEnd); | 1004 EXPECT_EQ(0, info.selectionEnd); |
1002 EXPECT_EQ(-1, info.compositionStart); | 1005 EXPECT_EQ(-1, info.compositionStart); |
1003 EXPECT_EQ(-1, info.compositionEnd); | 1006 EXPECT_EQ(-1, info.compositionEnd); |
1004 | 1007 |
1005 // Caret is on the right of composing text. | 1008 // Caret is on the right of composing text. |
1006 webView->commitText("c", 1); | 1009 inputMethodController()->commitText("c", 1); |
1007 info = webView->textInputInfo(); | 1010 info = webView->textInputInfo(); |
1008 EXPECT_EQ("cab", std::string(info.value.utf8().data())); | 1011 EXPECT_EQ("cab", std::string(info.value.utf8().data())); |
1009 EXPECT_EQ(2, info.selectionStart); | 1012 EXPECT_EQ(2, info.selectionStart); |
1010 EXPECT_EQ(2, info.selectionEnd); | 1013 EXPECT_EQ(2, info.selectionEnd); |
1011 EXPECT_EQ(-1, info.compositionStart); | 1014 EXPECT_EQ(-1, info.compositionStart); |
1012 EXPECT_EQ(-1, info.compositionEnd); | 1015 EXPECT_EQ(-1, info.compositionEnd); |
1013 | 1016 |
1014 // Caret is on the left boundary. | 1017 // Caret is on the left boundary. |
1015 webView->commitText("def", -5); | 1018 inputMethodController()->commitText("def", -5); |
1016 info = webView->textInputInfo(); | 1019 info = webView->textInputInfo(); |
1017 EXPECT_EQ("cadefb", std::string(info.value.utf8().data())); | 1020 EXPECT_EQ("cadefb", std::string(info.value.utf8().data())); |
1018 EXPECT_EQ(0, info.selectionStart); | 1021 EXPECT_EQ(0, info.selectionStart); |
1019 EXPECT_EQ(0, info.selectionEnd); | 1022 EXPECT_EQ(0, info.selectionEnd); |
1020 EXPECT_EQ(-1, info.compositionStart); | 1023 EXPECT_EQ(-1, info.compositionStart); |
1021 EXPECT_EQ(-1, info.compositionEnd); | 1024 EXPECT_EQ(-1, info.compositionEnd); |
1022 | 1025 |
1023 // Caret is on the right boundary. | 1026 // Caret is on the right boundary. |
1024 webView->commitText("g", 6); | 1027 inputMethodController()->commitText("g", 6); |
1025 info = webView->textInputInfo(); | 1028 info = webView->textInputInfo(); |
1026 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data())); | 1029 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data())); |
1027 EXPECT_EQ(7, info.selectionStart); | 1030 EXPECT_EQ(7, info.selectionStart); |
1028 EXPECT_EQ(7, info.selectionEnd); | 1031 EXPECT_EQ(7, info.selectionEnd); |
1029 EXPECT_EQ(-1, info.compositionStart); | 1032 EXPECT_EQ(-1, info.compositionStart); |
1030 EXPECT_EQ(-1, info.compositionEnd); | 1033 EXPECT_EQ(-1, info.compositionEnd); |
1031 | 1034 |
1032 // Caret exceeds the left boundary. | 1035 // Caret exceeds the left boundary. |
1033 webView->commitText("hi", -100); | 1036 inputMethodController()->commitText("hi", -100); |
1034 info = webView->textInputInfo(); | 1037 info = webView->textInputInfo(); |
1035 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data())); | 1038 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data())); |
1036 EXPECT_EQ(0, info.selectionStart); | 1039 EXPECT_EQ(0, info.selectionStart); |
1037 EXPECT_EQ(0, info.selectionEnd); | 1040 EXPECT_EQ(0, info.selectionEnd); |
1038 EXPECT_EQ(-1, info.compositionStart); | 1041 EXPECT_EQ(-1, info.compositionStart); |
1039 EXPECT_EQ(-1, info.compositionEnd); | 1042 EXPECT_EQ(-1, info.compositionEnd); |
1040 | 1043 |
1041 // Caret exceeds the right boundary. | 1044 // Caret exceeds the right boundary. |
1042 webView->commitText("jk", 100); | 1045 inputMethodController()->commitText("jk", 100); |
1043 info = webView->textInputInfo(); | 1046 info = webView->textInputInfo(); |
1044 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); | 1047 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); |
1045 EXPECT_EQ(11, info.selectionStart); | 1048 EXPECT_EQ(11, info.selectionStart); |
1046 EXPECT_EQ(11, info.selectionEnd); | 1049 EXPECT_EQ(11, info.selectionEnd); |
1047 EXPECT_EQ(-1, info.compositionStart); | 1050 EXPECT_EQ(-1, info.compositionStart); |
1048 EXPECT_EQ(-1, info.compositionEnd); | 1051 EXPECT_EQ(-1, info.compositionEnd); |
1049 } | 1052 } |
1050 | 1053 |
1051 TEST_F(WebViewTest, CommitTextWhileComposing) | 1054 TEST_F(WebViewTest, CommitTextWhileComposing) |
1052 { | 1055 { |
1053 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); | 1056 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); |
1054 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html"); | 1057 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html"); |
1055 webView->setInitialFocus(false); | 1058 webView->setInitialFocus(false); |
1056 | 1059 |
1057 WebVector<WebCompositionUnderline> emptyUnderlines; | 1060 WebVector<WebCompositionUnderline> emptyUnderlines; |
1058 webView->setComposition(WebString::fromUTF8("abc"), emptyUnderlines, 0, 0); | 1061 inputMethodController()->setComposition(WebString::fromUTF8("abc"), emptyUnd erlines, 0, 0); |
1059 WebTextInputInfo info = webView->textInputInfo(); | 1062 WebTextInputInfo info = webView->textInputInfo(); |
1060 EXPECT_EQ("abc", std::string(info.value.utf8().data())); | 1063 EXPECT_EQ("abc", std::string(info.value.utf8().data())); |
1061 EXPECT_EQ(0, info.selectionStart); | 1064 EXPECT_EQ(0, info.selectionStart); |
1062 EXPECT_EQ(0, info.selectionEnd); | 1065 EXPECT_EQ(0, info.selectionEnd); |
1063 EXPECT_EQ(0, info.compositionStart); | 1066 EXPECT_EQ(0, info.compositionStart); |
1064 EXPECT_EQ(3, info.compositionEnd); | 1067 EXPECT_EQ(3, info.compositionEnd); |
1065 | 1068 |
1066 // Deletes ongoing composition, inserts the specified text and moves the | 1069 // Deletes ongoing composition, inserts the specified text and moves the |
1067 // caret. | 1070 // caret. |
1068 webView->commitText("hello", -2); | 1071 inputMethodController()->commitText("hello", -2); |
1069 info = webView->textInputInfo(); | 1072 info = webView->textInputInfo(); |
1070 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1073 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1071 EXPECT_EQ(3, info.selectionStart); | 1074 EXPECT_EQ(3, info.selectionStart); |
1072 EXPECT_EQ(3, info.selectionEnd); | 1075 EXPECT_EQ(3, info.selectionEnd); |
1073 EXPECT_EQ(-1, info.compositionStart); | 1076 EXPECT_EQ(-1, info.compositionStart); |
1074 EXPECT_EQ(-1, info.compositionEnd); | 1077 EXPECT_EQ(-1, info.compositionEnd); |
1075 | 1078 |
1076 webView->setComposition(WebString::fromUTF8("abc"), emptyUnderlines, 0, 0); | 1079 inputMethodController()->setComposition(WebString::fromUTF8("abc"), emptyUnd erlines, 0, 0); |
1077 info = webView->textInputInfo(); | 1080 info = webView->textInputInfo(); |
1078 EXPECT_EQ("helabclo", std::string(info.value.utf8().data())); | 1081 EXPECT_EQ("helabclo", std::string(info.value.utf8().data())); |
1079 EXPECT_EQ(3, info.selectionStart); | 1082 EXPECT_EQ(3, info.selectionStart); |
1080 EXPECT_EQ(3, info.selectionEnd); | 1083 EXPECT_EQ(3, info.selectionEnd); |
1081 EXPECT_EQ(3, info.compositionStart); | 1084 EXPECT_EQ(3, info.compositionStart); |
1082 EXPECT_EQ(6, info.compositionEnd); | 1085 EXPECT_EQ(6, info.compositionEnd); |
1083 | 1086 |
1084 // Deletes ongoing composition and moves the caret. | 1087 // Deletes ongoing composition and moves the caret. |
1085 webView->commitText("", 2); | 1088 inputMethodController()->commitText("", 2); |
1086 info = webView->textInputInfo(); | 1089 info = webView->textInputInfo(); |
1087 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1090 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1088 EXPECT_EQ(5, info.selectionStart); | 1091 EXPECT_EQ(5, info.selectionStart); |
1089 EXPECT_EQ(5, info.selectionEnd); | 1092 EXPECT_EQ(5, info.selectionEnd); |
1090 EXPECT_EQ(-1, info.compositionStart); | 1093 EXPECT_EQ(-1, info.compositionStart); |
1091 EXPECT_EQ(-1, info.compositionEnd); | 1094 EXPECT_EQ(-1, info.compositionEnd); |
1092 | 1095 |
1093 // Inserts the specified text and moves the caret. | 1096 // Inserts the specified text and moves the caret. |
1094 webView->commitText("world", -5); | 1097 inputMethodController()->commitText("world", -5); |
1095 info = webView->textInputInfo(); | 1098 info = webView->textInputInfo(); |
1096 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 1099 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
1097 EXPECT_EQ(5, info.selectionStart); | 1100 EXPECT_EQ(5, info.selectionStart); |
1098 EXPECT_EQ(5, info.selectionEnd); | 1101 EXPECT_EQ(5, info.selectionEnd); |
1099 EXPECT_EQ(-1, info.compositionStart); | 1102 EXPECT_EQ(-1, info.compositionStart); |
1100 EXPECT_EQ(-1, info.compositionEnd); | 1103 EXPECT_EQ(-1, info.compositionEnd); |
1101 | 1104 |
1102 // Only moves the caret. | 1105 // Only moves the caret. |
1103 webView->commitText("", 5); | 1106 inputMethodController()->commitText("", 5); |
1104 info = webView->textInputInfo(); | 1107 info = webView->textInputInfo(); |
1105 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 1108 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
1106 EXPECT_EQ(10, info.selectionStart); | 1109 EXPECT_EQ(10, info.selectionStart); |
1107 EXPECT_EQ(10, info.selectionEnd); | 1110 EXPECT_EQ(10, info.selectionEnd); |
1108 EXPECT_EQ(-1, info.compositionStart); | 1111 EXPECT_EQ(-1, info.compositionStart); |
1109 EXPECT_EQ(-1, info.compositionEnd); | 1112 EXPECT_EQ(-1, info.compositionEnd); |
1110 } | 1113 } |
1111 | 1114 |
1112 TEST_F(WebViewTest, FinishCompositionDoesNotRevealSelection) | 1115 TEST_F(WebViewTest, FinishCompositionDoesNotRevealSelection) |
1113 { | 1116 { |
(...skipping 13 matching lines...) Expand all Loading... | |
1127 Element* element = static_cast<Element*>(webView->mainFrame()->document().ge tElementById("btn")); | 1130 Element* element = static_cast<Element*>(webView->mainFrame()->document().ge tElementById("btn")); |
1128 element->scrollIntoView(); | 1131 element->scrollIntoView(); |
1129 float offsetHeight = webView->mainFrame()->scrollOffset().height; | 1132 float offsetHeight = webView->mainFrame()->scrollOffset().height; |
1130 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 1133 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
1131 EXPECT_LT(0, offsetHeight); | 1134 EXPECT_LT(0, offsetHeight); |
1132 | 1135 |
1133 WebTextInputInfo info = webView->textInputInfo(); | 1136 WebTextInputInfo info = webView->textInputInfo(); |
1134 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1137 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1135 | 1138 |
1136 // Verify that the input field is not scrolled back into the viewport. | 1139 // Verify that the input field is not scrolled back into the viewport. |
1137 webView->finishComposingText(WebWidget::DoNotKeepSelection); | 1140 inputMethodController()->finishComposingText(WebInputMethodController::DoNot KeepSelection); |
1138 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 1141 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
1139 EXPECT_EQ(offsetHeight, webView->mainFrame()->scrollOffset().height); | 1142 EXPECT_EQ(offsetHeight, webView->mainFrame()->scrollOffset().height); |
1140 } | 1143 } |
1141 | 1144 |
1142 TEST_F(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) | 1145 TEST_F(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) |
1143 { | 1146 { |
1144 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("text_area_populated.html")); | 1147 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("text_area_populated.html")); |
1145 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a rea_populated.html"); | 1148 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a rea_populated.html"); |
1146 webView->setInitialFocus(false); | 1149 webView->setInitialFocus(false); |
1147 | 1150 |
1148 WebVector<WebCompositionUnderline> emptyUnderlines; | 1151 WebVector<WebCompositionUnderline> emptyUnderlines; |
1149 | 1152 |
1150 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1153 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
1151 frame->setEditableSelectionOffsets(4, 4); | 1154 frame->setEditableSelectionOffsets(4, 4); |
1152 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); | 1155 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
1153 | 1156 |
1154 WebTextInputInfo info = webView->textInputInfo(); | 1157 WebTextInputInfo info = webView->textInputInfo(); |
1155 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf 8().data())); | 1158 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf 8().data())); |
1156 EXPECT_EQ(4, info.selectionStart); | 1159 EXPECT_EQ(4, info.selectionStart); |
1157 EXPECT_EQ(4, info.selectionEnd); | 1160 EXPECT_EQ(4, info.selectionEnd); |
1158 EXPECT_EQ(8, info.compositionStart); | 1161 EXPECT_EQ(8, info.compositionStart); |
1159 EXPECT_EQ(12, info.compositionEnd); | 1162 EXPECT_EQ(12, info.compositionEnd); |
1160 | 1163 |
1161 webView->finishComposingText(WebWidget::KeepSelection); | 1164 inputMethodController()->finishComposingText(WebInputMethodController::KeepS election); |
1162 info = webView->textInputInfo(); | 1165 info = webView->textInputInfo(); |
1163 EXPECT_EQ(4, info.selectionStart); | 1166 EXPECT_EQ(4, info.selectionStart); |
1164 EXPECT_EQ(4, info.selectionEnd); | 1167 EXPECT_EQ(4, info.selectionEnd); |
1165 EXPECT_EQ(-1, info.compositionStart); | 1168 EXPECT_EQ(-1, info.compositionStart); |
1166 EXPECT_EQ(-1, info.compositionEnd); | 1169 EXPECT_EQ(-1, info.compositionEnd); |
1167 | 1170 |
1168 std::string compositionText("\n"); | 1171 std::string compositionText("\n"); |
1169 webView->commitText(WebString::fromUTF8(compositionText.c_str()), 0); | 1172 inputMethodController()->commitText(WebString::fromUTF8(compositionText.c_st r()), 0); |
1170 info = webView->textInputInfo(); | 1173 info = webView->textInputInfo(); |
1171 EXPECT_EQ(5, info.selectionStart); | 1174 EXPECT_EQ(5, info.selectionStart); |
1172 EXPECT_EQ(5, info.selectionEnd); | 1175 EXPECT_EQ(5, info.selectionEnd); |
1173 EXPECT_EQ(-1, info.compositionStart); | 1176 EXPECT_EQ(-1, info.compositionStart); |
1174 EXPECT_EQ(-1, info.compositionEnd); | 1177 EXPECT_EQ(-1, info.compositionEnd); |
1175 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u tf8().data())); | 1178 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u tf8().data())); |
1176 } | 1179 } |
1177 | 1180 |
1178 TEST_F(WebViewTest, ExtendSelectionAndDelete) | 1181 TEST_F(WebViewTest, ExtendSelectionAndDelete) |
1179 { | 1182 { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1219 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) | 1222 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) |
1220 { | 1223 { |
1221 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("text_area_populated.html")); | 1224 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("text_area_populated.html")); |
1222 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a rea_populated.html"); | 1225 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a rea_populated.html"); |
1223 webView->setInitialFocus(false); | 1226 webView->setInitialFocus(false); |
1224 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 1227 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
1225 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 1228 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
1226 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1229 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
1227 frame->setEditableSelectionOffsets(27, 27); | 1230 frame->setEditableSelectionOffsets(27, 27); |
1228 std::string newLineText("\n"); | 1231 std::string newLineText("\n"); |
1229 webView->commitText(WebString::fromUTF8(newLineText.c_str()), 0); | 1232 inputMethodController()->commitText(WebString::fromUTF8(newLineText.c_str()) , 0); |
1230 WebTextInputInfo info = webView->textInputInfo(); | 1233 WebTextInputInfo info = webView->textInputInfo(); |
1231 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u tf8().data())); | 1234 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u tf8().data())); |
1232 | 1235 |
1233 frame->setEditableSelectionOffsets(31, 31); | 1236 frame->setEditableSelectionOffsets(31, 31); |
1234 frame->setCompositionFromExistingText(30, 34, underlines); | 1237 frame->setCompositionFromExistingText(30, 34, underlines); |
1235 info = webView->textInputInfo(); | 1238 info = webView->textInputInfo(); |
1236 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u tf8().data())); | 1239 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u tf8().data())); |
1237 EXPECT_EQ(31, info.selectionStart); | 1240 EXPECT_EQ(31, info.selectionStart); |
1238 EXPECT_EQ(31, info.selectionEnd); | 1241 EXPECT_EQ(31, info.selectionEnd); |
1239 EXPECT_EQ(30, info.compositionStart); | 1242 EXPECT_EQ(30, info.compositionStart); |
1240 EXPECT_EQ(34, info.compositionEnd); | 1243 EXPECT_EQ(34, info.compositionEnd); |
1241 | 1244 |
1242 std::string compositionText("yolo"); | 1245 std::string compositionText("yolo"); |
1243 webView->commitText(WebString::fromUTF8(compositionText.c_str()), 0); | 1246 inputMethodController()->commitText(WebString::fromUTF8(compositionText.c_st r()), 0); |
1244 info = webView->textInputInfo(); | 1247 info = webView->textInputInfo(); |
1245 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u tf8().data())); | 1248 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u tf8().data())); |
1246 EXPECT_EQ(34, info.selectionStart); | 1249 EXPECT_EQ(34, info.selectionStart); |
1247 EXPECT_EQ(34, info.selectionEnd); | 1250 EXPECT_EQ(34, info.selectionEnd); |
1248 EXPECT_EQ(-1, info.compositionStart); | 1251 EXPECT_EQ(-1, info.compositionStart); |
1249 EXPECT_EQ(-1, info.compositionEnd); | 1252 EXPECT_EQ(-1, info.compositionEnd); |
1250 } | 1253 } |
1251 | 1254 |
1252 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) | 1255 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) |
1253 { | 1256 { |
(...skipping 13 matching lines...) Expand all Loading... | |
1267 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) | 1270 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) |
1268 { | 1271 { |
1269 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); | 1272 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); |
1270 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_ field_populated.html"); | 1273 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_ field_populated.html"); |
1271 webView->setInitialFocus(false); | 1274 webView->setInitialFocus(false); |
1272 | 1275 |
1273 std::string compositionTextFirst("hello "); | 1276 std::string compositionTextFirst("hello "); |
1274 std::string compositionTextSecond("world"); | 1277 std::string compositionTextSecond("world"); |
1275 WebVector<WebCompositionUnderline> emptyUnderlines; | 1278 WebVector<WebCompositionUnderline> emptyUnderlines; |
1276 | 1279 |
1277 webView->commitText(WebString::fromUTF8(compositionTextFirst.c_str()), 0); | 1280 inputMethodController()->commitText(WebString::fromUTF8(compositionTextFirst .c_str()), 0); |
1278 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5, 5); | 1281 inputMethodController()->setComposition(WebString::fromUTF8(compositionTextS econd.c_str()), emptyUnderlines, 5, 5); |
1279 | 1282 |
1280 WebTextInputInfo info = webView->textInputInfo(); | 1283 WebTextInputInfo info = webView->textInputInfo(); |
1281 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1284 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
1282 EXPECT_EQ(11, info.selectionStart); | 1285 EXPECT_EQ(11, info.selectionStart); |
1283 EXPECT_EQ(11, info.selectionEnd); | 1286 EXPECT_EQ(11, info.selectionEnd); |
1284 EXPECT_EQ(6, info.compositionStart); | 1287 EXPECT_EQ(6, info.compositionStart); |
1285 EXPECT_EQ(11, info.compositionEnd); | 1288 EXPECT_EQ(11, info.compositionEnd); |
1286 | 1289 |
1287 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1290 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
1288 frame->setEditableSelectionOffsets(6, 6); | 1291 frame->setEditableSelectionOffsets(6, 6); |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1710 return true; | 1713 return true; |
1711 } | 1714 } |
1712 | 1715 |
1713 bool WebViewTest::tapElementById(WebInputEvent::Type type, const WebString& id) | 1716 bool WebViewTest::tapElementById(WebInputEvent::Type type, const WebString& id) |
1714 { | 1717 { |
1715 DCHECK(m_webViewHelper.webView()); | 1718 DCHECK(m_webViewHelper.webView()); |
1716 Element* element = static_cast<Element*>(m_webViewHelper.webView()->mainFram e()->document().getElementById(id)); | 1719 Element* element = static_cast<Element*>(m_webViewHelper.webView()->mainFram e()->document().getElementById(id)); |
1717 return tapElement(type, element); | 1720 return tapElement(type, element); |
1718 } | 1721 } |
1719 | 1722 |
1723 WebInputMethodController* WebViewTest::inputMethodController() const | |
lfg
2016/09/21 16:56:14
Can you make this function take a frame as an argu
EhsanK
2016/09/26 20:54:29
This is supposed to return the controller for the
lfg
2016/09/29 14:16:41
I don't think I understand this.
Why can't you ju
EhsanK
2016/11/01 15:46:04
Removed the method, and now, similar to your sugge
| |
1724 { | |
1725 return m_webViewHelper.webView()->mainFrameImpl()->frameWidget()->getActiveW ebInputMethodController(); | |
1726 } | |
1727 | |
1720 TEST_F(WebViewTest, DetectContentAroundPosition) | 1728 TEST_F(WebViewTest, DetectContentAroundPosition) |
1721 { | 1729 { |
1722 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("content_listeners.html")); | 1730 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("content_listeners.html")); |
1723 | 1731 |
1724 ContentDetectorClient client; | 1732 ContentDetectorClient client; |
1725 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_li steners.html", true, 0, &client); | 1733 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_li steners.html", true, 0, &client); |
1726 webView->resize(WebSize(500, 300)); | 1734 webView->resize(WebSize(500, 300)); |
1727 webView->updateAllLifecyclePhases(); | 1735 webView->updateAllLifecyclePhases(); |
1728 runPendingTasks(); | 1736 runPendingTasks(); |
1729 | 1737 |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2310 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "compos ition_not_cancelled_by_backspace.html"); | 2318 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "compos ition_not_cancelled_by_backspace.html"); |
2311 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 2319 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
2312 frame->setAutofillClient(&client); | 2320 frame->setAutofillClient(&client); |
2313 webView->setInitialFocus(false); | 2321 webView->setInitialFocus(false); |
2314 | 2322 |
2315 // Test both input elements. | 2323 // Test both input elements. |
2316 for (int i = 0; i < 2; ++i) { | 2324 for (int i = 0; i < 2; ++i) { |
2317 // Select composition and do sanity check. | 2325 // Select composition and do sanity check. |
2318 WebVector<WebCompositionUnderline> emptyUnderlines; | 2326 WebVector<WebCompositionUnderline> emptyUnderlines; |
2319 frame->setEditableSelectionOffsets(6, 6); | 2327 frame->setEditableSelectionOffsets(6, 6); |
2320 EXPECT_TRUE(webView->setComposition("fghij", emptyUnderlines, 0, 5)); | 2328 EXPECT_TRUE(inputMethodController()->setComposition("fghij", emptyUnderl ines, 0, 5)); |
2321 frame->setEditableSelectionOffsets(11, 11); | 2329 frame->setEditableSelectionOffsets(11, 11); |
2322 verifySelectionAndComposition(webView, 11, 11, 6, 11, "initial case"); | 2330 verifySelectionAndComposition(webView, 11, 11, 6, 11, "initial case"); |
2323 | 2331 |
2324 // Press Backspace and verify composition didn't get cancelled. This is to verify the fix | 2332 // Press Backspace and verify composition didn't get cancelled. This is to verify the fix |
2325 // for crbug.com/429916. | 2333 // for crbug.com/429916. |
2326 WebKeyboardEvent keyEvent; | 2334 WebKeyboardEvent keyEvent; |
2327 keyEvent.domKey = Platform::current()->domKeyEnumFromString("\b"); | 2335 keyEvent.domKey = Platform::current()->domKeyEnumFromString("\b"); |
2328 keyEvent.windowsKeyCode = VKEY_BACK; | 2336 keyEvent.windowsKeyCode = VKEY_BACK; |
2329 keyEvent.type = WebInputEvent::RawKeyDown; | 2337 keyEvent.type = WebInputEvent::RawKeyDown; |
2330 webView->handleInputEvent(keyEvent); | 2338 webView->handleInputEvent(keyEvent); |
2331 | 2339 |
2332 frame->setEditableSelectionOffsets(6, 6); | 2340 frame->setEditableSelectionOffsets(6, 6); |
2333 EXPECT_TRUE(webView->setComposition("fghi", emptyUnderlines, 0, 4)); | 2341 EXPECT_TRUE(inputMethodController()->setComposition("fghi", emptyUnderli nes, 0, 4)); |
2334 frame->setEditableSelectionOffsets(10, 10); | 2342 frame->setEditableSelectionOffsets(10, 10); |
2335 verifySelectionAndComposition(webView, 10, 10, 6, 10, "after pressing Ba ckspace"); | 2343 verifySelectionAndComposition(webView, 10, 10, 6, 10, "after pressing Ba ckspace"); |
2336 | 2344 |
2337 keyEvent.type = WebInputEvent::KeyUp; | 2345 keyEvent.type = WebInputEvent::KeyUp; |
2338 webView->handleInputEvent(keyEvent); | 2346 webView->handleInputEvent(keyEvent); |
2339 | 2347 |
2340 webView->advanceFocus(false); | 2348 webView->advanceFocus(false); |
2341 } | 2349 } |
2342 | 2350 |
2343 frame->setAutofillClient(0); | 2351 frame->setAutofillClient(0); |
2344 } | 2352 } |
2345 | 2353 |
2346 TEST_F(WebViewTest, FinishComposingTextTriggersAutofillTextChange) | 2354 TEST_F(WebViewTest, FinishComposingTextTriggersAutofillTextChange) |
2347 { | 2355 { |
2348 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); | 2356 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); |
2349 MockAutofillClient client; | 2357 MockAutofillClient client; |
2350 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_ field_populated.html"); | 2358 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_ field_populated.html"); |
2351 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 2359 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
2352 frame->setAutofillClient(&client); | 2360 frame->setAutofillClient(&client); |
2353 webView->setInitialFocus(false); | 2361 webView->setInitialFocus(false); |
2354 | 2362 |
2355 // Set up a composition that needs to be committed. | 2363 // Set up a composition that needs to be committed. |
2356 std::string compositionText("testingtext"); | 2364 std::string compositionText("testingtext"); |
2357 | 2365 |
2358 WebVector<WebCompositionUnderline> emptyUnderlines; | 2366 WebVector<WebCompositionUnderline> emptyUnderlines; |
2359 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU nderlines, 0, compositionText.length()); | 2367 inputMethodController()->setComposition(WebString::fromUTF8(compositionText. c_str()), emptyUnderlines, 0, compositionText.length()); |
2360 | 2368 |
2361 WebTextInputInfo info = webView->textInputInfo(); | 2369 WebTextInputInfo info = webView->textInputInfo(); |
2362 EXPECT_EQ(0, info.selectionStart); | 2370 EXPECT_EQ(0, info.selectionStart); |
2363 EXPECT_EQ((int) compositionText.length(), info.selectionEnd); | 2371 EXPECT_EQ((int) compositionText.length(), info.selectionEnd); |
2364 EXPECT_EQ(0, info.compositionStart); | 2372 EXPECT_EQ(0, info.compositionStart); |
2365 EXPECT_EQ((int) compositionText.length(), info.compositionEnd); | 2373 EXPECT_EQ((int) compositionText.length(), info.compositionEnd); |
2366 | 2374 |
2367 client.clearChangeCounts(); | 2375 client.clearChangeCounts(); |
2368 webView->finishComposingText(WebWidget::KeepSelection); | 2376 inputMethodController()->finishComposingText(WebInputMethodController::KeepS election); |
2369 EXPECT_EQ(0, client.textChangesWhileIgnored()); | 2377 EXPECT_EQ(0, client.textChangesWhileIgnored()); |
2370 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); | 2378 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); |
2371 | 2379 |
2372 frame->setAutofillClient(0); | 2380 frame->setAutofillClient(0); |
2373 } | 2381 } |
2374 | 2382 |
2375 TEST_F(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) | 2383 TEST_F(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) |
2376 { | 2384 { |
2377 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); | 2385 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); |
2378 MockAutofillClient client; | 2386 MockAutofillClient client; |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3060 inputElement->setValue("testA"); | 3068 inputElement->setValue("testA"); |
3061 EXPECT_TRUE(client.textIsUpdated()); | 3069 EXPECT_TRUE(client.textIsUpdated()); |
3062 WebTextInputInfo info = webViewImpl->textInputInfo(); | 3070 WebTextInputInfo info = webViewImpl->textInputInfo(); |
3063 EXPECT_EQ("testA", std::string(info.value.utf8().data())); | 3071 EXPECT_EQ("testA", std::string(info.value.utf8().data())); |
3064 | 3072 |
3065 // (A.2) Focused and user input modifies value. | 3073 // (A.2) Focused and user input modifies value. |
3066 client.reset(); | 3074 client.reset(); |
3067 EXPECT_FALSE(client.textIsUpdated()); | 3075 EXPECT_FALSE(client.textIsUpdated()); |
3068 | 3076 |
3069 WebVector<WebCompositionUnderline> emptyUnderlines; | 3077 WebVector<WebCompositionUnderline> emptyUnderlines; |
3070 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1) ; | 3078 inputMethodController()->setComposition(WebString::fromUTF8("2"), emptyUnder lines, 1, 1); |
3071 webViewImpl->finishComposingText(WebWidget::KeepSelection); | 3079 inputMethodController()->finishComposingText(WebInputMethodController::KeepS election); |
3072 EXPECT_FALSE(client.textIsUpdated()); | 3080 EXPECT_FALSE(client.textIsUpdated()); |
3073 info = webViewImpl->textInputInfo(); | 3081 info = webViewImpl->textInputInfo(); |
3074 EXPECT_EQ("testA2", std::string(info.value.utf8().data())); | 3082 EXPECT_EQ("testA2", std::string(info.value.utf8().data())); |
3075 | 3083 |
3076 // (A.3) Unfocused and value is changed by script. | 3084 // (A.3) Unfocused and value is changed by script. |
3077 client.reset(); | 3085 client.reset(); |
3078 EXPECT_FALSE(client.textIsUpdated()); | 3086 EXPECT_FALSE(client.textIsUpdated()); |
3079 document->clearFocusedElement(); | 3087 document->clearFocusedElement(); |
3080 webViewImpl->setFocus(false); | 3088 webViewImpl->setFocus(false); |
3081 EXPECT_NE(document->focusedElement(), static_cast<Element*>(inputElement)); | 3089 EXPECT_NE(document->focusedElement(), static_cast<Element*>(inputElement)); |
3082 inputElement->setValue("testA3"); | 3090 inputElement->setValue("testA3"); |
3083 EXPECT_FALSE(client.textIsUpdated()); | 3091 EXPECT_FALSE(client.textIsUpdated()); |
3084 | 3092 |
3085 // (B) <textarea> | 3093 // (B) <textarea> |
3086 // (B.1) Focused and value is changed by script. | 3094 // (B.1) Focused and value is changed by script. |
3087 client.reset(); | 3095 client.reset(); |
3088 EXPECT_FALSE(client.textIsUpdated()); | 3096 EXPECT_FALSE(client.textIsUpdated()); |
3089 HTMLTextAreaElement* textAreaElement = toHTMLTextAreaElement(document->getEl ementById("textarea")); | 3097 HTMLTextAreaElement* textAreaElement = toHTMLTextAreaElement(document->getEl ementById("textarea")); |
3090 document->setFocusedElement(textAreaElement, FocusParams(SelectionBehaviorOn Focus::None, WebFocusTypeNone, nullptr)); | 3098 document->setFocusedElement(textAreaElement, FocusParams(SelectionBehaviorOn Focus::None, WebFocusTypeNone, nullptr)); |
3091 webViewImpl->setFocus(true); | 3099 webViewImpl->setFocus(true); |
3092 EXPECT_EQ(document->focusedElement(), static_cast<Element*>(textAreaElement) ); | 3100 EXPECT_EQ(document->focusedElement(), static_cast<Element*>(textAreaElement) ); |
3093 textAreaElement->setValue("testB"); | 3101 textAreaElement->setValue("testB"); |
3094 EXPECT_TRUE(client.textIsUpdated()); | 3102 EXPECT_TRUE(client.textIsUpdated()); |
3095 info = webViewImpl->textInputInfo(); | 3103 info = webViewImpl->textInputInfo(); |
3096 EXPECT_EQ("testB", std::string(info.value.utf8().data())); | 3104 EXPECT_EQ("testB", std::string(info.value.utf8().data())); |
3097 | 3105 |
3098 // (B.2) Focused and user input modifies value. | 3106 // (B.2) Focused and user input modifies value. |
3099 client.reset(); | 3107 client.reset(); |
3100 EXPECT_FALSE(client.textIsUpdated()); | 3108 EXPECT_FALSE(client.textIsUpdated()); |
3101 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1) ; | 3109 inputMethodController()->setComposition(WebString::fromUTF8("2"), emptyUnder lines, 1, 1); |
3102 webViewImpl->finishComposingText(WebWidget::KeepSelection); | 3110 inputMethodController()->finishComposingText(WebInputMethodController::KeepS election); |
3103 info = webViewImpl->textInputInfo(); | 3111 info = webViewImpl->textInputInfo(); |
3104 EXPECT_EQ("testB2", std::string(info.value.utf8().data())); | 3112 EXPECT_EQ("testB2", std::string(info.value.utf8().data())); |
3105 | 3113 |
3106 // (B.3) Unfocused and value is changed by script. | 3114 // (B.3) Unfocused and value is changed by script. |
3107 client.reset(); | 3115 client.reset(); |
3108 EXPECT_FALSE(client.textIsUpdated()); | 3116 EXPECT_FALSE(client.textIsUpdated()); |
3109 document->clearFocusedElement(); | 3117 document->clearFocusedElement(); |
3110 webViewImpl->setFocus(false); | 3118 webViewImpl->setFocus(false); |
3111 EXPECT_NE(document->focusedElement(), static_cast<Element*>(textAreaElement) ); | 3119 EXPECT_NE(document->focusedElement(), static_cast<Element*>(textAreaElement) ); |
3112 inputElement->setValue("testB3"); | 3120 inputElement->setValue("testB3"); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3185 | 3193 |
3186 TEST_F(WebViewTest, CompositionIsUserGesture) | 3194 TEST_F(WebViewTest, CompositionIsUserGesture) |
3187 { | 3195 { |
3188 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); | 3196 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); |
3189 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_ field_populated.html"); | 3197 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_ field_populated.html"); |
3190 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 3198 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
3191 MockAutofillClient client; | 3199 MockAutofillClient client; |
3192 frame->setAutofillClient(&client); | 3200 frame->setAutofillClient(&client); |
3193 webView->setInitialFocus(false); | 3201 webView->setInitialFocus(false); |
3194 | 3202 |
3195 EXPECT_TRUE(webView->setComposition(WebString::fromUTF8(std::string("hello") .c_str()), WebVector<WebCompositionUnderline>(), 3, 3)); | 3203 EXPECT_TRUE(inputMethodController()->setComposition(WebString::fromUTF8(std: :string("hello").c_str()), WebVector<WebCompositionUnderline>(), 3, 3)); |
3196 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 3204 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
3197 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 3205 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
3198 EXPECT_TRUE(frame->hasMarkedText()); | 3206 EXPECT_TRUE(frame->hasMarkedText()); |
3199 | 3207 |
3200 frame->setAutofillClient(0); | 3208 frame->setAutofillClient(0); |
3201 } | 3209 } |
3202 | 3210 |
3203 TEST_F(WebViewTest, CompareSelectAllToContentAsText) | 3211 TEST_F(WebViewTest, CompareSelectAllToContentAsText) |
3204 { | 3212 { |
3205 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("longpress_selection.html")); | 3213 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("longpress_selection.html")); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3533 | 3541 |
3534 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) | 3542 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) |
3535 { | 3543 { |
3536 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_password.html")); | 3544 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_password.html")); |
3537 MockAutofillClient client; | 3545 MockAutofillClient client; |
3538 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_ field_password.html", true); | 3546 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_ field_password.html", true); |
3539 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 3547 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
3540 frame->setAutofillClient(&client); | 3548 frame->setAutofillClient(&client); |
3541 webView->setInitialFocus(false); | 3549 webView->setInitialFocus(false); |
3542 | 3550 |
3543 EXPECT_TRUE(webView->commitText(WebString::fromUTF8(std::string("hello").c_s tr()), 0)); | 3551 EXPECT_TRUE(inputMethodController()->commitText(WebString::fromUTF8(std::str ing("hello").c_str()), 0)); |
3544 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 3552 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
3545 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 3553 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
3546 frame->setAutofillClient(0); | 3554 frame->setAutofillClient(0); |
3547 } | 3555 } |
3548 | 3556 |
3549 // Verify that a WebView created with a ScopedPageLoadDeferrer already on the | 3557 // Verify that a WebView created with a ScopedPageLoadDeferrer already on the |
3550 // stack defers its loads. | 3558 // stack defers its loads. |
3551 TEST_F(WebViewTest, CreatedDuringLoadDeferral) | 3559 TEST_F(WebViewTest, CreatedDuringLoadDeferral) |
3552 { | 3560 { |
3553 { | 3561 { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3611 EXPECT_TRUE(webView->page()->defersLoading()); | 3619 EXPECT_TRUE(webView->page()->defersLoading()); |
3612 } | 3620 } |
3613 | 3621 |
3614 EXPECT_TRUE(webView->page()->defersLoading()); | 3622 EXPECT_TRUE(webView->page()->defersLoading()); |
3615 } | 3623 } |
3616 | 3624 |
3617 EXPECT_FALSE(webView->page()->defersLoading()); | 3625 EXPECT_FALSE(webView->page()->defersLoading()); |
3618 } | 3626 } |
3619 | 3627 |
3620 } // namespace blink | 3628 } // namespace blink |
OLD | NEW |