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

Side by Side Diff: third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp

Issue 2675363003: [InputEvent] Fire "insertCompositionText" during IME (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/editing/InputMethodController.h" 5 #include "core/editing/InputMethodController.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/dom/Range.h" 9 #include "core/dom/Range.h"
10 #include "core/editing/Editor.h" 10 #include "core/editing/Editor.h"
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 1006 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
1007 1007
1008 document().setTitle(emptyString); 1008 document().setTitle(emptyString);
1009 controller().setComposition("hello", underlines, 5, 5); 1009 controller().setComposition("hello", underlines, 5, 5);
1010 EXPECT_STREQ("beforeinput.data:hello;input.data:hello;", 1010 EXPECT_STREQ("beforeinput.data:hello;input.data:hello;",
1011 document().title().utf8().data()); 1011 document().title().utf8().data());
1012 1012
1013 // Delete the existing composition. 1013 // Delete the existing composition.
1014 document().setTitle(emptyString); 1014 document().setTitle(emptyString);
1015 controller().setComposition("", underlines, 0, 0); 1015 controller().setComposition("", underlines, 0, 0);
1016 EXPECT_STREQ("beforeinput.data:;compositionend.data:;", 1016 EXPECT_STREQ("beforeinput.data:;input.data:;compositionend.data:;",
1017 document().title().utf8().data()); 1017 document().title().utf8().data());
1018 } 1018 }
1019 1019
1020 TEST_F(InputMethodControllerTest, CompositionInputEventForInsert) { 1020 TEST_F(InputMethodControllerTest, CompositionInputEventForInsert) {
1021 createHTMLWithCompositionInputEventListeners(); 1021 createHTMLWithCompositionInputEventListeners();
1022 1022
1023 // Simulate composition in the |contentEditable|. 1023 // Simulate composition in the |contentEditable|.
1024 Vector<CompositionUnderline> underlines; 1024 Vector<CompositionUnderline> underlines;
1025 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 1025 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
1026 1026
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 1060
1061 document().setTitle(emptyString); 1061 document().setTitle(emptyString);
1062 controller().setComposition("n", underlines, 1, 1); 1062 controller().setComposition("n", underlines, 1, 1);
1063 EXPECT_STREQ("beforeinput.data:n;input.data:n;", 1063 EXPECT_STREQ("beforeinput.data:n;input.data:n;",
1064 document().title().utf8().data()); 1064 document().title().utf8().data());
1065 1065
1066 // Insert empty text with previous composition. 1066 // Insert empty text with previous composition.
1067 document().setTitle(emptyString); 1067 document().setTitle(emptyString);
1068 document().updateStyleAndLayout(); 1068 document().updateStyleAndLayout();
1069 controller().commitText("", underlines, 1); 1069 controller().commitText("", underlines, 1);
1070 EXPECT_STREQ("beforeinput.data:;compositionend.data:;", 1070 EXPECT_STREQ("beforeinput.data:;input.data:;compositionend.data:;",
1071 document().title().utf8().data()); 1071 document().title().utf8().data());
1072 } 1072 }
1073 1073
1074 TEST_F(InputMethodControllerTest, CompositionEndEventWithNoSelection) { 1074 TEST_F(InputMethodControllerTest, CompositionEndEventWithNoSelection) {
1075 createHTMLWithCompositionEndEventListener(NoSelection); 1075 createHTMLWithCompositionEndEventListener(NoSelection);
1076 1076
1077 // Simulate composition in the |contentEditable|. 1077 // Simulate composition in the |contentEditable|.
1078 Vector<CompositionUnderline> underlines; 1078 Vector<CompositionUnderline> underlines;
1079 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 1079 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
1080 1080
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 1169
1170 controller().commitText(String("string"), underlines, 0); 1170 controller().commitText(String("string"), underlines, 0);
1171 1171
1172 ASSERT_EQ(1u, document().markers().markers().size()); 1172 ASSERT_EQ(1u, document().markers().markers().size());
1173 1173
1174 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset()); 1174 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset());
1175 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset()); 1175 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset());
1176 } 1176 }
1177 1177
1178 } // namespace blink 1178 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698