Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Unified Diff: third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp

Issue 2755013004: Improve how DocumentMarkerController updates markers in response to text edits (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 841eb7700b577d213aad53410443c8a00b8bb7ae..bd1ef3ef1f9190d976b53c649df4d32823989d6d 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
@@ -1566,15 +1566,12 @@ TEST_F(InputMethodControllerTest,
controller().setCompositionFromExistingText(emptyUnderlines, 6, 10);
controller().commitText(String(""), emptyUnderlines, 0);
- // Check that the marker was split when the space at the beginning was
- // converted to an nbsp
- EXPECT_EQ(2u, document().markers().markers().size());
- EXPECT_STREQ(
- "\xC2\xA0", // UTF-8 for an nbsp
+ // Check that the marker is still attached to " text" and includes the space
+ // before "text" but not the space after
+ EXPECT_EQ(1u, document().markers().markers().size());
+ ASSERT_STREQ(
+ "\xC2\xA0text",
getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
- EXPECT_STREQ(
- "text",
- getMarkedText(document().markers(), div->firstChild(), 1).utf8().data());
}
TEST_F(InputMethodControllerTest,
@@ -1597,15 +1594,12 @@ TEST_F(InputMethodControllerTest,
controller().setCompositionFromExistingText(emptyUnderlines, 6, 10);
controller().commitText(String(""), emptyUnderlines, 0);
- // Check that the marker was split when the space at the end was
- // converted to an nbsp
- EXPECT_EQ(2u, document().markers().markers().size());
- EXPECT_STREQ(
- "text",
+ // Check that the marker is still attached to "text " and includes the space
+ // after "text" but not the space before
+ EXPECT_EQ(1u, document().markers().markers().size());
+ ASSERT_STREQ(
+ "text\xC2\xA0",
getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
- EXPECT_STREQ(
- "\xC2\xA0", // UTF-8 for an nbsp
- getMarkedText(document().markers(), div->firstChild(), 1).utf8().data());
}
TEST_F(InputMethodControllerTest,
@@ -1629,18 +1623,12 @@ TEST_F(InputMethodControllerTest,
controller().setCompositionFromExistingText(emptyUnderlines, 6, 10);
controller().commitText(String(""), emptyUnderlines, 0);
- // Check that the marker was split into three pieces when the two spaces were
- // converted to nbsps
- EXPECT_EQ(3u, document().markers().markers().size());
- EXPECT_STREQ(
- "\xC2\xA0", // UTF-8 for an nbsp
+ // Check that the marker is still attached to " text " and includes both the
+ // space before "text" and the space after
+ EXPECT_EQ(1u, document().markers().markers().size());
+ ASSERT_STREQ(
+ "\xC2\xA0text\xC2\xA0",
getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
- EXPECT_STREQ(
- "text",
- getMarkedText(document().markers(), div->firstChild(), 1).utf8().data());
- EXPECT_STREQ(
- "\xC2\xA0", // UTF-8 for an nbsp
- getMarkedText(document().markers(), div->firstChild(), 2).utf8().data());
}
TEST_F(InputMethodControllerTest, Marker_ReplaceStartOfMarker) {
@@ -1658,11 +1646,10 @@ TEST_F(InputMethodControllerTest, Marker_ReplaceStartOfMarker) {
controller().setCompositionFromExistingText(emptyUnderlines, 0, 7);
controller().commitText(String("Original"), emptyUnderlines, 0);
- // Verify marker is under "al text"
- // ("Initial" and "Original" have "al" as a common suffix)
+ // Verify marker is under "Original text"
EXPECT_EQ(1u, document().markers().markers().size());
- EXPECT_STREQ(
- "al text",
+ ASSERT_STREQ(
+ "Original text",
getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
}
@@ -1704,10 +1691,10 @@ TEST_F(InputMethodControllerTest, Marker_ReplaceEndOfMarker) {
controller().setCompositionFromExistingText(emptyUnderlines, 8, 12);
controller().commitText(String("string"), emptyUnderlines, 0);
- // Verify marker is under "Initial "
+ // Verify marker is under "Initial string"
EXPECT_EQ(1u, document().markers().markers().size());
- EXPECT_STREQ(
- "Initial ",
+ ASSERT_STREQ(
+ "Initial string",
getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
}
@@ -1751,8 +1738,11 @@ TEST_F(InputMethodControllerTest, Marker_ReplaceEntireMarker) {
controller().setCompositionFromExistingText(emptyUnderlines, 8, 12);
controller().commitText(String("string"), emptyUnderlines, 0);
- // Verify marker was removed
- EXPECT_EQ(0u, document().markers().markers().size());
+ // Verify marker is under "string"
+ EXPECT_EQ(1u, document().markers().markers().size());
+ ASSERT_STREQ(
+ "string",
+ getMarkedText(document().markers(), div->firstChild(), 0).utf8().data());
}
TEST_F(InputMethodControllerTest, Marker_ReplaceTextWithMarkerAtBeginning) {

Powered by Google App Engine
This is Rietveld 408576698