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 437d2a0aa0765006a04a411dd164cf36052051d4..5ed7dfcacdb60c57fcd1f237c2e49e0ddf721772 100644 |
| --- a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp |
| +++ b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp |
| @@ -250,6 +250,23 @@ TEST_F(InputMethodControllerTest, |
| EXPECT_STREQ("<b>\xE0\xB0\x83</b>", div->innerHTML().utf8().data()); |
| } |
| +TEST_F(InputMethodControllerTest, FinishComposingTextKeepingStyle) { |
| + Element* div = insertHTMLElement( |
| + "<div id='sample' " |
| + "contenteditable>abc1<b>2</b>34567<b>8</b>9</div>", |
| + "sample"); |
| + |
| + Vector<CompositionUnderline> underlines; |
| + underlines.append(CompositionUnderline(3, 12, Color(255, 0, 0), false, 0)); |
| + controller().setCompositionFromExistingText(underlines, 3, 12); |
| + |
| + controller().setComposition(String("123hello789"), underlines, 11, 11); |
| + EXPECT_STREQ("abc1<b>2</b>3hello7<b>8</b>9", div->innerHTML().utf8().data()); |
| + |
| + controller().finishComposingText(InputMethodController::KeepSelection); |
| + EXPECT_STREQ("abc1<b>2</b>3hello7<b>8</b>9", div->innerHTML().utf8().data()); |
| +} |
| + |
| TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText) { |
| insertHTMLElement("<div id='sample' contenteditable>hello world</div>", |
| "sample"); |
| @@ -911,10 +928,9 @@ TEST_F(InputMethodControllerTest, CompositionInputEventForReplace) { |
| document().title().utf8().data()); |
| // Replace the existing composition. |
| - // TODO(yabinh): should be "beforeinput.data:hello;input.data:hello;". |
| document().setTitle(emptyString()); |
| controller().setComposition("hello", underlines, 0, 0); |
| - EXPECT_STREQ("beforeinput.data:o;input.data:o;", |
| + EXPECT_STREQ("beforeinput.data:hello;input.data:hello;", |
| document().title().utf8().data()); |
| } |
| @@ -985,6 +1001,32 @@ TEST_F(InputMethodControllerTest, CompositionInputEventForInsert) { |
| document().title().utf8().data()); |
| } |
|
yabinh
2016/11/25 04:36:27
It's better to have a test for inserting empty tex
|
| +TEST_F(InputMethodControllerTest, CompositionInputEventForInsertEmptyText) { |
| + createHTMLWithCompositionInputEventListeners(); |
| + |
| + // Simulate composition in the |contentEditable|. |
| + Vector<CompositionUnderline> underlines; |
| + underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
| + |
| + // Insert empty text without previous composition. |
| + document().setTitle(emptyString()); |
| + document().updateStyleAndLayout(); |
| + controller().commitText("", 0); |
| + EXPECT_STREQ("", document().title().utf8().data()); |
| + |
| + document().setTitle(emptyString()); |
| + controller().setComposition("n", underlines, 1, 1); |
| + EXPECT_STREQ("beforeinput.data:n;input.data:n;", |
| + document().title().utf8().data()); |
| + |
| + // Insert empty text with previous composition. |
| + document().setTitle(emptyString()); |
| + document().updateStyleAndLayout(); |
| + controller().commitText("", 1); |
| + EXPECT_STREQ("beforeinput.data:;compositionend.data:;", |
| + document().title().utf8().data()); |
| +} |
| + |
| TEST_F(InputMethodControllerTest, CompositionEndEventForConfirm) { |
| createHTMLWithCompositionEndEventListener(CaretSelection); |