| 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 e6452b0916c47d1ced5fb82a5e810e95f3239efe..67ba98de5b557ffd0fbc95af59a280ec3102d107 100644
|
| --- a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
|
| @@ -171,7 +171,8 @@ TEST_F(InputMethodControllerTest, SetCompositionFromExistingText) {
|
| "<div id='sample' contenteditable>hello world</div>", "sample");
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
| controller().setCompositionFromExistingText(underlines, 0, 5);
|
|
|
| Range* range = controller().compositionRange();
|
| @@ -190,7 +191,8 @@ TEST_F(InputMethodControllerTest, SetCompositionKeepingStyle) {
|
| "sample");
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(3, 12, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(3, 12, Color(255, 0, 0), false, 0, false));
|
| controller().setCompositionFromExistingText(underlines, 3, 12);
|
|
|
| // Subtract a character.
|
| @@ -219,7 +221,8 @@ TEST_F(InputMethodControllerTest, SetCompositionWithEmojiKeepingStyle) {
|
| "<div id='sample' contenteditable><b>🏠</b></div>", "sample");
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 2, Color(255, 0, 0), false, 0, false));
|
|
|
| controller().setCompositionFromExistingText(underlines, 0, 2);
|
|
|
| @@ -243,7 +246,8 @@ TEST_F(InputMethodControllerTest,
|
| "<div id='sample' contenteditable><b>ః</b></div>", "sample");
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 2, Color(255, 0, 0), false, 0, false));
|
| controller().setCompositionFromExistingText(underlines, 0, 1);
|
|
|
| // 0xE0 0xB0 0x83 0xE0 0xB0 0x83, a telugu character with 2 code points in
|
| @@ -265,7 +269,8 @@ TEST_F(InputMethodControllerTest, FinishComposingTextKeepingStyle) {
|
| "sample");
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(3, 12, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(3, 12, Color(255, 0, 0), false, 0, false));
|
| controller().setCompositionFromExistingText(underlines, 3, 12);
|
|
|
| controller().setComposition(String("123hello789"), underlines, 11, 11);
|
| @@ -282,7 +287,8 @@ TEST_F(InputMethodControllerTest, CommitTextKeepingStyle) {
|
| "sample");
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(3, 12, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(3, 12, Color(255, 0, 0), false, 0, false));
|
| controller().setCompositionFromExistingText(underlines, 3, 12);
|
|
|
| controller().commitText(String("123789"), underlines, 0);
|
| @@ -294,7 +300,8 @@ TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText) {
|
| "sample");
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
| controller().setCompositionFromExistingText(underlines, 0, 5);
|
|
|
| controller().finishComposingText(InputMethodController::KeepSelection);
|
| @@ -321,7 +328,8 @@ TEST_F(InputMethodControllerTest, DeleteBySettingEmptyComposition) {
|
| EXPECT_STREQ("foo", input->value().utf8().data());
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 3, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 3, Color(255, 0, 0), false, 0, false));
|
| controller().setCompositionFromExistingText(underlines, 0, 3);
|
|
|
| controller().setComposition(String(""), underlines, 0, 3);
|
| @@ -337,7 +345,8 @@ TEST_F(InputMethodControllerTest,
|
| "<div id='sample' contenteditable>\nhello world</div>", "sample");
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
| controller().setCompositionFromExistingText(underlines, 0, 5);
|
|
|
| Range* range = controller().compositionRange();
|
| @@ -354,7 +363,8 @@ TEST_F(InputMethodControllerTest,
|
| insertHTMLElement("<div id='sample' contenteditable>test</div>", "sample");
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(7, 8, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(7, 8, Color(255, 0, 0), false, 0, false));
|
| controller().setCompositionFromExistingText(underlines, 7, 8);
|
|
|
| EXPECT_FALSE(controller().compositionRange());
|
| @@ -365,7 +375,8 @@ TEST_F(InputMethodControllerTest, ConfirmPasswordComposition) {
|
| "<input id='sample' type='password' size='24'>", "sample"));
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
| controller().setComposition("foo", underlines, 0, 3);
|
| controller().finishComposingText(InputMethodController::KeepSelection);
|
|
|
| @@ -699,7 +710,8 @@ TEST_F(InputMethodControllerTest, SetCompositionForInputWithNewCaretPositions) {
|
| EXPECT_EQ(2u, controller().getSelectionOffsets().end());
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 2, Color(255, 0, 0), false, 0, false));
|
|
|
| // The caret exceeds left boundary.
|
| // "*heABllo", where * stands for caret.
|
| @@ -763,7 +775,8 @@ TEST_F(InputMethodControllerTest,
|
| EXPECT_EQ(17u, controller().getSelectionOffsets().end());
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 2, Color(255, 0, 0), false, 0, false));
|
|
|
| // The caret exceeds left boundary.
|
| // "*hello\nworld\n01234AB56789", where * stands for caret.
|
| @@ -853,9 +866,11 @@ TEST_F(InputMethodControllerTest, SetCompositionWithEmptyText) {
|
| EXPECT_EQ(2u, controller().getSelectionOffsets().end());
|
|
|
| Vector<CompositionUnderline> underlines0;
|
| - underlines0.push_back(CompositionUnderline(0, 0, Color(255, 0, 0), false, 0));
|
| + underlines0.push_back(
|
| + CompositionUnderline(0, 0, Color(255, 0, 0), false, 0, false));
|
| Vector<CompositionUnderline> underlines2;
|
| - underlines2.push_back(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0));
|
| + underlines2.push_back(
|
| + CompositionUnderline(0, 2, Color(255, 0, 0), false, 0, false));
|
|
|
| controller().setComposition("AB", underlines2, 2, 2);
|
| // With previous composition.
|
| @@ -876,7 +891,8 @@ TEST_F(InputMethodControllerTest, InsertLineBreakWhileComposingText) {
|
| insertHTMLElement("<div id='sample' contenteditable></div>", "sample");
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
| controller().setComposition("hello", underlines, 5, 5);
|
| EXPECT_STREQ("hello", div->innerText().utf8().data());
|
| EXPECT_EQ(5u, controller().getSelectionOffsets().start());
|
| @@ -893,7 +909,8 @@ TEST_F(InputMethodControllerTest, InsertLineBreakAfterConfirmingText) {
|
| insertHTMLElement("<div id='sample' contenteditable></div>", "sample");
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0));
|
| + underlines.append(
|
| + CompositionUnderline(0, 2, Color(255, 0, 0), false, 0, false));
|
| controller().commitText("hello", underlines, 0);
|
| EXPECT_STREQ("hello", div->innerText().utf8().data());
|
|
|
| @@ -924,7 +941,8 @@ TEST_F(InputMethodControllerTest, CompositionInputEventIsComposing) {
|
|
|
| // Simulate composition in the |contentEditable|.
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
| editable->focus();
|
|
|
| document().setTitle(emptyString());
|
| @@ -944,7 +962,8 @@ TEST_F(InputMethodControllerTest, CompositionInputEventForReplace) {
|
|
|
| // Simulate composition in the |contentEditable|.
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
|
|
| document().setTitle(emptyString());
|
| controller().setComposition("hell", underlines, 4, 4);
|
| @@ -963,7 +982,8 @@ TEST_F(InputMethodControllerTest, CompositionInputEventForConfirm) {
|
|
|
| // Simulate composition in the |contentEditable|.
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
|
|
| document().setTitle(emptyString());
|
| controller().setComposition("hello", underlines, 5, 5);
|
| @@ -983,7 +1003,8 @@ TEST_F(InputMethodControllerTest, CompositionInputEventForDelete) {
|
|
|
| // Simulate composition in the |contentEditable|.
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
|
|
| document().setTitle(emptyString());
|
| controller().setComposition("hello", underlines, 5, 5);
|
| @@ -1002,7 +1023,8 @@ TEST_F(InputMethodControllerTest, CompositionInputEventForInsert) {
|
|
|
| // Simulate composition in the |contentEditable|.
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
|
|
| // Insert new text without previous composition.
|
| document().setTitle(emptyString());
|
| @@ -1030,7 +1052,8 @@ TEST_F(InputMethodControllerTest, CompositionInputEventForInsertEmptyText) {
|
|
|
| // Simulate composition in the |contentEditable|.
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
|
|
| // Insert empty text without previous composition.
|
| document().setTitle(emptyString());
|
| @@ -1056,7 +1079,8 @@ TEST_F(InputMethodControllerTest, CompositionEndEventForConfirm) {
|
|
|
| // Simulate composition in the |contentEditable|.
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
|
|
| controller().setComposition("hello", underlines, 1, 1);
|
| document().updateStyleAndLayout();
|
| @@ -1076,7 +1100,8 @@ TEST_F(InputMethodControllerTest, CompositionEndEventForInsert) {
|
|
|
| // Simulate composition in the |contentEditable|.
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
|
|
| controller().setComposition("n", underlines, 1, 1);
|
|
|
| @@ -1094,7 +1119,8 @@ TEST_F(InputMethodControllerTest, CompositionEndEventWithRangeSelection) {
|
|
|
| // Simulate composition in the |contentEditable|.
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
|
|
| controller().setComposition("hello", underlines, 1, 1);
|
| document().updateStyleAndLayout();
|
| @@ -1114,7 +1140,8 @@ TEST_F(InputMethodControllerTest, CompositionEndEventWithNoSelection) {
|
|
|
| // Simulate composition in the |contentEditable|.
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 5, Color(255, 0, 0), false, 0, false));
|
|
|
| controller().setComposition("hello", underlines, 1, 1);
|
| document().updateStyleAndLayout();
|
| @@ -1153,7 +1180,8 @@ TEST_F(InputMethodControllerTest, SetCompositionPlainTextWithUnderline) {
|
| insertHTMLElement("<div id='sample' contenteditable></div>", "sample");
|
|
|
| Vector<CompositionUnderline> underlines;
|
| - underlines.push_back(CompositionUnderline(0, 1, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 1, Color(255, 0, 0), false, 0, false));
|
|
|
| controller().setComposition(" ", underlines, 1, 1);
|
|
|
| @@ -1171,7 +1199,8 @@ TEST_F(InputMethodControllerTest, CommitPlainTextWithUnderlineInsert) {
|
|
|
| controller().setEditableSelectionOffsets(PlainTextRange(8, 8));
|
|
|
| - underlines.push_back(CompositionUnderline(1, 11, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(1, 11, Color(255, 0, 0), false, 0, false));
|
|
|
| controller().commitText(String("underlined"), underlines, 0);
|
|
|
| @@ -1189,7 +1218,8 @@ TEST_F(InputMethodControllerTest, CommitPlainTextWithUnderlineReplace) {
|
|
|
| controller().setCompositionFromExistingText(underlines, 8, 12);
|
|
|
| - underlines.push_back(CompositionUnderline(1, 11, Color(255, 0, 0), false, 0));
|
| + underlines.push_back(
|
| + CompositionUnderline(1, 11, Color(255, 0, 0), false, 0, false));
|
|
|
| controller().commitText(String("string"), underlines, 0);
|
|
|
| @@ -1199,4 +1229,133 @@ TEST_F(InputMethodControllerTest, CommitPlainTextWithUnderlineReplace) {
|
| EXPECT_EQ(15u, document().markers().markers()[0]->endOffset());
|
| }
|
|
|
| +TEST_F(InputMethodControllerTest, UnderlinePersistence) {
|
| + insertHTMLElement("<div id='sample' contenteditable>Initial text.</div>",
|
| + "sample");
|
| + Vector<CompositionUnderline> emptyUnderlines;
|
| + controller().setCompositionFromExistingText(emptyUnderlines, 8, 12);
|
| +
|
| + // Add non-persisting underline
|
| + Vector<CompositionUnderline> nonPersistingUnderlines;
|
| + nonPersistingUnderlines.push_back(
|
| + CompositionUnderline(1, 11, Color(255, 0, 0), false, 0, false));
|
| + controller().commitText(String("string"), nonPersistingUnderlines, 0);
|
| +
|
| + EXPECT_EQ(1u, document().markers().markers().size());
|
| +
|
| + // setCompositionFromExistingText() should clear the non-persisting underline
|
| + controller().setCompositionFromExistingText(emptyUnderlines, 0, 7);
|
| + EXPECT_EQ(0u, document().markers().markers().size());
|
| +
|
| + // Add persisting underline.
|
| + Vector<CompositionUnderline> persistingUnderlines;
|
| + persistingUnderlines.push_back(
|
| + CompositionUnderline(1, 11, Color(255, 0, 0), false, 0, true));
|
| + controller().commitText(String("Replacement"), persistingUnderlines, 0);
|
| +
|
| + EXPECT_EQ(1u, document().markers().markers().size());
|
| +
|
| + // commitText() operation that should not affect the number of underlines
|
| + controller().setCompositionFromExistingText(emptyUnderlines, 11, 12);
|
| + controller().commitText(String(" "), emptyUnderlines, 0);
|
| +
|
| + EXPECT_EQ(1u, document().markers().markers().size());
|
| +
|
| + // finishComposingText() should not remove the persisting underline
|
| + controller().finishComposingText(InputMethodController::DoNotKeepSelection);
|
| +
|
| + EXPECT_EQ(1u, document().markers().markers().size());
|
| +}
|
| +
|
| +TEST_F(InputMethodControllerTest, DeleteStartOfMarker) {
|
| + insertHTMLElement("<div id='sample' contenteditable>Initial text.</div>",
|
| + "sample");
|
| +
|
| + Vector<CompositionUnderline> underlines;
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 7, Color(255, 0, 0), false, 0, true));
|
| + // Underline "Initial" with a persisting underline
|
| + controller().setCompositionFromExistingText(underlines, 0, 7);
|
| +
|
| + Vector<CompositionUnderline> emptyUnderlines;
|
| + // Set composition to "Ini"
|
| + controller().setCompositionFromExistingText(emptyUnderlines, 0, 3);
|
| + // Delete "Ini"
|
| + controller().commitText(String(""), emptyUnderlines, 0);
|
| +
|
| + // Check that the underline is still attached to "tial"
|
| + EXPECT_EQ(1u, document().markers().markers().size());
|
| + EXPECT_EQ(0u, document().markers().markers()[0]->startOffset());
|
| + EXPECT_EQ(4u, document().markers().markers()[0]->endOffset());
|
| +}
|
| +
|
| +TEST_F(InputMethodControllerTest, DeleteBeforeStartOfMarker) {
|
| + insertHTMLElement("<div id='sample' contenteditable>Initial text.</div>",
|
| + "sample");
|
| +
|
| + Vector<CompositionUnderline> underlines;
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 4, Color(255, 0, 0), false, 0, true));
|
| + // Underline "text" with a persisting underline
|
| + controller().setCompositionFromExistingText(underlines, 8, 12);
|
| +
|
| + Vector<CompositionUnderline> emptyUnderlines;
|
| + // Set composition to "Initial"
|
| + controller().setCompositionFromExistingText(emptyUnderlines, 0, 7);
|
| +
|
| + // Delete "Initial"
|
| + controller().commitText(String(""), emptyUnderlines, 0);
|
| +
|
| + // Check that the underline is still attached to "text"
|
| + EXPECT_EQ(1u, document().markers().markers().size());
|
| + EXPECT_EQ(1u, document().markers().markers()[0]->startOffset());
|
| + EXPECT_EQ(5u, document().markers().markers()[0]->endOffset());
|
| +}
|
| +
|
| +TEST_F(InputMethodControllerTest, DeleteEndOfMarker) {
|
| + insertHTMLElement("<div id='sample' contenteditable>Initial text.</div>",
|
| + "sample");
|
| +
|
| + Vector<CompositionUnderline> underlines;
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 4, Color(255, 0, 0), false, 0, true));
|
| + // Underline "text" with a persisting underline
|
| + controller().setCompositionFromExistingText(underlines, 8, 12);
|
| +
|
| + Vector<CompositionUnderline> emptyUnderlines;
|
| + // Set composition to "xt."
|
| + controller().setCompositionFromExistingText(emptyUnderlines, 10, 13);
|
| +
|
| + // Delete "xt."
|
| + controller().commitText(String(""), emptyUnderlines, 0);
|
| +
|
| + // Check that the underline is still attached to "te"
|
| + EXPECT_EQ(1u, document().markers().markers().size());
|
| + EXPECT_EQ(8u, document().markers().markers()[0]->startOffset());
|
| + EXPECT_EQ(10u, document().markers().markers()[0]->endOffset());
|
| +}
|
| +
|
| +TEST_F(InputMethodControllerTest, DeleteBeforeEndOfMarker) {
|
| + insertHTMLElement("<div id='sample' contenteditable>Initial text.</div>",
|
| + "sample");
|
| +
|
| + Vector<CompositionUnderline> underlines;
|
| + underlines.push_back(
|
| + CompositionUnderline(0, 4, Color(255, 0, 0), false, 0, true));
|
| + // Underline "text" with a persisting underline
|
| + controller().setCompositionFromExistingText(underlines, 8, 12);
|
| +
|
| + Vector<CompositionUnderline> emptyUnderlines;
|
| + // Set composition to "Initial"
|
| + controller().setCompositionFromExistingText(emptyUnderlines, 0, 7);
|
| +
|
| + // Delete "Initial"
|
| + controller().commitText(String(""), emptyUnderlines, 0);
|
| +
|
| + // Check that the underline is still attached to "text"
|
| + EXPECT_EQ(1u, document().markers().markers().size());
|
| + EXPECT_EQ(1u, document().markers().markers()[0]->startOffset());
|
| + EXPECT_EQ(5u, document().markers().markers()[0]->endOffset());
|
| +}
|
| +
|
| } // namespace blink
|
|
|