| 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 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); | 983 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
| 984 | 984 |
| 985 document().setTitle(emptyString()); | 985 document().setTitle(emptyString()); |
| 986 controller().setComposition("hello", underlines, 5, 5); | 986 controller().setComposition("hello", underlines, 5, 5); |
| 987 EXPECT_STREQ("beforeinput.data:hello;input.data:hello;", | 987 EXPECT_STREQ("beforeinput.data:hello;input.data:hello;", |
| 988 document().title().utf8().data()); | 988 document().title().utf8().data()); |
| 989 | 989 |
| 990 // Delete the existing composition. | 990 // Delete the existing composition. |
| 991 document().setTitle(emptyString()); | 991 document().setTitle(emptyString()); |
| 992 controller().setComposition("", underlines, 0, 0); | 992 controller().setComposition("", underlines, 0, 0); |
| 993 EXPECT_STREQ("beforeinput.data:;compositionend.data:;", | 993 EXPECT_STREQ("beforeinput.data:null;input.data:null;compositionend.data:;", |
| 994 document().title().utf8().data()); | 994 document().title().utf8().data()); |
| 995 } | 995 } |
| 996 | 996 |
| 997 TEST_F(InputMethodControllerTest, CompositionInputEventForInsert) { | 997 TEST_F(InputMethodControllerTest, CompositionInputEventForInsert) { |
| 998 createHTMLWithCompositionInputEventListeners(); | 998 createHTMLWithCompositionInputEventListeners(); |
| 999 | 999 |
| 1000 // Simulate composition in the |contentEditable|. | 1000 // Simulate composition in the |contentEditable|. |
| 1001 Vector<CompositionUnderline> underlines; | 1001 Vector<CompositionUnderline> underlines; |
| 1002 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); | 1002 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
| 1003 | 1003 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 | 1037 |
| 1038 document().setTitle(emptyString()); | 1038 document().setTitle(emptyString()); |
| 1039 controller().setComposition("n", underlines, 1, 1); | 1039 controller().setComposition("n", underlines, 1, 1); |
| 1040 EXPECT_STREQ("beforeinput.data:n;input.data:n;", | 1040 EXPECT_STREQ("beforeinput.data:n;input.data:n;", |
| 1041 document().title().utf8().data()); | 1041 document().title().utf8().data()); |
| 1042 | 1042 |
| 1043 // Insert empty text with previous composition. | 1043 // Insert empty text with previous composition. |
| 1044 document().setTitle(emptyString()); | 1044 document().setTitle(emptyString()); |
| 1045 document().updateStyleAndLayout(); | 1045 document().updateStyleAndLayout(); |
| 1046 controller().commitText("", 1); | 1046 controller().commitText("", 1); |
| 1047 EXPECT_STREQ("beforeinput.data:;compositionend.data:;", | 1047 EXPECT_STREQ("beforeinput.data:null;input.data:null;compositionend.data:;", |
| 1048 document().title().utf8().data()); | 1048 document().title().utf8().data()); |
| 1049 } | 1049 } |
| 1050 | 1050 |
| 1051 TEST_F(InputMethodControllerTest, CompositionEndEventForConfirm) { | 1051 TEST_F(InputMethodControllerTest, CompositionEndEventForConfirm) { |
| 1052 createHTMLWithCompositionEndEventListener(CaretSelection); | 1052 createHTMLWithCompositionEndEventListener(CaretSelection); |
| 1053 | 1053 |
| 1054 // Simulate composition in the |contentEditable|. | 1054 // Simulate composition in the |contentEditable|. |
| 1055 Vector<CompositionUnderline> underlines; | 1055 Vector<CompositionUnderline> underlines; |
| 1056 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); | 1056 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
| 1057 | 1057 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 EXPECT_EQ(WebTextInputTypeNone, controller().textInputType()); | 1140 EXPECT_EQ(WebTextInputTypeNone, controller().textInputType()); |
| 1141 | 1141 |
| 1142 document().getElementById("b")->focus(); | 1142 document().getElementById("b")->focus(); |
| 1143 EXPECT_EQ(WebTextInputTypeTelephone, controller().textInputType()); | 1143 EXPECT_EQ(WebTextInputTypeTelephone, controller().textInputType()); |
| 1144 | 1144 |
| 1145 controller().finishComposingText(InputMethodController::KeepSelection); | 1145 controller().finishComposingText(InputMethodController::KeepSelection); |
| 1146 EXPECT_EQ(WebTextInputTypeTelephone, controller().textInputType()); | 1146 EXPECT_EQ(WebTextInputTypeTelephone, controller().textInputType()); |
| 1147 } | 1147 } |
| 1148 | 1148 |
| 1149 } // namespace blink | 1149 } // namespace blink |
| OLD | NEW |