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

Unified Diff: third_party/WebKit/Source/web/tests/WebViewTest.cpp

Issue 2617443002: Implement ThreadedInputConnection.deleteSurroundingTextInCodePoints() (Closed)
Patch Set: Add more comments 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 side-by-side diff with in-line comments
Download patch
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 f190ac91c5137284e4e0baf55c96739e5a043074..590c7b3b17d89e6f66c91473b1bb7a16de27096d 100644
--- a/third_party/WebKit/Source/web/tests/WebViewTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
@@ -1409,6 +1409,49 @@ TEST_P(WebViewTest, DeleteSurroundingText) {
EXPECT_EQ(0, info.selectionEnd);
}
+TEST_P(WebViewTest, DeleteSurroundingTextInCodePoints) {
+ 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->deleteSurroundingTextInCodePoints(5, 8);
+ WebTextInputInfo info = webView->textInputInfo();
+ EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data()));
Changwan Ryu 2017/01/11 02:00:27 how about deleting a surrounding pair in this test
yabinh 2017/01/24 11:39:56 Done.
+ EXPECT_EQ(5, info.selectionStart);
+ EXPECT_EQ(5, info.selectionEnd);
+
+ frame->setEditableSelectionOffsets(5, 10);
+ frame->deleteSurroundingTextInCodePoints(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->deleteSurroundingTextInCodePoints(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->deleteSurroundingTextInCodePoints(0, 20);
+ info = webView->textInputInfo();
+ EXPECT_EQ("", std::string(info.value.utf8().data()));
+ EXPECT_EQ(0, info.selectionStart);
+ EXPECT_EQ(0, info.selectionEnd);
+
+ frame->deleteSurroundingTextInCodePoints(10, 10);
+ info = webView->textInputInfo();
+ EXPECT_EQ("", std::string(info.value.utf8().data()));
+ EXPECT_EQ(0, info.selectionStart);
+ EXPECT_EQ(0, info.selectionEnd);
+}
+
TEST_P(WebViewTest, SetCompositionFromExistingText) {
URLTestHelpers::registerMockedURLFromBaseURL(
WebString::fromUTF8(m_baseURL.c_str()),

Powered by Google App Engine
This is Rietveld 408576698