| 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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 EXPECT_EQ(1u, controller().getSelectionOffsets().start()); | 398 EXPECT_EQ(1u, controller().getSelectionOffsets().start()); |
| 399 EXPECT_EQ(1u, controller().getSelectionOffsets().end()); | 399 EXPECT_EQ(1u, controller().getSelectionOffsets().end()); |
| 400 } | 400 } |
| 401 | 401 |
| 402 TEST_F(InputMethodControllerTest, InsertLineBreakAfterConfirmingText) | 402 TEST_F(InputMethodControllerTest, InsertLineBreakAfterConfirmingText) |
| 403 { | 403 { |
| 404 Element* div = insertHTMLElement( | 404 Element* div = insertHTMLElement( |
| 405 "<div id='sample' contenteditable='true'></div>", | 405 "<div id='sample' contenteditable='true'></div>", |
| 406 "sample"); | 406 "sample"); |
| 407 | 407 |
| 408 controller().confirmCompositionOrInsertText("hello", InputMethodController::
ConfirmCompositionBehavior::KeepSelection); | 408 controller().confirmCompositionOrInsertText("hello", InputMethodController::
ConfirmCompositionBehavior::KeepSelection, 1); |
| 409 EXPECT_STREQ("hello", div->innerText().utf8().data()); | 409 EXPECT_STREQ("hello", div->innerText().utf8().data()); |
| 410 | 410 |
| 411 controller().setEditableSelectionOffsets(PlainTextRange(2, 2)); | 411 controller().setEditableSelectionOffsets(PlainTextRange(2, 2)); |
| 412 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); | 412 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); |
| 413 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); | 413 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); |
| 414 | 414 |
| 415 frame().editor().insertLineBreak(); | 415 frame().editor().insertLineBreak(); |
| 416 EXPECT_STREQ("he\nllo", div->innerText().utf8().data()); | 416 EXPECT_STREQ("he\nllo", div->innerText().utf8().data()); |
| 417 EXPECT_EQ(3u, controller().getSelectionOffsets().start()); | 417 EXPECT_EQ(3u, controller().getSelectionOffsets().start()); |
| 418 EXPECT_EQ(3u, controller().getSelectionOffsets().end()); | 418 EXPECT_EQ(3u, controller().getSelectionOffsets().end()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 document().setTitle(emptyString()); | 477 document().setTitle(emptyString()); |
| 478 controller().setComposition("ni", underlines, 0, 1); | 478 controller().setComposition("ni", underlines, 0, 1); |
| 479 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8()
.data()); | 479 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8()
.data()); |
| 480 | 480 |
| 481 document().setTitle(emptyString()); | 481 document().setTitle(emptyString()); |
| 482 controller().confirmComposition(); | 482 controller().confirmComposition(); |
| 483 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8()
.data()); | 483 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8()
.data()); |
| 484 } | 484 } |
| 485 | 485 |
| 486 } // namespace blink | 486 } // namespace blink |
| OLD | NEW |