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

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

Issue 2673303002: All offset in dom/Range.idl should be unsigned long (Closed)
Patch Set: Remove unnecessary static_cast Created 3 years, 10 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 TEST_F(InputMethodControllerTest, SetCompositionFromExistingText) { 169 TEST_F(InputMethodControllerTest, SetCompositionFromExistingText) {
170 Element* div = insertHTMLElement( 170 Element* div = insertHTMLElement(
171 "<div id='sample' contenteditable>hello world</div>", "sample"); 171 "<div id='sample' contenteditable>hello world</div>", "sample");
172 172
173 Vector<CompositionUnderline> underlines; 173 Vector<CompositionUnderline> underlines;
174 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 174 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
175 controller().setCompositionFromExistingText(underlines, 0, 5); 175 controller().setCompositionFromExistingText(underlines, 0, 5);
176 176
177 Range* range = controller().compositionRange(); 177 Range* range = controller().compositionRange();
178 EXPECT_EQ(0, range->startOffset()); 178 EXPECT_EQ(0u, range->startOffset());
179 EXPECT_EQ(5, range->endOffset()); 179 EXPECT_EQ(5u, range->endOffset());
180 180
181 PlainTextRange plainTextRange(PlainTextRange::create(*div, *range)); 181 PlainTextRange plainTextRange(PlainTextRange::create(*div, *range));
182 EXPECT_EQ(0u, plainTextRange.start()); 182 EXPECT_EQ(0u, plainTextRange.start());
183 EXPECT_EQ(5u, plainTextRange.end()); 183 EXPECT_EQ(5u, plainTextRange.end());
184 } 184 }
185 185
186 TEST_F(InputMethodControllerTest, SetCompositionAfterEmoji) { 186 TEST_F(InputMethodControllerTest, SetCompositionAfterEmoji) {
187 // "trophy" = U+1F3C6 = 0xF0 0x9F 0x8F 0x86 (UTF8). 187 // "trophy" = U+1F3C6 = 0xF0 0x9F 0x8F 0x86 (UTF8).
188 Element* div = insertHTMLElement( 188 Element* div = insertHTMLElement(
189 "<div id='sample' contenteditable>&#x1f3c6</div>", "sample"); 189 "<div id='sample' contenteditable>&#x1f3c6</div>", "sample");
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 // Creates a div with one leading new line char. The new line char is hidden 354 // Creates a div with one leading new line char. The new line char is hidden
355 // from the user and IME, but is visible to InputMethodController. 355 // from the user and IME, but is visible to InputMethodController.
356 Element* div = insertHTMLElement( 356 Element* div = insertHTMLElement(
357 "<div id='sample' contenteditable>\nhello world</div>", "sample"); 357 "<div id='sample' contenteditable>\nhello world</div>", "sample");
358 358
359 Vector<CompositionUnderline> underlines; 359 Vector<CompositionUnderline> underlines;
360 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 360 underlines.push_back(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
361 controller().setCompositionFromExistingText(underlines, 0, 5); 361 controller().setCompositionFromExistingText(underlines, 0, 5);
362 362
363 Range* range = controller().compositionRange(); 363 Range* range = controller().compositionRange();
364 EXPECT_EQ(1, range->startOffset()); 364 EXPECT_EQ(1u, range->startOffset());
365 EXPECT_EQ(6, range->endOffset()); 365 EXPECT_EQ(6u, range->endOffset());
366 366
367 PlainTextRange plainTextRange(PlainTextRange::create(*div, *range)); 367 PlainTextRange plainTextRange(PlainTextRange::create(*div, *range));
368 EXPECT_EQ(0u, plainTextRange.start()); 368 EXPECT_EQ(0u, plainTextRange.start());
369 EXPECT_EQ(5u, plainTextRange.end()); 369 EXPECT_EQ(5u, plainTextRange.end());
370 } 370 }
371 371
372 TEST_F(InputMethodControllerTest, 372 TEST_F(InputMethodControllerTest,
373 SetCompositionFromExistingTextWithInvalidOffsets) { 373 SetCompositionFromExistingTextWithInvalidOffsets) {
374 insertHTMLElement("<div id='sample' contenteditable>test</div>", "sample"); 374 insertHTMLElement("<div id='sample' contenteditable>test</div>", "sample");
375 375
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 1169
1170 controller().commitText(String("string"), underlines, 0); 1170 controller().commitText(String("string"), underlines, 0);
1171 1171
1172 ASSERT_EQ(1u, document().markers().markers().size()); 1172 ASSERT_EQ(1u, document().markers().markers().size());
1173 1173
1174 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset()); 1174 EXPECT_EQ(9u, document().markers().markers()[0]->startOffset());
1175 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset()); 1175 EXPECT_EQ(15u, document().markers().markers()[0]->endOffset());
1176 } 1176 }
1177 1177
1178 } // namespace blink 1178 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698