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

Unified Diff: third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp

Issue 1889053003: Fix InputConnection.deleteSurroundingText() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/core/editing/InputMethodControllerTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
index f84d2306a5ca8b951b5284d55508c9b0675a44fb..6ecf84cdbb3fd2b51c44746f4b5805067f3dee8a 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
@@ -190,4 +190,85 @@ TEST_F(InputMethodControllerTest, ConfirmPasswordComposition)
EXPECT_STREQ("foo", input->value().utf8().data());
}
+TEST_F(InputMethodControllerTest, DeleteSurroundingTextWithEmptyText)
+{
+ HTMLInputElement* input = toHTMLInputElement(
+ insertHTMLElement("<input id='sample'>", "sample"));
+
+ input->setValue("");
+ EXPECT_STREQ("", input->value().utf8().data());
+ controller().deleteSurroundingText(0, 0);
+ EXPECT_STREQ("", input->value().utf8().data());
+
+ input->setValue("");
+ EXPECT_STREQ("", input->value().utf8().data());
+ controller().deleteSurroundingText(1, 0);
+ EXPECT_STREQ("", input->value().utf8().data());
+
+ input->setValue("");
+ EXPECT_STREQ("", input->value().utf8().data());
+ controller().deleteSurroundingText(0, 1);
+ EXPECT_STREQ("", input->value().utf8().data());
+}
+
+TEST_F(InputMethodControllerTest, DeleteSurroundingTextWithRangeSelection)
+{
+ HTMLInputElement* input = toHTMLInputElement(
+ insertHTMLElement("<input id='sample'>", "sample"));
+
+ input->setValue("hello");
+ EXPECT_STREQ("hello", input->value().utf8().data());
+ controller().setEditableSelectionOffsets(PlainTextRange(1, 4));
+ controller().deleteSurroundingText(0, 0);
+ EXPECT_STREQ("hello", input->value().utf8().data());
+
+ input->setValue("hello");
+ EXPECT_STREQ("hello", input->value().utf8().data());
+ controller().setEditableSelectionOffsets(PlainTextRange(1, 4));
+ controller().deleteSurroundingText(1, 1);
+ EXPECT_STREQ("ell", input->value().utf8().data());
+
+ input->setValue("hello");
+ EXPECT_STREQ("hello", input->value().utf8().data());
+ controller().setEditableSelectionOffsets(PlainTextRange(1, 4));
+ controller().deleteSurroundingText(100, 0);
+ EXPECT_STREQ("ello", input->value().utf8().data());
+
+ input->setValue("hello");
+ EXPECT_STREQ("hello", input->value().utf8().data());
+ controller().setEditableSelectionOffsets(PlainTextRange(1, 4));
+ controller().deleteSurroundingText(0, 100);
+ EXPECT_STREQ("hell", input->value().utf8().data());
+}
+
+TEST_F(InputMethodControllerTest, DeleteSurroundingTextWithCursorSelection)
+{
+ HTMLInputElement* input = toHTMLInputElement(
+ insertHTMLElement("<input id='sample'>", "sample"));
+
+ input->setValue("hello");
+ EXPECT_STREQ("hello", input->value().utf8().data());
+ controller().setEditableSelectionOffsets(PlainTextRange(2, 2));
+ controller().deleteSurroundingText(0, 0);
+ EXPECT_STREQ("hello", input->value().utf8().data());
+
+ input->setValue("hello");
+ EXPECT_STREQ("hello", input->value().utf8().data());
+ controller().setEditableSelectionOffsets(PlainTextRange(2, 2));
+ controller().deleteSurroundingText(1, 1);
+ EXPECT_STREQ("hlo", input->value().utf8().data());
+
+ input->setValue("hello");
+ EXPECT_STREQ("hello", input->value().utf8().data());
+ controller().setEditableSelectionOffsets(PlainTextRange(2, 2));
+ controller().deleteSurroundingText(100, 0);
+ EXPECT_STREQ("llo", input->value().utf8().data());
+
+ input->setValue("hello");
+ EXPECT_STREQ("hello", input->value().utf8().data());
+ controller().setEditableSelectionOffsets(PlainTextRange(2, 2));
+ controller().deleteSurroundingText(0, 100);
+ EXPECT_STREQ("he", input->value().utf8().data());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698