| 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 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 EXPECT_EQ(1u, controller().getSelectionOffsets().start()); | 1055 EXPECT_EQ(1u, controller().getSelectionOffsets().start()); |
| 1056 EXPECT_EQ(1u, controller().getSelectionOffsets().end()); | 1056 EXPECT_EQ(1u, controller().getSelectionOffsets().end()); |
| 1057 | 1057 |
| 1058 // Confirm the ongoing composition. Note that it moves the caret to the end of | 1058 // Confirm the ongoing composition. Note that it moves the caret to the end of |
| 1059 // text [5,5] before firing 'compositonend' event. | 1059 // text [5,5] before firing 'compositonend' event. |
| 1060 controller().finishComposingText(InputMethodController::DoNotKeepSelection); | 1060 controller().finishComposingText(InputMethodController::DoNotKeepSelection); |
| 1061 document().updateStyleAndLayout(); | 1061 document().updateStyleAndLayout(); |
| 1062 EXPECT_TRUE(controller().getSelectionOffsets().isNull()); | 1062 EXPECT_TRUE(controller().getSelectionOffsets().isNull()); |
| 1063 } | 1063 } |
| 1064 | 1064 |
| 1065 TEST_F(InputMethodControllerTest, FinishCompositionRemovedRange) { |
| 1066 Element* inputA = |
| 1067 insertHTMLElement("<input id='a' /><br><input type='tel' id='b' />", "a"); |
| 1068 |
| 1069 EXPECT_EQ(WebTextInputTypeText, controller().textInputType()); |
| 1070 |
| 1071 // The test requires non-empty composition. |
| 1072 controller().setComposition("hello", Vector<CompositionUnderline>(), 5, 5); |
| 1073 EXPECT_EQ(WebTextInputTypeText, controller().textInputType()); |
| 1074 |
| 1075 // Remove element 'a'. |
| 1076 inputA->setOuterHTML("", ASSERT_NO_EXCEPTION); |
| 1077 EXPECT_EQ(WebTextInputTypeNone, controller().textInputType()); |
| 1078 |
| 1079 document().getElementById("b")->focus(); |
| 1080 EXPECT_EQ(WebTextInputTypeTelephone, controller().textInputType()); |
| 1081 |
| 1082 controller().finishComposingText(InputMethodController::KeepSelection); |
| 1083 EXPECT_EQ(WebTextInputTypeTelephone, controller().textInputType()); |
| 1084 } |
| 1085 |
| 1065 } // namespace blink | 1086 } // namespace blink |
| OLD | NEW |