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

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

Issue 1999423002: tyrbot test for commitText (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SetHasCompositionTextToTrue Created 4 years, 3 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/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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText) 114 TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText)
115 { 115 {
116 insertHTMLElement( 116 insertHTMLElement(
117 "<div id='sample' contenteditable='true'>hello world</div>", "sample"); 117 "<div id='sample' contenteditable='true'>hello world</div>", "sample");
118 118
119 Vector<CompositionUnderline> underlines; 119 Vector<CompositionUnderline> underlines;
120 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 120 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
121 controller().setCompositionFromExistingText(underlines, 0, 5); 121 controller().setCompositionFromExistingText(underlines, 0, 5);
122 122
123 controller().confirmComposition(); 123 controller().finishComposingText(InputMethodController::KeepSelection);
124 EXPECT_EQ(0, frame().selection().start().computeOffsetInContainerNode()); 124 EXPECT_EQ(0, frame().selection().start().computeOffsetInContainerNode());
125 EXPECT_EQ(0, frame().selection().end().computeOffsetInContainerNode()); 125 EXPECT_EQ(0, frame().selection().end().computeOffsetInContainerNode());
126 } 126 }
127 127
128 TEST_F(InputMethodControllerTest, DeleteBySettingEmptyComposition) 128 TEST_F(InputMethodControllerTest, DeleteBySettingEmptyComposition)
129 { 129 {
130 HTMLInputElement* input = toHTMLInputElement( 130 HTMLInputElement* input = toHTMLInputElement(
131 insertHTMLElement("<input id='sample'>", "sample")); 131 insertHTMLElement("<input id='sample'>", "sample"));
132 132
133 input->setValue("foo "); 133 input->setValue("foo ");
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 183 }
184 184
185 TEST_F(InputMethodControllerTest, ConfirmPasswordComposition) 185 TEST_F(InputMethodControllerTest, ConfirmPasswordComposition)
186 { 186 {
187 HTMLInputElement* input = toHTMLInputElement( 187 HTMLInputElement* input = toHTMLInputElement(
188 insertHTMLElement("<input id='sample' type='password' size='24'>", "samp le")); 188 insertHTMLElement("<input id='sample' type='password' size='24'>", "samp le"));
189 189
190 Vector<CompositionUnderline> underlines; 190 Vector<CompositionUnderline> underlines;
191 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 191 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
192 controller().setComposition("foo", underlines, 0, 3); 192 controller().setComposition("foo", underlines, 0, 3);
193 controller().confirmComposition(); 193 controller().finishComposingText(InputMethodController::KeepSelection);
194 194
195 EXPECT_STREQ("foo", input->value().utf8().data()); 195 EXPECT_STREQ("foo", input->value().utf8().data());
196 } 196 }
197 197
198 TEST_F(InputMethodControllerTest, SetCompositionForInputWithDifferentNewCursorPo sitions) 198 TEST_F(InputMethodControllerTest, SetCompositionForInputWithNewCaretPositions)
199 { 199 {
200 HTMLInputElement* input = toHTMLInputElement( 200 HTMLInputElement* input = toHTMLInputElement(
201 insertHTMLElement("<input id='sample'>", "sample")); 201 insertHTMLElement("<input id='sample'>", "sample"));
202 202
203 input->setValue("hello"); 203 input->setValue("hello");
204 controller().setEditableSelectionOffsets(PlainTextRange(2, 2)); 204 controller().setEditableSelectionOffsets(PlainTextRange(2, 2));
205 EXPECT_STREQ("hello", input->value().utf8().data()); 205 EXPECT_STREQ("hello", input->value().utf8().data());
206 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); 206 EXPECT_EQ(2u, controller().getSelectionOffsets().start());
207 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); 207 EXPECT_EQ(2u, controller().getSelectionOffsets().end());
208 208
209 Vector<CompositionUnderline> underlines; 209 Vector<CompositionUnderline> underlines;
210 underlines.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0)); 210 underlines.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0));
211 211
212 // The cursor exceeds left boundary. 212 // The caret exceeds left boundary.
213 // "*heABllo", where * stands for cursor. 213 // "*heABllo", where * stands for caret.
214 controller().setComposition("AB", underlines, -100, -100); 214 controller().setComposition("AB", underlines, -100, -100);
215 EXPECT_STREQ("heABllo", input->value().utf8().data()); 215 EXPECT_STREQ("heABllo", input->value().utf8().data());
216 EXPECT_EQ(0u, controller().getSelectionOffsets().start()); 216 EXPECT_EQ(0u, controller().getSelectionOffsets().start());
217 EXPECT_EQ(0u, controller().getSelectionOffsets().end()); 217 EXPECT_EQ(0u, controller().getSelectionOffsets().end());
218 218
219 // The cursor is on left boundary. 219 // The caret is on left boundary.
220 // "*heABllo". 220 // "*heABllo".
221 controller().setComposition("AB", underlines, -2, -2); 221 controller().setComposition("AB", underlines, -2, -2);
222 EXPECT_STREQ("heABllo", input->value().utf8().data()); 222 EXPECT_STREQ("heABllo", input->value().utf8().data());
223 EXPECT_EQ(0u, controller().getSelectionOffsets().start()); 223 EXPECT_EQ(0u, controller().getSelectionOffsets().start());
224 EXPECT_EQ(0u, controller().getSelectionOffsets().end()); 224 EXPECT_EQ(0u, controller().getSelectionOffsets().end());
225 225
226 // The cursor is before the composing text. 226 // The caret is before the composing text.
227 // "he*ABllo". 227 // "he*ABllo".
228 controller().setComposition("AB", underlines, 0, 0); 228 controller().setComposition("AB", underlines, 0, 0);
229 EXPECT_STREQ("heABllo", input->value().utf8().data()); 229 EXPECT_STREQ("heABllo", input->value().utf8().data());
230 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); 230 EXPECT_EQ(2u, controller().getSelectionOffsets().start());
231 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); 231 EXPECT_EQ(2u, controller().getSelectionOffsets().end());
232 232
233 // The cursor is after the composing text. 233 // The caret is after the composing text.
234 // "heAB*llo". 234 // "heAB*llo".
235 controller().setComposition("AB", underlines, 2, 2); 235 controller().setComposition("AB", underlines, 2, 2);
236 EXPECT_STREQ("heABllo", input->value().utf8().data()); 236 EXPECT_STREQ("heABllo", input->value().utf8().data());
237 EXPECT_EQ(4u, controller().getSelectionOffsets().start()); 237 EXPECT_EQ(4u, controller().getSelectionOffsets().start());
238 EXPECT_EQ(4u, controller().getSelectionOffsets().end()); 238 EXPECT_EQ(4u, controller().getSelectionOffsets().end());
239 239
240 // The cursor is on right boundary. 240 // The caret is on right boundary.
241 // "heABllo*". 241 // "heABllo*".
242 controller().setComposition("AB", underlines, 5, 5); 242 controller().setComposition("AB", underlines, 5, 5);
243 EXPECT_STREQ("heABllo", input->value().utf8().data()); 243 EXPECT_STREQ("heABllo", input->value().utf8().data());
244 EXPECT_EQ(7u, controller().getSelectionOffsets().start()); 244 EXPECT_EQ(7u, controller().getSelectionOffsets().start());
245 EXPECT_EQ(7u, controller().getSelectionOffsets().end()); 245 EXPECT_EQ(7u, controller().getSelectionOffsets().end());
246 246
247 // The cursor exceeds right boundary. 247 // The caret exceeds right boundary.
248 // "heABllo*". 248 // "heABllo*".
249 controller().setComposition("AB", underlines, 100, 100); 249 controller().setComposition("AB", underlines, 100, 100);
250 EXPECT_STREQ("heABllo", input->value().utf8().data()); 250 EXPECT_STREQ("heABllo", input->value().utf8().data());
251 EXPECT_EQ(7u, controller().getSelectionOffsets().start()); 251 EXPECT_EQ(7u, controller().getSelectionOffsets().start());
252 EXPECT_EQ(7u, controller().getSelectionOffsets().end()); 252 EXPECT_EQ(7u, controller().getSelectionOffsets().end());
253 } 253 }
254 254
255 TEST_F(InputMethodControllerTest, SetCompositionForContentEditableWithDifferentN ewCursorPositions) 255 TEST_F(InputMethodControllerTest, SetCompositionForContentEditableWithNewCaretPo sitions)
256 { 256 {
257 // There are 7 nodes and 5+1+5+1+3+4+3 characters: "hello", '\n', "world", " \n", "012", "3456", "789". 257 // There are 7 nodes and 5+1+5+1+3+4+3 characters: "hello", '\n', "world", " \n", "012", "3456", "789".
258 Element* div = insertHTMLElement( 258 Element* div = insertHTMLElement(
259 "<div id='sample' contenteditable='true'>" 259 "<div id='sample' contenteditable='true'>"
260 "hello" 260 "hello"
261 "<div id='sample2' contenteditable='true'>world" 261 "<div id='sample2' contenteditable='true'>world"
262 "<p>012<b>3456</b><i>789</i></p>" 262 "<p>012<b>3456</b><i>789</i></p>"
263 "</div>" 263 "</div>"
264 "</div>", 264 "</div>",
265 "sample"); 265 "sample");
266 266
267 controller().setEditableSelectionOffsets(PlainTextRange(17, 17)); 267 controller().setEditableSelectionOffsets(PlainTextRange(17, 17));
268 EXPECT_STREQ("hello\nworld\n0123456789", div->innerText().utf8().data()); 268 EXPECT_STREQ("hello\nworld\n0123456789", div->innerText().utf8().data());
269 EXPECT_EQ(17u, controller().getSelectionOffsets().start()); 269 EXPECT_EQ(17u, controller().getSelectionOffsets().start());
270 EXPECT_EQ(17u, controller().getSelectionOffsets().end()); 270 EXPECT_EQ(17u, controller().getSelectionOffsets().end());
271 271
272 Vector<CompositionUnderline> underlines; 272 Vector<CompositionUnderline> underlines;
273 underlines.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0)); 273 underlines.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0));
274 274
275 // The cursor exceeds left boundary. 275 // The caret exceeds left boundary.
276 // "*hello\nworld\n01234AB56789", where * stands for cursor. 276 // "*hello\nworld\n01234AB56789", where * stands for caret.
277 controller().setComposition("AB", underlines, -100, -100); 277 controller().setComposition("AB", underlines, -100, -100);
278 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); 278 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data());
279 EXPECT_EQ(0u, controller().getSelectionOffsets().start()); 279 EXPECT_EQ(0u, controller().getSelectionOffsets().start());
280 EXPECT_EQ(0u, controller().getSelectionOffsets().end()); 280 EXPECT_EQ(0u, controller().getSelectionOffsets().end());
281 281
282 // The cursor is on left boundary. 282 // The caret is on left boundary.
283 // "*hello\nworld\n01234AB56789". 283 // "*hello\nworld\n01234AB56789".
284 controller().setComposition("AB", underlines, -17, -17); 284 controller().setComposition("AB", underlines, -17, -17);
285 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); 285 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data());
286 EXPECT_EQ(0u, controller().getSelectionOffsets().start()); 286 EXPECT_EQ(0u, controller().getSelectionOffsets().start());
287 EXPECT_EQ(0u, controller().getSelectionOffsets().end()); 287 EXPECT_EQ(0u, controller().getSelectionOffsets().end());
288 288
289 // The cursor is in the 1st node. 289 // The caret is in the 1st node.
290 // "he*llo\nworld\n01234AB56789". 290 // "he*llo\nworld\n01234AB56789".
291 controller().setComposition("AB", underlines, -15, -15); 291 controller().setComposition("AB", underlines, -15, -15);
292 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); 292 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data());
293 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); 293 EXPECT_EQ(2u, controller().getSelectionOffsets().start());
294 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); 294 EXPECT_EQ(2u, controller().getSelectionOffsets().end());
295 295
296 // The cursor is on right boundary of the 1st node. 296 // The caret is on right boundary of the 1st node.
297 // "hello*\nworld\n01234AB56789". 297 // "hello*\nworld\n01234AB56789".
298 controller().setComposition("AB", underlines, -12, -12); 298 controller().setComposition("AB", underlines, -12, -12);
299 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); 299 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data());
300 EXPECT_EQ(5u, controller().getSelectionOffsets().start()); 300 EXPECT_EQ(5u, controller().getSelectionOffsets().start());
301 EXPECT_EQ(5u, controller().getSelectionOffsets().end()); 301 EXPECT_EQ(5u, controller().getSelectionOffsets().end());
302 302
303 // The cursor is on right boundary of the 2nd node. 303 // The caret is on right boundary of the 2nd node.
304 // "hello\n*world\n01234AB56789". 304 // "hello\n*world\n01234AB56789".
305 controller().setComposition("AB", underlines, -11, -11); 305 controller().setComposition("AB", underlines, -11, -11);
306 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); 306 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data());
307 EXPECT_EQ(6u, controller().getSelectionOffsets().start()); 307 EXPECT_EQ(6u, controller().getSelectionOffsets().start());
308 EXPECT_EQ(6u, controller().getSelectionOffsets().end()); 308 EXPECT_EQ(6u, controller().getSelectionOffsets().end());
309 309
310 // The cursor is on right boundary of the 3rd node. 310 // The caret is on right boundary of the 3rd node.
311 // "hello\nworld*\n01234AB56789". 311 // "hello\nworld*\n01234AB56789".
312 controller().setComposition("AB", underlines, -6, -6); 312 controller().setComposition("AB", underlines, -6, -6);
313 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); 313 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data());
314 EXPECT_EQ(11u, controller().getSelectionOffsets().start()); 314 EXPECT_EQ(11u, controller().getSelectionOffsets().start());
315 EXPECT_EQ(11u, controller().getSelectionOffsets().end()); 315 EXPECT_EQ(11u, controller().getSelectionOffsets().end());
316 316
317 // The cursor is on right boundary of the 4th node. 317 // The caret is on right boundary of the 4th node.
318 // "hello\nworld\n*01234AB56789". 318 // "hello\nworld\n*01234AB56789".
319 controller().setComposition("AB", underlines, -5, -5); 319 controller().setComposition("AB", underlines, -5, -5);
320 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); 320 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data());
321 EXPECT_EQ(12u, controller().getSelectionOffsets().start()); 321 EXPECT_EQ(12u, controller().getSelectionOffsets().start());
322 EXPECT_EQ(12u, controller().getSelectionOffsets().end()); 322 EXPECT_EQ(12u, controller().getSelectionOffsets().end());
323 323
324 // The cursor is before the composing text. 324 // The caret is before the composing text.
325 // "hello\nworld\n01234*AB56789". 325 // "hello\nworld\n01234*AB56789".
326 controller().setComposition("AB", underlines, 0, 0); 326 controller().setComposition("AB", underlines, 0, 0);
327 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); 327 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data());
328 EXPECT_EQ(17u, controller().getSelectionOffsets().start()); 328 EXPECT_EQ(17u, controller().getSelectionOffsets().start());
329 EXPECT_EQ(17u, controller().getSelectionOffsets().end()); 329 EXPECT_EQ(17u, controller().getSelectionOffsets().end());
330 330
331 // The cursor is after the composing text. 331 // The caret is after the composing text.
332 // "hello\nworld\n01234AB*56789". 332 // "hello\nworld\n01234AB*56789".
333 controller().setComposition("AB", underlines, 2, 2); 333 controller().setComposition("AB", underlines, 2, 2);
334 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); 334 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data());
335 EXPECT_EQ(19u, controller().getSelectionOffsets().start()); 335 EXPECT_EQ(19u, controller().getSelectionOffsets().start());
336 EXPECT_EQ(19u, controller().getSelectionOffsets().end()); 336 EXPECT_EQ(19u, controller().getSelectionOffsets().end());
337 337
338 // The cursor is on right boundary. 338 // The caret is on right boundary.
339 // "hello\nworld\n01234AB56789*". 339 // "hello\nworld\n01234AB56789*".
340 controller().setComposition("AB", underlines, 7, 7); 340 controller().setComposition("AB", underlines, 7, 7);
341 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); 341 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data());
342 EXPECT_EQ(24u, controller().getSelectionOffsets().start()); 342 EXPECT_EQ(24u, controller().getSelectionOffsets().start());
343 EXPECT_EQ(24u, controller().getSelectionOffsets().end()); 343 EXPECT_EQ(24u, controller().getSelectionOffsets().end());
344 344
345 // The cursor exceeds right boundary. 345 // The caret exceeds right boundary.
346 // "hello\nworld\n01234AB56789*". 346 // "hello\nworld\n01234AB56789*".
347 controller().setComposition("AB", underlines, 100, 100); 347 controller().setComposition("AB", underlines, 100, 100);
348 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); 348 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data());
349 EXPECT_EQ(24u, controller().getSelectionOffsets().start()); 349 EXPECT_EQ(24u, controller().getSelectionOffsets().start());
350 EXPECT_EQ(24u, controller().getSelectionOffsets().end()); 350 EXPECT_EQ(24u, controller().getSelectionOffsets().end());
351 } 351 }
352 352
353 TEST_F(InputMethodControllerTest, SetCompositionWithEmptyText) 353 TEST_F(InputMethodControllerTest, SetCompositionWithEmptyText)
354 { 354 {
355 Element* div = insertHTMLElement( 355 Element* div = insertHTMLElement(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 EXPECT_EQ(1u, controller().getSelectionOffsets().start()); 398 EXPECT_EQ(1u, controller().getSelectionOffsets().start());
399 EXPECT_EQ(1u, controller().getSelectionOffsets().end()); 399 EXPECT_EQ(1u, controller().getSelectionOffsets().end());
400 } 400 }
401 401
402 TEST_F(InputMethodControllerTest, InsertLineBreakAfterConfirmingText) 402 TEST_F(InputMethodControllerTest, InsertLineBreakAfterConfirmingText)
403 { 403 {
404 Element* div = insertHTMLElement( 404 Element* div = insertHTMLElement(
405 "<div id='sample' contenteditable='true'></div>", 405 "<div id='sample' contenteditable='true'></div>",
406 "sample"); 406 "sample");
407 407
408 controller().confirmCompositionOrInsertText("hello", InputMethodController:: ConfirmCompositionBehavior::KeepSelection); 408 controller().commitText("hello", 0);
409 EXPECT_STREQ("hello", div->innerText().utf8().data()); 409 EXPECT_STREQ("hello", div->innerText().utf8().data());
410 410
411 controller().setEditableSelectionOffsets(PlainTextRange(2, 2)); 411 controller().setEditableSelectionOffsets(PlainTextRange(2, 2));
412 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); 412 EXPECT_EQ(2u, controller().getSelectionOffsets().start());
413 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); 413 EXPECT_EQ(2u, controller().getSelectionOffsets().end());
414 414
415 frame().editor().insertLineBreak(); 415 frame().editor().insertLineBreak();
416 EXPECT_STREQ("he\nllo", div->innerText().utf8().data()); 416 EXPECT_STREQ("he\nllo", div->innerText().utf8().data());
417 EXPECT_EQ(3u, controller().getSelectionOffsets().start()); 417 EXPECT_EQ(3u, controller().getSelectionOffsets().start());
418 EXPECT_EQ(3u, controller().getSelectionOffsets().end()); 418 EXPECT_EQ(3u, controller().getSelectionOffsets().end());
(...skipping 18 matching lines...) Expand all
437 // Simulate composition in the |contentEditable|. 437 // Simulate composition in the |contentEditable|.
438 Vector<CompositionUnderline> underlines; 438 Vector<CompositionUnderline> underlines;
439 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 439 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
440 editable->focus(); 440 editable->focus();
441 441
442 document().setTitle(emptyString()); 442 document().setTitle(emptyString());
443 controller().setComposition("foo", underlines, 0, 3); 443 controller().setComposition("foo", underlines, 0, 3);
444 EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", documen t().title().utf8().data()); 444 EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", documen t().title().utf8().data());
445 445
446 document().setTitle(emptyString()); 446 document().setTitle(emptyString());
447 controller().confirmComposition(); 447 controller().finishComposingText(InputMethodController::KeepSelection);
448 // Last pair of InputEvent should also be inside composition scope. 448 // Last pair of InputEvent should also be inside composition scope.
449 EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", documen t().title().utf8().data()); 449 EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", documen t().title().utf8().data());
450 } 450 }
451 451
452 TEST_F(InputMethodControllerTest, CompositionInputEventData) 452 TEST_F(InputMethodControllerTest, CompositionInputEventData)
453 { 453 {
454 document().settings()->setScriptEnabled(true); 454 document().settings()->setScriptEnabled(true);
455 Element* editable = insertHTMLElement("<div id='sample' contentEditable='tru e'></div>", "sample"); 455 Element* editable = insertHTMLElement("<div id='sample' contentEditable='tru e'></div>", "sample");
456 Element* script = document().createElement("script", ASSERT_NO_EXCEPTION); 456 Element* script = document().createElement("script", ASSERT_NO_EXCEPTION);
457 script->setInnerHTML( 457 script->setInnerHTML(
(...skipping 14 matching lines...) Expand all
472 472
473 document().setTitle(emptyString()); 473 document().setTitle(emptyString());
474 controller().setComposition("n", underlines, 0, 1); 474 controller().setComposition("n", underlines, 0, 1);
475 EXPECT_STREQ("beforeinput.data:n;input.data:n;", document().title().utf8().d ata()); 475 EXPECT_STREQ("beforeinput.data:n;input.data:n;", document().title().utf8().d ata());
476 476
477 document().setTitle(emptyString()); 477 document().setTitle(emptyString());
478 controller().setComposition("ni", underlines, 0, 1); 478 controller().setComposition("ni", underlines, 0, 1);
479 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8() .data()); 479 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8() .data());
480 480
481 document().setTitle(emptyString()); 481 document().setTitle(emptyString());
482 controller().confirmComposition(); 482 controller().finishComposingText(InputMethodController::KeepSelection);
483 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8() .data()); 483 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8() .data());
484 } 484 }
485 485
486 } // namespace blink 486 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/InputMethodController.cpp ('k') | third_party/WebKit/Source/web/WebFrameWidgetImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698