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

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

Issue 2883073002: 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 f487105f6a1cf44d5150230de935fe104e605ffa..509ad602cd86e3ca2dd74c659a2a6c154774132f 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,
« no previous file with comments | « third_party/WebKit/Source/core/editing/InputMethodController.cpp ('k') | third_party/WebKit/Source/web/WebLocalFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698