Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp |
| index cfce7ed4321ce2a651f7a175a04aecf55e470121..3a439011bbe9ccf2e04b6484013f75adafac028a 100644 |
| --- a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp |
| +++ b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp |
| @@ -115,6 +115,43 @@ TEST_F(InputMethodControllerTest, SetCompositionFromExistingText) |
| PlainTextRange plainTextRange(PlainTextRange::create(*div, *range)); |
| EXPECT_EQ(0u, plainTextRange.start()); |
| EXPECT_EQ(5u, plainTextRange.end()); |
| + |
| + controller().setComposition(String("hellobar"), underlines, 8, 8); |
| + range = controller().compositionRange(); |
| + EXPECT_EQ(0, range->startOffset()); |
| + EXPECT_EQ(8, range->endOffset()); |
| +} |
| + |
| +TEST_F(InputMethodControllerTest, SetCompositionKeepingStyle) |
| +{ |
| + Element* div = insertHTMLElement( |
| + "<div id='sample' contenteditable='true'><b>he</b>llo</div>", "sample"); |
| + |
| + Vector<CompositionUnderline> underlines; |
| + underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
| + controller().setCompositionFromExistingText(underlines, 0, 5); |
| + |
| + controller().setComposition(String("hell"), underlines, 4, 4); |
| + EXPECT_STREQ("<b>he</b>ll", div->innerHTML().utf8().data()); |
| + |
| + controller().setComposition(String("hello"), underlines, 5, 5); |
| + EXPECT_STREQ("<b>he</b>llo", div->innerHTML().utf8().data()); |
| +} |
| + |
| +TEST_F(InputMethodControllerTest, SetCompositionWithMultiCodeTextKeepingStyle) |
| +{ |
| + Element* div = insertHTMLElement( |
| + "<div id='sample' contenteditable='true'><i>hello</i>world<b>🏠</b></div>", "sample"); // U+1F3E0 = 0xF0 0x9F 0x8F 0xA0 (UTF8) |
|
Changwan Ryu
2016/09/27 09:17:11
could you add some explanation to the UTF8 code yo
yabinh
2016/09/27 12:46:47
Done.
|
| + |
| + Vector<CompositionUnderline> underlines; |
| + underlines.append(CompositionUnderline(0, 12, Color(255, 0, 0), false, 0)); |
| + controller().setCompositionFromExistingText(underlines, 0, 12); |
| + |
| + controller().setComposition(String::fromUTF8("helloworld\xF0\x9F\x8F\xAB"), underlines, 12, 12); |
| + EXPECT_STREQ("<i>hello</i>world<b>\xF0\x9F\x8F\xAB</b>", div->innerHTML().utf8().data()); |
| + |
| + controller().setComposition(String::fromUTF8("helloworld\xF0\x9F\x8F\xA0"), underlines, 12, 12); |
| + EXPECT_STREQ("<i>hello</i>world<b>\xF0\x9F\x8F\xA0</b>", div->innerHTML().utf8().data()); |
| } |
| TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText) |
| @@ -485,7 +522,7 @@ TEST_F(InputMethodControllerTest, CompositionInputEventData) |
| document().setTitle(emptyString()); |
| controller().setComposition("ni", underlines, 0, 1); |
| - EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8().data()); |
| + EXPECT_STREQ("beforeinput.data:i;input.data:i;", document().title().utf8().data()); |
| document().setTitle(emptyString()); |
| controller().finishComposingText(InputMethodController::KeepSelection); |