| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 "sample"); | 302 "sample"); |
| 303 | 303 |
| 304 Vector<CompositionUnderline> underlines; | 304 Vector<CompositionUnderline> underlines; |
| 305 underlines.push_back(CompositionUnderline(3, 12, Color(255, 0, 0), false, 0)); | 305 underlines.push_back(CompositionUnderline(3, 12, Color(255, 0, 0), false, 0)); |
| 306 controller().setCompositionFromExistingText(underlines, 3, 12); | 306 controller().setCompositionFromExistingText(underlines, 3, 12); |
| 307 | 307 |
| 308 controller().commitText(String("123789"), underlines, 0); | 308 controller().commitText(String("123789"), underlines, 0); |
| 309 EXPECT_STREQ("abc1<b>2</b>37<b>8</b>9", div->innerHTML().utf8().data()); | 309 EXPECT_STREQ("abc1<b>2</b>37<b>8</b>9", div->innerHTML().utf8().data()); |
| 310 } | 310 } |
| 311 | 311 |
| 312 TEST_F(InputMethodControllerTest, InsertTextWithNewLine) { |
| 313 Element* div = |
| 314 insertHTMLElement("<div id='sample' contenteditable></div>", "sample"); |
| 315 Vector<CompositionUnderline> underlines; |
| 316 underlines.push_back(CompositionUnderline(0, 11, Color(255, 0, 0), false, 0)); |
| 317 |
| 318 controller().commitText(String("hello\nworld"), underlines, 0); |
| 319 EXPECT_STREQ("hello<div>world</div>", div->innerHTML().utf8().data()); |
| 320 } |
| 321 |
| 322 TEST_F(InputMethodControllerTest, InsertTextWithNewLineIncrementally) { |
| 323 Element* div = |
| 324 insertHTMLElement("<div id='sample' contenteditable></div>", "sample"); |
| 325 |
| 326 Vector<CompositionUnderline> underlines; |
| 327 underlines.push_back(CompositionUnderline(0, 11, Color(255, 0, 0), false, 0)); |
| 328 controller().setComposition("foo", underlines, 0, 2); |
| 329 EXPECT_STREQ("foo", div->innerHTML().utf8().data()); |
| 330 |
| 331 controller().commitText(String("hello\nworld"), underlines, 0); |
| 332 EXPECT_STREQ("hello<div>world</div>", div->innerHTML().utf8().data()); |
| 333 } |
| 334 |
| 312 TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText) { | 335 TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText) { |
| 313 insertHTMLElement("<div id='sample' contenteditable>hello world</div>", | 336 insertHTMLElement("<div id='sample' contenteditable>hello world</div>", |
| 314 "sample"); | 337 "sample"); |
| 315 | 338 |
| 316 Vector<CompositionUnderline> underlines; | 339 Vector<CompositionUnderline> underlines; |
| 317 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); | 340 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
| 318 controller().setCompositionFromExistingText(underlines, 0, 5); | 341 controller().setCompositionFromExistingText(underlines, 0, 5); |
| 319 | 342 |
| 320 controller().finishComposingText(InputMethodController::KeepSelection); | 343 controller().finishComposingText(InputMethodController::KeepSelection); |
| 321 EXPECT_EQ(0, frame().selection().start().computeOffsetInContainerNode()); | 344 EXPECT_EQ(0, frame().selection().start().computeOffsetInContainerNode()); |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 | 1192 |
| 1170 controller().commitText(String("string"), underlines, 0); | 1193 controller().commitText(String("string"), underlines, 0); |
| 1171 | 1194 |
| 1172 ASSERT_EQ(1u, document().markers().markers().size()); | 1195 ASSERT_EQ(1u, document().markers().markers().size()); |
| 1173 | 1196 |
| 1174 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset()); | 1197 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset()); |
| 1175 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset()); | 1198 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset()); |
| 1176 } | 1199 } |
| 1177 | 1200 |
| 1178 } // namespace blink | 1201 } // namespace blink |
| OLD | NEW |