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

Side by Side Diff: third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp

Issue 2634243002: Fix a bug when inputting text after grapheme cluster (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | third_party/WebKit/Source/core/editing/commands/InsertIncrementalTextCommand.cpp » ('j') | 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 Range* range = controller().compositionRange(); 177 Range* range = controller().compositionRange();
178 EXPECT_EQ(0, range->startOffset()); 178 EXPECT_EQ(0, range->startOffset());
179 EXPECT_EQ(5, range->endOffset()); 179 EXPECT_EQ(5, range->endOffset());
180 180
181 PlainTextRange plainTextRange(PlainTextRange::create(*div, *range)); 181 PlainTextRange plainTextRange(PlainTextRange::create(*div, *range));
182 EXPECT_EQ(0u, plainTextRange.start()); 182 EXPECT_EQ(0u, plainTextRange.start());
183 EXPECT_EQ(5u, plainTextRange.end()); 183 EXPECT_EQ(5u, plainTextRange.end());
184 } 184 }
185 185
186 TEST_F(InputMethodControllerTest, SetCompositionAfterEmoji) {
187 // "trophy" = U+1F3C6 = 0xF0 0x9F 0x8F 0x86 (UTF8).
188 Element* div = insertHTMLElement(
189 "<div id='sample' contenteditable>&#x1f3c6</div>", "sample");
190
191 Vector<CompositionUnderline> underlines;
192 underlines.push_back(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0));
193
194 document().updateStyleAndLayout();
195 controller().setEditableSelectionOffsets(PlainTextRange(2, 2));
196 EXPECT_EQ(2, frame().selection().start().computeOffsetInContainerNode());
197 EXPECT_EQ(2, frame().selection().end().computeOffsetInContainerNode());
198
199 controller().setComposition(String("a"), underlines, 1, 1);
200 EXPECT_STREQ("\xF0\x9F\x8F\x86\x61", div->innerText().utf8().data());
201
202 controller().setComposition(String("ab"), underlines, 2, 2);
203 EXPECT_STREQ("\xF0\x9F\x8F\x86\x61\x62", div->innerText().utf8().data());
204 }
205
186 TEST_F(InputMethodControllerTest, SetCompositionKeepingStyle) { 206 TEST_F(InputMethodControllerTest, SetCompositionKeepingStyle) {
187 Element* div = insertHTMLElement( 207 Element* div = insertHTMLElement(
188 "<div id='sample' " 208 "<div id='sample' "
189 "contenteditable>abc1<b>2</b>34567<b>8</b>9d<b>e</b>f</div>", 209 "contenteditable>abc1<b>2</b>34567<b>8</b>9d<b>e</b>f</div>",
190 "sample"); 210 "sample");
191 211
192 Vector<CompositionUnderline> underlines; 212 Vector<CompositionUnderline> underlines;
193 underlines.push_back(CompositionUnderline(3, 12, Color(255, 0, 0), false, 0)); 213 underlines.push_back(CompositionUnderline(3, 12, Color(255, 0, 0), false, 0));
194 controller().setCompositionFromExistingText(underlines, 3, 12); 214 controller().setCompositionFromExistingText(underlines, 3, 12);
195 215
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 1213
1194 controller().commitText(String("string"), underlines, 0); 1214 controller().commitText(String("string"), underlines, 0);
1195 1215
1196 ASSERT_EQ(1u, document().markers().markers().size()); 1216 ASSERT_EQ(1u, document().markers().markers().size());
1197 1217
1198 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset()); 1218 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset());
1199 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset()); 1219 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset());
1200 } 1220 }
1201 1221
1202 } // namespace blink 1222 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/commands/InsertIncrementalTextCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698