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

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

Issue 2689233006: Fix bug on Android causing composition underlines to appear in the wrong place (Closed)
Patch Set: Got test case working (the trick is to manually add the line break) Created 3 years, 10 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 af4913f8026b15cf7dc9fdb0f1393e7f3ac4e5c8..d704a3b1c075d008dbdcfc3b7594ff1546d40a6f 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
@@ -1196,4 +1196,38 @@ TEST_F(InputMethodControllerTest, CommitPlainTextWithUnderlineReplace) {
EXPECT_EQ(15u, document().markers().markers()[0]->endOffset());
}
+TEST_F(InputMethodControllerTest,
+ CompositionUnderlineAppearsCorrectlyAfterNewline) {
+ Element* div =
+ insertHTMLElement("<div id='sample' contenteditable></div>", "sample");
+
+ Vector<CompositionUnderline> underlines;
+ controller().setComposition(String("hello"), underlines, 6, 6);
+ controller().finishComposingText(InputMethodController::KeepSelection);
+ frame().editor().insertLineBreak();
+
+ controller().setCompositionFromExistingText(underlines, 8, 8);
+
+ underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
+ controller().setComposition(String("world"), underlines, 0, 0);
+ ASSERT_EQ(1u, document().markers().markers().size());
+
+ // Verify composition underline shows up on the second line, not the first
+ ASSERT_EQ(0u, document()
+ .markers()
+ .markersInRange(PlainTextRange(0, 5).createRange(*div),
+ DocumentMarker::AllMarkers())
+ .size());
+ ASSERT_EQ(1u, document()
+ .markers()
+ .markersInRange(PlainTextRange(6, 11).createRange(*div),
+ DocumentMarker::AllMarkers())
+ .size());
+
+ // Verify marker has correct start/end offsets (measured from the beginning
+ // of the node, which is the beginning of the line)
+ EXPECT_EQ(0u, document().markers().markers()[0]->startOffset());
+ EXPECT_EQ(5u, document().markers().markers()[0]->endOffset());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698