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 29a7b6b8a670aca9a87eee86260d11f1b46411bc..fd9cbfc69a66a3ee02d26765f62184de77502de7 100644 |
--- a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp |
+++ b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp |
@@ -208,13 +208,6 @@ TEST_F(InputMethodControllerTest, SetCompositionForInputWithDifferentNewCursorPo |
Vector<CompositionUnderline> underlines; |
underlines.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0)); |
- // The cursor exceeds left boundary. |
- // "*heABllo", where * stands for cursor. |
- controller().setComposition("AB", underlines, -100, -100); |
- EXPECT_STREQ("heABllo", input->value().utf8().data()); |
- EXPECT_EQ(0u, controller().getSelectionOffsets().start()); |
- EXPECT_EQ(0u, controller().getSelectionOffsets().end()); |
- |
// The cursor is on left boundary. |
// "*heABllo". |
controller().setComposition("AB", underlines, -2, -2); |
@@ -242,13 +235,6 @@ TEST_F(InputMethodControllerTest, SetCompositionForInputWithDifferentNewCursorPo |
EXPECT_STREQ("heABllo", input->value().utf8().data()); |
EXPECT_EQ(7u, controller().getSelectionOffsets().start()); |
EXPECT_EQ(7u, controller().getSelectionOffsets().end()); |
- |
- // The cursor exceeds right boundary. |
- // "heABllo*". |
- controller().setComposition("AB", underlines, 100, 100); |
- EXPECT_STREQ("heABllo", input->value().utf8().data()); |
- EXPECT_EQ(7u, controller().getSelectionOffsets().start()); |
- EXPECT_EQ(7u, controller().getSelectionOffsets().end()); |
} |
TEST_F(InputMethodControllerTest, SetCompositionForContentEditableWithDifferentNewCursorPositions) |
@@ -271,13 +257,6 @@ TEST_F(InputMethodControllerTest, SetCompositionForContentEditableWithDifferentN |
Vector<CompositionUnderline> underlines; |
underlines.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0)); |
- // The cursor exceeds left boundary. |
- // "*hello\nworld\n01234AB56789", where * stands for cursor. |
- controller().setComposition("AB", underlines, -100, -100); |
- EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); |
- EXPECT_EQ(0u, controller().getSelectionOffsets().start()); |
- EXPECT_EQ(0u, controller().getSelectionOffsets().end()); |
- |
// The cursor is on left boundary. |
// "*hello\nworld\n01234AB56789". |
controller().setComposition("AB", underlines, -17, -17); |
@@ -340,13 +319,36 @@ TEST_F(InputMethodControllerTest, SetCompositionForContentEditableWithDifferentN |
EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); |
EXPECT_EQ(24u, controller().getSelectionOffsets().start()); |
EXPECT_EQ(24u, controller().getSelectionOffsets().end()); |
+} |
- // The cursor exceeds right boundary. |
- // "hello\nworld\n01234AB56789*". |
- controller().setComposition("AB", underlines, 100, 100); |
- EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); |
- EXPECT_EQ(24u, controller().getSelectionOffsets().start()); |
- EXPECT_EQ(24u, controller().getSelectionOffsets().end()); |
+TEST_F(InputMethodControllerTest, SetCompositionWithEmptyText) |
+{ |
+ Element* div = insertHTMLElement( |
+ "<div id='sample' contenteditable='true'>hello</div>", |
+ "sample"); |
+ |
+ controller().setEditableSelectionOffsets(PlainTextRange(2, 2)); |
+ EXPECT_STREQ("hello", div->innerText().utf8().data()); |
+ EXPECT_EQ(2u, controller().getSelectionOffsets().start()); |
+ EXPECT_EQ(2u, controller().getSelectionOffsets().end()); |
+ |
+ Vector<CompositionUnderline> underlines0; |
+ underlines0.append(CompositionUnderline(0, 0, Color(255, 0, 0), false, 0)); |
+ Vector<CompositionUnderline> underlines2; |
+ underlines2.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0)); |
+ |
+ controller().setComposition("AB", underlines2, 2, 2); |
+ // With previous composition. |
+ controller().setComposition("", underlines0, 2, 2); |
+ EXPECT_STREQ("hello", div->innerText().utf8().data()); |
+ EXPECT_EQ(4u, controller().getSelectionOffsets().start()); |
+ EXPECT_EQ(4u, controller().getSelectionOffsets().end()); |
+ |
+ // Without previous composition. |
+ controller().setComposition("", underlines0, -1, -1); |
+ EXPECT_STREQ("hello", div->innerText().utf8().data()); |
+ EXPECT_EQ(3u, controller().getSelectionOffsets().start()); |
+ EXPECT_EQ(3u, controller().getSelectionOffsets().end()); |
} |
TEST_F(InputMethodControllerTest, CompositionFireBeforeInput) |