| Index: third_party/WebKit/Source/web/tests/WebViewTest.cpp
|
| diff --git a/third_party/WebKit/Source/web/tests/WebViewTest.cpp b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
|
| index a32e4562bcd64f4aa8be19556a92a42d1114d5fa..833818a97e05ea1a7f8951ec0a10a1d374fbc0ab 100644
|
| --- a/third_party/WebKit/Source/web/tests/WebViewTest.cpp
|
| +++ b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
|
| @@ -917,6 +917,47 @@ TEST_F(WebViewTest, ExtendSelectionAndDelete)
|
| EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data()));
|
| }
|
|
|
| +TEST_F(WebViewTest, DeleteSurroundingText)
|
| +{
|
| + URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html"));
|
| + WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_field_populated.html");
|
| + WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
|
| + webView->setInitialFocus(false);
|
| +
|
| + frame->setEditableSelectionOffsets(10, 10);
|
| + frame->deleteSurroundingText(5, 8);
|
| + WebTextInputInfo info = webView->textInputInfo();
|
| + EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data()));
|
| + EXPECT_EQ(5, info.selectionStart);
|
| + EXPECT_EQ(5, info.selectionEnd);
|
| +
|
| + frame->setEditableSelectionOffsets(5, 10);
|
| + frame->deleteSurroundingText(3, 5);
|
| + info = webView->textInputInfo();
|
| + EXPECT_EQ("01ijklmstuvwxyz", std::string(info.value.utf8().data()));
|
| + EXPECT_EQ(2, info.selectionStart);
|
| + EXPECT_EQ(7, info.selectionEnd);
|
| +
|
| + frame->setEditableSelectionOffsets(5, 5);
|
| + frame->deleteSurroundingText(10, 0);
|
| + info = webView->textInputInfo();
|
| + EXPECT_EQ("lmstuvwxyz", std::string(info.value.utf8().data()));
|
| + EXPECT_EQ(0, info.selectionStart);
|
| + EXPECT_EQ(0, info.selectionEnd);
|
| +
|
| + frame->deleteSurroundingText(0, 20);
|
| + info = webView->textInputInfo();
|
| + EXPECT_EQ("", std::string(info.value.utf8().data()));
|
| + EXPECT_EQ(0, info.selectionStart);
|
| + EXPECT_EQ(0, info.selectionEnd);
|
| +
|
| + frame->deleteSurroundingText(10, 10);
|
| + info = webView->textInputInfo();
|
| + EXPECT_EQ("", std::string(info.value.utf8().data()));
|
| + EXPECT_EQ(0, info.selectionStart);
|
| + EXPECT_EQ(0, info.selectionEnd);
|
| +}
|
| +
|
| TEST_F(WebViewTest, SetCompositionFromExistingText)
|
| {
|
| URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html"));
|
|
|