| OLD | NEW |
| 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 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 Vector<CompositionUnderline> underlines; | 946 Vector<CompositionUnderline> underlines; |
| 947 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); | 947 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
| 948 editable->focus(); | 948 editable->focus(); |
| 949 | 949 |
| 950 document().setTitle(emptyString); | 950 document().setTitle(emptyString); |
| 951 controller().setComposition("foo", underlines, 0, 3); | 951 controller().setComposition("foo", underlines, 0, 3); |
| 952 EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", | 952 EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", |
| 953 document().title().utf8().data()); | 953 document().title().utf8().data()); |
| 954 | 954 |
| 955 document().setTitle(emptyString); | 955 document().setTitle(emptyString); |
| 956 controller().finishComposingText(InputMethodController::KeepSelection); | 956 controller().commitText("bar", underlines, 0); |
| 957 // Last pair of InputEvent should also be inside composition scope. | 957 // Last pair of InputEvent should also be inside composition scope. |
| 958 EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", | 958 EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", |
| 959 document().title().utf8().data()); | 959 document().title().utf8().data()); |
| 960 } | 960 } |
| 961 | 961 |
| 962 TEST_F(InputMethodControllerTest, CompositionInputEventForReplace) { | 962 TEST_F(InputMethodControllerTest, CompositionInputEventForReplace) { |
| 963 createHTMLWithCompositionInputEventListeners(); | 963 createHTMLWithCompositionInputEventListeners(); |
| 964 | 964 |
| 965 // Simulate composition in the |contentEditable|. | 965 // Simulate composition in the |contentEditable|. |
| 966 Vector<CompositionUnderline> underlines; | 966 Vector<CompositionUnderline> underlines; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 986 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); | 986 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
| 987 | 987 |
| 988 document().setTitle(emptyString); | 988 document().setTitle(emptyString); |
| 989 controller().setComposition("hello", underlines, 5, 5); | 989 controller().setComposition("hello", underlines, 5, 5); |
| 990 EXPECT_STREQ("beforeinput.data:hello;input.data:hello;", | 990 EXPECT_STREQ("beforeinput.data:hello;input.data:hello;", |
| 991 document().title().utf8().data()); | 991 document().title().utf8().data()); |
| 992 | 992 |
| 993 // Confirm the ongoing composition. | 993 // Confirm the ongoing composition. |
| 994 document().setTitle(emptyString); | 994 document().setTitle(emptyString); |
| 995 controller().finishComposingText(InputMethodController::KeepSelection); | 995 controller().finishComposingText(InputMethodController::KeepSelection); |
| 996 EXPECT_STREQ( | 996 EXPECT_STREQ("compositionend.data:hello;", document().title().utf8().data()); |
| 997 "beforeinput.data:hello;input.data:hello;compositionend.data:hello;", | |
| 998 document().title().utf8().data()); | |
| 999 } | 997 } |
| 1000 | 998 |
| 1001 TEST_F(InputMethodControllerTest, CompositionInputEventForDelete) { | 999 TEST_F(InputMethodControllerTest, CompositionInputEventForDelete) { |
| 1002 createHTMLWithCompositionInputEventListeners(); | 1000 createHTMLWithCompositionInputEventListeners(); |
| 1003 | 1001 |
| 1004 // Simulate composition in the |contentEditable|. | 1002 // Simulate composition in the |contentEditable|. |
| 1005 Vector<CompositionUnderline> underlines; | 1003 Vector<CompositionUnderline> underlines; |
| 1006 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); | 1004 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
| 1007 | 1005 |
| 1008 document().setTitle(emptyString); | 1006 document().setTitle(emptyString); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 | 1167 |
| 1170 controller().commitText(String("string"), underlines, 0); | 1168 controller().commitText(String("string"), underlines, 0); |
| 1171 | 1169 |
| 1172 ASSERT_EQ(1u, document().markers().markers().size()); | 1170 ASSERT_EQ(1u, document().markers().markers().size()); |
| 1173 | 1171 |
| 1174 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset()); | 1172 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset()); |
| 1175 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset()); | 1173 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset()); |
| 1176 } | 1174 } |
| 1177 | 1175 |
| 1178 } // namespace blink | 1176 } // namespace blink |
| OLD | NEW |