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 1d1eaf64d0da2b65835dd646f456a9ec1104c2e7..1c405319152f32758b99f5896b50e38716358f07 100644 |
| --- a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp |
| +++ b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp |
| @@ -852,6 +852,18 @@ TEST_F(InputMethodControllerTest, CompositionInputEventData) { |
| "document.getElementById('sample').addEventListener('input', " |
| "function(event) {" |
| " document.title += `input.data:${event.data};`;" |
| + "});" |
| + "document.getElementById('sample').addEventListener('compositionend', " |
| + "function(event) {" |
|
yosin_UTC9
2016/11/15 02:27:05
nit: s/function(event)/event =>/
More ES6-ish ;-)
yabinh
2016/11/15 19:47:36
Done.
Also applied the same style in other place.
|
| + " document.title += `compositionend.data:${event.data};`;" |
| + // Reset the selection to [0,0] on receiving 'compositonend' event. |
| + " var node = document.getElementById('sample').firstChild;" |
|
yosin_UTC9
2016/11/15 02:27:04
nit: s/var/const/
yabinh
2016/11/15 19:47:36
Done.
|
| + " var range = document.createRange();" |
|
yosin_UTC9
2016/11/15 02:27:05
Just write as below:
getSeleciton().collapse(node,
yabinh
2016/11/15 19:47:36
Done.
|
| + " range.setStart(node, 0);" |
| + " range.setEnd(node, 0);" |
| + " var selection = getSelection();" |
| + " selection.removeAllRanges();" |
| + " selection.addRange(range);" |
| "});", |
| ASSERT_NO_EXCEPTION); |
| document().body()->appendChild(script, ASSERT_NO_EXCEPTION); |
| @@ -862,20 +874,59 @@ TEST_F(InputMethodControllerTest, CompositionInputEventData) { |
| underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
| editable->focus(); |
| + // Create new composition. |
| document().setTitle(emptyString()); |
| - controller().setComposition("n", underlines, 0, 1); |
| + controller().setComposition("n", underlines, 1, 1); |
| EXPECT_STREQ("beforeinput.data:n;input.data:n;", |
| document().title().utf8().data()); |
| + // Update the existing composition. |
| + // TODO(yabinh): should be "beforeinput.data:ni;input.data:ni;". |
| document().setTitle(emptyString()); |
| - controller().setComposition("ni", underlines, 0, 1); |
| + controller().setComposition("ni", underlines, 2, 2); |
| EXPECT_STREQ("beforeinput.data:i;input.data:i;", |
| document().title().utf8().data()); |
| + // Confirm the ongoing composition. |
| document().setTitle(emptyString()); |
| controller().finishComposingText(InputMethodController::KeepSelection); |
| - EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", |
| + EXPECT_STREQ("beforeinput.data:ni;input.data:ni;compositionend.data:ni;", |
| + document().title().utf8().data()); |
| + document().updateStyleAndLayout(); |
| + EXPECT_EQ(0u, controller().getSelectionOffsets().start()); |
| + EXPECT_EQ(0u, controller().getSelectionOffsets().end()); |
| + |
| + // Delete the existing composition. |
| + document().setTitle(emptyString()); |
| + controller().setComposition("n", underlines, 1, 1); |
| + EXPECT_STREQ("beforeinput.data:n;input.data:n;", |
| + document().title().utf8().data()); |
| + document().setTitle(emptyString()); |
| + controller().setComposition("", underlines, 0, 0); |
| + EXPECT_STREQ("beforeinput.data:;compositionend.data:;", |
| document().title().utf8().data()); |
| + document().updateStyleAndLayout(); |
| + EXPECT_EQ(0u, controller().getSelectionOffsets().start()); |
| + EXPECT_EQ(0u, controller().getSelectionOffsets().end()); |
| + |
| + // Insert new text without previous composition. |
| + document().setTitle(emptyString()); |
| + controller().commitText("hello", 0); |
| + EXPECT_STREQ("beforeinput.data:hello;input.data:hello;", |
| + document().title().utf8().data()); |
| + |
| + // Insert new text with previous composition. |
| + document().setTitle(emptyString()); |
| + controller().setComposition("n", underlines, 1, 1); |
| + EXPECT_STREQ("beforeinput.data:n;input.data:n;", |
| + document().title().utf8().data()); |
| + document().setTitle(emptyString()); |
| + controller().commitText("abc", 0); |
| + EXPECT_STREQ("beforeinput.data:abc;input.data:abc;compositionend.data:abc;", |
| + document().title().utf8().data()); |
| + document().updateStyleAndLayout(); |
| + EXPECT_EQ(0u, controller().getSelectionOffsets().start()); |
| + EXPECT_EQ(0u, controller().getSelectionOffsets().end()); |
| } |
| } // namespace blink |