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

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

Issue 2874783004: Remove selected text when committing empty text (Closed)
Patch Set: Created 3 years, 7 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 3857308030c399a5366c91b2d15f82efec4b6eef..4ad2ef16152303d34ef87022cc372d624e438ade 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
@@ -1272,7 +1272,7 @@ TEST_F(InputMethodControllerTest, CompositionInputEventForInsertEmptyText) {
GetDocument().setTitle(g_empty_string);
GetDocument().UpdateStyleAndLayout();
Controller().CommitText("", underlines, 0);
- EXPECT_STREQ("", GetDocument().title().Utf8().data());
+ EXPECT_STREQ("beforeinput.data:;", GetDocument().title().Utf8().data());
GetDocument().setTitle(g_empty_string);
Controller().SetComposition("n", underlines, 1, 1);
@@ -1507,6 +1507,22 @@ TEST_F(InputMethodControllerTest, WhitespaceFixup) {
EXPECT_STREQ(" text ", div->innerHTML().Utf8().data());
}
+TEST_F(InputMethodControllerTest, CommitEmptyTextDeletesSelection) {
+ HTMLInputElement* input =
+ toHTMLInputElement(InsertHTMLElement("<input id='sample'>", "sample"));
+
+ input->setValue("Abc Def Ghi");
+ GetDocument().UpdateStyleAndLayout();
+ Vector<CompositionUnderline> empty_underlines;
+ Controller().SetEditableSelectionOffsets(PlainTextRange(4, 8));
+ Controller().CommitText(String(""), empty_underlines, 0);
+ EXPECT_STREQ("Abc Ghi", input->value().Utf8().data());
+
+ Controller().SetEditableSelectionOffsets(PlainTextRange(4, 7));
+ Controller().CommitText(String("1"), empty_underlines, 0);
+ EXPECT_STREQ("Abc 1", input->value().Utf8().data());
+}
+
static String GetMarkedText(
DocumentMarkerController& document_marker_controller,
Node* node,

Powered by Google App Engine
This is Rietveld 408576698