Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebViewTest.cpp

Issue 2568093003: Support parsing BackgroundSpans and UnderlineSpans in Android IME's commitText() (Closed)
Patch Set: Use addCompositionUnderlines() where I said I couldn't Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 WebString::fromUTF8(m_baseURL.c_str()), 1003 WebString::fromUTF8(m_baseURL.c_str()),
1004 WebString::fromUTF8("input_field_populated.html")); 1004 WebString::fromUTF8("input_field_populated.html"));
1005 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 1005 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
1006 m_baseURL + "input_field_populated.html"); 1006 m_baseURL + "input_field_populated.html");
1007 webView->setInitialFocus(false); 1007 webView->setInitialFocus(false);
1008 WebInputMethodController* activeInputMethodController = 1008 WebInputMethodController* activeInputMethodController =
1009 webView->mainFrameImpl() 1009 webView->mainFrameImpl()
1010 ->frameWidget() 1010 ->frameWidget()
1011 ->getActiveWebInputMethodController(); 1011 ->getActiveWebInputMethodController();
1012 1012
1013 activeInputMethodController->commitText("hello", 0); 1013 WebVector<WebCompositionUnderline> emptyUnderlines;
1014 activeInputMethodController->commitText("world", -5); 1014
1015 activeInputMethodController->commitText("hello", emptyUnderlines, 0);
1016 activeInputMethodController->commitText("world", emptyUnderlines, -5);
1015 WebTextInputInfo info = activeInputMethodController->textInputInfo(); 1017 WebTextInputInfo info = activeInputMethodController->textInputInfo();
1018
1016 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); 1019 EXPECT_EQ("helloworld", std::string(info.value.utf8().data()));
1017 EXPECT_EQ(5, info.selectionStart); 1020 EXPECT_EQ(5, info.selectionStart);
1018 EXPECT_EQ(5, info.selectionEnd); 1021 EXPECT_EQ(5, info.selectionEnd);
1019 EXPECT_EQ(-1, info.compositionStart); 1022 EXPECT_EQ(-1, info.compositionStart);
1020 EXPECT_EQ(-1, info.compositionEnd); 1023 EXPECT_EQ(-1, info.compositionEnd);
1021 1024
1022 WebVector<WebCompositionUnderline> emptyUnderlines;
1023 // Set up a composition that needs to be committed. 1025 // Set up a composition that needs to be committed.
1024 std::string compositionText("ABC"); 1026 std::string compositionText("ABC");
1025 1027
1026 // Caret is on the left of composing text. 1028 // Caret is on the left of composing text.
1027 activeInputMethodController->setComposition( 1029 activeInputMethodController->setComposition(
1028 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0, 0); 1030 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0, 0);
1029 info = activeInputMethodController->textInputInfo(); 1031 info = activeInputMethodController->textInputInfo();
1030 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); 1032 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data()));
1031 EXPECT_EQ(5, info.selectionStart); 1033 EXPECT_EQ(5, info.selectionStart);
1032 EXPECT_EQ(5, info.selectionEnd); 1034 EXPECT_EQ(5, info.selectionEnd);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 WebString::fromUTF8(m_baseURL.c_str()), 1112 WebString::fromUTF8(m_baseURL.c_str()),
1111 WebString::fromUTF8("input_field_populated.html")); 1113 WebString::fromUTF8("input_field_populated.html"));
1112 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 1114 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
1113 m_baseURL + "input_field_populated.html"); 1115 m_baseURL + "input_field_populated.html");
1114 webView->setInitialFocus(false); 1116 webView->setInitialFocus(false);
1115 WebInputMethodController* activeInputMethodController = 1117 WebInputMethodController* activeInputMethodController =
1116 webView->mainFrameImpl() 1118 webView->mainFrameImpl()
1117 ->frameWidget() 1119 ->frameWidget()
1118 ->getActiveWebInputMethodController(); 1120 ->getActiveWebInputMethodController();
1119 1121
1120 activeInputMethodController->commitText("hello", 0); 1122 WebVector<WebCompositionUnderline> emptyUnderlines;
1123
1124 activeInputMethodController->commitText("hello", emptyUnderlines, 0);
1121 WebTextInputInfo info = activeInputMethodController->textInputInfo(); 1125 WebTextInputInfo info = activeInputMethodController->textInputInfo();
1126
1122 EXPECT_EQ("hello", std::string(info.value.utf8().data())); 1127 EXPECT_EQ("hello", std::string(info.value.utf8().data()));
1123 EXPECT_EQ(5, info.selectionStart); 1128 EXPECT_EQ(5, info.selectionStart);
1124 EXPECT_EQ(5, info.selectionEnd); 1129 EXPECT_EQ(5, info.selectionEnd);
1125 EXPECT_EQ(-1, info.compositionStart); 1130 EXPECT_EQ(-1, info.compositionStart);
1126 EXPECT_EQ(-1, info.compositionEnd); 1131 EXPECT_EQ(-1, info.compositionEnd);
1127 1132
1128 WebVector<WebCompositionUnderline> emptyUnderlines;
1129
1130 activeInputMethodController->setComposition(WebString::fromUTF8(""), 1133 activeInputMethodController->setComposition(WebString::fromUTF8(""),
1131 emptyUnderlines, 0, 0); 1134 emptyUnderlines, 0, 0);
1132 info = activeInputMethodController->textInputInfo(); 1135 info = activeInputMethodController->textInputInfo();
1133 EXPECT_EQ("hello", std::string(info.value.utf8().data())); 1136 EXPECT_EQ("hello", std::string(info.value.utf8().data()));
1134 EXPECT_EQ(5, info.selectionStart); 1137 EXPECT_EQ(5, info.selectionStart);
1135 EXPECT_EQ(5, info.selectionEnd); 1138 EXPECT_EQ(5, info.selectionEnd);
1136 EXPECT_EQ(-1, info.compositionStart); 1139 EXPECT_EQ(-1, info.compositionStart);
1137 EXPECT_EQ(-1, info.compositionEnd); 1140 EXPECT_EQ(-1, info.compositionEnd);
1138 1141
1139 activeInputMethodController->setComposition(WebString::fromUTF8(""), 1142 activeInputMethodController->setComposition(WebString::fromUTF8(""),
(...skipping 11 matching lines...) Expand all
1151 WebString::fromUTF8(m_baseURL.c_str()), 1154 WebString::fromUTF8(m_baseURL.c_str()),
1152 WebString::fromUTF8("input_field_populated.html")); 1155 WebString::fromUTF8("input_field_populated.html"));
1153 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 1156 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
1154 m_baseURL + "input_field_populated.html"); 1157 m_baseURL + "input_field_populated.html");
1155 webView->setInitialFocus(false); 1158 webView->setInitialFocus(false);
1156 WebInputMethodController* activeInputMethodController = 1159 WebInputMethodController* activeInputMethodController =
1157 webView->mainFrameImpl() 1160 webView->mainFrameImpl()
1158 ->frameWidget() 1161 ->frameWidget()
1159 ->getActiveWebInputMethodController(); 1162 ->getActiveWebInputMethodController();
1160 1163
1164 WebVector<WebCompositionUnderline> emptyUnderlines;
1165
1161 // Caret is on the left of composing text. 1166 // Caret is on the left of composing text.
1162 activeInputMethodController->commitText("ab", -2); 1167 activeInputMethodController->commitText("ab", emptyUnderlines, -2);
1163 WebTextInputInfo info = activeInputMethodController->textInputInfo(); 1168 WebTextInputInfo info = activeInputMethodController->textInputInfo();
1164 EXPECT_EQ("ab", std::string(info.value.utf8().data())); 1169 EXPECT_EQ("ab", std::string(info.value.utf8().data()));
1165 EXPECT_EQ(0, info.selectionStart); 1170 EXPECT_EQ(0, info.selectionStart);
1166 EXPECT_EQ(0, info.selectionEnd); 1171 EXPECT_EQ(0, info.selectionEnd);
1167 EXPECT_EQ(-1, info.compositionStart); 1172 EXPECT_EQ(-1, info.compositionStart);
1168 EXPECT_EQ(-1, info.compositionEnd); 1173 EXPECT_EQ(-1, info.compositionEnd);
1169 1174
1170 // Caret is on the right of composing text. 1175 // Caret is on the right of composing text.
1171 activeInputMethodController->commitText("c", 1); 1176 activeInputMethodController->commitText("c", emptyUnderlines, 1);
1172 info = activeInputMethodController->textInputInfo(); 1177 info = activeInputMethodController->textInputInfo();
1173 EXPECT_EQ("cab", std::string(info.value.utf8().data())); 1178 EXPECT_EQ("cab", std::string(info.value.utf8().data()));
1174 EXPECT_EQ(2, info.selectionStart); 1179 EXPECT_EQ(2, info.selectionStart);
1175 EXPECT_EQ(2, info.selectionEnd); 1180 EXPECT_EQ(2, info.selectionEnd);
1176 EXPECT_EQ(-1, info.compositionStart); 1181 EXPECT_EQ(-1, info.compositionStart);
1177 EXPECT_EQ(-1, info.compositionEnd); 1182 EXPECT_EQ(-1, info.compositionEnd);
1178 1183
1179 // Caret is on the left boundary. 1184 // Caret is on the left boundary.
1180 activeInputMethodController->commitText("def", -5); 1185 activeInputMethodController->commitText("def", emptyUnderlines, -5);
1181 info = activeInputMethodController->textInputInfo(); 1186 info = activeInputMethodController->textInputInfo();
1182 EXPECT_EQ("cadefb", std::string(info.value.utf8().data())); 1187 EXPECT_EQ("cadefb", std::string(info.value.utf8().data()));
1183 EXPECT_EQ(0, info.selectionStart); 1188 EXPECT_EQ(0, info.selectionStart);
1184 EXPECT_EQ(0, info.selectionEnd); 1189 EXPECT_EQ(0, info.selectionEnd);
1185 EXPECT_EQ(-1, info.compositionStart); 1190 EXPECT_EQ(-1, info.compositionStart);
1186 EXPECT_EQ(-1, info.compositionEnd); 1191 EXPECT_EQ(-1, info.compositionEnd);
1187 1192
1188 // Caret is on the right boundary. 1193 // Caret is on the right boundary.
1189 activeInputMethodController->commitText("g", 6); 1194 activeInputMethodController->commitText("g", emptyUnderlines, 6);
1190 info = activeInputMethodController->textInputInfo(); 1195 info = activeInputMethodController->textInputInfo();
1191 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data())); 1196 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data()));
1192 EXPECT_EQ(7, info.selectionStart); 1197 EXPECT_EQ(7, info.selectionStart);
1193 EXPECT_EQ(7, info.selectionEnd); 1198 EXPECT_EQ(7, info.selectionEnd);
1194 EXPECT_EQ(-1, info.compositionStart); 1199 EXPECT_EQ(-1, info.compositionStart);
1195 EXPECT_EQ(-1, info.compositionEnd); 1200 EXPECT_EQ(-1, info.compositionEnd);
1196 1201
1197 // Caret exceeds the left boundary. 1202 // Caret exceeds the left boundary.
1198 activeInputMethodController->commitText("hi", -100); 1203 activeInputMethodController->commitText("hi", emptyUnderlines, -100);
1199 info = activeInputMethodController->textInputInfo(); 1204 info = activeInputMethodController->textInputInfo();
1200 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data())); 1205 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data()));
1201 EXPECT_EQ(0, info.selectionStart); 1206 EXPECT_EQ(0, info.selectionStart);
1202 EXPECT_EQ(0, info.selectionEnd); 1207 EXPECT_EQ(0, info.selectionEnd);
1203 EXPECT_EQ(-1, info.compositionStart); 1208 EXPECT_EQ(-1, info.compositionStart);
1204 EXPECT_EQ(-1, info.compositionEnd); 1209 EXPECT_EQ(-1, info.compositionEnd);
1205 1210
1206 // Caret exceeds the right boundary. 1211 // Caret exceeds the right boundary.
1207 activeInputMethodController->commitText("jk", 100); 1212 activeInputMethodController->commitText("jk", emptyUnderlines, 100);
1208 info = activeInputMethodController->textInputInfo(); 1213 info = activeInputMethodController->textInputInfo();
1209 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); 1214 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data()));
1210 EXPECT_EQ(11, info.selectionStart); 1215 EXPECT_EQ(11, info.selectionStart);
1211 EXPECT_EQ(11, info.selectionEnd); 1216 EXPECT_EQ(11, info.selectionEnd);
1212 EXPECT_EQ(-1, info.compositionStart); 1217 EXPECT_EQ(-1, info.compositionStart);
1213 EXPECT_EQ(-1, info.compositionEnd); 1218 EXPECT_EQ(-1, info.compositionEnd);
1214 } 1219 }
1215 1220
1216 TEST_P(WebViewTest, CommitTextWhileComposing) { 1221 TEST_P(WebViewTest, CommitTextWhileComposing) {
1217 URLTestHelpers::registerMockedURLFromBaseURL( 1222 URLTestHelpers::registerMockedURLFromBaseURL(
(...skipping 12 matching lines...) Expand all
1230 emptyUnderlines, 0, 0); 1235 emptyUnderlines, 0, 0);
1231 WebTextInputInfo info = activeInputMethodController->textInputInfo(); 1236 WebTextInputInfo info = activeInputMethodController->textInputInfo();
1232 EXPECT_EQ("abc", std::string(info.value.utf8().data())); 1237 EXPECT_EQ("abc", std::string(info.value.utf8().data()));
1233 EXPECT_EQ(0, info.selectionStart); 1238 EXPECT_EQ(0, info.selectionStart);
1234 EXPECT_EQ(0, info.selectionEnd); 1239 EXPECT_EQ(0, info.selectionEnd);
1235 EXPECT_EQ(0, info.compositionStart); 1240 EXPECT_EQ(0, info.compositionStart);
1236 EXPECT_EQ(3, info.compositionEnd); 1241 EXPECT_EQ(3, info.compositionEnd);
1237 1242
1238 // Deletes ongoing composition, inserts the specified text and moves the 1243 // Deletes ongoing composition, inserts the specified text and moves the
1239 // caret. 1244 // caret.
1240 activeInputMethodController->commitText("hello", -2); 1245 activeInputMethodController->commitText("hello", emptyUnderlines, -2);
1241 info = activeInputMethodController->textInputInfo(); 1246 info = activeInputMethodController->textInputInfo();
1242 EXPECT_EQ("hello", std::string(info.value.utf8().data())); 1247 EXPECT_EQ("hello", std::string(info.value.utf8().data()));
1243 EXPECT_EQ(3, info.selectionStart); 1248 EXPECT_EQ(3, info.selectionStart);
1244 EXPECT_EQ(3, info.selectionEnd); 1249 EXPECT_EQ(3, info.selectionEnd);
1245 EXPECT_EQ(-1, info.compositionStart); 1250 EXPECT_EQ(-1, info.compositionStart);
1246 EXPECT_EQ(-1, info.compositionEnd); 1251 EXPECT_EQ(-1, info.compositionEnd);
1247 1252
1248 activeInputMethodController->setComposition(WebString::fromUTF8("abc"), 1253 activeInputMethodController->setComposition(WebString::fromUTF8("abc"),
1249 emptyUnderlines, 0, 0); 1254 emptyUnderlines, 0, 0);
1250 info = activeInputMethodController->textInputInfo(); 1255 info = activeInputMethodController->textInputInfo();
1251 EXPECT_EQ("helabclo", std::string(info.value.utf8().data())); 1256 EXPECT_EQ("helabclo", std::string(info.value.utf8().data()));
1252 EXPECT_EQ(3, info.selectionStart); 1257 EXPECT_EQ(3, info.selectionStart);
1253 EXPECT_EQ(3, info.selectionEnd); 1258 EXPECT_EQ(3, info.selectionEnd);
1254 EXPECT_EQ(3, info.compositionStart); 1259 EXPECT_EQ(3, info.compositionStart);
1255 EXPECT_EQ(6, info.compositionEnd); 1260 EXPECT_EQ(6, info.compositionEnd);
1256 1261
1257 // Deletes ongoing composition and moves the caret. 1262 // Deletes ongoing composition and moves the caret.
1258 activeInputMethodController->commitText("", 2); 1263 activeInputMethodController->commitText("", emptyUnderlines, 2);
1259 info = activeInputMethodController->textInputInfo(); 1264 info = activeInputMethodController->textInputInfo();
1260 EXPECT_EQ("hello", std::string(info.value.utf8().data())); 1265 EXPECT_EQ("hello", std::string(info.value.utf8().data()));
1261 EXPECT_EQ(5, info.selectionStart); 1266 EXPECT_EQ(5, info.selectionStart);
1262 EXPECT_EQ(5, info.selectionEnd); 1267 EXPECT_EQ(5, info.selectionEnd);
1263 EXPECT_EQ(-1, info.compositionStart); 1268 EXPECT_EQ(-1, info.compositionStart);
1264 EXPECT_EQ(-1, info.compositionEnd); 1269 EXPECT_EQ(-1, info.compositionEnd);
1265 1270
1266 // Inserts the specified text and moves the caret. 1271 // Inserts the specified text and moves the caret.
1267 activeInputMethodController->commitText("world", -5); 1272 activeInputMethodController->commitText("world", emptyUnderlines, -5);
1268 info = activeInputMethodController->textInputInfo(); 1273 info = activeInputMethodController->textInputInfo();
1269 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); 1274 EXPECT_EQ("helloworld", std::string(info.value.utf8().data()));
1270 EXPECT_EQ(5, info.selectionStart); 1275 EXPECT_EQ(5, info.selectionStart);
1271 EXPECT_EQ(5, info.selectionEnd); 1276 EXPECT_EQ(5, info.selectionEnd);
1272 EXPECT_EQ(-1, info.compositionStart); 1277 EXPECT_EQ(-1, info.compositionStart);
1273 EXPECT_EQ(-1, info.compositionEnd); 1278 EXPECT_EQ(-1, info.compositionEnd);
1274 1279
1275 // Only moves the caret. 1280 // Only moves the caret.
1276 activeInputMethodController->commitText("", 5); 1281 activeInputMethodController->commitText("", emptyUnderlines, 5);
1277 info = activeInputMethodController->textInputInfo(); 1282 info = activeInputMethodController->textInputInfo();
1278 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); 1283 EXPECT_EQ("helloworld", std::string(info.value.utf8().data()));
1279 EXPECT_EQ(10, info.selectionStart); 1284 EXPECT_EQ(10, info.selectionStart);
1280 EXPECT_EQ(10, info.selectionEnd); 1285 EXPECT_EQ(10, info.selectionEnd);
1281 EXPECT_EQ(-1, info.compositionStart); 1286 EXPECT_EQ(-1, info.compositionStart);
1282 EXPECT_EQ(-1, info.compositionEnd); 1287 EXPECT_EQ(-1, info.compositionEnd);
1283 } 1288 }
1284 1289
1285 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) { 1290 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) {
1286 URLTestHelpers::registerMockedURLFromBaseURL( 1291 URLTestHelpers::registerMockedURLFromBaseURL(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 activeInputMethodController->finishComposingText( 1350 activeInputMethodController->finishComposingText(
1346 WebInputMethodController::KeepSelection); 1351 WebInputMethodController::KeepSelection);
1347 info = activeInputMethodController->textInputInfo(); 1352 info = activeInputMethodController->textInputInfo();
1348 EXPECT_EQ(4, info.selectionStart); 1353 EXPECT_EQ(4, info.selectionStart);
1349 EXPECT_EQ(4, info.selectionEnd); 1354 EXPECT_EQ(4, info.selectionEnd);
1350 EXPECT_EQ(-1, info.compositionStart); 1355 EXPECT_EQ(-1, info.compositionStart);
1351 EXPECT_EQ(-1, info.compositionEnd); 1356 EXPECT_EQ(-1, info.compositionEnd);
1352 1357
1353 std::string compositionText("\n"); 1358 std::string compositionText("\n");
1354 activeInputMethodController->commitText( 1359 activeInputMethodController->commitText(
1355 WebString::fromUTF8(compositionText.c_str()), 0); 1360 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0);
1356 info = activeInputMethodController->textInputInfo(); 1361 info = activeInputMethodController->textInputInfo();
1357 EXPECT_EQ(5, info.selectionStart); 1362 EXPECT_EQ(5, info.selectionStart);
1358 EXPECT_EQ(5, info.selectionEnd); 1363 EXPECT_EQ(5, info.selectionEnd);
1359 EXPECT_EQ(-1, info.compositionStart); 1364 EXPECT_EQ(-1, info.compositionStart);
1360 EXPECT_EQ(-1, info.compositionEnd); 1365 EXPECT_EQ(-1, info.compositionEnd);
1361 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", 1366 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz",
1362 std::string(info.value.utf8().data())); 1367 std::string(info.value.utf8().data()));
1363 } 1368 }
1364 1369
1365 TEST_P(WebViewTest, ExtendSelectionAndDelete) { 1370 TEST_P(WebViewTest, ExtendSelectionAndDelete) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 WebViewImpl* webView = 1468 WebViewImpl* webView =
1464 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); 1469 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html");
1465 webView->setInitialFocus(false); 1470 webView->setInitialFocus(false);
1466 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); 1471 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1));
1467 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); 1472 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0);
1468 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 1473 WebLocalFrameImpl* frame = webView->mainFrameImpl();
1469 WebInputMethodController* activeInputMethodController = 1474 WebInputMethodController* activeInputMethodController =
1470 frame->frameWidget()->getActiveWebInputMethodController(); 1475 frame->frameWidget()->getActiveWebInputMethodController();
1471 frame->setEditableSelectionOffsets(27, 27); 1476 frame->setEditableSelectionOffsets(27, 27);
1472 std::string newLineText("\n"); 1477 std::string newLineText("\n");
1478 WebVector<WebCompositionUnderline> emptyUnderlines;
1473 activeInputMethodController->commitText( 1479 activeInputMethodController->commitText(
1474 WebString::fromUTF8(newLineText.c_str()), 0); 1480 WebString::fromUTF8(newLineText.c_str()), emptyUnderlines, 0);
1475 WebTextInputInfo info = activeInputMethodController->textInputInfo(); 1481 WebTextInputInfo info = activeInputMethodController->textInputInfo();
1476 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", 1482 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz",
1477 std::string(info.value.utf8().data())); 1483 std::string(info.value.utf8().data()));
1478 1484
1479 frame->setEditableSelectionOffsets(31, 31); 1485 frame->setEditableSelectionOffsets(31, 31);
1480 frame->setCompositionFromExistingText(30, 34, underlines); 1486 frame->setCompositionFromExistingText(30, 34, underlines);
1481 info = activeInputMethodController->textInputInfo(); 1487 info = activeInputMethodController->textInputInfo();
1482 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", 1488 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz",
1483 std::string(info.value.utf8().data())); 1489 std::string(info.value.utf8().data()));
1484 EXPECT_EQ(31, info.selectionStart); 1490 EXPECT_EQ(31, info.selectionStart);
1485 EXPECT_EQ(31, info.selectionEnd); 1491 EXPECT_EQ(31, info.selectionEnd);
1486 EXPECT_EQ(30, info.compositionStart); 1492 EXPECT_EQ(30, info.compositionStart);
1487 EXPECT_EQ(34, info.compositionEnd); 1493 EXPECT_EQ(34, info.compositionEnd);
1488 1494
1489 std::string compositionText("yolo"); 1495 std::string compositionText("yolo");
1490 activeInputMethodController->commitText( 1496 activeInputMethodController->commitText(
1491 WebString::fromUTF8(compositionText.c_str()), 0); 1497 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0);
1492 info = activeInputMethodController->textInputInfo(); 1498 info = activeInputMethodController->textInputInfo();
1493 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", 1499 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz",
1494 std::string(info.value.utf8().data())); 1500 std::string(info.value.utf8().data()));
1495 EXPECT_EQ(34, info.selectionStart); 1501 EXPECT_EQ(34, info.selectionStart);
1496 EXPECT_EQ(34, info.selectionEnd); 1502 EXPECT_EQ(34, info.selectionEnd);
1497 EXPECT_EQ(-1, info.compositionStart); 1503 EXPECT_EQ(-1, info.compositionStart);
1498 EXPECT_EQ(-1, info.compositionEnd); 1504 EXPECT_EQ(-1, info.compositionEnd);
1499 } 1505 }
1500 1506
1501 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) { 1507 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) {
(...skipping 22 matching lines...) Expand all
1524 webView->setInitialFocus(false); 1530 webView->setInitialFocus(false);
1525 1531
1526 std::string compositionTextFirst("hello "); 1532 std::string compositionTextFirst("hello ");
1527 std::string compositionTextSecond("world"); 1533 std::string compositionTextSecond("world");
1528 WebVector<WebCompositionUnderline> emptyUnderlines; 1534 WebVector<WebCompositionUnderline> emptyUnderlines;
1529 WebInputMethodController* activeInputMethodController = 1535 WebInputMethodController* activeInputMethodController =
1530 webView->mainFrameImpl() 1536 webView->mainFrameImpl()
1531 ->frameWidget() 1537 ->frameWidget()
1532 ->getActiveWebInputMethodController(); 1538 ->getActiveWebInputMethodController();
1533 activeInputMethodController->commitText( 1539 activeInputMethodController->commitText(
1534 WebString::fromUTF8(compositionTextFirst.c_str()), 0); 1540 WebString::fromUTF8(compositionTextFirst.c_str()), emptyUnderlines, 0);
1535 activeInputMethodController->setComposition( 1541 activeInputMethodController->setComposition(
1536 WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5, 1542 WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5,
1537 5); 1543 5);
1538 1544
1539 WebTextInputInfo info = activeInputMethodController->textInputInfo(); 1545 WebTextInputInfo info = activeInputMethodController->textInputInfo();
1540 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); 1546 EXPECT_EQ("hello world", std::string(info.value.utf8().data()));
1541 EXPECT_EQ(11, info.selectionStart); 1547 EXPECT_EQ(11, info.selectionStart);
1542 EXPECT_EQ(11, info.selectionEnd); 1548 EXPECT_EQ(11, info.selectionEnd);
1543 EXPECT_EQ(6, info.compositionStart); 1549 EXPECT_EQ(6, info.compositionStart);
1544 EXPECT_EQ(11, info.compositionEnd); 1550 EXPECT_EQ(11, info.compositionEnd);
(...skipping 2518 matching lines...) Expand 10 before | Expand all | Expand 10 after
4063 URLTestHelpers::registerMockedURLFromBaseURL( 4069 URLTestHelpers::registerMockedURLFromBaseURL(
4064 WebString::fromUTF8(m_baseURL.c_str()), 4070 WebString::fromUTF8(m_baseURL.c_str()),
4065 WebString::fromUTF8("input_field_password.html")); 4071 WebString::fromUTF8("input_field_password.html"));
4066 MockAutofillClient client; 4072 MockAutofillClient client;
4067 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 4073 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
4068 m_baseURL + "input_field_password.html", true); 4074 m_baseURL + "input_field_password.html", true);
4069 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 4075 WebLocalFrameImpl* frame = webView->mainFrameImpl();
4070 frame->setAutofillClient(&client); 4076 frame->setAutofillClient(&client);
4071 webView->setInitialFocus(false); 4077 webView->setInitialFocus(false);
4072 4078
4079 WebVector<WebCompositionUnderline> emptyUnderlines;
4080
4073 EXPECT_TRUE( 4081 EXPECT_TRUE(
4074 frame->frameWidget()->getActiveWebInputMethodController()->commitText( 4082 frame->frameWidget()->getActiveWebInputMethodController()->commitText(
4075 WebString::fromUTF8(std::string("hello").c_str()), 0)); 4083 WebString::fromUTF8(std::string("hello").c_str()), emptyUnderlines,
4084 0));
4076 EXPECT_EQ(1, client.textChangesFromUserGesture()); 4085 EXPECT_EQ(1, client.textChangesFromUserGesture());
4077 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); 4086 EXPECT_FALSE(UserGestureIndicator::processingUserGesture());
4078 frame->setAutofillClient(0); 4087 frame->setAutofillClient(0);
4079 } 4088 }
4080 4089
4081 // Verify that a WebView created with a ScopedPageSuspender already on the 4090 // Verify that a WebView created with a ScopedPageSuspender already on the
4082 // stack defers its loads. 4091 // stack defers its loads.
4083 TEST_P(WebViewTest, CreatedDuringPageSuspension) { 4092 TEST_P(WebViewTest, CreatedDuringPageSuspension) {
4084 { 4093 {
4085 WebViewImpl* webView = m_webViewHelper.initialize(); 4094 WebViewImpl* webView = m_webViewHelper.initialize();
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
4343 frame->printBegin(printParams, WebNode()); 4352 frame->printBegin(printParams, WebNode());
4344 webView->resize(WebSize(500, 500)); 4353 webView->resize(WebSize(500, 500));
4345 EXPECT_EQ(500, vwElement->offsetWidth()); 4354 EXPECT_EQ(500, vwElement->offsetWidth());
4346 4355
4347 webView->resize(WebSize(800, 600)); 4356 webView->resize(WebSize(800, 600));
4348 frame->printEnd(); 4357 frame->printEnd();
4349 EXPECT_EQ(800, vwElement->offsetWidth()); 4358 EXPECT_EQ(800, vwElement->offsetWidth());
4350 } 4359 }
4351 4360
4352 } // namespace blink 4361 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698