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

Side by Side 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: Don't change param names 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/InputMethodController.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/editing/InputMethodController.h" 5 #include "core/editing/InputMethodController.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/dom/Range.h" 9 #include "core/dom/Range.h"
10 #include "core/editing/Editor.h" 10 #include "core/editing/Editor.h"
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 underlines.push_back(CompositionUnderline(1, 11, Color(255, 0, 0), false, 0)); 1197 underlines.push_back(CompositionUnderline(1, 11, Color(255, 0, 0), false, 0));
1198 1198
1199 controller().commitText(String("string"), underlines, 0); 1199 controller().commitText(String("string"), underlines, 0);
1200 1200
1201 ASSERT_EQ(1u, document().markers().markers().size()); 1201 ASSERT_EQ(1u, document().markers().markers().size());
1202 1202
1203 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset()); 1203 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset());
1204 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset()); 1204 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset());
1205 } 1205 }
1206 1206
1207 TEST_F(InputMethodControllerTest,
1208 CompositionUnderlineAppearsCorrectlyAfterNewline) {
1209 Element* div =
1210 insertHTMLElement("<div id='sample' contenteditable></div>", "sample");
1211
1212 Vector<CompositionUnderline> underlines;
1213 controller().setComposition(String("hello"), underlines, 6, 6);
1214 controller().finishComposingText(InputMethodController::KeepSelection);
1215 frame().editor().insertLineBreak();
1216
1217 controller().setCompositionFromExistingText(underlines, 8, 8);
1218
1219 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
1220 controller().setComposition(String("world"), underlines, 0, 0);
1221 ASSERT_EQ(1u, document().markers().markers().size());
1222
1223 // Verify composition underline shows up on the second line, not the first
1224 ASSERT_EQ(0u, document()
1225 .markers()
1226 .markersInRange(PlainTextRange(0, 5).createRange(*div),
1227 DocumentMarker::AllMarkers())
1228 .size());
1229 ASSERT_EQ(1u, document()
1230 .markers()
1231 .markersInRange(PlainTextRange(6, 11).createRange(*div),
1232 DocumentMarker::AllMarkers())
1233 .size());
1234
1235 // Verify marker has correct start/end offsets (measured from the beginning
1236 // of the node, which is the beginning of the line)
1237 EXPECT_EQ(0u, document().markers().markers()[0]->startOffset());
1238 EXPECT_EQ(5u, document().markers().markers()[0]->endOffset());
1239 }
1240
1207 } // namespace blink 1241 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/InputMethodController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698