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 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 frame->extendSelectionAndDelete(5, 8); | 1255 frame->extendSelectionAndDelete(5, 8); |
1256 WebTextInputInfo info = webView->textInputInfo(); | 1256 WebTextInputInfo info = webView->textInputInfo(); |
1257 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); | 1257 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
1258 EXPECT_EQ(5, info.selectionStart); | 1258 EXPECT_EQ(5, info.selectionStart); |
1259 EXPECT_EQ(5, info.selectionEnd); | 1259 EXPECT_EQ(5, info.selectionEnd); |
1260 frame->extendSelectionAndDelete(10, 0); | 1260 frame->extendSelectionAndDelete(10, 0); |
1261 info = webView->textInputInfo(); | 1261 info = webView->textInputInfo(); |
1262 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); | 1262 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
1263 } | 1263 } |
1264 | 1264 |
| 1265 TEST_F(WebViewTest, DeleteSurroundingText) { |
| 1266 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1267 WebString::fromUTF8(m_baseURL.c_str()), |
| 1268 WebString::fromUTF8("input_field_populated.html")); |
| 1269 WebView* webView = m_webViewHelper.initializeAndLoad( |
| 1270 m_baseURL + "input_field_populated.html"); |
| 1271 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); |
| 1272 webView->setInitialFocus(false); |
| 1273 |
| 1274 frame->setEditableSelectionOffsets(10, 10); |
| 1275 frame->deleteSurroundingText(5, 8); |
| 1276 WebTextInputInfo info = webView->textInputInfo(); |
| 1277 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
| 1278 EXPECT_EQ(5, info.selectionStart); |
| 1279 EXPECT_EQ(5, info.selectionEnd); |
| 1280 |
| 1281 frame->setEditableSelectionOffsets(5, 10); |
| 1282 frame->deleteSurroundingText(3, 5); |
| 1283 info = webView->textInputInfo(); |
| 1284 EXPECT_EQ("01ijklmstuvwxyz", std::string(info.value.utf8().data())); |
| 1285 EXPECT_EQ(2, info.selectionStart); |
| 1286 EXPECT_EQ(7, info.selectionEnd); |
| 1287 |
| 1288 frame->setEditableSelectionOffsets(5, 5); |
| 1289 frame->deleteSurroundingText(10, 0); |
| 1290 info = webView->textInputInfo(); |
| 1291 EXPECT_EQ("lmstuvwxyz", std::string(info.value.utf8().data())); |
| 1292 EXPECT_EQ(0, info.selectionStart); |
| 1293 EXPECT_EQ(0, info.selectionEnd); |
| 1294 |
| 1295 frame->deleteSurroundingText(0, 20); |
| 1296 info = webView->textInputInfo(); |
| 1297 EXPECT_EQ("", std::string(info.value.utf8().data())); |
| 1298 EXPECT_EQ(0, info.selectionStart); |
| 1299 EXPECT_EQ(0, info.selectionEnd); |
| 1300 |
| 1301 frame->deleteSurroundingText(10, 10); |
| 1302 info = webView->textInputInfo(); |
| 1303 EXPECT_EQ("", std::string(info.value.utf8().data())); |
| 1304 EXPECT_EQ(0, info.selectionStart); |
| 1305 EXPECT_EQ(0, info.selectionEnd); |
| 1306 } |
| 1307 |
1265 TEST_F(WebViewTest, SetCompositionFromExistingText) { | 1308 TEST_F(WebViewTest, SetCompositionFromExistingText) { |
1266 URLTestHelpers::registerMockedURLFromBaseURL( | 1309 URLTestHelpers::registerMockedURLFromBaseURL( |
1267 WebString::fromUTF8(m_baseURL.c_str()), | 1310 WebString::fromUTF8(m_baseURL.c_str()), |
1268 WebString::fromUTF8("input_field_populated.html")); | 1311 WebString::fromUTF8("input_field_populated.html")); |
1269 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 1312 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
1270 m_baseURL + "input_field_populated.html"); | 1313 m_baseURL + "input_field_populated.html"); |
1271 webView->setInitialFocus(false); | 1314 webView->setInitialFocus(false); |
1272 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 1315 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
1273 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 1316 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
1274 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1317 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
(...skipping 2812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4087 .translate(50, 55) | 4130 .translate(50, 55) |
4088 .scale(1. / 2.f); | 4131 .scale(1. / 2.f); |
4089 EXPECT_EQ(expectedMatrix, | 4132 EXPECT_EQ(expectedMatrix, |
4090 webViewImpl->getDeviceEmulationTransformForTesting()); | 4133 webViewImpl->getDeviceEmulationTransformForTesting()); |
4091 // visibleContentRect doesn't change. | 4134 // visibleContentRect doesn't change. |
4092 EXPECT_EQ(IntRect(50, 55, 50, 75), | 4135 EXPECT_EQ(IntRect(50, 55, 50, 75), |
4093 *devToolsEmulator->visibleContentRectForPainting()); | 4136 *devToolsEmulator->visibleContentRectForPainting()); |
4094 } | 4137 } |
4095 | 4138 |
4096 } // namespace blink | 4139 } // namespace blink |
OLD | NEW |