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..e9041ed208867ad4fdec8a1aad9cacac15144aaf 100644 |
| --- a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp |
| +++ b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp |
| @@ -115,6 +115,58 @@ 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()); |
|
aelias_OOO_until_Jul13
2016/09/28 23:58:29
Please add another test case for backspace.
yabinh
2016/10/11 01:42:23
Line#134 is for backspace(from "hello" to "hell").
|
| +} |
| + |
| +TEST_F(InputMethodControllerTest, SetCompositionWithMultiCodeTextKeepingStyle) |
| +{ |
| + // U+1F3E0 = 0xF0 0x9F 0x8F 0xA0 (UTF8). It's an emoji character with |
| + // surrogate pairs. |
| + Element* div = insertHTMLElement( |
| + "<div id='sample' contenteditable='true'><b>🏠</b></div>", "sample"); |
| + Vector<CompositionUnderline> underlines; |
| + underlines.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0)); |
| + controller().setCompositionFromExistingText(underlines, 0, 2); |
| + |
| + // 0xF0 0x9F 0x8F 0xAB is also an emoji character with surrogate pairs. |
| + controller().setComposition(String::fromUTF8("\xF0\x9F\x8F\xAB"), underlines, 2, 2); |
| + EXPECT_STREQ("<b>\xF0\x9F\x8F\xAB</b>", div->innerHTML().utf8().data()); |
| + |
| + controller().setComposition(String::fromUTF8("\xF0\x9F\x8F\xA0"), underlines, 2, 2); |
| + EXPECT_STREQ("<b>\xF0\x9F\x8F\xA0</b>", div->innerHTML().utf8().data()); |
| + |
| + // U+0C03 = 0xE0 0xB0 0x83 (UTF8), a telugu character with 1 code point. |
| + div = insertHTMLElement( |
| + "<div id='sample' contenteditable='true'><b>ః</b></div>", "sample"); |
| + controller().setCompositionFromExistingText(underlines, 0, 1); |
| + |
| + // 0xE0 0xB0 0x83 0xE0 0xB0 0x83, a telugu character with 2 code points in |
| + // 1 grapheme cluster. |
| + controller().setComposition(String::fromUTF8("\xE0\xB0\x83\xE0\xB0\x83"), underlines, 2, 2); |
| + EXPECT_STREQ("<b>\xE0\xB0\x83\xE0\xB0\x83</b>", div->innerHTML().utf8().data()); |
| + |
| + controller().setComposition(String::fromUTF8("\xE0\xB0\x83"), underlines, 1, 1); |
|
yabinh
2016/09/27 12:46:47
Note that if we use code point to decide the commo
|
| + EXPECT_STREQ("<b>\xE0\xB0\x83</b>", div->innerHTML().utf8().data()); |
| } |
| TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText) |
| @@ -485,7 +537,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); |