OLD | NEW |
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText) | 120 TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText) |
121 { | 121 { |
122 insertHTMLElement( | 122 insertHTMLElement( |
123 "<div id='sample' contenteditable='true'>hello world</div>", "sample"); | 123 "<div id='sample' contenteditable='true'>hello world</div>", "sample"); |
124 | 124 |
125 Vector<CompositionUnderline> underlines; | 125 Vector<CompositionUnderline> underlines; |
126 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); | 126 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
127 controller().setCompositionFromExistingText(underlines, 0, 5); | 127 controller().setCompositionFromExistingText(underlines, 0, 5); |
128 | 128 |
129 controller().confirmComposition(); | 129 controller().finishComposingText(InputMethodController::KeepSelection); |
130 EXPECT_EQ(0, frame().selection().start().computeOffsetInContainerNode()); | 130 EXPECT_EQ(0, frame().selection().start().computeOffsetInContainerNode()); |
131 EXPECT_EQ(0, frame().selection().end().computeOffsetInContainerNode()); | 131 EXPECT_EQ(0, frame().selection().end().computeOffsetInContainerNode()); |
132 } | 132 } |
133 | 133 |
134 TEST_F(InputMethodControllerTest, DeleteBySettingEmptyComposition) | 134 TEST_F(InputMethodControllerTest, DeleteBySettingEmptyComposition) |
135 { | 135 { |
136 HTMLInputElement* input = toHTMLInputElement( | 136 HTMLInputElement* input = toHTMLInputElement( |
137 insertHTMLElement("<input id='sample'>", "sample")); | 137 insertHTMLElement("<input id='sample'>", "sample")); |
138 | 138 |
139 input->setValue("foo "); | 139 input->setValue("foo "); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 | 192 |
193 TEST_F(InputMethodControllerTest, ConfirmPasswordComposition) | 193 TEST_F(InputMethodControllerTest, ConfirmPasswordComposition) |
194 { | 194 { |
195 HTMLInputElement* input = toHTMLInputElement( | 195 HTMLInputElement* input = toHTMLInputElement( |
196 insertHTMLElement("<input id='sample' type='password' size='24'>", "samp
le")); | 196 insertHTMLElement("<input id='sample' type='password' size='24'>", "samp
le")); |
197 | 197 |
198 Vector<CompositionUnderline> underlines; | 198 Vector<CompositionUnderline> underlines; |
199 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); | 199 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
200 controller().setComposition("foo", underlines, 0, 3); | 200 controller().setComposition("foo", underlines, 0, 3); |
201 controller().confirmComposition(); | 201 controller().finishComposingText(InputMethodController::KeepSelection); |
202 | 202 |
203 EXPECT_STREQ("foo", input->value().utf8().data()); | 203 EXPECT_STREQ("foo", input->value().utf8().data()); |
204 } | 204 } |
205 | 205 |
206 TEST_F(InputMethodControllerTest, SetCompositionForInputWithDifferentNewCursorPo
sitions) | 206 TEST_F(InputMethodControllerTest, SetCompositionForInputWithNewCaretPositions) |
207 { | 207 { |
208 HTMLInputElement* input = toHTMLInputElement( | 208 HTMLInputElement* input = toHTMLInputElement( |
209 insertHTMLElement("<input id='sample'>", "sample")); | 209 insertHTMLElement("<input id='sample'>", "sample")); |
210 | 210 |
211 input->setValue("hello"); | 211 input->setValue("hello"); |
212 document().updateStyleAndLayout(); | 212 document().updateStyleAndLayout(); |
213 controller().setEditableSelectionOffsets(PlainTextRange(2, 2)); | 213 controller().setEditableSelectionOffsets(PlainTextRange(2, 2)); |
214 EXPECT_STREQ("hello", input->value().utf8().data()); | 214 EXPECT_STREQ("hello", input->value().utf8().data()); |
215 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); | 215 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); |
216 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); | 216 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); |
217 | 217 |
218 Vector<CompositionUnderline> underlines; | 218 Vector<CompositionUnderline> underlines; |
219 underlines.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0)); | 219 underlines.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0)); |
220 | 220 |
221 // The cursor exceeds left boundary. | 221 // The caret exceeds left boundary. |
222 // "*heABllo", where * stands for cursor. | 222 // "*heABllo", where * stands for caret. |
223 controller().setComposition("AB", underlines, -100, -100); | 223 controller().setComposition("AB", underlines, -100, -100); |
224 EXPECT_STREQ("heABllo", input->value().utf8().data()); | 224 EXPECT_STREQ("heABllo", input->value().utf8().data()); |
225 EXPECT_EQ(0u, controller().getSelectionOffsets().start()); | 225 EXPECT_EQ(0u, controller().getSelectionOffsets().start()); |
226 EXPECT_EQ(0u, controller().getSelectionOffsets().end()); | 226 EXPECT_EQ(0u, controller().getSelectionOffsets().end()); |
227 | 227 |
228 // The cursor is on left boundary. | 228 // The caret is on left boundary. |
229 // "*heABllo". | 229 // "*heABllo". |
230 controller().setComposition("AB", underlines, -2, -2); | 230 controller().setComposition("AB", underlines, -2, -2); |
231 EXPECT_STREQ("heABllo", input->value().utf8().data()); | 231 EXPECT_STREQ("heABllo", input->value().utf8().data()); |
232 EXPECT_EQ(0u, controller().getSelectionOffsets().start()); | 232 EXPECT_EQ(0u, controller().getSelectionOffsets().start()); |
233 EXPECT_EQ(0u, controller().getSelectionOffsets().end()); | 233 EXPECT_EQ(0u, controller().getSelectionOffsets().end()); |
234 | 234 |
235 // The cursor is before the composing text. | 235 // The caret is before the composing text. |
236 // "he*ABllo". | 236 // "he*ABllo". |
237 controller().setComposition("AB", underlines, 0, 0); | 237 controller().setComposition("AB", underlines, 0, 0); |
238 EXPECT_STREQ("heABllo", input->value().utf8().data()); | 238 EXPECT_STREQ("heABllo", input->value().utf8().data()); |
239 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); | 239 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); |
240 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); | 240 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); |
241 | 241 |
242 // The cursor is after the composing text. | 242 // The caret is after the composing text. |
243 // "heAB*llo". | 243 // "heAB*llo". |
244 controller().setComposition("AB", underlines, 2, 2); | 244 controller().setComposition("AB", underlines, 2, 2); |
245 EXPECT_STREQ("heABllo", input->value().utf8().data()); | 245 EXPECT_STREQ("heABllo", input->value().utf8().data()); |
246 EXPECT_EQ(4u, controller().getSelectionOffsets().start()); | 246 EXPECT_EQ(4u, controller().getSelectionOffsets().start()); |
247 EXPECT_EQ(4u, controller().getSelectionOffsets().end()); | 247 EXPECT_EQ(4u, controller().getSelectionOffsets().end()); |
248 | 248 |
249 // The cursor is on right boundary. | 249 // The caret is on right boundary. |
250 // "heABllo*". | 250 // "heABllo*". |
251 controller().setComposition("AB", underlines, 5, 5); | 251 controller().setComposition("AB", underlines, 5, 5); |
252 EXPECT_STREQ("heABllo", input->value().utf8().data()); | 252 EXPECT_STREQ("heABllo", input->value().utf8().data()); |
253 EXPECT_EQ(7u, controller().getSelectionOffsets().start()); | 253 EXPECT_EQ(7u, controller().getSelectionOffsets().start()); |
254 EXPECT_EQ(7u, controller().getSelectionOffsets().end()); | 254 EXPECT_EQ(7u, controller().getSelectionOffsets().end()); |
255 | 255 |
256 // The cursor exceeds right boundary. | 256 // The caret exceeds right boundary. |
257 // "heABllo*". | 257 // "heABllo*". |
258 controller().setComposition("AB", underlines, 100, 100); | 258 controller().setComposition("AB", underlines, 100, 100); |
259 EXPECT_STREQ("heABllo", input->value().utf8().data()); | 259 EXPECT_STREQ("heABllo", input->value().utf8().data()); |
260 EXPECT_EQ(7u, controller().getSelectionOffsets().start()); | 260 EXPECT_EQ(7u, controller().getSelectionOffsets().start()); |
261 EXPECT_EQ(7u, controller().getSelectionOffsets().end()); | 261 EXPECT_EQ(7u, controller().getSelectionOffsets().end()); |
262 } | 262 } |
263 | 263 |
264 TEST_F(InputMethodControllerTest, SetCompositionForContentEditableWithDifferentN
ewCursorPositions) | 264 TEST_F(InputMethodControllerTest, SetCompositionForContentEditableWithNewCaretPo
sitions) |
265 { | 265 { |
266 // There are 7 nodes and 5+1+5+1+3+4+3 characters: "hello", '\n', "world", "
\n", "012", "3456", "789". | 266 // There are 7 nodes and 5+1+5+1+3+4+3 characters: "hello", '\n', "world", "
\n", "012", "3456", "789". |
267 Element* div = insertHTMLElement( | 267 Element* div = insertHTMLElement( |
268 "<div id='sample' contenteditable='true'>" | 268 "<div id='sample' contenteditable='true'>" |
269 "hello" | 269 "hello" |
270 "<div id='sample2' contenteditable='true'>world" | 270 "<div id='sample2' contenteditable='true'>world" |
271 "<p>012<b>3456</b><i>789</i></p>" | 271 "<p>012<b>3456</b><i>789</i></p>" |
272 "</div>" | 272 "</div>" |
273 "</div>", | 273 "</div>", |
274 "sample"); | 274 "sample"); |
275 | 275 |
276 controller().setEditableSelectionOffsets(PlainTextRange(17, 17)); | 276 controller().setEditableSelectionOffsets(PlainTextRange(17, 17)); |
277 EXPECT_STREQ("hello\nworld\n0123456789", div->innerText().utf8().data()); | 277 EXPECT_STREQ("hello\nworld\n0123456789", div->innerText().utf8().data()); |
278 EXPECT_EQ(17u, controller().getSelectionOffsets().start()); | 278 EXPECT_EQ(17u, controller().getSelectionOffsets().start()); |
279 EXPECT_EQ(17u, controller().getSelectionOffsets().end()); | 279 EXPECT_EQ(17u, controller().getSelectionOffsets().end()); |
280 | 280 |
281 Vector<CompositionUnderline> underlines; | 281 Vector<CompositionUnderline> underlines; |
282 underlines.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0)); | 282 underlines.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0)); |
283 | 283 |
284 // The cursor exceeds left boundary. | 284 // The caret exceeds left boundary. |
285 // "*hello\nworld\n01234AB56789", where * stands for cursor. | 285 // "*hello\nworld\n01234AB56789", where * stands for caret. |
286 controller().setComposition("AB", underlines, -100, -100); | 286 controller().setComposition("AB", underlines, -100, -100); |
287 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); | 287 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); |
288 EXPECT_EQ(0u, controller().getSelectionOffsets().start()); | 288 EXPECT_EQ(0u, controller().getSelectionOffsets().start()); |
289 EXPECT_EQ(0u, controller().getSelectionOffsets().end()); | 289 EXPECT_EQ(0u, controller().getSelectionOffsets().end()); |
290 | 290 |
291 // The cursor is on left boundary. | 291 // The caret is on left boundary. |
292 // "*hello\nworld\n01234AB56789". | 292 // "*hello\nworld\n01234AB56789". |
293 controller().setComposition("AB", underlines, -17, -17); | 293 controller().setComposition("AB", underlines, -17, -17); |
294 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); | 294 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); |
295 EXPECT_EQ(0u, controller().getSelectionOffsets().start()); | 295 EXPECT_EQ(0u, controller().getSelectionOffsets().start()); |
296 EXPECT_EQ(0u, controller().getSelectionOffsets().end()); | 296 EXPECT_EQ(0u, controller().getSelectionOffsets().end()); |
297 | 297 |
298 // The cursor is in the 1st node. | 298 // The caret is in the 1st node. |
299 // "he*llo\nworld\n01234AB56789". | 299 // "he*llo\nworld\n01234AB56789". |
300 controller().setComposition("AB", underlines, -15, -15); | 300 controller().setComposition("AB", underlines, -15, -15); |
301 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); | 301 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); |
302 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); | 302 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); |
303 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); | 303 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); |
304 | 304 |
305 // The cursor is on right boundary of the 1st node. | 305 // The caret is on right boundary of the 1st node. |
306 // "hello*\nworld\n01234AB56789". | 306 // "hello*\nworld\n01234AB56789". |
307 controller().setComposition("AB", underlines, -12, -12); | 307 controller().setComposition("AB", underlines, -12, -12); |
308 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); | 308 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); |
309 EXPECT_EQ(5u, controller().getSelectionOffsets().start()); | 309 EXPECT_EQ(5u, controller().getSelectionOffsets().start()); |
310 EXPECT_EQ(5u, controller().getSelectionOffsets().end()); | 310 EXPECT_EQ(5u, controller().getSelectionOffsets().end()); |
311 | 311 |
312 // The cursor is on right boundary of the 2nd node. | 312 // The caret is on right boundary of the 2nd node. |
313 // "hello\n*world\n01234AB56789". | 313 // "hello\n*world\n01234AB56789". |
314 controller().setComposition("AB", underlines, -11, -11); | 314 controller().setComposition("AB", underlines, -11, -11); |
315 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); | 315 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); |
316 EXPECT_EQ(6u, controller().getSelectionOffsets().start()); | 316 EXPECT_EQ(6u, controller().getSelectionOffsets().start()); |
317 EXPECT_EQ(6u, controller().getSelectionOffsets().end()); | 317 EXPECT_EQ(6u, controller().getSelectionOffsets().end()); |
318 | 318 |
319 // The cursor is on right boundary of the 3rd node. | 319 // The caret is on right boundary of the 3rd node. |
320 // "hello\nworld*\n01234AB56789". | 320 // "hello\nworld*\n01234AB56789". |
321 controller().setComposition("AB", underlines, -6, -6); | 321 controller().setComposition("AB", underlines, -6, -6); |
322 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); | 322 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); |
323 EXPECT_EQ(11u, controller().getSelectionOffsets().start()); | 323 EXPECT_EQ(11u, controller().getSelectionOffsets().start()); |
324 EXPECT_EQ(11u, controller().getSelectionOffsets().end()); | 324 EXPECT_EQ(11u, controller().getSelectionOffsets().end()); |
325 | 325 |
326 // The cursor is on right boundary of the 4th node. | 326 // The caret is on right boundary of the 4th node. |
327 // "hello\nworld\n*01234AB56789". | 327 // "hello\nworld\n*01234AB56789". |
328 controller().setComposition("AB", underlines, -5, -5); | 328 controller().setComposition("AB", underlines, -5, -5); |
329 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); | 329 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); |
330 EXPECT_EQ(12u, controller().getSelectionOffsets().start()); | 330 EXPECT_EQ(12u, controller().getSelectionOffsets().start()); |
331 EXPECT_EQ(12u, controller().getSelectionOffsets().end()); | 331 EXPECT_EQ(12u, controller().getSelectionOffsets().end()); |
332 | 332 |
333 // The cursor is before the composing text. | 333 // The caret is before the composing text. |
334 // "hello\nworld\n01234*AB56789". | 334 // "hello\nworld\n01234*AB56789". |
335 controller().setComposition("AB", underlines, 0, 0); | 335 controller().setComposition("AB", underlines, 0, 0); |
336 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); | 336 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); |
337 EXPECT_EQ(17u, controller().getSelectionOffsets().start()); | 337 EXPECT_EQ(17u, controller().getSelectionOffsets().start()); |
338 EXPECT_EQ(17u, controller().getSelectionOffsets().end()); | 338 EXPECT_EQ(17u, controller().getSelectionOffsets().end()); |
339 | 339 |
340 // The cursor is after the composing text. | 340 // The caret is after the composing text. |
341 // "hello\nworld\n01234AB*56789". | 341 // "hello\nworld\n01234AB*56789". |
342 controller().setComposition("AB", underlines, 2, 2); | 342 controller().setComposition("AB", underlines, 2, 2); |
343 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); | 343 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); |
344 EXPECT_EQ(19u, controller().getSelectionOffsets().start()); | 344 EXPECT_EQ(19u, controller().getSelectionOffsets().start()); |
345 EXPECT_EQ(19u, controller().getSelectionOffsets().end()); | 345 EXPECT_EQ(19u, controller().getSelectionOffsets().end()); |
346 | 346 |
347 // The cursor is on right boundary. | 347 // The caret is on right boundary. |
348 // "hello\nworld\n01234AB56789*". | 348 // "hello\nworld\n01234AB56789*". |
349 controller().setComposition("AB", underlines, 7, 7); | 349 controller().setComposition("AB", underlines, 7, 7); |
350 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); | 350 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); |
351 EXPECT_EQ(24u, controller().getSelectionOffsets().start()); | 351 EXPECT_EQ(24u, controller().getSelectionOffsets().start()); |
352 EXPECT_EQ(24u, controller().getSelectionOffsets().end()); | 352 EXPECT_EQ(24u, controller().getSelectionOffsets().end()); |
353 | 353 |
354 // The cursor exceeds right boundary. | 354 // The caret exceeds right boundary. |
355 // "hello\nworld\n01234AB56789*". | 355 // "hello\nworld\n01234AB56789*". |
356 controller().setComposition("AB", underlines, 100, 100); | 356 controller().setComposition("AB", underlines, 100, 100); |
357 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); | 357 EXPECT_STREQ("hello\nworld\n01234AB56789", div->innerText().utf8().data()); |
358 EXPECT_EQ(24u, controller().getSelectionOffsets().start()); | 358 EXPECT_EQ(24u, controller().getSelectionOffsets().start()); |
359 EXPECT_EQ(24u, controller().getSelectionOffsets().end()); | 359 EXPECT_EQ(24u, controller().getSelectionOffsets().end()); |
360 } | 360 } |
361 | 361 |
362 TEST_F(InputMethodControllerTest, SetCompositionWithEmptyText) | 362 TEST_F(InputMethodControllerTest, SetCompositionWithEmptyText) |
363 { | 363 { |
364 Element* div = insertHTMLElement( | 364 Element* div = insertHTMLElement( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 EXPECT_EQ(1u, controller().getSelectionOffsets().start()); | 407 EXPECT_EQ(1u, controller().getSelectionOffsets().start()); |
408 EXPECT_EQ(1u, controller().getSelectionOffsets().end()); | 408 EXPECT_EQ(1u, controller().getSelectionOffsets().end()); |
409 } | 409 } |
410 | 410 |
411 TEST_F(InputMethodControllerTest, InsertLineBreakAfterConfirmingText) | 411 TEST_F(InputMethodControllerTest, InsertLineBreakAfterConfirmingText) |
412 { | 412 { |
413 Element* div = insertHTMLElement( | 413 Element* div = insertHTMLElement( |
414 "<div id='sample' contenteditable='true'></div>", | 414 "<div id='sample' contenteditable='true'></div>", |
415 "sample"); | 415 "sample"); |
416 | 416 |
417 controller().confirmCompositionOrInsertText("hello", InputMethodController::
ConfirmCompositionBehavior::KeepSelection); | 417 controller().commitText("hello", 0); |
418 EXPECT_STREQ("hello", div->innerText().utf8().data()); | 418 EXPECT_STREQ("hello", div->innerText().utf8().data()); |
419 | 419 |
420 controller().setEditableSelectionOffsets(PlainTextRange(2, 2)); | 420 controller().setEditableSelectionOffsets(PlainTextRange(2, 2)); |
421 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); | 421 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); |
422 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); | 422 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); |
423 | 423 |
424 frame().editor().insertLineBreak(); | 424 frame().editor().insertLineBreak(); |
425 EXPECT_STREQ("he\nllo", div->innerText().utf8().data()); | 425 EXPECT_STREQ("he\nllo", div->innerText().utf8().data()); |
426 EXPECT_EQ(3u, controller().getSelectionOffsets().start()); | 426 EXPECT_EQ(3u, controller().getSelectionOffsets().start()); |
427 EXPECT_EQ(3u, controller().getSelectionOffsets().end()); | 427 EXPECT_EQ(3u, controller().getSelectionOffsets().end()); |
(...skipping 18 matching lines...) Expand all Loading... |
446 // Simulate composition in the |contentEditable|. | 446 // Simulate composition in the |contentEditable|. |
447 Vector<CompositionUnderline> underlines; | 447 Vector<CompositionUnderline> underlines; |
448 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); | 448 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); |
449 editable->focus(); | 449 editable->focus(); |
450 | 450 |
451 document().setTitle(emptyString()); | 451 document().setTitle(emptyString()); |
452 controller().setComposition("foo", underlines, 0, 3); | 452 controller().setComposition("foo", underlines, 0, 3); |
453 EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", documen
t().title().utf8().data()); | 453 EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", documen
t().title().utf8().data()); |
454 | 454 |
455 document().setTitle(emptyString()); | 455 document().setTitle(emptyString()); |
456 controller().confirmComposition(); | 456 controller().finishComposingText(InputMethodController::KeepSelection); |
457 // Last pair of InputEvent should also be inside composition scope. | 457 // Last pair of InputEvent should also be inside composition scope. |
458 EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", documen
t().title().utf8().data()); | 458 EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", documen
t().title().utf8().data()); |
459 } | 459 } |
460 | 460 |
461 TEST_F(InputMethodControllerTest, CompositionInputEventData) | 461 TEST_F(InputMethodControllerTest, CompositionInputEventData) |
462 { | 462 { |
463 document().settings()->setScriptEnabled(true); | 463 document().settings()->setScriptEnabled(true); |
464 Element* editable = insertHTMLElement("<div id='sample' contentEditable='tru
e'></div>", "sample"); | 464 Element* editable = insertHTMLElement("<div id='sample' contentEditable='tru
e'></div>", "sample"); |
465 Element* script = document().createElement("script", ASSERT_NO_EXCEPTION); | 465 Element* script = document().createElement("script", ASSERT_NO_EXCEPTION); |
466 script->setInnerHTML( | 466 script->setInnerHTML( |
(...skipping 14 matching lines...) Expand all Loading... |
481 | 481 |
482 document().setTitle(emptyString()); | 482 document().setTitle(emptyString()); |
483 controller().setComposition("n", underlines, 0, 1); | 483 controller().setComposition("n", underlines, 0, 1); |
484 EXPECT_STREQ("beforeinput.data:n;input.data:n;", document().title().utf8().d
ata()); | 484 EXPECT_STREQ("beforeinput.data:n;input.data:n;", document().title().utf8().d
ata()); |
485 | 485 |
486 document().setTitle(emptyString()); | 486 document().setTitle(emptyString()); |
487 controller().setComposition("ni", underlines, 0, 1); | 487 controller().setComposition("ni", underlines, 0, 1); |
488 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8()
.data()); | 488 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8()
.data()); |
489 | 489 |
490 document().setTitle(emptyString()); | 490 document().setTitle(emptyString()); |
491 controller().confirmComposition(); | 491 controller().finishComposingText(InputMethodController::KeepSelection); |
492 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8()
.data()); | 492 EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8()
.data()); |
493 } | 493 } |
494 | 494 |
495 } // namespace blink | 495 } // namespace blink |
OLD | NEW |