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

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

Issue 2073863003: [WIP, not for review] Workaround for setComposition styling clobber (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/events/MouseEvent.h" 10 #include "core/events/MouseEvent.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 100 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
101 controller().setCompositionFromExistingText(underlines, 0, 5); 101 controller().setCompositionFromExistingText(underlines, 0, 5);
102 102
103 Range* range = controller().compositionRange(); 103 Range* range = controller().compositionRange();
104 EXPECT_EQ(0, range->startOffset()); 104 EXPECT_EQ(0, range->startOffset());
105 EXPECT_EQ(5, range->endOffset()); 105 EXPECT_EQ(5, range->endOffset());
106 106
107 PlainTextRange plainTextRange(PlainTextRange::create(*div, *range)); 107 PlainTextRange plainTextRange(PlainTextRange::create(*div, *range));
108 EXPECT_EQ(0u, plainTextRange.start()); 108 EXPECT_EQ(0u, plainTextRange.start());
109 EXPECT_EQ(5u, plainTextRange.end()); 109 EXPECT_EQ(5u, plainTextRange.end());
110
111 controller().setComposition(String("hellobar"), underlines, 8, 8);
112 range = controller().compositionRange();
113 EXPECT_EQ(0, range->startOffset());
114 EXPECT_EQ(8, range->endOffset());
115
116 controller().confirmComposition();
110 } 117 }
111 118
112 TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText) 119 TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText)
113 { 120 {
114 insertHTMLElement( 121 insertHTMLElement(
115 "<div id='sample' contenteditable='true'>hello world</div>", "sample"); 122 "<div id='sample' contenteditable='true'>hello world</div>", "sample");
116 123
117 Vector<CompositionUnderline> underlines; 124 Vector<CompositionUnderline> underlines;
118 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 125 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
119 controller().setCompositionFromExistingText(underlines, 0, 5); 126 controller().setCompositionFromExistingText(underlines, 0, 5);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 controller().setComposition("foo", underlines, 0, 3); 377 controller().setComposition("foo", underlines, 0, 3);
371 EXPECT_STREQ("beforeinput.isComposing:true", document().title().utf8().data( )); 378 EXPECT_STREQ("beforeinput.isComposing:true", document().title().utf8().data( ));
372 379
373 document().setTitle(emptyString()); 380 document().setTitle(emptyString());
374 controller().confirmComposition(); 381 controller().confirmComposition();
375 // Last 'beforeinput' should also be inside composition scope. 382 // Last 'beforeinput' should also be inside composition scope.
376 EXPECT_STREQ("beforeinput.isComposing:true", document().title().utf8().data( )); 383 EXPECT_STREQ("beforeinput.isComposing:true", document().title().utf8().data( ));
377 } 384 }
378 385
379 } // namespace blink 386 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698