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

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

Issue 2233573002: Revert of Fix setComposingText with empty text when newCursorPosition != 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/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/events/MouseEvent.h" 10 #include "core/events/MouseEvent.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 EXPECT_EQ(24u, controller().getSelectionOffsets().end()); 342 EXPECT_EQ(24u, controller().getSelectionOffsets().end());
343 343
344 // The cursor exceeds right boundary. 344 // The cursor exceeds right boundary.
345 // "hello\nworld\n01234AB56789*". 345 // "hello\nworld\n01234AB56789*".
346 controller().setComposition("AB", underlines, 100, 100); 346 controller().setComposition("AB", underlines, 100, 100);
347 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); 347 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data());
348 EXPECT_EQ(24u, controller().getSelectionOffsets().start()); 348 EXPECT_EQ(24u, controller().getSelectionOffsets().start());
349 EXPECT_EQ(24u, controller().getSelectionOffsets().end()); 349 EXPECT_EQ(24u, controller().getSelectionOffsets().end());
350 } 350 }
351 351
352 TEST_F(InputMethodControllerTest, SetCompositionWithEmptyText)
353 {
354 Element* div = insertHTMLElement(
355 "<div id='sample' contenteditable='true'>hello</div>",
356 "sample");
357
358 controller().setEditableSelectionOffsets(PlainTextRange(2, 2));
359 EXPECT_STREQ("hello", div->innerText().utf8().data());
360 EXPECT_EQ(2u, controller().getSelectionOffsets().start());
361 EXPECT_EQ(2u, controller().getSelectionOffsets().end());
362
363 Vector<CompositionUnderline> underlines0;
364 underlines0.append(CompositionUnderline(0, 0, Color(255, 0, 0), false, 0));
365 Vector<CompositionUnderline> underlines2;
366 underlines2.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0));
367
368 controller().setComposition("AB", underlines2, 2, 2);
369 // With previous composition.
370 controller().setComposition("", underlines0, 2, 2);
371 EXPECT_STREQ("hello", div->innerText().utf8().data());
372 EXPECT_EQ(4u, controller().getSelectionOffsets().start());
373 EXPECT_EQ(4u, controller().getSelectionOffsets().end());
374
375 // Without previous composition.
376 controller().setComposition("", underlines0, -1, -1);
377 EXPECT_STREQ("hello", div->innerText().utf8().data());
378 EXPECT_EQ(3u, controller().getSelectionOffsets().start());
379 EXPECT_EQ(3u, controller().getSelectionOffsets().end());
380 }
381
382 TEST_F(InputMethodControllerTest, CompositionInputEventIsComposing) 352 TEST_F(InputMethodControllerTest, CompositionInputEventIsComposing)
383 { 353 {
384 document().settings()->setScriptEnabled(true); 354 document().settings()->setScriptEnabled(true);
385 Element* editable = insertHTMLElement("<div id='sample' contentEditable='tru e'></div>", "sample"); 355 Element* editable = insertHTMLElement("<div id='sample' contentEditable='tru e'></div>", "sample");
386 Element* script = document().createElement("script", ASSERT_NO_EXCEPTION); 356 Element* script = document().createElement("script", ASSERT_NO_EXCEPTION);
387 script->setInnerHTML( 357 script->setInnerHTML(
388 "document.getElementById('sample').addEventListener('beforeinput', funct ion(event) {" 358 "document.getElementById('sample').addEventListener('beforeinput', funct ion(event) {"
389 " document.title = `beforeinput.isComposing:${event.isComposing};`;" 359 " document.title = `beforeinput.isComposing:${event.isComposing};`;"
390 "});" 360 "});"
391 "document.getElementById('sample').addEventListener('input', function(ev ent) {" 361 "document.getElementById('sample').addEventListener('input', function(ev ent) {"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 document().setTitle(emptyString()); 408 document().setTitle(emptyString());
439 controller().setComposition("ni", underlines, 0, 1); 409 controller().setComposition("ni", underlines, 0, 1);
440 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8() .data()); 410 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8() .data());
441 411
442 document().setTitle(emptyString()); 412 document().setTitle(emptyString());
443 controller().confirmComposition(); 413 controller().confirmComposition();
444 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8() .data()); 414 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8() .data());
445 } 415 }
446 416
447 } // namespace blink 417 } // 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