5#include "flutter/shell/platform/common/text_input_model.h"
11#include "gtest/gtest.h"
16 auto model = std::make_unique<TextInputModel>();
17 model->SetText(
"ABCDE");
18 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
22 auto model = std::make_unique<TextInputModel>();
23 model->SetText(
"😄🙃🤪🧐");
24 EXPECT_STREQ(model->GetText().c_str(),
"😄🙃🤪🧐");
28 auto model = std::make_unique<TextInputModel>();
30 EXPECT_STREQ(model->GetText().c_str(),
"");
34 auto model = std::make_unique<TextInputModel>();
35 model->SetText(
"ABCDE");
36 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
38 EXPECT_STREQ(model->GetText().c_str(),
"");
42 auto model = std::make_unique<TextInputModel>();
43 model->SetText(
"ABCDE");
45 EXPECT_EQ(model->selection(),
TextRange(3));
46 model->SetText(
"FGHJI");
47 EXPECT_EQ(model->selection(),
TextRange(0));
51 auto model = std::make_unique<TextInputModel>();
52 model->SetText(
"ABCDE");
54 EXPECT_EQ(model->selection(),
TextRange(0));
55 EXPECT_EQ(model->composing_range(),
TextRange(0));
56 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
60 auto model = std::make_unique<TextInputModel>();
61 model->SetText(
"ABCDE");
62 model->BeginComposing();
65 EXPECT_EQ(model->selection(),
TextRange(1));
66 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
67 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
71 auto model = std::make_unique<TextInputModel>();
72 model->SetText(
"ABCDE");
74 EXPECT_EQ(model->selection(),
TextRange(2));
75 EXPECT_EQ(model->composing_range(),
TextRange(0));
76 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
80 auto model = std::make_unique<TextInputModel>();
81 model->SetText(
"ABCDE");
82 model->BeginComposing();
85 EXPECT_EQ(model->selection(),
TextRange(2));
86 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
87 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
91 auto model = std::make_unique<TextInputModel>();
92 model->SetText(
"ABCDE");
94 EXPECT_EQ(model->selection(),
TextRange(5));
95 EXPECT_EQ(model->composing_range(),
TextRange(0));
96 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
100 auto model = std::make_unique<TextInputModel>();
101 model->SetText(
"ABCDE");
102 model->BeginComposing();
105 EXPECT_EQ(model->selection(),
TextRange(4));
106 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
107 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
111 auto model = std::make_unique<TextInputModel>();
112 model->SetText(
"ABCDE");
114 EXPECT_EQ(model->selection(),
TextRange(1, 4));
115 EXPECT_EQ(model->composing_range(),
TextRange(0));
116 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
120 auto model = std::make_unique<TextInputModel>();
121 model->SetText(
"ABCDE");
122 model->BeginComposing();
124 EXPECT_FALSE(model->SetSelection(
TextRange(1, 4)));
125 EXPECT_EQ(model->selection(),
TextRange(1));
126 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
127 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
131 auto model = std::make_unique<TextInputModel>();
132 model->SetText(
"ABCDE");
134 EXPECT_EQ(model->selection(),
TextRange(4, 1));
135 EXPECT_EQ(model->composing_range(),
TextRange(0));
136 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
140 auto model = std::make_unique<TextInputModel>();
141 model->SetText(
"ABCDE");
142 model->BeginComposing();
144 EXPECT_FALSE(model->SetSelection(
TextRange(4, 1)));
145 EXPECT_EQ(model->selection(),
TextRange(1));
146 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
147 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
151 auto model = std::make_unique<TextInputModel>();
152 model->SetText(
"ABCDE");
153 EXPECT_FALSE(model->SetSelection(
TextRange(4, 6)));
154 EXPECT_FALSE(model->SetSelection(
TextRange(5, 6)));
155 EXPECT_FALSE(model->SetSelection(
TextRange(6)));
159 auto model = std::make_unique<TextInputModel>();
160 model->SetText(
"ABCDE");
161 model->BeginComposing();
163 EXPECT_FALSE(model->SetSelection(
TextRange(0)));
164 EXPECT_EQ(model->selection(),
TextRange(1));
165 EXPECT_FALSE(model->SetSelection(
TextRange(5)));
166 EXPECT_EQ(model->selection(),
TextRange(1));
167 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
171 auto model = std::make_unique<TextInputModel>();
172 model->SetText(
"ABCDE");
173 model->BeginComposing();
175 EXPECT_EQ(model->selection(),
TextRange(0));
176 EXPECT_EQ(model->composing_range(),
TextRange(0));
177 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
181 auto model = std::make_unique<TextInputModel>();
182 model->SetText(
"ABCDE");
183 model->BeginComposing();
185 EXPECT_EQ(model->selection(),
TextRange(2));
186 EXPECT_EQ(model->composing_range(),
TextRange(2));
187 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
191 auto model = std::make_unique<TextInputModel>();
192 model->SetText(
"ABCDE");
193 model->BeginComposing();
195 EXPECT_EQ(model->selection(),
TextRange(5));
196 EXPECT_EQ(model->composing_range(),
TextRange(5));
197 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
201 auto model = std::make_unique<TextInputModel>();
202 model->SetText(
"ABCDE");
203 model->BeginComposing();
205 EXPECT_EQ(model->selection(),
TextRange(4));
206 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
207 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
211 auto model = std::make_unique<TextInputModel>();
212 model->SetText(
"ABCDE");
213 model->BeginComposing();
215 EXPECT_EQ(model->selection(),
TextRange(4));
216 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
217 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
221 auto model = std::make_unique<TextInputModel>();
222 model->SetText(
"ABCDE");
223 model->BeginComposing();
224 EXPECT_FALSE(model->SetComposingRange(
TextRange(4, 6), 0));
225 EXPECT_FALSE(model->SetComposingRange(
TextRange(5, 6), 0));
226 EXPECT_FALSE(model->SetComposingRange(
TextRange(6, 6), 0));
231 auto model = std::make_unique<TextInputModel>();
232 model->SetText(
"ABCDE");
236 model->BeginComposing();
237 EXPECT_EQ(model->selection(),
TextRange(0));
238 EXPECT_EQ(model->composing_range(),
TextRange(0));
239 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
242 model->CommitComposing();
243 EXPECT_EQ(model->selection(),
TextRange(0));
244 EXPECT_EQ(model->composing_range(),
TextRange(0));
245 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
248 model->EndComposing();
249 EXPECT_EQ(model->selection(),
TextRange(0));
250 EXPECT_EQ(model->composing_range(),
TextRange(0));
251 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
256 auto model = std::make_unique<TextInputModel>();
257 model->SetText(
"ABCDE");
261 model->BeginComposing();
262 EXPECT_EQ(model->selection(),
TextRange(1, 3));
263 EXPECT_EQ(model->composing_range(),
TextRange(1));
264 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
267 model->CommitComposing();
268 EXPECT_EQ(model->selection(),
TextRange(1, 3));
269 EXPECT_EQ(model->composing_range(),
TextRange(1));
270 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
273 model->EndComposing();
274 EXPECT_EQ(model->selection(),
TextRange(1, 3));
275 EXPECT_EQ(model->composing_range(),
TextRange(0));
276 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
281 auto model = std::make_unique<TextInputModel>();
282 model->SetText(
"ABCDE");
286 model->BeginComposing();
287 EXPECT_EQ(model->selection(),
TextRange(1));
288 EXPECT_EQ(model->composing_range(),
TextRange(1));
289 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
293 model->UpdateComposingText(
"つ");
294 EXPECT_EQ(model->selection(),
TextRange(2));
295 EXPECT_EQ(model->composing_range(),
TextRange(1, 2));
296 EXPECT_STREQ(model->GetText().c_str(),
"AつBCDE");
297 model->UpdateComposingText(
"つる");
298 EXPECT_EQ(model->selection(),
TextRange(3));
299 EXPECT_EQ(model->composing_range(),
TextRange(1, 3));
300 EXPECT_STREQ(model->GetText().c_str(),
"AつるBCDE");
303 model->UpdateComposingText(
"鶴");
305 EXPECT_EQ(model->selection(),
TextRange(1));
306 EXPECT_EQ(model->composing_range(),
TextRange(1, 2));
307 EXPECT_STREQ(model->GetText().c_str(),
"A鶴BCDE");
310 model->CommitComposing();
311 EXPECT_EQ(model->selection(),
TextRange(2));
312 EXPECT_EQ(model->composing_range(),
TextRange(2));
313 EXPECT_STREQ(model->GetText().c_str(),
"A鶴BCDE");
317 model->UpdateComposingText(
"が");
318 EXPECT_EQ(model->selection(),
TextRange(3));
319 EXPECT_EQ(model->composing_range(),
TextRange(2, 3));
320 EXPECT_STREQ(model->GetText().c_str(),
"A鶴がBCDE");
323 model->CommitComposing();
324 EXPECT_EQ(model->selection(),
TextRange(3));
325 EXPECT_EQ(model->composing_range(),
TextRange(3));
326 EXPECT_STREQ(model->GetText().c_str(),
"A鶴がBCDE");
329 model->EndComposing();
330 EXPECT_EQ(model->selection(),
TextRange(3));
331 EXPECT_EQ(model->composing_range(),
TextRange(0));
332 EXPECT_STREQ(model->GetText().c_str(),
"A鶴がBCDE");
337 auto model = std::make_unique<TextInputModel>();
338 model->SetText(
"ABCDE");
342 model->BeginComposing();
343 EXPECT_EQ(model->selection(),
TextRange(1, 3));
344 EXPECT_EQ(model->composing_range(),
TextRange(1));
345 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
350 model->UpdateComposingText(
"つ");
351 EXPECT_EQ(model->selection(),
TextRange(2));
352 EXPECT_EQ(model->composing_range(),
TextRange(1, 2));
353 EXPECT_STREQ(model->GetText().c_str(),
"AつDE");
357 model->UpdateComposingText(
"つる");
358 EXPECT_EQ(model->selection(),
TextRange(3));
359 EXPECT_EQ(model->composing_range(),
TextRange(1, 3));
360 EXPECT_STREQ(model->GetText().c_str(),
"AつるDE");
363 model->UpdateComposingText(
"鶴");
365 EXPECT_EQ(model->selection(),
TextRange(1));
366 EXPECT_EQ(model->composing_range(),
TextRange(1, 2));
367 EXPECT_STREQ(model->GetText().c_str(),
"A鶴DE");
370 model->CommitComposing();
371 EXPECT_EQ(model->selection(),
TextRange(2));
372 EXPECT_EQ(model->composing_range(),
TextRange(2));
373 EXPECT_STREQ(model->GetText().c_str(),
"A鶴DE");
377 model->UpdateComposingText(
"が");
378 EXPECT_EQ(model->selection(),
TextRange(3));
379 EXPECT_EQ(model->composing_range(),
TextRange(2, 3));
380 EXPECT_STREQ(model->GetText().c_str(),
"A鶴がDE");
383 model->CommitComposing();
384 EXPECT_EQ(model->selection(),
TextRange(3));
385 EXPECT_EQ(model->composing_range(),
TextRange(3));
386 EXPECT_STREQ(model->GetText().c_str(),
"A鶴がDE");
389 model->EndComposing();
390 EXPECT_EQ(model->selection(),
TextRange(3));
391 EXPECT_EQ(model->composing_range(),
TextRange(0));
392 EXPECT_STREQ(model->GetText().c_str(),
"A鶴がDE");
396 auto model = std::make_unique<TextInputModel>();
397 model->SetText(
"ABCDE");
398 model->BeginComposing();
399 model->SetComposingRange(
TextRange(1, 2), 1);
400 model->UpdateComposingText(
"");
401 EXPECT_EQ(model->selection(),
TextRange(1));
402 EXPECT_EQ(model->composing_range(),
TextRange(1));
403 model->SetText(
"ACDE");
407 auto model = std::make_unique<TextInputModel>();
408 model->SetText(
"ABCDE");
409 model->BeginComposing();
410 model->SetComposingRange(
TextRange(4, 5), 1);
411 model->UpdateComposingText(u
"ぴょんぴょん",
TextRange(3, 6));
412 EXPECT_STREQ(model->GetText().c_str(),
"ABCDぴょんぴょん");
413 EXPECT_EQ(model->selection(),
TextRange(7, 10));
414 EXPECT_EQ(model->composing_range(),
TextRange(4, 10));
418 auto model = std::make_unique<TextInputModel>();
419 model->AddCodePoint(
'A');
420 model->AddCodePoint(
'B');
421 model->AddCodePoint(0x1f604);
422 model->AddCodePoint(
'D');
423 model->AddCodePoint(
'E');
424 EXPECT_EQ(model->selection(),
TextRange(6));
425 EXPECT_EQ(model->composing_range(),
TextRange(0));
426 EXPECT_STREQ(model->GetText().c_str(),
"AB😄DE");
430 auto model = std::make_unique<TextInputModel>();
431 model->SetText(
"ABCDE");
433 model->AddCodePoint(
'x');
434 EXPECT_EQ(model->selection(),
TextRange(2));
435 EXPECT_EQ(model->composing_range(),
TextRange(0));
436 EXPECT_STREQ(model->GetText().c_str(),
"AxE");
440 auto model = std::make_unique<TextInputModel>();
441 model->SetText(
"ABCDE");
443 model->AddCodePoint(
'x');
444 EXPECT_EQ(model->selection(),
TextRange(2));
445 EXPECT_EQ(model->composing_range(),
TextRange(0));
446 EXPECT_STREQ(model->GetText().c_str(),
"AxE");
450 auto model = std::make_unique<TextInputModel>();
451 model->SetText(
"ABCDE");
453 model->AddCodePoint(0x1f604);
454 EXPECT_EQ(model->selection(),
TextRange(3));
455 EXPECT_EQ(model->composing_range(),
TextRange(0));
456 EXPECT_STREQ(model->GetText().c_str(),
"A😄E");
460 auto model = std::make_unique<TextInputModel>();
461 model->SetText(
"ABCDE");
463 model->AddCodePoint(0x1f604);
464 EXPECT_EQ(model->selection(),
TextRange(3));
465 EXPECT_EQ(model->composing_range(),
TextRange(0));
466 EXPECT_STREQ(model->GetText().c_str(),
"A😄E");
470 auto model = std::make_unique<TextInputModel>();
471 model->AddText(u
"ABCDE");
473 model->AddText(
"FGHIJ");
474 EXPECT_EQ(model->selection(),
TextRange(12));
475 EXPECT_EQ(model->composing_range(),
TextRange(0));
476 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE😄FGHIJ");
480 auto model = std::make_unique<TextInputModel>();
481 model->SetText(
"ABCDE");
483 model->AddText(
"xy");
484 EXPECT_EQ(model->selection(),
TextRange(3));
485 EXPECT_EQ(model->composing_range(),
TextRange(0));
486 EXPECT_STREQ(model->GetText().c_str(),
"AxyE");
490 auto model = std::make_unique<TextInputModel>();
491 model->SetText(
"ABCDE");
493 model->AddText(
"xy");
494 EXPECT_EQ(model->selection(),
TextRange(3));
495 EXPECT_EQ(model->composing_range(),
TextRange(0));
496 EXPECT_STREQ(model->GetText().c_str(),
"AxyE");
500 auto model = std::make_unique<TextInputModel>();
501 model->SetText(
"ABCDE");
503 model->AddText(u
"😄🙃");
504 EXPECT_EQ(model->selection(),
TextRange(5));
505 EXPECT_EQ(model->composing_range(),
TextRange(0));
506 EXPECT_STREQ(model->GetText().c_str(),
"A😄🙃E");
510 auto model = std::make_unique<TextInputModel>();
511 model->SetText(
"ABCDE");
513 model->AddText(u
"😄🙃");
514 EXPECT_EQ(model->selection(),
TextRange(5));
515 EXPECT_EQ(model->composing_range(),
TextRange(0));
516 EXPECT_STREQ(model->GetText().c_str(),
"A😄🙃E");
520 auto model = std::make_unique<TextInputModel>();
521 model->SetText(
"ABCDE");
523 ASSERT_TRUE(model->Delete());
524 EXPECT_EQ(model->selection(),
TextRange(0));
525 EXPECT_EQ(model->composing_range(),
TextRange(0));
526 EXPECT_STREQ(model->GetText().c_str(),
"BCDE");
530 auto model = std::make_unique<TextInputModel>();
531 model->SetText(
"ABCDE");
533 ASSERT_TRUE(model->Delete());
534 EXPECT_EQ(model->selection(),
TextRange(2));
535 EXPECT_EQ(model->composing_range(),
TextRange(0));
536 EXPECT_STREQ(model->GetText().c_str(),
"ABDE");
540 auto model = std::make_unique<TextInputModel>();
541 model->SetText(
"ABCDE");
543 ASSERT_FALSE(model->Delete());
544 EXPECT_EQ(model->selection(),
TextRange(5));
545 EXPECT_EQ(model->composing_range(),
TextRange(0));
546 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
550 auto model = std::make_unique<TextInputModel>();
551 model->SetText(
"😄🙃🤪🧐");
553 ASSERT_TRUE(model->Delete());
554 EXPECT_EQ(model->selection(),
TextRange(4));
555 EXPECT_EQ(model->composing_range(),
TextRange(0));
556 EXPECT_STREQ(model->GetText().c_str(),
"😄🙃🧐");
560 auto model = std::make_unique<TextInputModel>();
561 model->SetText(
"ABCDE");
563 ASSERT_TRUE(model->Delete());
564 EXPECT_EQ(model->selection(),
TextRange(1));
565 EXPECT_EQ(model->composing_range(),
TextRange(0));
566 EXPECT_STREQ(model->GetText().c_str(),
"AE");
570 auto model = std::make_unique<TextInputModel>();
571 model->SetText(
"ABCDE");
573 ASSERT_TRUE(model->Delete());
574 EXPECT_EQ(model->selection(),
TextRange(1));
575 EXPECT_EQ(model->composing_range(),
TextRange(0));
576 EXPECT_STREQ(model->GetText().c_str(),
"AE");
580 auto model = std::make_unique<TextInputModel>();
581 model->SetText(
"ABCDE");
582 model->BeginComposing();
584 EXPECT_EQ(model->selection(),
TextRange(1));
585 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
586 ASSERT_TRUE(model->Delete());
587 EXPECT_EQ(model->selection(),
TextRange(1));
588 EXPECT_EQ(model->composing_range(),
TextRange(1, 3));
589 EXPECT_STREQ(model->GetText().c_str(),
"ACDE");
593 auto model = std::make_unique<TextInputModel>();
594 model->SetText(
"ABCDE");
595 model->BeginComposing();
597 EXPECT_EQ(model->selection(),
TextRange(1));
598 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
599 ASSERT_TRUE(model->Delete());
600 EXPECT_EQ(model->selection(),
TextRange(1));
601 EXPECT_EQ(model->composing_range(),
TextRange(3, 1));
602 EXPECT_STREQ(model->GetText().c_str(),
"ACDE");
606 auto model = std::make_unique<TextInputModel>();
607 model->SetText(
"ABCDE");
608 model->BeginComposing();
610 ASSERT_TRUE(model->Delete());
611 EXPECT_EQ(model->selection(),
TextRange(2));
612 EXPECT_EQ(model->composing_range(),
TextRange(1, 3));
613 EXPECT_STREQ(model->GetText().c_str(),
"ABDE");
617 auto model = std::make_unique<TextInputModel>();
618 model->SetText(
"ABCDE");
619 model->BeginComposing();
621 ASSERT_TRUE(model->Delete());
622 EXPECT_EQ(model->selection(),
TextRange(2));
623 EXPECT_EQ(model->composing_range(),
TextRange(3, 1));
624 EXPECT_STREQ(model->GetText().c_str(),
"ABDE");
628 auto model = std::make_unique<TextInputModel>();
629 model->SetText(
"ABCDE");
630 model->BeginComposing();
632 ASSERT_FALSE(model->Delete());
633 EXPECT_EQ(model->selection(),
TextRange(4));
634 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
635 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
639 auto model = std::make_unique<TextInputModel>();
640 model->SetText(
"ABCDE");
641 model->BeginComposing();
643 ASSERT_FALSE(model->Delete());
644 EXPECT_EQ(model->selection(),
TextRange(4));
645 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
646 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
650 auto model = std::make_unique<TextInputModel>();
651 model->SetText(
"ABCDE");
654 EXPECT_EQ(model->selection(),
TextRange(2));
655 EXPECT_EQ(model->composing_range(),
TextRange(0));
656 EXPECT_STREQ(model->GetText().c_str(),
"ABDE");
660 auto model = std::make_unique<TextInputModel>();
661 model->SetText(
"ABCDE");
662 model->BeginComposing();
665 EXPECT_EQ(model->selection(),
TextRange(2));
666 EXPECT_EQ(model->composing_range(),
TextRange(1, 3));
667 EXPECT_STREQ(model->GetText().c_str(),
"ABDE");
671 auto model = std::make_unique<TextInputModel>();
672 model->SetText(
"ABCDE");
675 EXPECT_EQ(model->selection(),
TextRange(2));
676 EXPECT_EQ(model->composing_range(),
TextRange(0));
677 EXPECT_STREQ(model->GetText().c_str(),
"AB");
681 auto model = std::make_unique<TextInputModel>();
682 model->SetText(
"ABCDE");
683 model->BeginComposing();
686 EXPECT_EQ(model->selection(),
TextRange(2));
687 EXPECT_EQ(model->composing_range(),
TextRange(1, 2));
688 EXPECT_STREQ(model->GetText().c_str(),
"ABE");
692 auto model = std::make_unique<TextInputModel>();
693 model->SetText(
"ABCDE");
696 EXPECT_EQ(model->selection(),
TextRange(2));
697 EXPECT_EQ(model->composing_range(),
TextRange(0));
698 EXPECT_STREQ(model->GetText().c_str(),
"AB");
702 auto model = std::make_unique<TextInputModel>();
703 model->SetText(
"ABCDE");
704 model->BeginComposing();
707 EXPECT_EQ(model->selection(),
TextRange(2));
708 EXPECT_EQ(model->composing_range(),
TextRange(1, 2));
709 EXPECT_STREQ(model->GetText().c_str(),
"ABE");
713 auto model = std::make_unique<TextInputModel>();
714 model->SetText(
"ABCDE");
717 EXPECT_EQ(model->selection(),
TextRange(1));
718 EXPECT_EQ(model->composing_range(),
TextRange(0));
719 EXPECT_STREQ(model->GetText().c_str(),
"ACDE");
723 auto model = std::make_unique<TextInputModel>();
724 model->SetText(
"ABCDE");
725 model->BeginComposing();
728 EXPECT_EQ(model->selection(),
TextRange(2));
729 EXPECT_EQ(model->composing_range(),
TextRange(1, 3));
730 EXPECT_STREQ(model->GetText().c_str(),
"ABDE");
734 auto model = std::make_unique<TextInputModel>();
735 model->SetText(
"ABCDE");
738 EXPECT_EQ(model->selection(),
TextRange(0));
739 EXPECT_EQ(model->composing_range(),
TextRange(0));
740 EXPECT_STREQ(model->GetText().c_str(),
"CDE");
744 auto model = std::make_unique<TextInputModel>();
745 model->SetText(
"ABCDE");
746 model->BeginComposing();
749 EXPECT_EQ(model->selection(),
TextRange(1));
750 EXPECT_EQ(model->composing_range(),
TextRange(1, 2));
751 EXPECT_STREQ(model->GetText().c_str(),
"ADE");
755 auto model = std::make_unique<TextInputModel>();
756 model->SetText(
"ABCDE");
759 EXPECT_EQ(model->selection(),
TextRange(0));
760 EXPECT_EQ(model->composing_range(),
TextRange(0));
761 EXPECT_STREQ(model->GetText().c_str(),
"CDE");
765 auto model = std::make_unique<TextInputModel>();
766 model->SetText(
"ABCDE");
767 model->BeginComposing();
770 EXPECT_EQ(model->selection(),
TextRange(1));
771 EXPECT_EQ(model->composing_range(),
TextRange(1, 2));
772 EXPECT_STREQ(model->GetText().c_str(),
"ADE");
776 auto model = std::make_unique<TextInputModel>();
777 model->SetText(
"ABCDE");
780 EXPECT_EQ(model->selection(),
TextRange(2));
781 EXPECT_EQ(model->composing_range(),
TextRange(0));
782 EXPECT_STREQ(model->GetText().c_str(),
"ABCE");
786 auto model = std::make_unique<TextInputModel>();
787 model->SetText(
"ABCDE");
788 model->BeginComposing();
791 EXPECT_EQ(model->selection(),
TextRange(1));
792 EXPECT_EQ(model->composing_range(),
TextRange(1, 3));
793 EXPECT_STREQ(model->GetText().c_str(),
"ABDE");
797 auto model = std::make_unique<TextInputModel>();
798 model->SetText(
"ABCDE");
801 EXPECT_EQ(model->selection(),
TextRange(2));
802 EXPECT_EQ(model->composing_range(),
TextRange(0));
803 EXPECT_STREQ(model->GetText().c_str(),
"ABC");
807 auto model = std::make_unique<TextInputModel>();
808 model->SetText(
"ABCDE");
809 model->BeginComposing();
812 EXPECT_EQ(model->selection(),
TextRange(1));
813 EXPECT_EQ(model->composing_range(),
TextRange(1, 2));
814 EXPECT_STREQ(model->GetText().c_str(),
"ABE");
818 auto model = std::make_unique<TextInputModel>();
819 model->SetText(
"ABCDE");
822 EXPECT_EQ(model->selection(),
TextRange(2));
823 EXPECT_EQ(model->composing_range(),
TextRange(0));
824 EXPECT_STREQ(model->GetText().c_str(),
"ABC");
828 auto model = std::make_unique<TextInputModel>();
829 model->SetText(
"ABCDE");
830 model->BeginComposing();
833 EXPECT_EQ(model->selection(),
TextRange(1));
834 EXPECT_EQ(model->composing_range(),
TextRange(1, 2));
835 EXPECT_STREQ(model->GetText().c_str(),
"ABE");
839 auto model = std::make_unique<TextInputModel>();
840 model->SetText(
"ABCDE");
843 EXPECT_EQ(model->selection(),
TextRange(3));
844 EXPECT_EQ(model->composing_range(),
TextRange(0));
845 EXPECT_STREQ(model->GetText().c_str(),
"ABCE");
849 auto model = std::make_unique<TextInputModel>();
850 model->SetText(
"ABCDE");
853 EXPECT_EQ(model->selection(),
TextRange(3));
854 EXPECT_EQ(model->composing_range(),
TextRange(0));
855 EXPECT_STREQ(model->GetText().c_str(),
"ABCE");
859 auto model = std::make_unique<TextInputModel>();
860 model->SetText(
"ABCDE");
862 ASSERT_FALSE(model->Backspace());
863 EXPECT_EQ(model->selection(),
TextRange(0));
864 EXPECT_EQ(model->composing_range(),
TextRange(0));
865 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
869 auto model = std::make_unique<TextInputModel>();
870 model->SetText(
"ABCDE");
872 ASSERT_TRUE(model->Backspace());
873 EXPECT_EQ(model->selection(),
TextRange(1));
874 EXPECT_EQ(model->composing_range(),
TextRange(0));
875 EXPECT_STREQ(model->GetText().c_str(),
"ACDE");
879 auto model = std::make_unique<TextInputModel>();
880 model->SetText(
"ABCDE");
882 ASSERT_TRUE(model->Backspace());
883 EXPECT_EQ(model->selection(),
TextRange(4));
884 EXPECT_EQ(model->composing_range(),
TextRange(0));
885 EXPECT_STREQ(model->GetText().c_str(),
"ABCD");
889 auto model = std::make_unique<TextInputModel>();
890 model->SetText(
"😄🙃🤪🧐");
892 ASSERT_TRUE(model->Backspace());
893 EXPECT_EQ(model->selection(),
TextRange(2));
894 EXPECT_EQ(model->composing_range(),
TextRange(0));
895 EXPECT_STREQ(model->GetText().c_str(),
"😄🤪🧐");
899 auto model = std::make_unique<TextInputModel>();
900 model->SetText(
"ABCDE");
902 ASSERT_TRUE(model->Delete());
903 EXPECT_EQ(model->selection(),
TextRange(1));
904 EXPECT_EQ(model->composing_range(),
TextRange(0));
905 EXPECT_STREQ(model->GetText().c_str(),
"AE");
909 auto model = std::make_unique<TextInputModel>();
910 model->SetText(
"ABCDE");
912 ASSERT_TRUE(model->Delete());
913 EXPECT_EQ(model->selection(),
TextRange(1));
914 EXPECT_EQ(model->composing_range(),
TextRange(0));
915 EXPECT_STREQ(model->GetText().c_str(),
"AE");
919 auto model = std::make_unique<TextInputModel>();
920 model->SetText(
"ABCDE");
921 model->BeginComposing();
923 ASSERT_FALSE(model->Backspace());
924 EXPECT_EQ(model->selection(),
TextRange(1));
925 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
926 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
930 auto model = std::make_unique<TextInputModel>();
931 model->SetText(
"ABCDE");
932 model->BeginComposing();
934 ASSERT_FALSE(model->Backspace());
935 EXPECT_EQ(model->selection(),
TextRange(1));
936 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
937 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
941 auto model = std::make_unique<TextInputModel>();
942 model->SetText(
"ABCDE");
943 model->BeginComposing();
945 ASSERT_TRUE(model->Backspace());
946 EXPECT_EQ(model->selection(),
TextRange(1));
947 EXPECT_EQ(model->composing_range(),
TextRange(1, 3));
948 EXPECT_STREQ(model->GetText().c_str(),
"ACDE");
952 auto model = std::make_unique<TextInputModel>();
953 model->SetText(
"ABCDE");
954 model->BeginComposing();
956 ASSERT_TRUE(model->Backspace());
957 EXPECT_EQ(model->selection(),
TextRange(1));
958 EXPECT_EQ(model->composing_range(),
TextRange(3, 1));
959 EXPECT_STREQ(model->GetText().c_str(),
"ACDE");
963 auto model = std::make_unique<TextInputModel>();
964 model->SetText(
"ABCDE");
965 model->BeginComposing();
967 ASSERT_TRUE(model->Backspace());
968 EXPECT_EQ(model->selection(),
TextRange(3));
969 EXPECT_EQ(model->composing_range(),
TextRange(1, 3));
970 EXPECT_STREQ(model->GetText().c_str(),
"ABCE");
974 auto model = std::make_unique<TextInputModel>();
975 model->SetText(
"ABCDE");
976 model->BeginComposing();
978 ASSERT_TRUE(model->Backspace());
979 EXPECT_EQ(model->selection(),
TextRange(3));
980 EXPECT_EQ(model->composing_range(),
TextRange(3, 1));
981 EXPECT_STREQ(model->GetText().c_str(),
"ABCE");
985 auto model = std::make_unique<TextInputModel>();
986 model->SetText(
"ABCDE");
989 EXPECT_EQ(model->selection(),
TextRange(1));
990 EXPECT_EQ(model->composing_range(),
TextRange(0));
991 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
995 auto model = std::make_unique<TextInputModel>();
996 model->SetText(
"ABCDE");
999 EXPECT_EQ(model->selection(),
TextRange(3));
1000 EXPECT_EQ(model->composing_range(),
TextRange(0));
1001 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1005 auto model = std::make_unique<TextInputModel>();
1006 model->SetText(
"ABCDE");
1008 EXPECT_FALSE(model->MoveCursorForward());
1009 EXPECT_EQ(model->selection(),
TextRange(5));
1010 EXPECT_EQ(model->composing_range(),
TextRange(0));
1011 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1015 auto model = std::make_unique<TextInputModel>();
1016 model->SetText(
"😄🙃🤪🧐");
1018 ASSERT_TRUE(model->MoveCursorForward());
1019 EXPECT_EQ(model->selection(),
TextRange(6));
1020 EXPECT_EQ(model->composing_range(),
TextRange(0));
1021 EXPECT_STREQ(model->GetText().c_str(),
"😄🙃🤪🧐");
1025 auto model = std::make_unique<TextInputModel>();
1026 model->SetText(
"ABCDE");
1029 EXPECT_EQ(model->selection(),
TextRange(4));
1030 EXPECT_EQ(model->composing_range(),
TextRange(0));
1031 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1035 auto model = std::make_unique<TextInputModel>();
1036 model->SetText(
"ABCDE");
1039 EXPECT_EQ(model->selection(),
TextRange(4));
1040 EXPECT_EQ(model->composing_range(),
TextRange(0));
1041 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1045 auto model = std::make_unique<TextInputModel>();
1046 model->SetText(
"ABCDE");
1047 model->BeginComposing();
1050 EXPECT_EQ(model->selection(),
TextRange(2));
1051 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1052 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1056 auto model = std::make_unique<TextInputModel>();
1057 model->SetText(
"ABCDE");
1058 model->BeginComposing();
1061 EXPECT_EQ(model->selection(),
TextRange(2));
1062 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1063 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1067 auto model = std::make_unique<TextInputModel>();
1068 model->SetText(
"ABCDE");
1069 model->BeginComposing();
1072 EXPECT_EQ(model->selection(),
TextRange(3));
1073 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1074 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1078 auto model = std::make_unique<TextInputModel>();
1079 model->SetText(
"ABCDE");
1080 model->BeginComposing();
1083 EXPECT_EQ(model->selection(),
TextRange(3));
1084 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1085 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1089 auto model = std::make_unique<TextInputModel>();
1090 model->SetText(
"ABCDE");
1091 model->BeginComposing();
1093 EXPECT_FALSE(model->MoveCursorForward());
1094 EXPECT_EQ(model->selection(),
TextRange(4));
1095 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1096 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1100 auto model = std::make_unique<TextInputModel>();
1101 model->SetText(
"ABCDE");
1102 model->BeginComposing();
1104 EXPECT_FALSE(model->MoveCursorForward());
1105 EXPECT_EQ(model->selection(),
TextRange(4));
1106 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1107 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1111 auto model = std::make_unique<TextInputModel>();
1112 model->SetText(
"ABCDE");
1114 EXPECT_FALSE(model->MoveCursorBack());
1115 EXPECT_EQ(model->selection(),
TextRange(0));
1116 EXPECT_EQ(model->composing_range(),
TextRange(0));
1117 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1121 auto model = std::make_unique<TextInputModel>();
1122 model->SetText(
"ABCDE");
1125 EXPECT_EQ(model->selection(),
TextRange(1));
1126 EXPECT_EQ(model->composing_range(),
TextRange(0));
1127 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1131 auto model = std::make_unique<TextInputModel>();
1132 model->SetText(
"ABCDE");
1135 EXPECT_EQ(model->selection(),
TextRange(4));
1136 EXPECT_EQ(model->composing_range(),
TextRange(0));
1137 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1141 auto model = std::make_unique<TextInputModel>();
1142 model->SetText(
"😄🙃🤪🧐");
1144 ASSERT_TRUE(model->MoveCursorBack());
1145 EXPECT_EQ(model->selection(),
TextRange(2));
1146 EXPECT_EQ(model->composing_range(),
TextRange(0));
1147 EXPECT_STREQ(model->GetText().c_str(),
"😄🙃🤪🧐");
1151 auto model = std::make_unique<TextInputModel>();
1152 model->SetText(
"ABCDE");
1155 EXPECT_EQ(model->selection(),
TextRange(1));
1156 EXPECT_EQ(model->composing_range(),
TextRange(0));
1157 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1161 auto model = std::make_unique<TextInputModel>();
1162 model->SetText(
"ABCDE");
1165 EXPECT_EQ(model->selection(),
TextRange(1));
1166 EXPECT_EQ(model->composing_range(),
TextRange(0));
1167 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1171 auto model = std::make_unique<TextInputModel>();
1172 model->SetText(
"ABCDE");
1173 model->BeginComposing();
1176 EXPECT_FALSE(model->MoveCursorBack());
1177 EXPECT_EQ(model->selection(),
TextRange(1));
1178 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1179 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1183 auto model = std::make_unique<TextInputModel>();
1184 model->SetText(
"ABCDE");
1185 model->BeginComposing();
1188 EXPECT_FALSE(model->MoveCursorBack());
1189 EXPECT_EQ(model->selection(),
TextRange(1));
1190 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1191 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1195 auto model = std::make_unique<TextInputModel>();
1196 model->SetText(
"ABCDE");
1197 model->BeginComposing();
1200 EXPECT_EQ(model->selection(),
TextRange(1));
1201 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1202 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1206 auto model = std::make_unique<TextInputModel>();
1207 model->SetText(
"ABCDE");
1208 model->BeginComposing();
1211 EXPECT_EQ(model->selection(),
TextRange(1));
1212 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1213 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1217 auto model = std::make_unique<TextInputModel>();
1218 model->SetText(
"ABCDE");
1219 model->BeginComposing();
1222 EXPECT_EQ(model->selection(),
TextRange(3));
1223 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1224 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1228 auto model = std::make_unique<TextInputModel>();
1229 model->SetText(
"ABCDE");
1230 model->BeginComposing();
1233 EXPECT_EQ(model->selection(),
TextRange(3));
1234 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1235 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1239 auto model = std::make_unique<TextInputModel>();
1240 model->SetText(
"ABCDE");
1242 EXPECT_FALSE(model->MoveCursorToBeginning());
1243 EXPECT_EQ(model->selection(),
TextRange(0));
1244 EXPECT_EQ(model->composing_range(),
TextRange(0));
1245 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1249 auto model = std::make_unique<TextInputModel>();
1250 model->SetText(
"ABCDE");
1252 EXPECT_FALSE(model->SelectToBeginning());
1253 EXPECT_EQ(model->selection(),
TextRange(0));
1254 EXPECT_EQ(model->composing_range(),
TextRange(0));
1255 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1259 auto model = std::make_unique<TextInputModel>();
1260 model->SetText(
"ABCDE");
1263 EXPECT_EQ(model->selection(),
TextRange(0));
1264 EXPECT_EQ(model->composing_range(),
TextRange(0));
1265 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1269 auto model = std::make_unique<TextInputModel>();
1270 model->SetText(
"ABCDE");
1273 EXPECT_EQ(model->selection(),
TextRange(2, 0));
1274 EXPECT_EQ(model->composing_range(),
TextRange(0));
1275 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1279 auto model = std::make_unique<TextInputModel>();
1280 model->SetText(
"ABCDE");
1283 EXPECT_EQ(model->selection(),
TextRange(0));
1284 EXPECT_EQ(model->composing_range(),
TextRange(0));
1285 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1289 auto model = std::make_unique<TextInputModel>();
1290 model->SetText(
"ABCDE");
1293 EXPECT_EQ(model->selection(),
TextRange(5, 0));
1294 EXPECT_EQ(model->composing_range(),
TextRange(0));
1295 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1299 auto model = std::make_unique<TextInputModel>();
1300 model->SetText(
"ABCDE");
1303 EXPECT_EQ(model->selection(),
TextRange(0));
1304 EXPECT_EQ(model->composing_range(),
TextRange(0));
1305 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1309 auto model = std::make_unique<TextInputModel>();
1310 model->SetText(
"ABCDE");
1313 EXPECT_EQ(model->selection(),
TextRange(1, 0));
1314 EXPECT_EQ(model->composing_range(),
TextRange(0));
1315 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1319 auto model = std::make_unique<TextInputModel>();
1320 model->SetText(
"ABCDE");
1323 EXPECT_EQ(model->selection(),
TextRange(0));
1324 EXPECT_EQ(model->composing_range(),
TextRange(0));
1325 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1329 auto model = std::make_unique<TextInputModel>();
1330 model->SetText(
"ABCDE");
1333 EXPECT_EQ(model->selection(),
TextRange(4, 0));
1334 EXPECT_EQ(model->composing_range(),
TextRange(0));
1335 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1339 auto model = std::make_unique<TextInputModel>();
1340 model->SetText(
"ABCDE");
1341 model->BeginComposing();
1343 EXPECT_FALSE(model->MoveCursorToBeginning());
1344 EXPECT_EQ(model->selection(),
TextRange(1));
1345 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1346 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1350 auto model = std::make_unique<TextInputModel>();
1351 model->SetText(
"ABCDE");
1352 model->BeginComposing();
1354 EXPECT_FALSE(model->SelectToBeginning());
1355 EXPECT_EQ(model->selection(),
TextRange(1));
1356 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1357 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1361 auto model = std::make_unique<TextInputModel>();
1362 model->SetText(
"ABCDE");
1363 model->BeginComposing();
1365 EXPECT_FALSE(model->MoveCursorToBeginning());
1366 EXPECT_EQ(model->selection(),
TextRange(1));
1367 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1368 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1372 auto model = std::make_unique<TextInputModel>();
1373 model->SetText(
"ABCDE");
1374 model->BeginComposing();
1376 EXPECT_FALSE(model->SelectToBeginning());
1377 EXPECT_EQ(model->selection(),
TextRange(1));
1378 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1379 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1383 auto model = std::make_unique<TextInputModel>();
1384 model->SetText(
"ABCDE");
1385 model->BeginComposing();
1388 EXPECT_EQ(model->selection(),
TextRange(1));
1389 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1390 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1394 auto model = std::make_unique<TextInputModel>();
1395 model->SetText(
"ABCDE");
1396 model->BeginComposing();
1399 EXPECT_EQ(model->selection(),
TextRange(2, 1));
1400 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1401 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1405 auto model = std::make_unique<TextInputModel>();
1406 model->SetText(
"ABCDE");
1407 model->BeginComposing();
1410 EXPECT_EQ(model->selection(),
TextRange(1));
1411 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1412 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1416 auto model = std::make_unique<TextInputModel>();
1417 model->SetText(
"ABCDE");
1418 model->BeginComposing();
1421 EXPECT_EQ(model->selection(),
TextRange(2, 1));
1422 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1423 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1427 auto model = std::make_unique<TextInputModel>();
1428 model->SetText(
"ABCDE");
1429 model->BeginComposing();
1432 EXPECT_EQ(model->selection(),
TextRange(1));
1433 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1434 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1438 auto model = std::make_unique<TextInputModel>();
1439 model->SetText(
"ABCDE");
1440 model->BeginComposing();
1443 EXPECT_EQ(model->selection(),
TextRange(1));
1444 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1445 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1449 auto model = std::make_unique<TextInputModel>();
1450 model->SetText(
"ABCDE");
1451 model->BeginComposing();
1454 EXPECT_EQ(model->selection(),
TextRange(1));
1455 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1456 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1460 auto model = std::make_unique<TextInputModel>();
1461 model->SetText(
"ABCDE");
1462 model->BeginComposing();
1465 EXPECT_EQ(model->selection(),
TextRange(4, 1));
1466 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1467 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1471 auto model = std::make_unique<TextInputModel>();
1472 model->SetText(
"ABCDE");
1475 EXPECT_EQ(model->selection(),
TextRange(5));
1476 EXPECT_EQ(model->composing_range(),
TextRange(0));
1477 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1481 auto model = std::make_unique<TextInputModel>();
1482 model->SetText(
"ABCDE");
1485 EXPECT_EQ(model->selection(),
TextRange(0, 5));
1486 EXPECT_EQ(model->composing_range(),
TextRange(0));
1487 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1491 auto model = std::make_unique<TextInputModel>();
1492 model->SetText(
"ABCDE");
1495 EXPECT_EQ(model->selection(),
TextRange(5));
1496 EXPECT_EQ(model->composing_range(),
TextRange(0));
1497 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1501 auto model = std::make_unique<TextInputModel>();
1502 model->SetText(
"ABCDE");
1505 EXPECT_EQ(model->selection(),
TextRange(2, 5));
1506 EXPECT_EQ(model->composing_range(),
TextRange(0));
1507 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1511 auto model = std::make_unique<TextInputModel>();
1512 model->SetText(
"ABCDE");
1514 EXPECT_FALSE(model->MoveCursorToEnd());
1515 EXPECT_EQ(model->selection(),
TextRange(5));
1516 EXPECT_EQ(model->composing_range(),
TextRange(0));
1517 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1521 auto model = std::make_unique<TextInputModel>();
1522 model->SetText(
"ABCDE");
1524 EXPECT_FALSE(model->SelectToEnd());
1525 EXPECT_EQ(model->selection(),
TextRange(5));
1526 EXPECT_EQ(model->composing_range(),
TextRange(0));
1527 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1531 auto model = std::make_unique<TextInputModel>();
1532 model->SetText(
"ABCDE");
1535 EXPECT_EQ(model->selection(),
TextRange(5));
1536 EXPECT_EQ(model->composing_range(),
TextRange(0));
1537 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1541 auto model = std::make_unique<TextInputModel>();
1542 model->SetText(
"ABCDE");
1545 EXPECT_EQ(model->selection(),
TextRange(1, 5));
1546 EXPECT_EQ(model->composing_range(),
TextRange(0));
1547 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1551 auto model = std::make_unique<TextInputModel>();
1552 model->SetText(
"ABCDE");
1555 EXPECT_EQ(model->selection(),
TextRange(5));
1556 EXPECT_EQ(model->composing_range(),
TextRange(0));
1557 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1561 auto model = std::make_unique<TextInputModel>();
1562 model->SetText(
"ABCDE");
1565 EXPECT_EQ(model->selection(),
TextRange(4, 5));
1566 EXPECT_EQ(model->composing_range(),
TextRange(0));
1567 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1571 auto model = std::make_unique<TextInputModel>();
1572 model->SetText(
"ABCDE");
1573 model->BeginComposing();
1576 EXPECT_EQ(model->selection(),
TextRange(4));
1577 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1578 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1582 auto model = std::make_unique<TextInputModel>();
1583 model->SetText(
"ABCDE");
1584 model->BeginComposing();
1587 EXPECT_EQ(model->selection(),
TextRange(1, 4));
1588 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1589 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1593 auto model = std::make_unique<TextInputModel>();
1594 model->SetText(
"ABCDE");
1595 model->BeginComposing();
1598 EXPECT_EQ(model->selection(),
TextRange(4));
1599 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1600 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1604 auto model = std::make_unique<TextInputModel>();
1605 model->SetText(
"ABCDE");
1606 model->BeginComposing();
1609 EXPECT_EQ(model->selection(),
TextRange(1, 4));
1610 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1611 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1615 auto model = std::make_unique<TextInputModel>();
1616 model->SetText(
"ABCDE");
1617 model->BeginComposing();
1620 EXPECT_EQ(model->selection(),
TextRange(4));
1621 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1622 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1626 auto model = std::make_unique<TextInputModel>();
1627 model->SetText(
"ABCDE");
1628 model->BeginComposing();
1631 EXPECT_EQ(model->selection(),
TextRange(2, 4));
1632 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1633 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1637 auto model = std::make_unique<TextInputModel>();
1638 model->SetText(
"ABCDE");
1639 model->BeginComposing();
1642 EXPECT_EQ(model->selection(),
TextRange(4));
1643 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1644 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1648 auto model = std::make_unique<TextInputModel>();
1649 model->SetText(
"ABCDE");
1650 model->BeginComposing();
1653 EXPECT_EQ(model->selection(),
TextRange(2, 4));
1654 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1655 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1659 auto model = std::make_unique<TextInputModel>();
1660 model->SetText(
"ABCDE");
1661 model->BeginComposing();
1663 EXPECT_FALSE(model->MoveCursorToEnd());
1664 EXPECT_EQ(model->selection(),
TextRange(4));
1665 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1666 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1670 auto model = std::make_unique<TextInputModel>();
1671 model->SetText(
"ABCDE");
1672 model->BeginComposing();
1674 EXPECT_FALSE(model->SelectToEnd());
1675 EXPECT_EQ(model->selection(),
TextRange(4));
1676 EXPECT_EQ(model->composing_range(),
TextRange(1, 4));
1677 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1681 auto model = std::make_unique<TextInputModel>();
1682 model->SetText(
"ABCDE");
1683 model->BeginComposing();
1685 EXPECT_FALSE(model->MoveCursorToEnd());
1686 EXPECT_EQ(model->selection(),
TextRange(4));
1687 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1688 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1692 auto model = std::make_unique<TextInputModel>();
1693 model->SetText(
"ABCDE");
1694 model->BeginComposing();
1696 EXPECT_FALSE(model->SelectToEnd());
1697 EXPECT_EQ(model->selection(),
TextRange(4));
1698 EXPECT_EQ(model->composing_range(),
TextRange(4, 1));
1699 EXPECT_STREQ(model->GetText().c_str(),
"ABCDE");
1703 auto model = std::make_unique<TextInputModel>();
1705 model->SetText(
"$¢€𐍈");
1707 EXPECT_EQ(model->GetCursorOffset(), 0);
1709 EXPECT_EQ(model->GetCursorOffset(), 1);
1711 EXPECT_EQ(model->GetCursorOffset(), 3);
1713 EXPECT_EQ(model->GetCursorOffset(), 6);
1715 EXPECT_EQ(model->GetCursorOffset(), 10);
1719 auto model = std::make_unique<TextInputModel>();
1720 model->SetText(
"ABCDE");
1722 EXPECT_EQ(model->GetCursorOffset(), 4);
1726 auto model = std::make_unique<TextInputModel>();
1727 model->SetText(
"ABCDE");
1729 EXPECT_EQ(model->GetCursorOffset(), 1);
TEST(FrameTimingsRecorderTest, RecordVsync)
SkRange< size_t > TextRange
#define EXPECT_TRUE(handle)