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 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 WebString::fromUTF8(m_baseURL.c_str()), | 988 WebString::fromUTF8(m_baseURL.c_str()), |
989 WebString::fromUTF8("input_field_populated.html")); | 989 WebString::fromUTF8("input_field_populated.html")); |
990 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 990 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
991 m_baseURL + "input_field_populated.html"); | 991 m_baseURL + "input_field_populated.html"); |
992 webView->setInitialFocus(false); | 992 webView->setInitialFocus(false); |
993 WebInputMethodController* activeInputMethodController = | 993 WebInputMethodController* activeInputMethodController = |
994 webView->mainFrameImpl() | 994 webView->mainFrameImpl() |
995 ->frameWidget() | 995 ->frameWidget() |
996 ->getActiveWebInputMethodController(); | 996 ->getActiveWebInputMethodController(); |
997 | 997 |
998 activeInputMethodController->commitText("hello", 0); | 998 WebVector<WebCompositionUnderline> emptyUnderlines; |
999 activeInputMethodController->commitText("world", -5); | 999 |
| 1000 activeInputMethodController->commitText("hello", emptyUnderlines, 0); |
| 1001 activeInputMethodController->commitText("world", emptyUnderlines, -5); |
1000 WebTextInputInfo info = webView->textInputInfo(); | 1002 WebTextInputInfo info = webView->textInputInfo(); |
1001 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 1003 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
1002 EXPECT_EQ(5, info.selectionStart); | 1004 EXPECT_EQ(5, info.selectionStart); |
1003 EXPECT_EQ(5, info.selectionEnd); | 1005 EXPECT_EQ(5, info.selectionEnd); |
1004 EXPECT_EQ(-1, info.compositionStart); | 1006 EXPECT_EQ(-1, info.compositionStart); |
1005 EXPECT_EQ(-1, info.compositionEnd); | 1007 EXPECT_EQ(-1, info.compositionEnd); |
1006 | 1008 |
1007 WebVector<WebCompositionUnderline> emptyUnderlines; | |
1008 // Set up a composition that needs to be committed. | 1009 // Set up a composition that needs to be committed. |
1009 std::string compositionText("ABC"); | 1010 std::string compositionText("ABC"); |
1010 | 1011 |
1011 // Caret is on the left of composing text. | 1012 // Caret is on the left of composing text. |
1012 activeInputMethodController->setComposition( | 1013 activeInputMethodController->setComposition( |
1013 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0, 0); | 1014 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0, 0); |
1014 info = webView->textInputInfo(); | 1015 info = webView->textInputInfo(); |
1015 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1016 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
1016 EXPECT_EQ(5, info.selectionStart); | 1017 EXPECT_EQ(5, info.selectionStart); |
1017 EXPECT_EQ(5, info.selectionEnd); | 1018 EXPECT_EQ(5, info.selectionEnd); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 WebString::fromUTF8(m_baseURL.c_str()), | 1096 WebString::fromUTF8(m_baseURL.c_str()), |
1096 WebString::fromUTF8("input_field_populated.html")); | 1097 WebString::fromUTF8("input_field_populated.html")); |
1097 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 1098 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
1098 m_baseURL + "input_field_populated.html"); | 1099 m_baseURL + "input_field_populated.html"); |
1099 webView->setInitialFocus(false); | 1100 webView->setInitialFocus(false); |
1100 WebInputMethodController* activeInputMethodController = | 1101 WebInputMethodController* activeInputMethodController = |
1101 webView->mainFrameImpl() | 1102 webView->mainFrameImpl() |
1102 ->frameWidget() | 1103 ->frameWidget() |
1103 ->getActiveWebInputMethodController(); | 1104 ->getActiveWebInputMethodController(); |
1104 | 1105 |
1105 activeInputMethodController->commitText("hello", 0); | 1106 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1107 |
| 1108 activeInputMethodController->commitText("hello", emptyUnderlines, 0); |
1106 WebTextInputInfo info = webView->textInputInfo(); | 1109 WebTextInputInfo info = webView->textInputInfo(); |
1107 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1110 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1108 EXPECT_EQ(5, info.selectionStart); | 1111 EXPECT_EQ(5, info.selectionStart); |
1109 EXPECT_EQ(5, info.selectionEnd); | 1112 EXPECT_EQ(5, info.selectionEnd); |
1110 EXPECT_EQ(-1, info.compositionStart); | 1113 EXPECT_EQ(-1, info.compositionStart); |
1111 EXPECT_EQ(-1, info.compositionEnd); | 1114 EXPECT_EQ(-1, info.compositionEnd); |
1112 | 1115 |
1113 WebVector<WebCompositionUnderline> emptyUnderlines; | |
1114 | |
1115 activeInputMethodController->setComposition(WebString::fromUTF8(""), | 1116 activeInputMethodController->setComposition(WebString::fromUTF8(""), |
1116 emptyUnderlines, 0, 0); | 1117 emptyUnderlines, 0, 0); |
1117 info = webView->textInputInfo(); | 1118 info = webView->textInputInfo(); |
1118 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1119 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1119 EXPECT_EQ(5, info.selectionStart); | 1120 EXPECT_EQ(5, info.selectionStart); |
1120 EXPECT_EQ(5, info.selectionEnd); | 1121 EXPECT_EQ(5, info.selectionEnd); |
1121 EXPECT_EQ(-1, info.compositionStart); | 1122 EXPECT_EQ(-1, info.compositionStart); |
1122 EXPECT_EQ(-1, info.compositionEnd); | 1123 EXPECT_EQ(-1, info.compositionEnd); |
1123 | 1124 |
1124 activeInputMethodController->setComposition(WebString::fromUTF8(""), | 1125 activeInputMethodController->setComposition(WebString::fromUTF8(""), |
(...skipping 11 matching lines...) Expand all Loading... |
1136 WebString::fromUTF8(m_baseURL.c_str()), | 1137 WebString::fromUTF8(m_baseURL.c_str()), |
1137 WebString::fromUTF8("input_field_populated.html")); | 1138 WebString::fromUTF8("input_field_populated.html")); |
1138 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 1139 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
1139 m_baseURL + "input_field_populated.html"); | 1140 m_baseURL + "input_field_populated.html"); |
1140 webView->setInitialFocus(false); | 1141 webView->setInitialFocus(false); |
1141 WebInputMethodController* activeInputMethodController = | 1142 WebInputMethodController* activeInputMethodController = |
1142 webView->mainFrameImpl() | 1143 webView->mainFrameImpl() |
1143 ->frameWidget() | 1144 ->frameWidget() |
1144 ->getActiveWebInputMethodController(); | 1145 ->getActiveWebInputMethodController(); |
1145 | 1146 |
| 1147 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1148 |
1146 // Caret is on the left of composing text. | 1149 // Caret is on the left of composing text. |
1147 activeInputMethodController->commitText("ab", -2); | 1150 activeInputMethodController->commitText("ab", emptyUnderlines, -2); |
1148 WebTextInputInfo info = webView->textInputInfo(); | 1151 WebTextInputInfo info = webView->textInputInfo(); |
1149 EXPECT_EQ("ab", std::string(info.value.utf8().data())); | 1152 EXPECT_EQ("ab", std::string(info.value.utf8().data())); |
1150 EXPECT_EQ(0, info.selectionStart); | 1153 EXPECT_EQ(0, info.selectionStart); |
1151 EXPECT_EQ(0, info.selectionEnd); | 1154 EXPECT_EQ(0, info.selectionEnd); |
1152 EXPECT_EQ(-1, info.compositionStart); | 1155 EXPECT_EQ(-1, info.compositionStart); |
1153 EXPECT_EQ(-1, info.compositionEnd); | 1156 EXPECT_EQ(-1, info.compositionEnd); |
1154 | 1157 |
1155 // Caret is on the right of composing text. | 1158 // Caret is on the right of composing text. |
1156 activeInputMethodController->commitText("c", 1); | 1159 activeInputMethodController->commitText("c", emptyUnderlines, 1); |
1157 info = webView->textInputInfo(); | 1160 info = webView->textInputInfo(); |
1158 EXPECT_EQ("cab", std::string(info.value.utf8().data())); | 1161 EXPECT_EQ("cab", std::string(info.value.utf8().data())); |
1159 EXPECT_EQ(2, info.selectionStart); | 1162 EXPECT_EQ(2, info.selectionStart); |
1160 EXPECT_EQ(2, info.selectionEnd); | 1163 EXPECT_EQ(2, info.selectionEnd); |
1161 EXPECT_EQ(-1, info.compositionStart); | 1164 EXPECT_EQ(-1, info.compositionStart); |
1162 EXPECT_EQ(-1, info.compositionEnd); | 1165 EXPECT_EQ(-1, info.compositionEnd); |
1163 | 1166 |
1164 // Caret is on the left boundary. | 1167 // Caret is on the left boundary. |
1165 activeInputMethodController->commitText("def", -5); | 1168 activeInputMethodController->commitText("def", emptyUnderlines, -5); |
1166 info = webView->textInputInfo(); | 1169 info = webView->textInputInfo(); |
1167 EXPECT_EQ("cadefb", std::string(info.value.utf8().data())); | 1170 EXPECT_EQ("cadefb", std::string(info.value.utf8().data())); |
1168 EXPECT_EQ(0, info.selectionStart); | 1171 EXPECT_EQ(0, info.selectionStart); |
1169 EXPECT_EQ(0, info.selectionEnd); | 1172 EXPECT_EQ(0, info.selectionEnd); |
1170 EXPECT_EQ(-1, info.compositionStart); | 1173 EXPECT_EQ(-1, info.compositionStart); |
1171 EXPECT_EQ(-1, info.compositionEnd); | 1174 EXPECT_EQ(-1, info.compositionEnd); |
1172 | 1175 |
1173 // Caret is on the right boundary. | 1176 // Caret is on the right boundary. |
1174 activeInputMethodController->commitText("g", 6); | 1177 activeInputMethodController->commitText("g", emptyUnderlines, 6); |
1175 info = webView->textInputInfo(); | 1178 info = webView->textInputInfo(); |
1176 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data())); | 1179 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data())); |
1177 EXPECT_EQ(7, info.selectionStart); | 1180 EXPECT_EQ(7, info.selectionStart); |
1178 EXPECT_EQ(7, info.selectionEnd); | 1181 EXPECT_EQ(7, info.selectionEnd); |
1179 EXPECT_EQ(-1, info.compositionStart); | 1182 EXPECT_EQ(-1, info.compositionStart); |
1180 EXPECT_EQ(-1, info.compositionEnd); | 1183 EXPECT_EQ(-1, info.compositionEnd); |
1181 | 1184 |
1182 // Caret exceeds the left boundary. | 1185 // Caret exceeds the left boundary. |
1183 activeInputMethodController->commitText("hi", -100); | 1186 activeInputMethodController->commitText("hi", emptyUnderlines, -100); |
1184 info = webView->textInputInfo(); | 1187 info = webView->textInputInfo(); |
1185 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data())); | 1188 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data())); |
1186 EXPECT_EQ(0, info.selectionStart); | 1189 EXPECT_EQ(0, info.selectionStart); |
1187 EXPECT_EQ(0, info.selectionEnd); | 1190 EXPECT_EQ(0, info.selectionEnd); |
1188 EXPECT_EQ(-1, info.compositionStart); | 1191 EXPECT_EQ(-1, info.compositionStart); |
1189 EXPECT_EQ(-1, info.compositionEnd); | 1192 EXPECT_EQ(-1, info.compositionEnd); |
1190 | 1193 |
1191 // Caret exceeds the right boundary. | 1194 // Caret exceeds the right boundary. |
1192 activeInputMethodController->commitText("jk", 100); | 1195 activeInputMethodController->commitText("jk", emptyUnderlines, 100); |
1193 info = webView->textInputInfo(); | 1196 info = webView->textInputInfo(); |
1194 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); | 1197 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); |
1195 EXPECT_EQ(11, info.selectionStart); | 1198 EXPECT_EQ(11, info.selectionStart); |
1196 EXPECT_EQ(11, info.selectionEnd); | 1199 EXPECT_EQ(11, info.selectionEnd); |
1197 EXPECT_EQ(-1, info.compositionStart); | 1200 EXPECT_EQ(-1, info.compositionStart); |
1198 EXPECT_EQ(-1, info.compositionEnd); | 1201 EXPECT_EQ(-1, info.compositionEnd); |
1199 } | 1202 } |
1200 | 1203 |
1201 TEST_P(WebViewTest, CommitTextWhileComposing) { | 1204 TEST_P(WebViewTest, CommitTextWhileComposing) { |
1202 URLTestHelpers::registerMockedURLFromBaseURL( | 1205 URLTestHelpers::registerMockedURLFromBaseURL( |
(...skipping 12 matching lines...) Expand all Loading... |
1215 emptyUnderlines, 0, 0); | 1218 emptyUnderlines, 0, 0); |
1216 WebTextInputInfo info = webView->textInputInfo(); | 1219 WebTextInputInfo info = webView->textInputInfo(); |
1217 EXPECT_EQ("abc", std::string(info.value.utf8().data())); | 1220 EXPECT_EQ("abc", std::string(info.value.utf8().data())); |
1218 EXPECT_EQ(0, info.selectionStart); | 1221 EXPECT_EQ(0, info.selectionStart); |
1219 EXPECT_EQ(0, info.selectionEnd); | 1222 EXPECT_EQ(0, info.selectionEnd); |
1220 EXPECT_EQ(0, info.compositionStart); | 1223 EXPECT_EQ(0, info.compositionStart); |
1221 EXPECT_EQ(3, info.compositionEnd); | 1224 EXPECT_EQ(3, info.compositionEnd); |
1222 | 1225 |
1223 // Deletes ongoing composition, inserts the specified text and moves the | 1226 // Deletes ongoing composition, inserts the specified text and moves the |
1224 // caret. | 1227 // caret. |
1225 activeInputMethodController->commitText("hello", -2); | 1228 activeInputMethodController->commitText("hello", emptyUnderlines, -2); |
1226 info = webView->textInputInfo(); | 1229 info = webView->textInputInfo(); |
1227 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1230 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1228 EXPECT_EQ(3, info.selectionStart); | 1231 EXPECT_EQ(3, info.selectionStart); |
1229 EXPECT_EQ(3, info.selectionEnd); | 1232 EXPECT_EQ(3, info.selectionEnd); |
1230 EXPECT_EQ(-1, info.compositionStart); | 1233 EXPECT_EQ(-1, info.compositionStart); |
1231 EXPECT_EQ(-1, info.compositionEnd); | 1234 EXPECT_EQ(-1, info.compositionEnd); |
1232 | 1235 |
1233 activeInputMethodController->setComposition(WebString::fromUTF8("abc"), | 1236 activeInputMethodController->setComposition(WebString::fromUTF8("abc"), |
1234 emptyUnderlines, 0, 0); | 1237 emptyUnderlines, 0, 0); |
1235 info = webView->textInputInfo(); | 1238 info = webView->textInputInfo(); |
1236 EXPECT_EQ("helabclo", std::string(info.value.utf8().data())); | 1239 EXPECT_EQ("helabclo", std::string(info.value.utf8().data())); |
1237 EXPECT_EQ(3, info.selectionStart); | 1240 EXPECT_EQ(3, info.selectionStart); |
1238 EXPECT_EQ(3, info.selectionEnd); | 1241 EXPECT_EQ(3, info.selectionEnd); |
1239 EXPECT_EQ(3, info.compositionStart); | 1242 EXPECT_EQ(3, info.compositionStart); |
1240 EXPECT_EQ(6, info.compositionEnd); | 1243 EXPECT_EQ(6, info.compositionEnd); |
1241 | 1244 |
1242 // Deletes ongoing composition and moves the caret. | 1245 // Deletes ongoing composition and moves the caret. |
1243 activeInputMethodController->commitText("", 2); | 1246 activeInputMethodController->commitText("", emptyUnderlines, 2); |
1244 info = webView->textInputInfo(); | 1247 info = webView->textInputInfo(); |
1245 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1248 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1246 EXPECT_EQ(5, info.selectionStart); | 1249 EXPECT_EQ(5, info.selectionStart); |
1247 EXPECT_EQ(5, info.selectionEnd); | 1250 EXPECT_EQ(5, 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 // Inserts the specified text and moves the caret. | 1254 // Inserts the specified text and moves the caret. |
1252 activeInputMethodController->commitText("world", -5); | 1255 activeInputMethodController->commitText("world", emptyUnderlines, -5); |
1253 info = webView->textInputInfo(); | 1256 info = webView->textInputInfo(); |
1254 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 1257 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
1255 EXPECT_EQ(5, info.selectionStart); | 1258 EXPECT_EQ(5, info.selectionStart); |
1256 EXPECT_EQ(5, info.selectionEnd); | 1259 EXPECT_EQ(5, info.selectionEnd); |
1257 EXPECT_EQ(-1, info.compositionStart); | 1260 EXPECT_EQ(-1, info.compositionStart); |
1258 EXPECT_EQ(-1, info.compositionEnd); | 1261 EXPECT_EQ(-1, info.compositionEnd); |
1259 | 1262 |
1260 // Only moves the caret. | 1263 // Only moves the caret. |
1261 activeInputMethodController->commitText("", 5); | 1264 activeInputMethodController->commitText("", emptyUnderlines, 5); |
1262 info = webView->textInputInfo(); | 1265 info = webView->textInputInfo(); |
1263 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 1266 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
1264 EXPECT_EQ(10, info.selectionStart); | 1267 EXPECT_EQ(10, info.selectionStart); |
1265 EXPECT_EQ(10, info.selectionEnd); | 1268 EXPECT_EQ(10, info.selectionEnd); |
1266 EXPECT_EQ(-1, info.compositionStart); | 1269 EXPECT_EQ(-1, info.compositionStart); |
1267 EXPECT_EQ(-1, info.compositionEnd); | 1270 EXPECT_EQ(-1, info.compositionEnd); |
1268 } | 1271 } |
1269 | 1272 |
1270 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) { | 1273 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) { |
1271 URLTestHelpers::registerMockedURLFromBaseURL( | 1274 URLTestHelpers::registerMockedURLFromBaseURL( |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 activeInputMethodController->finishComposingText( | 1333 activeInputMethodController->finishComposingText( |
1331 WebInputMethodController::KeepSelection); | 1334 WebInputMethodController::KeepSelection); |
1332 info = webView->textInputInfo(); | 1335 info = webView->textInputInfo(); |
1333 EXPECT_EQ(4, info.selectionStart); | 1336 EXPECT_EQ(4, info.selectionStart); |
1334 EXPECT_EQ(4, info.selectionEnd); | 1337 EXPECT_EQ(4, info.selectionEnd); |
1335 EXPECT_EQ(-1, info.compositionStart); | 1338 EXPECT_EQ(-1, info.compositionStart); |
1336 EXPECT_EQ(-1, info.compositionEnd); | 1339 EXPECT_EQ(-1, info.compositionEnd); |
1337 | 1340 |
1338 std::string compositionText("\n"); | 1341 std::string compositionText("\n"); |
1339 activeInputMethodController->commitText( | 1342 activeInputMethodController->commitText( |
1340 WebString::fromUTF8(compositionText.c_str()), 0); | 1343 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0); |
1341 info = webView->textInputInfo(); | 1344 info = webView->textInputInfo(); |
1342 EXPECT_EQ(5, info.selectionStart); | 1345 EXPECT_EQ(5, info.selectionStart); |
1343 EXPECT_EQ(5, info.selectionEnd); | 1346 EXPECT_EQ(5, info.selectionEnd); |
1344 EXPECT_EQ(-1, info.compositionStart); | 1347 EXPECT_EQ(-1, info.compositionStart); |
1345 EXPECT_EQ(-1, info.compositionEnd); | 1348 EXPECT_EQ(-1, info.compositionEnd); |
1346 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", | 1349 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", |
1347 std::string(info.value.utf8().data())); | 1350 std::string(info.value.utf8().data())); |
1348 } | 1351 } |
1349 | 1352 |
1350 TEST_P(WebViewTest, ExtendSelectionAndDelete) { | 1353 TEST_P(WebViewTest, ExtendSelectionAndDelete) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 WebViewImpl* webView = | 1445 WebViewImpl* webView = |
1443 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); | 1446 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); |
1444 webView->setInitialFocus(false); | 1447 webView->setInitialFocus(false); |
1445 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 1448 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
1446 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 1449 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
1447 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1450 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
1448 WebInputMethodController* activeInputMethodController = | 1451 WebInputMethodController* activeInputMethodController = |
1449 frame->frameWidget()->getActiveWebInputMethodController(); | 1452 frame->frameWidget()->getActiveWebInputMethodController(); |
1450 frame->setEditableSelectionOffsets(27, 27); | 1453 frame->setEditableSelectionOffsets(27, 27); |
1451 std::string newLineText("\n"); | 1454 std::string newLineText("\n"); |
| 1455 WebVector<WebCompositionUnderline> emptyUnderlines; |
1452 activeInputMethodController->commitText( | 1456 activeInputMethodController->commitText( |
1453 WebString::fromUTF8(newLineText.c_str()), 0); | 1457 WebString::fromUTF8(newLineText.c_str()), emptyUnderlines, 0); |
1454 WebTextInputInfo info = webView->textInputInfo(); | 1458 WebTextInputInfo info = webView->textInputInfo(); |
1455 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", | 1459 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", |
1456 std::string(info.value.utf8().data())); | 1460 std::string(info.value.utf8().data())); |
1457 | 1461 |
1458 frame->setEditableSelectionOffsets(31, 31); | 1462 frame->setEditableSelectionOffsets(31, 31); |
1459 frame->setCompositionFromExistingText(30, 34, underlines); | 1463 frame->setCompositionFromExistingText(30, 34, underlines); |
1460 info = webView->textInputInfo(); | 1464 info = webView->textInputInfo(); |
1461 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", | 1465 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", |
1462 std::string(info.value.utf8().data())); | 1466 std::string(info.value.utf8().data())); |
1463 EXPECT_EQ(31, info.selectionStart); | 1467 EXPECT_EQ(31, info.selectionStart); |
1464 EXPECT_EQ(31, info.selectionEnd); | 1468 EXPECT_EQ(31, info.selectionEnd); |
1465 EXPECT_EQ(30, info.compositionStart); | 1469 EXPECT_EQ(30, info.compositionStart); |
1466 EXPECT_EQ(34, info.compositionEnd); | 1470 EXPECT_EQ(34, info.compositionEnd); |
1467 | 1471 |
1468 std::string compositionText("yolo"); | 1472 std::string compositionText("yolo"); |
1469 activeInputMethodController->commitText( | 1473 activeInputMethodController->commitText( |
1470 WebString::fromUTF8(compositionText.c_str()), 0); | 1474 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0); |
1471 info = webView->textInputInfo(); | 1475 info = webView->textInputInfo(); |
1472 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", | 1476 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", |
1473 std::string(info.value.utf8().data())); | 1477 std::string(info.value.utf8().data())); |
1474 EXPECT_EQ(34, info.selectionStart); | 1478 EXPECT_EQ(34, info.selectionStart); |
1475 EXPECT_EQ(34, info.selectionEnd); | 1479 EXPECT_EQ(34, info.selectionEnd); |
1476 EXPECT_EQ(-1, info.compositionStart); | 1480 EXPECT_EQ(-1, info.compositionStart); |
1477 EXPECT_EQ(-1, info.compositionEnd); | 1481 EXPECT_EQ(-1, info.compositionEnd); |
1478 } | 1482 } |
1479 | 1483 |
1480 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) { | 1484 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) { |
(...skipping 22 matching lines...) Expand all Loading... |
1503 webView->setInitialFocus(false); | 1507 webView->setInitialFocus(false); |
1504 | 1508 |
1505 std::string compositionTextFirst("hello "); | 1509 std::string compositionTextFirst("hello "); |
1506 std::string compositionTextSecond("world"); | 1510 std::string compositionTextSecond("world"); |
1507 WebVector<WebCompositionUnderline> emptyUnderlines; | 1511 WebVector<WebCompositionUnderline> emptyUnderlines; |
1508 WebInputMethodController* activeInputMethodController = | 1512 WebInputMethodController* activeInputMethodController = |
1509 webView->mainFrameImpl() | 1513 webView->mainFrameImpl() |
1510 ->frameWidget() | 1514 ->frameWidget() |
1511 ->getActiveWebInputMethodController(); | 1515 ->getActiveWebInputMethodController(); |
1512 activeInputMethodController->commitText( | 1516 activeInputMethodController->commitText( |
1513 WebString::fromUTF8(compositionTextFirst.c_str()), 0); | 1517 WebString::fromUTF8(compositionTextFirst.c_str()), emptyUnderlines, 0); |
1514 activeInputMethodController->setComposition( | 1518 activeInputMethodController->setComposition( |
1515 WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5, | 1519 WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5, |
1516 5); | 1520 5); |
1517 | 1521 |
1518 WebTextInputInfo info = webView->textInputInfo(); | 1522 WebTextInputInfo info = webView->textInputInfo(); |
1519 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1523 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
1520 EXPECT_EQ(11, info.selectionStart); | 1524 EXPECT_EQ(11, info.selectionStart); |
1521 EXPECT_EQ(11, info.selectionEnd); | 1525 EXPECT_EQ(11, info.selectionEnd); |
1522 EXPECT_EQ(6, info.compositionStart); | 1526 EXPECT_EQ(6, info.compositionStart); |
1523 EXPECT_EQ(11, info.compositionEnd); | 1527 EXPECT_EQ(11, info.compositionEnd); |
(...skipping 2493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4017 URLTestHelpers::registerMockedURLFromBaseURL( | 4021 URLTestHelpers::registerMockedURLFromBaseURL( |
4018 WebString::fromUTF8(m_baseURL.c_str()), | 4022 WebString::fromUTF8(m_baseURL.c_str()), |
4019 WebString::fromUTF8("input_field_password.html")); | 4023 WebString::fromUTF8("input_field_password.html")); |
4020 MockAutofillClient client; | 4024 MockAutofillClient client; |
4021 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 4025 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
4022 m_baseURL + "input_field_password.html", true); | 4026 m_baseURL + "input_field_password.html", true); |
4023 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 4027 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
4024 frame->setAutofillClient(&client); | 4028 frame->setAutofillClient(&client); |
4025 webView->setInitialFocus(false); | 4029 webView->setInitialFocus(false); |
4026 | 4030 |
| 4031 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 4032 |
4027 EXPECT_TRUE( | 4033 EXPECT_TRUE( |
4028 frame->frameWidget()->getActiveWebInputMethodController()->commitText( | 4034 frame->frameWidget()->getActiveWebInputMethodController()->commitText( |
4029 WebString::fromUTF8(std::string("hello").c_str()), 0)); | 4035 WebString::fromUTF8(std::string("hello").c_str()), emptyUnderlines, |
| 4036 0)); |
4030 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 4037 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
4031 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 4038 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
4032 frame->setAutofillClient(0); | 4039 frame->setAutofillClient(0); |
4033 } | 4040 } |
4034 | 4041 |
4035 // Verify that a WebView created with a ScopedPageSuspender already on the | 4042 // Verify that a WebView created with a ScopedPageSuspender already on the |
4036 // stack defers its loads. | 4043 // stack defers its loads. |
4037 TEST_P(WebViewTest, CreatedDuringPageSuspension) { | 4044 TEST_P(WebViewTest, CreatedDuringPageSuspension) { |
4038 { | 4045 { |
4039 WebViewImpl* webView = m_webViewHelper.initialize(); | 4046 WebViewImpl* webView = m_webViewHelper.initialize(); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4245 .translate(50, 55) | 4252 .translate(50, 55) |
4246 .scale(1. / 2.f); | 4253 .scale(1. / 2.f); |
4247 EXPECT_EQ(expectedMatrix, | 4254 EXPECT_EQ(expectedMatrix, |
4248 webViewImpl->getDeviceEmulationTransformForTesting()); | 4255 webViewImpl->getDeviceEmulationTransformForTesting()); |
4249 // visibleContentRect doesn't change. | 4256 // visibleContentRect doesn't change. |
4250 EXPECT_EQ(IntRect(50, 55, 50, 75), | 4257 EXPECT_EQ(IntRect(50, 55, 50, 75), |
4251 *devToolsEmulator->visibleContentRectForPainting()); | 4258 *devToolsEmulator->visibleContentRectForPainting()); |
4252 } | 4259 } |
4253 | 4260 |
4254 } // namespace blink | 4261 } // namespace blink |
OLD | NEW |