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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 #include "public/web/WebCache.h" | 78 #include "public/web/WebCache.h" |
79 #include "public/web/WebDateTimeChooserCompletion.h" | 79 #include "public/web/WebDateTimeChooserCompletion.h" |
80 #include "public/web/WebDeviceEmulationParams.h" | 80 #include "public/web/WebDeviceEmulationParams.h" |
81 #include "public/web/WebDocument.h" | 81 #include "public/web/WebDocument.h" |
82 #include "public/web/WebElement.h" | 82 #include "public/web/WebElement.h" |
83 #include "public/web/WebFrame.h" | 83 #include "public/web/WebFrame.h" |
84 #include "public/web/WebFrameClient.h" | 84 #include "public/web/WebFrameClient.h" |
85 #include "public/web/WebFrameContentDumper.h" | 85 #include "public/web/WebFrameContentDumper.h" |
86 #include "public/web/WebHitTestResult.h" | 86 #include "public/web/WebHitTestResult.h" |
87 #include "public/web/WebInputEvent.h" | 87 #include "public/web/WebInputEvent.h" |
| 88 #include "public/web/WebInputMethodController.h" |
88 #include "public/web/WebScriptSource.h" | 89 #include "public/web/WebScriptSource.h" |
89 #include "public/web/WebSettings.h" | 90 #include "public/web/WebSettings.h" |
90 #include "public/web/WebTreeScopeType.h" | 91 #include "public/web/WebTreeScopeType.h" |
91 #include "public/web/WebViewClient.h" | 92 #include "public/web/WebViewClient.h" |
92 #include "public/web/WebWidget.h" | 93 #include "public/web/WebWidget.h" |
93 #include "public/web/WebWidgetClient.h" | 94 #include "public/web/WebWidgetClient.h" |
94 #include "testing/gtest/include/gtest/gtest.h" | 95 #include "testing/gtest/include/gtest/gtest.h" |
95 #include "third_party/skia/include/core/SkBitmap.h" | 96 #include "third_party/skia/include/core/SkBitmap.h" |
96 #include "third_party/skia/include/core/SkCanvas.h" | 97 #include "third_party/skia/include/core/SkCanvas.h" |
97 #include "web/DevToolsEmulator.h" | 98 #include "web/DevToolsEmulator.h" |
| 99 #include "web/WebInputMethodControllerImpl.h" |
98 #include "web/WebLocalFrameImpl.h" | 100 #include "web/WebLocalFrameImpl.h" |
99 #include "web/WebSettingsImpl.h" | 101 #include "web/WebSettingsImpl.h" |
100 #include "web/WebViewImpl.h" | 102 #include "web/WebViewImpl.h" |
101 #include "web/tests/FrameTestHelpers.h" | 103 #include "web/tests/FrameTestHelpers.h" |
102 #include "wtf/PtrUtil.h" | 104 #include "wtf/PtrUtil.h" |
103 #include <memory> | 105 #include <memory> |
104 | 106 |
105 #if OS(MACOSX) | 107 #if OS(MACOSX) |
106 #include "public/web/mac/WebSubstringUtil.h" | 108 #include "public/web/mac/WebSubstringUtil.h" |
107 #endif | 109 #endif |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 EXPECT_EQ(8, info.selectionStart); | 885 EXPECT_EQ(8, info.selectionStart); |
884 EXPECT_EQ(19, info.selectionEnd); | 886 EXPECT_EQ(19, info.selectionEnd); |
885 EXPECT_EQ(-1, info.compositionStart); | 887 EXPECT_EQ(-1, info.compositionStart); |
886 EXPECT_EQ(-1, info.compositionEnd); | 888 EXPECT_EQ(-1, info.compositionEnd); |
887 } | 889 } |
888 | 890 |
889 TEST_F(WebViewTest, FinishComposingTextCursorPositionChange) { | 891 TEST_F(WebViewTest, FinishComposingTextCursorPositionChange) { |
890 URLTestHelpers::registerMockedURLFromBaseURL( | 892 URLTestHelpers::registerMockedURLFromBaseURL( |
891 WebString::fromUTF8(m_baseURL.c_str()), | 893 WebString::fromUTF8(m_baseURL.c_str()), |
892 WebString::fromUTF8("input_field_populated.html")); | 894 WebString::fromUTF8("input_field_populated.html")); |
893 WebView* webView = m_webViewHelper.initializeAndLoad( | 895 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
894 m_baseURL + "input_field_populated.html"); | 896 m_baseURL + "input_field_populated.html"); |
895 webView->setInitialFocus(false); | 897 webView->setInitialFocus(false); |
896 | 898 |
897 // Set up a composition that needs to be committed. | 899 // Set up a composition that needs to be committed. |
898 std::string compositionText("hello"); | 900 std::string compositionText("hello"); |
899 | 901 |
| 902 WebInputMethodController* activeInputMethodController = |
| 903 webView->mainFrameImpl() |
| 904 ->frameWidget() |
| 905 ->getActiveWebInputMethodController(); |
900 WebVector<WebCompositionUnderline> emptyUnderlines; | 906 WebVector<WebCompositionUnderline> emptyUnderlines; |
901 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 907 activeInputMethodController->setComposition( |
902 emptyUnderlines, 3, 3); | 908 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3); |
903 | 909 |
904 WebTextInputInfo info = webView->textInputInfo(); | 910 WebTextInputInfo info = webView->textInputInfo(); |
905 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 911 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
906 EXPECT_EQ(3, info.selectionStart); | 912 EXPECT_EQ(3, info.selectionStart); |
907 EXPECT_EQ(3, info.selectionEnd); | 913 EXPECT_EQ(3, info.selectionEnd); |
908 EXPECT_EQ(0, info.compositionStart); | 914 EXPECT_EQ(0, info.compositionStart); |
909 EXPECT_EQ(5, info.compositionEnd); | 915 EXPECT_EQ(5, info.compositionEnd); |
910 | 916 |
911 webView->finishComposingText(WebWidget::KeepSelection); | 917 activeInputMethodController->finishComposingText( |
| 918 WebInputMethodController::KeepSelection); |
912 info = webView->textInputInfo(); | 919 info = webView->textInputInfo(); |
913 EXPECT_EQ(3, info.selectionStart); | 920 EXPECT_EQ(3, info.selectionStart); |
914 EXPECT_EQ(3, info.selectionEnd); | 921 EXPECT_EQ(3, info.selectionEnd); |
915 EXPECT_EQ(-1, info.compositionStart); | 922 EXPECT_EQ(-1, info.compositionStart); |
916 EXPECT_EQ(-1, info.compositionEnd); | 923 EXPECT_EQ(-1, info.compositionEnd); |
917 | 924 |
918 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 925 activeInputMethodController->setComposition( |
919 emptyUnderlines, 3, 3); | 926 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3); |
920 info = webView->textInputInfo(); | 927 info = webView->textInputInfo(); |
921 EXPECT_EQ("helhellolo", std::string(info.value.utf8().data())); | 928 EXPECT_EQ("helhellolo", std::string(info.value.utf8().data())); |
922 EXPECT_EQ(6, info.selectionStart); | 929 EXPECT_EQ(6, info.selectionStart); |
923 EXPECT_EQ(6, info.selectionEnd); | 930 EXPECT_EQ(6, info.selectionEnd); |
924 EXPECT_EQ(3, info.compositionStart); | 931 EXPECT_EQ(3, info.compositionStart); |
925 EXPECT_EQ(8, info.compositionEnd); | 932 EXPECT_EQ(8, info.compositionEnd); |
926 | 933 |
927 webView->finishComposingText(WebWidget::DoNotKeepSelection); | 934 activeInputMethodController->finishComposingText( |
| 935 WebInputMethodController::DoNotKeepSelection); |
928 info = webView->textInputInfo(); | 936 info = webView->textInputInfo(); |
929 EXPECT_EQ(8, info.selectionStart); | 937 EXPECT_EQ(8, info.selectionStart); |
930 EXPECT_EQ(8, info.selectionEnd); | 938 EXPECT_EQ(8, info.selectionEnd); |
931 EXPECT_EQ(-1, info.compositionStart); | 939 EXPECT_EQ(-1, info.compositionStart); |
932 EXPECT_EQ(-1, info.compositionEnd); | 940 EXPECT_EQ(-1, info.compositionEnd); |
933 } | 941 } |
934 | 942 |
935 TEST_F(WebViewTest, SetCompositionForNewCaretPositions) { | 943 TEST_F(WebViewTest, SetCompositionForNewCaretPositions) { |
936 URLTestHelpers::registerMockedURLFromBaseURL( | 944 URLTestHelpers::registerMockedURLFromBaseURL( |
937 WebString::fromUTF8(m_baseURL.c_str()), | 945 WebString::fromUTF8(m_baseURL.c_str()), |
938 WebString::fromUTF8("input_field_populated.html")); | 946 WebString::fromUTF8("input_field_populated.html")); |
939 WebView* webView = m_webViewHelper.initializeAndLoad( | 947 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
940 m_baseURL + "input_field_populated.html"); | 948 m_baseURL + "input_field_populated.html"); |
941 webView->setInitialFocus(false); | 949 webView->setInitialFocus(false); |
| 950 WebInputMethodController* activeInputMethodController = |
| 951 webView->mainFrameImpl() |
| 952 ->frameWidget() |
| 953 ->getActiveWebInputMethodController(); |
942 | 954 |
943 webView->commitText("hello", 0); | 955 activeInputMethodController->commitText("hello", 0); |
944 webView->commitText("world", -5); | 956 activeInputMethodController->commitText("world", -5); |
945 WebTextInputInfo info = webView->textInputInfo(); | 957 WebTextInputInfo info = webView->textInputInfo(); |
946 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 958 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
947 EXPECT_EQ(5, info.selectionStart); | 959 EXPECT_EQ(5, info.selectionStart); |
948 EXPECT_EQ(5, info.selectionEnd); | 960 EXPECT_EQ(5, info.selectionEnd); |
949 EXPECT_EQ(-1, info.compositionStart); | 961 EXPECT_EQ(-1, info.compositionStart); |
950 EXPECT_EQ(-1, info.compositionEnd); | 962 EXPECT_EQ(-1, info.compositionEnd); |
951 | 963 |
952 WebVector<WebCompositionUnderline> emptyUnderlines; | 964 WebVector<WebCompositionUnderline> emptyUnderlines; |
953 // Set up a composition that needs to be committed. | 965 // Set up a composition that needs to be committed. |
954 std::string compositionText("ABC"); | 966 std::string compositionText("ABC"); |
955 | 967 |
956 // Caret is on the left of composing text. | 968 // Caret is on the left of composing text. |
957 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 969 activeInputMethodController->setComposition( |
958 emptyUnderlines, 0, 0); | 970 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0, 0); |
959 info = webView->textInputInfo(); | 971 info = webView->textInputInfo(); |
960 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 972 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
961 EXPECT_EQ(5, info.selectionStart); | 973 EXPECT_EQ(5, info.selectionStart); |
962 EXPECT_EQ(5, info.selectionEnd); | 974 EXPECT_EQ(5, info.selectionEnd); |
963 EXPECT_EQ(5, info.compositionStart); | 975 EXPECT_EQ(5, info.compositionStart); |
964 EXPECT_EQ(8, info.compositionEnd); | 976 EXPECT_EQ(8, info.compositionEnd); |
965 | 977 |
966 // Caret is on the right of composing text. | 978 // Caret is on the right of composing text. |
967 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 979 activeInputMethodController->setComposition( |
968 emptyUnderlines, 3, 3); | 980 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3); |
969 info = webView->textInputInfo(); | 981 info = webView->textInputInfo(); |
970 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 982 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
971 EXPECT_EQ(8, info.selectionStart); | 983 EXPECT_EQ(8, info.selectionStart); |
972 EXPECT_EQ(8, info.selectionEnd); | 984 EXPECT_EQ(8, info.selectionEnd); |
973 EXPECT_EQ(5, info.compositionStart); | 985 EXPECT_EQ(5, info.compositionStart); |
974 EXPECT_EQ(8, info.compositionEnd); | 986 EXPECT_EQ(8, info.compositionEnd); |
975 | 987 |
976 // Caret is between composing text and left boundary. | 988 // Caret is between composing text and left boundary. |
977 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 989 activeInputMethodController->setComposition( |
978 emptyUnderlines, -2, -2); | 990 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -2, -2); |
979 info = webView->textInputInfo(); | 991 info = webView->textInputInfo(); |
980 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 992 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
981 EXPECT_EQ(3, info.selectionStart); | 993 EXPECT_EQ(3, info.selectionStart); |
982 EXPECT_EQ(3, info.selectionEnd); | 994 EXPECT_EQ(3, info.selectionEnd); |
983 EXPECT_EQ(5, info.compositionStart); | 995 EXPECT_EQ(5, info.compositionStart); |
984 EXPECT_EQ(8, info.compositionEnd); | 996 EXPECT_EQ(8, info.compositionEnd); |
985 | 997 |
986 // Caret is between composing text and right boundary. | 998 // Caret is between composing text and right boundary. |
987 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 999 activeInputMethodController->setComposition( |
988 emptyUnderlines, 5, 5); | 1000 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 5, 5); |
989 info = webView->textInputInfo(); | 1001 info = webView->textInputInfo(); |
990 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1002 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
991 EXPECT_EQ(10, info.selectionStart); | 1003 EXPECT_EQ(10, info.selectionStart); |
992 EXPECT_EQ(10, info.selectionEnd); | 1004 EXPECT_EQ(10, info.selectionEnd); |
993 EXPECT_EQ(5, info.compositionStart); | 1005 EXPECT_EQ(5, info.compositionStart); |
994 EXPECT_EQ(8, info.compositionEnd); | 1006 EXPECT_EQ(8, info.compositionEnd); |
995 | 1007 |
996 // Caret is on the left boundary. | 1008 // Caret is on the left boundary. |
997 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 1009 activeInputMethodController->setComposition( |
998 emptyUnderlines, -5, -5); | 1010 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -5, -5); |
999 info = webView->textInputInfo(); | 1011 info = webView->textInputInfo(); |
1000 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1012 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
1001 EXPECT_EQ(0, info.selectionStart); | 1013 EXPECT_EQ(0, info.selectionStart); |
1002 EXPECT_EQ(0, info.selectionEnd); | 1014 EXPECT_EQ(0, info.selectionEnd); |
1003 EXPECT_EQ(5, info.compositionStart); | 1015 EXPECT_EQ(5, info.compositionStart); |
1004 EXPECT_EQ(8, info.compositionEnd); | 1016 EXPECT_EQ(8, info.compositionEnd); |
1005 | 1017 |
1006 // Caret is on the right boundary. | 1018 // Caret is on the right boundary. |
1007 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 1019 activeInputMethodController->setComposition( |
1008 emptyUnderlines, 8, 8); | 1020 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 8, 8); |
1009 info = webView->textInputInfo(); | 1021 info = webView->textInputInfo(); |
1010 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1022 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
1011 EXPECT_EQ(13, info.selectionStart); | 1023 EXPECT_EQ(13, info.selectionStart); |
1012 EXPECT_EQ(13, info.selectionEnd); | 1024 EXPECT_EQ(13, info.selectionEnd); |
1013 EXPECT_EQ(5, info.compositionStart); | 1025 EXPECT_EQ(5, info.compositionStart); |
1014 EXPECT_EQ(8, info.compositionEnd); | 1026 EXPECT_EQ(8, info.compositionEnd); |
1015 | 1027 |
1016 // Caret exceeds the left boundary. | 1028 // Caret exceeds the left boundary. |
1017 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 1029 activeInputMethodController->setComposition( |
1018 emptyUnderlines, -100, -100); | 1030 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -100, |
| 1031 -100); |
1019 info = webView->textInputInfo(); | 1032 info = webView->textInputInfo(); |
1020 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1033 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
1021 EXPECT_EQ(0, info.selectionStart); | 1034 EXPECT_EQ(0, info.selectionStart); |
1022 EXPECT_EQ(0, info.selectionEnd); | 1035 EXPECT_EQ(0, info.selectionEnd); |
1023 EXPECT_EQ(5, info.compositionStart); | 1036 EXPECT_EQ(5, info.compositionStart); |
1024 EXPECT_EQ(8, info.compositionEnd); | 1037 EXPECT_EQ(8, info.compositionEnd); |
1025 | 1038 |
1026 // Caret exceeds the right boundary. | 1039 // Caret exceeds the right boundary. |
1027 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 1040 activeInputMethodController->setComposition( |
1028 emptyUnderlines, 100, 100); | 1041 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 100, 100); |
1029 info = webView->textInputInfo(); | 1042 info = webView->textInputInfo(); |
1030 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1043 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
1031 EXPECT_EQ(13, info.selectionStart); | 1044 EXPECT_EQ(13, info.selectionStart); |
1032 EXPECT_EQ(13, info.selectionEnd); | 1045 EXPECT_EQ(13, info.selectionEnd); |
1033 EXPECT_EQ(5, info.compositionStart); | 1046 EXPECT_EQ(5, info.compositionStart); |
1034 EXPECT_EQ(8, info.compositionEnd); | 1047 EXPECT_EQ(8, info.compositionEnd); |
1035 } | 1048 } |
1036 | 1049 |
1037 TEST_F(WebViewTest, SetCompositionWithEmptyText) { | 1050 TEST_F(WebViewTest, SetCompositionWithEmptyText) { |
1038 URLTestHelpers::registerMockedURLFromBaseURL( | 1051 URLTestHelpers::registerMockedURLFromBaseURL( |
1039 WebString::fromUTF8(m_baseURL.c_str()), | 1052 WebString::fromUTF8(m_baseURL.c_str()), |
1040 WebString::fromUTF8("input_field_populated.html")); | 1053 WebString::fromUTF8("input_field_populated.html")); |
1041 WebView* webView = m_webViewHelper.initializeAndLoad( | 1054 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
1042 m_baseURL + "input_field_populated.html"); | 1055 m_baseURL + "input_field_populated.html"); |
1043 webView->setInitialFocus(false); | 1056 webView->setInitialFocus(false); |
| 1057 WebInputMethodController* activeInputMethodController = |
| 1058 webView->mainFrameImpl() |
| 1059 ->frameWidget() |
| 1060 ->getActiveWebInputMethodController(); |
1044 | 1061 |
1045 webView->commitText("hello", 0); | 1062 activeInputMethodController->commitText("hello", 0); |
1046 WebTextInputInfo info = webView->textInputInfo(); | 1063 WebTextInputInfo info = webView->textInputInfo(); |
1047 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1064 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1048 EXPECT_EQ(5, info.selectionStart); | 1065 EXPECT_EQ(5, info.selectionStart); |
1049 EXPECT_EQ(5, info.selectionEnd); | 1066 EXPECT_EQ(5, info.selectionEnd); |
1050 EXPECT_EQ(-1, info.compositionStart); | 1067 EXPECT_EQ(-1, info.compositionStart); |
1051 EXPECT_EQ(-1, info.compositionEnd); | 1068 EXPECT_EQ(-1, info.compositionEnd); |
1052 | 1069 |
1053 WebVector<WebCompositionUnderline> emptyUnderlines; | 1070 WebVector<WebCompositionUnderline> emptyUnderlines; |
1054 | 1071 |
1055 webView->setComposition(WebString::fromUTF8(""), emptyUnderlines, 0, 0); | 1072 activeInputMethodController->setComposition(WebString::fromUTF8(""), |
| 1073 emptyUnderlines, 0, 0); |
1056 info = webView->textInputInfo(); | 1074 info = webView->textInputInfo(); |
1057 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1075 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1058 EXPECT_EQ(5, info.selectionStart); | 1076 EXPECT_EQ(5, info.selectionStart); |
1059 EXPECT_EQ(5, info.selectionEnd); | 1077 EXPECT_EQ(5, info.selectionEnd); |
1060 EXPECT_EQ(-1, info.compositionStart); | 1078 EXPECT_EQ(-1, info.compositionStart); |
1061 EXPECT_EQ(-1, info.compositionEnd); | 1079 EXPECT_EQ(-1, info.compositionEnd); |
1062 | 1080 |
1063 webView->setComposition(WebString::fromUTF8(""), emptyUnderlines, -2, -2); | 1081 activeInputMethodController->setComposition(WebString::fromUTF8(""), |
| 1082 emptyUnderlines, -2, -2); |
1064 info = webView->textInputInfo(); | 1083 info = webView->textInputInfo(); |
1065 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1084 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1066 EXPECT_EQ(3, info.selectionStart); | 1085 EXPECT_EQ(3, info.selectionStart); |
1067 EXPECT_EQ(3, info.selectionEnd); | 1086 EXPECT_EQ(3, info.selectionEnd); |
1068 EXPECT_EQ(-1, info.compositionStart); | 1087 EXPECT_EQ(-1, info.compositionStart); |
1069 EXPECT_EQ(-1, info.compositionEnd); | 1088 EXPECT_EQ(-1, info.compositionEnd); |
1070 } | 1089 } |
1071 | 1090 |
1072 TEST_F(WebViewTest, CommitTextForNewCaretPositions) { | 1091 TEST_F(WebViewTest, CommitTextForNewCaretPositions) { |
1073 URLTestHelpers::registerMockedURLFromBaseURL( | 1092 URLTestHelpers::registerMockedURLFromBaseURL( |
1074 WebString::fromUTF8(m_baseURL.c_str()), | 1093 WebString::fromUTF8(m_baseURL.c_str()), |
1075 WebString::fromUTF8("input_field_populated.html")); | 1094 WebString::fromUTF8("input_field_populated.html")); |
1076 WebView* webView = m_webViewHelper.initializeAndLoad( | 1095 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
1077 m_baseURL + "input_field_populated.html"); | 1096 m_baseURL + "input_field_populated.html"); |
1078 webView->setInitialFocus(false); | 1097 webView->setInitialFocus(false); |
| 1098 WebInputMethodController* activeInputMethodController = |
| 1099 webView->mainFrameImpl() |
| 1100 ->frameWidget() |
| 1101 ->getActiveWebInputMethodController(); |
1079 | 1102 |
1080 // Caret is on the left of composing text. | 1103 // Caret is on the left of composing text. |
1081 webView->commitText("ab", -2); | 1104 activeInputMethodController->commitText("ab", -2); |
1082 WebTextInputInfo info = webView->textInputInfo(); | 1105 WebTextInputInfo info = webView->textInputInfo(); |
1083 EXPECT_EQ("ab", std::string(info.value.utf8().data())); | 1106 EXPECT_EQ("ab", std::string(info.value.utf8().data())); |
1084 EXPECT_EQ(0, info.selectionStart); | 1107 EXPECT_EQ(0, info.selectionStart); |
1085 EXPECT_EQ(0, info.selectionEnd); | 1108 EXPECT_EQ(0, info.selectionEnd); |
1086 EXPECT_EQ(-1, info.compositionStart); | 1109 EXPECT_EQ(-1, info.compositionStart); |
1087 EXPECT_EQ(-1, info.compositionEnd); | 1110 EXPECT_EQ(-1, info.compositionEnd); |
1088 | 1111 |
1089 // Caret is on the right of composing text. | 1112 // Caret is on the right of composing text. |
1090 webView->commitText("c", 1); | 1113 activeInputMethodController->commitText("c", 1); |
1091 info = webView->textInputInfo(); | 1114 info = webView->textInputInfo(); |
1092 EXPECT_EQ("cab", std::string(info.value.utf8().data())); | 1115 EXPECT_EQ("cab", std::string(info.value.utf8().data())); |
1093 EXPECT_EQ(2, info.selectionStart); | 1116 EXPECT_EQ(2, info.selectionStart); |
1094 EXPECT_EQ(2, info.selectionEnd); | 1117 EXPECT_EQ(2, info.selectionEnd); |
1095 EXPECT_EQ(-1, info.compositionStart); | 1118 EXPECT_EQ(-1, info.compositionStart); |
1096 EXPECT_EQ(-1, info.compositionEnd); | 1119 EXPECT_EQ(-1, info.compositionEnd); |
1097 | 1120 |
1098 // Caret is on the left boundary. | 1121 // Caret is on the left boundary. |
1099 webView->commitText("def", -5); | 1122 activeInputMethodController->commitText("def", -5); |
1100 info = webView->textInputInfo(); | 1123 info = webView->textInputInfo(); |
1101 EXPECT_EQ("cadefb", std::string(info.value.utf8().data())); | 1124 EXPECT_EQ("cadefb", std::string(info.value.utf8().data())); |
1102 EXPECT_EQ(0, info.selectionStart); | 1125 EXPECT_EQ(0, info.selectionStart); |
1103 EXPECT_EQ(0, info.selectionEnd); | 1126 EXPECT_EQ(0, info.selectionEnd); |
1104 EXPECT_EQ(-1, info.compositionStart); | 1127 EXPECT_EQ(-1, info.compositionStart); |
1105 EXPECT_EQ(-1, info.compositionEnd); | 1128 EXPECT_EQ(-1, info.compositionEnd); |
1106 | 1129 |
1107 // Caret is on the right boundary. | 1130 // Caret is on the right boundary. |
1108 webView->commitText("g", 6); | 1131 activeInputMethodController->commitText("g", 6); |
1109 info = webView->textInputInfo(); | 1132 info = webView->textInputInfo(); |
1110 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data())); | 1133 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data())); |
1111 EXPECT_EQ(7, info.selectionStart); | 1134 EXPECT_EQ(7, info.selectionStart); |
1112 EXPECT_EQ(7, info.selectionEnd); | 1135 EXPECT_EQ(7, info.selectionEnd); |
1113 EXPECT_EQ(-1, info.compositionStart); | 1136 EXPECT_EQ(-1, info.compositionStart); |
1114 EXPECT_EQ(-1, info.compositionEnd); | 1137 EXPECT_EQ(-1, info.compositionEnd); |
1115 | 1138 |
1116 // Caret exceeds the left boundary. | 1139 // Caret exceeds the left boundary. |
1117 webView->commitText("hi", -100); | 1140 activeInputMethodController->commitText("hi", -100); |
1118 info = webView->textInputInfo(); | 1141 info = webView->textInputInfo(); |
1119 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data())); | 1142 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data())); |
1120 EXPECT_EQ(0, info.selectionStart); | 1143 EXPECT_EQ(0, info.selectionStart); |
1121 EXPECT_EQ(0, info.selectionEnd); | 1144 EXPECT_EQ(0, info.selectionEnd); |
1122 EXPECT_EQ(-1, info.compositionStart); | 1145 EXPECT_EQ(-1, info.compositionStart); |
1123 EXPECT_EQ(-1, info.compositionEnd); | 1146 EXPECT_EQ(-1, info.compositionEnd); |
1124 | 1147 |
1125 // Caret exceeds the right boundary. | 1148 // Caret exceeds the right boundary. |
1126 webView->commitText("jk", 100); | 1149 activeInputMethodController->commitText("jk", 100); |
1127 info = webView->textInputInfo(); | 1150 info = webView->textInputInfo(); |
1128 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); | 1151 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); |
1129 EXPECT_EQ(11, info.selectionStart); | 1152 EXPECT_EQ(11, info.selectionStart); |
1130 EXPECT_EQ(11, info.selectionEnd); | 1153 EXPECT_EQ(11, info.selectionEnd); |
1131 EXPECT_EQ(-1, info.compositionStart); | 1154 EXPECT_EQ(-1, info.compositionStart); |
1132 EXPECT_EQ(-1, info.compositionEnd); | 1155 EXPECT_EQ(-1, info.compositionEnd); |
1133 } | 1156 } |
1134 | 1157 |
1135 TEST_F(WebViewTest, CommitTextWhileComposing) { | 1158 TEST_F(WebViewTest, CommitTextWhileComposing) { |
1136 URLTestHelpers::registerMockedURLFromBaseURL( | 1159 URLTestHelpers::registerMockedURLFromBaseURL( |
1137 WebString::fromUTF8(m_baseURL.c_str()), | 1160 WebString::fromUTF8(m_baseURL.c_str()), |
1138 WebString::fromUTF8("input_field_populated.html")); | 1161 WebString::fromUTF8("input_field_populated.html")); |
1139 WebView* webView = m_webViewHelper.initializeAndLoad( | 1162 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
1140 m_baseURL + "input_field_populated.html"); | 1163 m_baseURL + "input_field_populated.html"); |
1141 webView->setInitialFocus(false); | 1164 webView->setInitialFocus(false); |
| 1165 WebInputMethodController* activeInputMethodController = |
| 1166 webView->mainFrameImpl() |
| 1167 ->frameWidget() |
| 1168 ->getActiveWebInputMethodController(); |
1142 | 1169 |
1143 WebVector<WebCompositionUnderline> emptyUnderlines; | 1170 WebVector<WebCompositionUnderline> emptyUnderlines; |
1144 webView->setComposition(WebString::fromUTF8("abc"), emptyUnderlines, 0, 0); | 1171 activeInputMethodController->setComposition(WebString::fromUTF8("abc"), |
| 1172 emptyUnderlines, 0, 0); |
1145 WebTextInputInfo info = webView->textInputInfo(); | 1173 WebTextInputInfo info = webView->textInputInfo(); |
1146 EXPECT_EQ("abc", std::string(info.value.utf8().data())); | 1174 EXPECT_EQ("abc", std::string(info.value.utf8().data())); |
1147 EXPECT_EQ(0, info.selectionStart); | 1175 EXPECT_EQ(0, info.selectionStart); |
1148 EXPECT_EQ(0, info.selectionEnd); | 1176 EXPECT_EQ(0, info.selectionEnd); |
1149 EXPECT_EQ(0, info.compositionStart); | 1177 EXPECT_EQ(0, info.compositionStart); |
1150 EXPECT_EQ(3, info.compositionEnd); | 1178 EXPECT_EQ(3, info.compositionEnd); |
1151 | 1179 |
1152 // Deletes ongoing composition, inserts the specified text and moves the | 1180 // Deletes ongoing composition, inserts the specified text and moves the |
1153 // caret. | 1181 // caret. |
1154 webView->commitText("hello", -2); | 1182 activeInputMethodController->commitText("hello", -2); |
1155 info = webView->textInputInfo(); | 1183 info = webView->textInputInfo(); |
1156 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1184 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1157 EXPECT_EQ(3, info.selectionStart); | 1185 EXPECT_EQ(3, info.selectionStart); |
1158 EXPECT_EQ(3, info.selectionEnd); | 1186 EXPECT_EQ(3, info.selectionEnd); |
1159 EXPECT_EQ(-1, info.compositionStart); | 1187 EXPECT_EQ(-1, info.compositionStart); |
1160 EXPECT_EQ(-1, info.compositionEnd); | 1188 EXPECT_EQ(-1, info.compositionEnd); |
1161 | 1189 |
1162 webView->setComposition(WebString::fromUTF8("abc"), emptyUnderlines, 0, 0); | 1190 activeInputMethodController->setComposition(WebString::fromUTF8("abc"), |
| 1191 emptyUnderlines, 0, 0); |
1163 info = webView->textInputInfo(); | 1192 info = webView->textInputInfo(); |
1164 EXPECT_EQ("helabclo", std::string(info.value.utf8().data())); | 1193 EXPECT_EQ("helabclo", std::string(info.value.utf8().data())); |
1165 EXPECT_EQ(3, info.selectionStart); | 1194 EXPECT_EQ(3, info.selectionStart); |
1166 EXPECT_EQ(3, info.selectionEnd); | 1195 EXPECT_EQ(3, info.selectionEnd); |
1167 EXPECT_EQ(3, info.compositionStart); | 1196 EXPECT_EQ(3, info.compositionStart); |
1168 EXPECT_EQ(6, info.compositionEnd); | 1197 EXPECT_EQ(6, info.compositionEnd); |
1169 | 1198 |
1170 // Deletes ongoing composition and moves the caret. | 1199 // Deletes ongoing composition and moves the caret. |
1171 webView->commitText("", 2); | 1200 activeInputMethodController->commitText("", 2); |
1172 info = webView->textInputInfo(); | 1201 info = webView->textInputInfo(); |
1173 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1202 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1174 EXPECT_EQ(5, info.selectionStart); | 1203 EXPECT_EQ(5, info.selectionStart); |
1175 EXPECT_EQ(5, info.selectionEnd); | 1204 EXPECT_EQ(5, info.selectionEnd); |
1176 EXPECT_EQ(-1, info.compositionStart); | 1205 EXPECT_EQ(-1, info.compositionStart); |
1177 EXPECT_EQ(-1, info.compositionEnd); | 1206 EXPECT_EQ(-1, info.compositionEnd); |
1178 | 1207 |
1179 // Inserts the specified text and moves the caret. | 1208 // Inserts the specified text and moves the caret. |
1180 webView->commitText("world", -5); | 1209 activeInputMethodController->commitText("world", -5); |
1181 info = webView->textInputInfo(); | 1210 info = webView->textInputInfo(); |
1182 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 1211 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
1183 EXPECT_EQ(5, info.selectionStart); | 1212 EXPECT_EQ(5, info.selectionStart); |
1184 EXPECT_EQ(5, info.selectionEnd); | 1213 EXPECT_EQ(5, info.selectionEnd); |
1185 EXPECT_EQ(-1, info.compositionStart); | 1214 EXPECT_EQ(-1, info.compositionStart); |
1186 EXPECT_EQ(-1, info.compositionEnd); | 1215 EXPECT_EQ(-1, info.compositionEnd); |
1187 | 1216 |
1188 // Only moves the caret. | 1217 // Only moves the caret. |
1189 webView->commitText("", 5); | 1218 activeInputMethodController->commitText("", 5); |
1190 info = webView->textInputInfo(); | 1219 info = webView->textInputInfo(); |
1191 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 1220 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
1192 EXPECT_EQ(10, info.selectionStart); | 1221 EXPECT_EQ(10, info.selectionStart); |
1193 EXPECT_EQ(10, info.selectionEnd); | 1222 EXPECT_EQ(10, info.selectionEnd); |
1194 EXPECT_EQ(-1, info.compositionStart); | 1223 EXPECT_EQ(-1, info.compositionStart); |
1195 EXPECT_EQ(-1, info.compositionEnd); | 1224 EXPECT_EQ(-1, info.compositionEnd); |
1196 } | 1225 } |
1197 | 1226 |
1198 TEST_F(WebViewTest, FinishCompositionDoesNotRevealSelection) { | 1227 TEST_F(WebViewTest, FinishCompositionDoesNotRevealSelection) { |
1199 URLTestHelpers::registerMockedURLFromBaseURL( | 1228 URLTestHelpers::registerMockedURLFromBaseURL( |
(...skipping 17 matching lines...) Expand all Loading... |
1217 webView->mainFrame()->document().getElementById("btn")); | 1246 webView->mainFrame()->document().getElementById("btn")); |
1218 element->scrollIntoView(); | 1247 element->scrollIntoView(); |
1219 float offsetHeight = webView->mainFrame()->scrollOffset().height; | 1248 float offsetHeight = webView->mainFrame()->scrollOffset().height; |
1220 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 1249 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
1221 EXPECT_LT(0, offsetHeight); | 1250 EXPECT_LT(0, offsetHeight); |
1222 | 1251 |
1223 WebTextInputInfo info = webView->textInputInfo(); | 1252 WebTextInputInfo info = webView->textInputInfo(); |
1224 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1253 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1225 | 1254 |
1226 // Verify that the input field is not scrolled back into the viewport. | 1255 // Verify that the input field is not scrolled back into the viewport. |
1227 webView->finishComposingText(WebWidget::DoNotKeepSelection); | 1256 frame->frameWidget() |
| 1257 ->getActiveWebInputMethodController() |
| 1258 ->finishComposingText(WebInputMethodController::DoNotKeepSelection); |
1228 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 1259 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
1229 EXPECT_EQ(offsetHeight, webView->mainFrame()->scrollOffset().height); | 1260 EXPECT_EQ(offsetHeight, webView->mainFrame()->scrollOffset().height); |
1230 } | 1261 } |
1231 | 1262 |
1232 TEST_F(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) { | 1263 TEST_F(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) { |
1233 URLTestHelpers::registerMockedURLFromBaseURL( | 1264 URLTestHelpers::registerMockedURLFromBaseURL( |
1234 WebString::fromUTF8(m_baseURL.c_str()), | 1265 WebString::fromUTF8(m_baseURL.c_str()), |
1235 WebString::fromUTF8("text_area_populated.html")); | 1266 WebString::fromUTF8("text_area_populated.html")); |
1236 WebViewImpl* webView = | 1267 WebViewImpl* webView = |
1237 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); | 1268 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); |
1238 webView->setInitialFocus(false); | 1269 webView->setInitialFocus(false); |
1239 | 1270 |
1240 WebVector<WebCompositionUnderline> emptyUnderlines; | 1271 WebVector<WebCompositionUnderline> emptyUnderlines; |
1241 | 1272 |
1242 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1273 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
1243 frame->setEditableSelectionOffsets(4, 4); | 1274 frame->setEditableSelectionOffsets(4, 4); |
1244 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); | 1275 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
1245 | 1276 |
1246 WebTextInputInfo info = webView->textInputInfo(); | 1277 WebTextInputInfo info = webView->textInputInfo(); |
1247 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", | 1278 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", |
1248 std::string(info.value.utf8().data())); | 1279 std::string(info.value.utf8().data())); |
1249 EXPECT_EQ(4, info.selectionStart); | 1280 EXPECT_EQ(4, info.selectionStart); |
1250 EXPECT_EQ(4, info.selectionEnd); | 1281 EXPECT_EQ(4, info.selectionEnd); |
1251 EXPECT_EQ(8, info.compositionStart); | 1282 EXPECT_EQ(8, info.compositionStart); |
1252 EXPECT_EQ(12, info.compositionEnd); | 1283 EXPECT_EQ(12, info.compositionEnd); |
1253 | 1284 |
1254 webView->finishComposingText(WebWidget::KeepSelection); | 1285 WebInputMethodController* activeInputMethodController = |
| 1286 frame->frameWidget()->getActiveWebInputMethodController(); |
| 1287 activeInputMethodController->finishComposingText( |
| 1288 WebInputMethodController::KeepSelection); |
1255 info = webView->textInputInfo(); | 1289 info = webView->textInputInfo(); |
1256 EXPECT_EQ(4, info.selectionStart); | 1290 EXPECT_EQ(4, info.selectionStart); |
1257 EXPECT_EQ(4, info.selectionEnd); | 1291 EXPECT_EQ(4, info.selectionEnd); |
1258 EXPECT_EQ(-1, info.compositionStart); | 1292 EXPECT_EQ(-1, info.compositionStart); |
1259 EXPECT_EQ(-1, info.compositionEnd); | 1293 EXPECT_EQ(-1, info.compositionEnd); |
1260 | 1294 |
1261 std::string compositionText("\n"); | 1295 std::string compositionText("\n"); |
1262 webView->commitText(WebString::fromUTF8(compositionText.c_str()), 0); | 1296 activeInputMethodController->commitText( |
| 1297 WebString::fromUTF8(compositionText.c_str()), 0); |
1263 info = webView->textInputInfo(); | 1298 info = webView->textInputInfo(); |
1264 EXPECT_EQ(5, info.selectionStart); | 1299 EXPECT_EQ(5, info.selectionStart); |
1265 EXPECT_EQ(5, info.selectionEnd); | 1300 EXPECT_EQ(5, info.selectionEnd); |
1266 EXPECT_EQ(-1, info.compositionStart); | 1301 EXPECT_EQ(-1, info.compositionStart); |
1267 EXPECT_EQ(-1, info.compositionEnd); | 1302 EXPECT_EQ(-1, info.compositionEnd); |
1268 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", | 1303 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", |
1269 std::string(info.value.utf8().data())); | 1304 std::string(info.value.utf8().data())); |
1270 } | 1305 } |
1271 | 1306 |
1272 TEST_F(WebViewTest, ExtendSelectionAndDelete) { | 1307 TEST_F(WebViewTest, ExtendSelectionAndDelete) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) { | 1395 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) { |
1361 URLTestHelpers::registerMockedURLFromBaseURL( | 1396 URLTestHelpers::registerMockedURLFromBaseURL( |
1362 WebString::fromUTF8(m_baseURL.c_str()), | 1397 WebString::fromUTF8(m_baseURL.c_str()), |
1363 WebString::fromUTF8("text_area_populated.html")); | 1398 WebString::fromUTF8("text_area_populated.html")); |
1364 WebViewImpl* webView = | 1399 WebViewImpl* webView = |
1365 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); | 1400 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); |
1366 webView->setInitialFocus(false); | 1401 webView->setInitialFocus(false); |
1367 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 1402 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
1368 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 1403 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
1369 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1404 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1405 WebInputMethodController* activeInputMethodController = |
| 1406 frame->frameWidget()->getActiveWebInputMethodController(); |
1370 frame->setEditableSelectionOffsets(27, 27); | 1407 frame->setEditableSelectionOffsets(27, 27); |
1371 std::string newLineText("\n"); | 1408 std::string newLineText("\n"); |
1372 webView->commitText(WebString::fromUTF8(newLineText.c_str()), 0); | 1409 activeInputMethodController->commitText( |
| 1410 WebString::fromUTF8(newLineText.c_str()), 0); |
1373 WebTextInputInfo info = webView->textInputInfo(); | 1411 WebTextInputInfo info = webView->textInputInfo(); |
1374 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", | 1412 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", |
1375 std::string(info.value.utf8().data())); | 1413 std::string(info.value.utf8().data())); |
1376 | 1414 |
1377 frame->setEditableSelectionOffsets(31, 31); | 1415 frame->setEditableSelectionOffsets(31, 31); |
1378 frame->setCompositionFromExistingText(30, 34, underlines); | 1416 frame->setCompositionFromExistingText(30, 34, underlines); |
1379 info = webView->textInputInfo(); | 1417 info = webView->textInputInfo(); |
1380 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", | 1418 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", |
1381 std::string(info.value.utf8().data())); | 1419 std::string(info.value.utf8().data())); |
1382 EXPECT_EQ(31, info.selectionStart); | 1420 EXPECT_EQ(31, info.selectionStart); |
1383 EXPECT_EQ(31, info.selectionEnd); | 1421 EXPECT_EQ(31, info.selectionEnd); |
1384 EXPECT_EQ(30, info.compositionStart); | 1422 EXPECT_EQ(30, info.compositionStart); |
1385 EXPECT_EQ(34, info.compositionEnd); | 1423 EXPECT_EQ(34, info.compositionEnd); |
1386 | 1424 |
1387 std::string compositionText("yolo"); | 1425 std::string compositionText("yolo"); |
1388 webView->commitText(WebString::fromUTF8(compositionText.c_str()), 0); | 1426 activeInputMethodController->commitText( |
| 1427 WebString::fromUTF8(compositionText.c_str()), 0); |
1389 info = webView->textInputInfo(); | 1428 info = webView->textInputInfo(); |
1390 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", | 1429 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", |
1391 std::string(info.value.utf8().data())); | 1430 std::string(info.value.utf8().data())); |
1392 EXPECT_EQ(34, info.selectionStart); | 1431 EXPECT_EQ(34, info.selectionStart); |
1393 EXPECT_EQ(34, info.selectionEnd); | 1432 EXPECT_EQ(34, info.selectionEnd); |
1394 EXPECT_EQ(-1, info.compositionStart); | 1433 EXPECT_EQ(-1, info.compositionStart); |
1395 EXPECT_EQ(-1, info.compositionEnd); | 1434 EXPECT_EQ(-1, info.compositionEnd); |
1396 } | 1435 } |
1397 | 1436 |
1398 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) { | 1437 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) { |
(...skipping 17 matching lines...) Expand all Loading... |
1416 URLTestHelpers::registerMockedURLFromBaseURL( | 1455 URLTestHelpers::registerMockedURLFromBaseURL( |
1417 WebString::fromUTF8(m_baseURL.c_str()), | 1456 WebString::fromUTF8(m_baseURL.c_str()), |
1418 WebString::fromUTF8("input_field_populated.html")); | 1457 WebString::fromUTF8("input_field_populated.html")); |
1419 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 1458 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
1420 m_baseURL + "input_field_populated.html"); | 1459 m_baseURL + "input_field_populated.html"); |
1421 webView->setInitialFocus(false); | 1460 webView->setInitialFocus(false); |
1422 | 1461 |
1423 std::string compositionTextFirst("hello "); | 1462 std::string compositionTextFirst("hello "); |
1424 std::string compositionTextSecond("world"); | 1463 std::string compositionTextSecond("world"); |
1425 WebVector<WebCompositionUnderline> emptyUnderlines; | 1464 WebVector<WebCompositionUnderline> emptyUnderlines; |
1426 | 1465 WebInputMethodController* activeInputMethodController = |
1427 webView->commitText(WebString::fromUTF8(compositionTextFirst.c_str()), 0); | 1466 webView->mainFrameImpl() |
1428 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()), | 1467 ->frameWidget() |
1429 emptyUnderlines, 5, 5); | 1468 ->getActiveWebInputMethodController(); |
| 1469 activeInputMethodController->commitText( |
| 1470 WebString::fromUTF8(compositionTextFirst.c_str()), 0); |
| 1471 activeInputMethodController->setComposition( |
| 1472 WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5, |
| 1473 5); |
1430 | 1474 |
1431 WebTextInputInfo info = webView->textInputInfo(); | 1475 WebTextInputInfo info = webView->textInputInfo(); |
1432 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1476 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
1433 EXPECT_EQ(11, info.selectionStart); | 1477 EXPECT_EQ(11, info.selectionStart); |
1434 EXPECT_EQ(11, info.selectionEnd); | 1478 EXPECT_EQ(11, info.selectionEnd); |
1435 EXPECT_EQ(6, info.compositionStart); | 1479 EXPECT_EQ(6, info.compositionStart); |
1436 EXPECT_EQ(11, info.compositionEnd); | 1480 EXPECT_EQ(11, info.compositionEnd); |
1437 | 1481 |
1438 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1482 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
1439 frame->setEditableSelectionOffsets(6, 6); | 1483 frame->setEditableSelectionOffsets(6, 6); |
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2657 m_baseURL + "composition_not_cancelled_by_backspace.html"); | 2701 m_baseURL + "composition_not_cancelled_by_backspace.html"); |
2658 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 2702 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
2659 frame->setAutofillClient(&client); | 2703 frame->setAutofillClient(&client); |
2660 webView->setInitialFocus(false); | 2704 webView->setInitialFocus(false); |
2661 | 2705 |
2662 // Test both input elements. | 2706 // Test both input elements. |
2663 for (int i = 0; i < 2; ++i) { | 2707 for (int i = 0; i < 2; ++i) { |
2664 // Select composition and do sanity check. | 2708 // Select composition and do sanity check. |
2665 WebVector<WebCompositionUnderline> emptyUnderlines; | 2709 WebVector<WebCompositionUnderline> emptyUnderlines; |
2666 frame->setEditableSelectionOffsets(6, 6); | 2710 frame->setEditableSelectionOffsets(6, 6); |
2667 EXPECT_TRUE(webView->setComposition("fghij", emptyUnderlines, 0, 5)); | 2711 WebInputMethodController* activeInputMethodController = |
| 2712 frame->frameWidget()->getActiveWebInputMethodController(); |
| 2713 EXPECT_TRUE(activeInputMethodController->setComposition( |
| 2714 "fghij", emptyUnderlines, 0, 5)); |
2668 frame->setEditableSelectionOffsets(11, 11); | 2715 frame->setEditableSelectionOffsets(11, 11); |
2669 verifySelectionAndComposition(webView, 11, 11, 6, 11, "initial case"); | 2716 verifySelectionAndComposition(webView, 11, 11, 6, 11, "initial case"); |
2670 | 2717 |
2671 // Press Backspace and verify composition didn't get cancelled. This is to | 2718 // Press Backspace and verify composition didn't get cancelled. This is to |
2672 // verify the fix for crbug.com/429916. | 2719 // verify the fix for crbug.com/429916. |
2673 WebKeyboardEvent keyEvent; | 2720 WebKeyboardEvent keyEvent; |
2674 keyEvent.domKey = Platform::current()->domKeyEnumFromString("\b"); | 2721 keyEvent.domKey = Platform::current()->domKeyEnumFromString("\b"); |
2675 keyEvent.windowsKeyCode = VKEY_BACK; | 2722 keyEvent.windowsKeyCode = VKEY_BACK; |
2676 keyEvent.type = WebInputEvent::RawKeyDown; | 2723 keyEvent.type = WebInputEvent::RawKeyDown; |
2677 webView->handleInputEvent(keyEvent); | 2724 webView->handleInputEvent(keyEvent); |
2678 | 2725 |
2679 frame->setEditableSelectionOffsets(6, 6); | 2726 frame->setEditableSelectionOffsets(6, 6); |
2680 EXPECT_TRUE(webView->setComposition("fghi", emptyUnderlines, 0, 4)); | 2727 EXPECT_TRUE(activeInputMethodController->setComposition( |
| 2728 "fghi", emptyUnderlines, 0, 4)); |
2681 frame->setEditableSelectionOffsets(10, 10); | 2729 frame->setEditableSelectionOffsets(10, 10); |
2682 verifySelectionAndComposition(webView, 10, 10, 6, 10, | 2730 verifySelectionAndComposition(webView, 10, 10, 6, 10, |
2683 "after pressing Backspace"); | 2731 "after pressing Backspace"); |
2684 | 2732 |
2685 keyEvent.type = WebInputEvent::KeyUp; | 2733 keyEvent.type = WebInputEvent::KeyUp; |
2686 webView->handleInputEvent(keyEvent); | 2734 webView->handleInputEvent(keyEvent); |
2687 | 2735 |
2688 webView->advanceFocus(false); | 2736 webView->advanceFocus(false); |
2689 } | 2737 } |
2690 | 2738 |
2691 frame->setAutofillClient(0); | 2739 frame->setAutofillClient(0); |
2692 } | 2740 } |
2693 | 2741 |
2694 TEST_F(WebViewTest, FinishComposingTextTriggersAutofillTextChange) { | 2742 TEST_F(WebViewTest, FinishComposingTextTriggersAutofillTextChange) { |
2695 URLTestHelpers::registerMockedURLFromBaseURL( | 2743 URLTestHelpers::registerMockedURLFromBaseURL( |
2696 WebString::fromUTF8(m_baseURL.c_str()), | 2744 WebString::fromUTF8(m_baseURL.c_str()), |
2697 WebString::fromUTF8("input_field_populated.html")); | 2745 WebString::fromUTF8("input_field_populated.html")); |
2698 MockAutofillClient client; | 2746 MockAutofillClient client; |
2699 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 2747 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
2700 m_baseURL + "input_field_populated.html"); | 2748 m_baseURL + "input_field_populated.html"); |
2701 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 2749 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
2702 frame->setAutofillClient(&client); | 2750 frame->setAutofillClient(&client); |
2703 webView->setInitialFocus(false); | 2751 webView->setInitialFocus(false); |
2704 | 2752 WebInputMethodController* activeInputMethodController = |
| 2753 frame->frameWidget()->getActiveWebInputMethodController(); |
2705 // Set up a composition that needs to be committed. | 2754 // Set up a composition that needs to be committed. |
2706 std::string compositionText("testingtext"); | 2755 std::string compositionText("testingtext"); |
2707 | 2756 |
2708 WebVector<WebCompositionUnderline> emptyUnderlines; | 2757 WebVector<WebCompositionUnderline> emptyUnderlines; |
2709 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 2758 activeInputMethodController->setComposition( |
2710 emptyUnderlines, 0, compositionText.length()); | 2759 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0, |
| 2760 compositionText.length()); |
2711 | 2761 |
2712 WebTextInputInfo info = webView->textInputInfo(); | 2762 WebTextInputInfo info = webView->textInputInfo(); |
2713 EXPECT_EQ(0, info.selectionStart); | 2763 EXPECT_EQ(0, info.selectionStart); |
2714 EXPECT_EQ((int)compositionText.length(), info.selectionEnd); | 2764 EXPECT_EQ((int)compositionText.length(), info.selectionEnd); |
2715 EXPECT_EQ(0, info.compositionStart); | 2765 EXPECT_EQ(0, info.compositionStart); |
2716 EXPECT_EQ((int)compositionText.length(), info.compositionEnd); | 2766 EXPECT_EQ((int)compositionText.length(), info.compositionEnd); |
2717 | 2767 |
2718 client.clearChangeCounts(); | 2768 client.clearChangeCounts(); |
2719 webView->finishComposingText(WebWidget::KeepSelection); | 2769 activeInputMethodController->finishComposingText( |
| 2770 WebInputMethodController::KeepSelection); |
2720 EXPECT_EQ(0, client.textChangesWhileIgnored()); | 2771 EXPECT_EQ(0, client.textChangesWhileIgnored()); |
2721 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); | 2772 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); |
2722 | 2773 |
2723 frame->setAutofillClient(0); | 2774 frame->setAutofillClient(0); |
2724 } | 2775 } |
2725 | 2776 |
2726 TEST_F(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) { | 2777 TEST_F(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) { |
2727 URLTestHelpers::registerMockedURLFromBaseURL( | 2778 URLTestHelpers::registerMockedURLFromBaseURL( |
2728 WebString::fromUTF8(m_baseURL.c_str()), | 2779 WebString::fromUTF8(m_baseURL.c_str()), |
2729 WebString::fromUTF8("input_field_populated.html")); | 2780 WebString::fromUTF8("input_field_populated.html")); |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3463 NonUserInputTextUpdateWebWidgetClient client; | 3514 NonUserInputTextUpdateWebWidgetClient client; |
3464 std::string url = m_baseURL + "non_user_input_text_update.html"; | 3515 std::string url = m_baseURL + "non_user_input_text_update.html"; |
3465 URLTestHelpers::registerMockedURLLoad(toKURL(url), | 3516 URLTestHelpers::registerMockedURLLoad(toKURL(url), |
3466 "non_user_input_text_update.html"); | 3517 "non_user_input_text_update.html"); |
3467 WebViewImpl* webViewImpl = | 3518 WebViewImpl* webViewImpl = |
3468 m_webViewHelper.initializeAndLoad(url, true, nullptr, nullptr, &client); | 3519 m_webViewHelper.initializeAndLoad(url, true, nullptr, nullptr, &client); |
3469 webViewImpl->setInitialFocus(false); | 3520 webViewImpl->setInitialFocus(false); |
3470 | 3521 |
3471 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); | 3522 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); |
3472 Document* document = frame->frame()->document(); | 3523 Document* document = frame->frame()->document(); |
| 3524 WebInputMethodController* activeInputMethodController = |
| 3525 frame->frameWidget()->getActiveWebInputMethodController(); |
3473 | 3526 |
3474 // (A) <input> | 3527 // (A) <input> |
3475 // (A.1) Focused and value is changed by script. | 3528 // (A.1) Focused and value is changed by script. |
3476 client.reset(); | 3529 client.reset(); |
3477 EXPECT_FALSE(client.textIsUpdated()); | 3530 EXPECT_FALSE(client.textIsUpdated()); |
3478 | 3531 |
3479 HTMLInputElement* inputElement = | 3532 HTMLInputElement* inputElement = |
3480 toHTMLInputElement(document->getElementById("input")); | 3533 toHTMLInputElement(document->getElementById("input")); |
3481 document->setFocusedElement( | 3534 document->setFocusedElement( |
3482 inputElement, | 3535 inputElement, |
3483 FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); | 3536 FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); |
3484 webViewImpl->setFocus(true); | 3537 webViewImpl->setFocus(true); |
3485 EXPECT_EQ(document->focusedElement(), static_cast<Element*>(inputElement)); | 3538 EXPECT_EQ(document->focusedElement(), static_cast<Element*>(inputElement)); |
3486 | 3539 |
3487 // Emulate value change from script. | 3540 // Emulate value change from script. |
3488 inputElement->setValue("testA"); | 3541 inputElement->setValue("testA"); |
3489 EXPECT_TRUE(client.textIsUpdated()); | 3542 EXPECT_TRUE(client.textIsUpdated()); |
3490 WebTextInputInfo info = webViewImpl->textInputInfo(); | 3543 WebTextInputInfo info = webViewImpl->textInputInfo(); |
3491 EXPECT_EQ("testA", std::string(info.value.utf8().data())); | 3544 EXPECT_EQ("testA", std::string(info.value.utf8().data())); |
3492 | 3545 |
3493 // (A.2) Focused and user input modifies value. | 3546 // (A.2) Focused and user input modifies value. |
3494 client.reset(); | 3547 client.reset(); |
3495 EXPECT_FALSE(client.textIsUpdated()); | 3548 EXPECT_FALSE(client.textIsUpdated()); |
3496 | 3549 |
3497 WebVector<WebCompositionUnderline> emptyUnderlines; | 3550 WebVector<WebCompositionUnderline> emptyUnderlines; |
3498 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1); | 3551 activeInputMethodController->setComposition(WebString::fromUTF8("2"), |
3499 webViewImpl->finishComposingText(WebWidget::KeepSelection); | 3552 emptyUnderlines, 1, 1); |
| 3553 activeInputMethodController->finishComposingText( |
| 3554 WebInputMethodController::KeepSelection); |
3500 EXPECT_FALSE(client.textIsUpdated()); | 3555 EXPECT_FALSE(client.textIsUpdated()); |
3501 info = webViewImpl->textInputInfo(); | 3556 info = webViewImpl->textInputInfo(); |
3502 EXPECT_EQ("testA2", std::string(info.value.utf8().data())); | 3557 EXPECT_EQ("testA2", std::string(info.value.utf8().data())); |
3503 | 3558 |
3504 // (A.3) Unfocused and value is changed by script. | 3559 // (A.3) Unfocused and value is changed by script. |
3505 client.reset(); | 3560 client.reset(); |
3506 EXPECT_FALSE(client.textIsUpdated()); | 3561 EXPECT_FALSE(client.textIsUpdated()); |
3507 document->clearFocusedElement(); | 3562 document->clearFocusedElement(); |
3508 webViewImpl->setFocus(false); | 3563 webViewImpl->setFocus(false); |
3509 EXPECT_NE(document->focusedElement(), static_cast<Element*>(inputElement)); | 3564 EXPECT_NE(document->focusedElement(), static_cast<Element*>(inputElement)); |
(...skipping 12 matching lines...) Expand all Loading... |
3522 webViewImpl->setFocus(true); | 3577 webViewImpl->setFocus(true); |
3523 EXPECT_EQ(document->focusedElement(), static_cast<Element*>(textAreaElement)); | 3578 EXPECT_EQ(document->focusedElement(), static_cast<Element*>(textAreaElement)); |
3524 textAreaElement->setValue("testB"); | 3579 textAreaElement->setValue("testB"); |
3525 EXPECT_TRUE(client.textIsUpdated()); | 3580 EXPECT_TRUE(client.textIsUpdated()); |
3526 info = webViewImpl->textInputInfo(); | 3581 info = webViewImpl->textInputInfo(); |
3527 EXPECT_EQ("testB", std::string(info.value.utf8().data())); | 3582 EXPECT_EQ("testB", std::string(info.value.utf8().data())); |
3528 | 3583 |
3529 // (B.2) Focused and user input modifies value. | 3584 // (B.2) Focused and user input modifies value. |
3530 client.reset(); | 3585 client.reset(); |
3531 EXPECT_FALSE(client.textIsUpdated()); | 3586 EXPECT_FALSE(client.textIsUpdated()); |
3532 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1); | 3587 activeInputMethodController->setComposition(WebString::fromUTF8("2"), |
3533 webViewImpl->finishComposingText(WebWidget::KeepSelection); | 3588 emptyUnderlines, 1, 1); |
| 3589 activeInputMethodController->finishComposingText( |
| 3590 WebInputMethodController::KeepSelection); |
3534 info = webViewImpl->textInputInfo(); | 3591 info = webViewImpl->textInputInfo(); |
3535 EXPECT_EQ("testB2", std::string(info.value.utf8().data())); | 3592 EXPECT_EQ("testB2", std::string(info.value.utf8().data())); |
3536 | 3593 |
3537 // (B.3) Unfocused and value is changed by script. | 3594 // (B.3) Unfocused and value is changed by script. |
3538 client.reset(); | 3595 client.reset(); |
3539 EXPECT_FALSE(client.textIsUpdated()); | 3596 EXPECT_FALSE(client.textIsUpdated()); |
3540 document->clearFocusedElement(); | 3597 document->clearFocusedElement(); |
3541 webViewImpl->setFocus(false); | 3598 webViewImpl->setFocus(false); |
3542 EXPECT_NE(document->focusedElement(), static_cast<Element*>(textAreaElement)); | 3599 EXPECT_NE(document->focusedElement(), static_cast<Element*>(textAreaElement)); |
3543 inputElement->setValue("testB3"); | 3600 inputElement->setValue("testB3"); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3624 WebString::fromUTF8(m_baseURL.c_str()), | 3681 WebString::fromUTF8(m_baseURL.c_str()), |
3625 WebString::fromUTF8("input_field_populated.html")); | 3682 WebString::fromUTF8("input_field_populated.html")); |
3626 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 3683 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
3627 m_baseURL + "input_field_populated.html"); | 3684 m_baseURL + "input_field_populated.html"); |
3628 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 3685 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
3629 MockAutofillClient client; | 3686 MockAutofillClient client; |
3630 frame->setAutofillClient(&client); | 3687 frame->setAutofillClient(&client); |
3631 webView->setInitialFocus(false); | 3688 webView->setInitialFocus(false); |
3632 | 3689 |
3633 EXPECT_TRUE( | 3690 EXPECT_TRUE( |
3634 webView->setComposition(WebString::fromUTF8(std::string("hello").c_str()), | 3691 frame->frameWidget()->getActiveWebInputMethodController()->setComposition( |
3635 WebVector<WebCompositionUnderline>(), 3, 3)); | 3692 WebString::fromUTF8(std::string("hello").c_str()), |
| 3693 WebVector<WebCompositionUnderline>(), 3, 3)); |
3636 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 3694 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
3637 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 3695 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
3638 EXPECT_TRUE(frame->hasMarkedText()); | 3696 EXPECT_TRUE(frame->hasMarkedText()); |
3639 | 3697 |
3640 frame->setAutofillClient(0); | 3698 frame->setAutofillClient(0); |
3641 } | 3699 } |
3642 | 3700 |
3643 TEST_F(WebViewTest, CompareSelectAllToContentAsText) { | 3701 TEST_F(WebViewTest, CompareSelectAllToContentAsText) { |
3644 URLTestHelpers::registerMockedURLFromBaseURL( | 3702 URLTestHelpers::registerMockedURLFromBaseURL( |
3645 WebString::fromUTF8(m_baseURL.c_str()), | 3703 WebString::fromUTF8(m_baseURL.c_str()), |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4023 URLTestHelpers::registerMockedURLFromBaseURL( | 4081 URLTestHelpers::registerMockedURLFromBaseURL( |
4024 WebString::fromUTF8(m_baseURL.c_str()), | 4082 WebString::fromUTF8(m_baseURL.c_str()), |
4025 WebString::fromUTF8("input_field_password.html")); | 4083 WebString::fromUTF8("input_field_password.html")); |
4026 MockAutofillClient client; | 4084 MockAutofillClient client; |
4027 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 4085 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
4028 m_baseURL + "input_field_password.html", true); | 4086 m_baseURL + "input_field_password.html", true); |
4029 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 4087 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
4030 frame->setAutofillClient(&client); | 4088 frame->setAutofillClient(&client); |
4031 webView->setInitialFocus(false); | 4089 webView->setInitialFocus(false); |
4032 | 4090 |
4033 EXPECT_TRUE(webView->commitText( | 4091 EXPECT_TRUE( |
4034 WebString::fromUTF8(std::string("hello").c_str()), 0)); | 4092 frame->frameWidget()->getActiveWebInputMethodController()->commitText( |
| 4093 WebString::fromUTF8(std::string("hello").c_str()), 0)); |
4035 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 4094 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
4036 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 4095 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
4037 frame->setAutofillClient(0); | 4096 frame->setAutofillClient(0); |
4038 } | 4097 } |
4039 | 4098 |
4040 // Verify that a WebView created with a ScopedPageLoadDeferrer already on the | 4099 // Verify that a WebView created with a ScopedPageLoadDeferrer already on the |
4041 // stack defers its loads. | 4100 // stack defers its loads. |
4042 TEST_F(WebViewTest, CreatedDuringLoadDeferral) { | 4101 TEST_F(WebViewTest, CreatedDuringLoadDeferral) { |
4043 { | 4102 { |
4044 WebViewImpl* webView = m_webViewHelper.initialize(); | 4103 WebViewImpl* webView = m_webViewHelper.initialize(); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4250 .translate(50, 55) | 4309 .translate(50, 55) |
4251 .scale(1. / 2.f); | 4310 .scale(1. / 2.f); |
4252 EXPECT_EQ(expectedMatrix, | 4311 EXPECT_EQ(expectedMatrix, |
4253 webViewImpl->getDeviceEmulationTransformForTesting()); | 4312 webViewImpl->getDeviceEmulationTransformForTesting()); |
4254 // visibleContentRect doesn't change. | 4313 // visibleContentRect doesn't change. |
4255 EXPECT_EQ(IntRect(50, 55, 50, 75), | 4314 EXPECT_EQ(IntRect(50, 55, 50, 75), |
4256 *devToolsEmulator->visibleContentRectForPainting()); | 4315 *devToolsEmulator->visibleContentRectForPainting()); |
4257 } | 4316 } |
4258 | 4317 |
4259 } // namespace blink | 4318 } // namespace blink |
OLD | NEW |