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

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

Issue 1889053003: Fix InputConnection.deleteSurroundingText() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 insertHTMLElement("<input id='sample' type='password' size='24'>", "samp le")); 183 insertHTMLElement("<input id='sample' type='password' size='24'>", "samp le"));
184 184
185 Vector<CompositionUnderline> underlines; 185 Vector<CompositionUnderline> underlines;
186 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 186 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
187 controller().setComposition("foo", underlines, 0, 3); 187 controller().setComposition("foo", underlines, 0, 3);
188 controller().confirmComposition(); 188 controller().confirmComposition();
189 189
190 EXPECT_STREQ("foo", input->value().utf8().data()); 190 EXPECT_STREQ("foo", input->value().utf8().data());
191 } 191 }
192 192
193 TEST_F(InputMethodControllerTest, DeleteSurroundingTextWithEmptyText)
194 {
195 HTMLInputElement* input = toHTMLInputElement(
196 insertHTMLElement("<input id='sample'>", "sample"));
197
198 input->setValue("");
199 EXPECT_STREQ("", input->value().utf8().data());
200 controller().deleteSurroundingText(0, 0);
201 EXPECT_STREQ("", input->value().utf8().data());
202
203 input->setValue("");
204 EXPECT_STREQ("", input->value().utf8().data());
205 controller().deleteSurroundingText(1, 0);
206 EXPECT_STREQ("", input->value().utf8().data());
207
208 input->setValue("");
209 EXPECT_STREQ("", input->value().utf8().data());
210 controller().deleteSurroundingText(0, 1);
211 EXPECT_STREQ("", input->value().utf8().data());
212 }
213
214 TEST_F(InputMethodControllerTest, DeleteSurroundingTextWithRangeSelection)
215 {
216 HTMLInputElement* input = toHTMLInputElement(
217 insertHTMLElement("<input id='sample'>", "sample"));
218
219 input->setValue("hello");
220 EXPECT_STREQ("hello", input->value().utf8().data());
221 controller().setEditableSelectionOffsets(PlainTextRange(1, 4));
222 controller().deleteSurroundingText(0, 0);
223 EXPECT_STREQ("hello", input->value().utf8().data());
224
225 input->setValue("hello");
226 EXPECT_STREQ("hello", input->value().utf8().data());
227 controller().setEditableSelectionOffsets(PlainTextRange(1, 4));
228 controller().deleteSurroundingText(1, 1);
229 EXPECT_STREQ("ell", input->value().utf8().data());
230
231 input->setValue("hello");
232 EXPECT_STREQ("hello", input->value().utf8().data());
233 controller().setEditableSelectionOffsets(PlainTextRange(1, 4));
234 controller().deleteSurroundingText(100, 0);
235 EXPECT_STREQ("ello", input->value().utf8().data());
236
237 input->setValue("hello");
238 EXPECT_STREQ("hello", input->value().utf8().data());
239 controller().setEditableSelectionOffsets(PlainTextRange(1, 4));
240 controller().deleteSurroundingText(0, 100);
241 EXPECT_STREQ("hell", input->value().utf8().data());
242 }
243
244 TEST_F(InputMethodControllerTest, DeleteSurroundingTextWithCursorSelection)
245 {
246 HTMLInputElement* input = toHTMLInputElement(
247 insertHTMLElement("<input id='sample'>", "sample"));
248
249 input->setValue("hello");
250 EXPECT_STREQ("hello", input->value().utf8().data());
251 controller().setEditableSelectionOffsets(PlainTextRange(2, 2));
252 controller().deleteSurroundingText(0, 0);
253 EXPECT_STREQ("hello", input->value().utf8().data());
254
255 input->setValue("hello");
256 EXPECT_STREQ("hello", input->value().utf8().data());
257 controller().setEditableSelectionOffsets(PlainTextRange(2, 2));
258 controller().deleteSurroundingText(1, 1);
259 EXPECT_STREQ("hlo", input->value().utf8().data());
260
261 input->setValue("hello");
262 EXPECT_STREQ("hello", input->value().utf8().data());
263 controller().setEditableSelectionOffsets(PlainTextRange(2, 2));
264 controller().deleteSurroundingText(100, 0);
265 EXPECT_STREQ("llo", input->value().utf8().data());
266
267 input->setValue("hello");
268 EXPECT_STREQ("hello", input->value().utf8().data());
269 controller().setEditableSelectionOffsets(PlainTextRange(2, 2));
270 controller().deleteSurroundingText(0, 100);
271 EXPECT_STREQ("he", input->value().utf8().data());
272 }
273
193 } // namespace blink 274 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698