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

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

Issue 1847583003: Fix setComposingText when newCursorPosition != 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modified some C++ unit tests Created 4 years, 8 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
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/Element.h" 7 #include "core/dom/Element.h"
8 #include "core/dom/Range.h" 8 #include "core/dom/Range.h"
9 #include "core/editing/FrameSelection.h" 9 #include "core/editing/FrameSelection.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 167 }
168 168
169 TEST_F(InputMethodControllerTest, SetCompositionFromExistingTextWithInvalidOffse ts) 169 TEST_F(InputMethodControllerTest, SetCompositionFromExistingTextWithInvalidOffse ts)
170 { 170 {
171 insertHTMLElement("<div id='sample' contenteditable='true'>test</div>", "sam ple"); 171 insertHTMLElement("<div id='sample' contenteditable='true'>test</div>", "sam ple");
172 172
173 Vector<CompositionUnderline> underlines; 173 Vector<CompositionUnderline> underlines;
174 underlines.append(CompositionUnderline(7, 8, Color(255, 0, 0), false, 0)); 174 underlines.append(CompositionUnderline(7, 8, Color(255, 0, 0), false, 0));
175 controller().setCompositionFromExistingText(underlines, 7, 8); 175 controller().setCompositionFromExistingText(underlines, 7, 8);
176 176
177 EXPECT_FALSE(controller().compositionRange()); 177 // If it exceeds the right boundary, it should stay at the right boundary
178 RawPtr<Range> range = controller().compositionRange();
179 EXPECT_EQ(6, range->startOffset());
180 EXPECT_EQ(6, range->endOffset());
Changwan Ryu 2016/04/05 07:50:37 I think you need more tests, e.g. (-1, 8), (-4, -2
yabinh 2016/04/05 08:06:41 Acknowledged.
178 } 181 }
179 182
180 TEST_F(InputMethodControllerTest, ConfirmPasswordComposition) 183 TEST_F(InputMethodControllerTest, ConfirmPasswordComposition)
181 { 184 {
182 HTMLInputElement* input = toHTMLInputElement( 185 HTMLInputElement* input = toHTMLInputElement(
183 insertHTMLElement("<input id='sample' type='password' size='24'>", "samp le")); 186 insertHTMLElement("<input id='sample' type='password' size='24'>", "samp le"));
184 187
185 Vector<CompositionUnderline> underlines; 188 Vector<CompositionUnderline> underlines;
186 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 189 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
187 controller().setComposition("foo", underlines, 0, 3); 190 controller().setComposition("foo", underlines, 0, 3);
188 controller().confirmComposition(); 191 controller().confirmComposition();
189 192
190 EXPECT_STREQ("foo", input->value().utf8().data()); 193 EXPECT_STREQ("foo", input->value().utf8().data());
191 } 194 }
192 195
193 } // namespace blink 196 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698