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

Side by Side Diff: ui/views/controls/textfield/textfield_views_model_unittest.cc

Issue 117983002: Prefix string16 with base:: in ui/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <vector> 5 #include <vector>
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 : ViewsTestBase(), 49 : ViewsTestBase(),
50 composition_text_confirmed_or_cleared_(false) { 50 composition_text_confirmed_or_cleared_(false) {
51 } 51 }
52 52
53 virtual void OnCompositionTextConfirmedOrCleared() OVERRIDE { 53 virtual void OnCompositionTextConfirmedOrCleared() OVERRIDE {
54 composition_text_confirmed_or_cleared_ = true; 54 composition_text_confirmed_or_cleared_ = true;
55 } 55 }
56 56
57 protected: 57 protected:
58 void ResetModel(TextfieldViewsModel* model) const { 58 void ResetModel(TextfieldViewsModel* model) const {
59 model->SetText(string16()); 59 model->SetText(base::string16());
60 model->ClearEditHistory(); 60 model->ClearEditHistory();
61 } 61 }
62 62
63 bool composition_text_confirmed_or_cleared_; 63 bool composition_text_confirmed_or_cleared_;
64 64
65 private: 65 private:
66 DISALLOW_COPY_AND_ASSIGN(TextfieldViewsModelTest); 66 DISALLOW_COPY_AND_ASSIGN(TextfieldViewsModelTest);
67 }; 67 };
68 68
69 TEST_F(TextfieldViewsModelTest, EditString) { 69 TEST_F(TextfieldViewsModelTest, EditString) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // The first 2 characters are not strong directionality characters. 236 // The first 2 characters are not strong directionality characters.
237 model.SetText(WideToUTF16(L"\x002C\x0020\x05D1\x05BC\x05B7\x05E9\x05BC")); 237 model.SetText(WideToUTF16(L"\x002C\x0020\x05D1\x05BC\x05B7\x05E9\x05BC"));
238 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_LEFT, false); 238 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_LEFT, false);
239 EXPECT_TRUE(model.Backspace()); 239 EXPECT_TRUE(model.Backspace());
240 EXPECT_EQ(WideToUTF16(L"\x002C\x0020\x05D1\x05BC\x05B7\x05E9"), 240 EXPECT_EQ(WideToUTF16(L"\x002C\x0020\x05D1\x05BC\x05B7\x05E9"),
241 model.GetText()); 241 model.GetText());
242 } 242 }
243 243
244 TEST_F(TextfieldViewsModelTest, EmptyString) { 244 TEST_F(TextfieldViewsModelTest, EmptyString) {
245 TextfieldViewsModel model(NULL); 245 TextfieldViewsModel model(NULL);
246 EXPECT_EQ(string16(), model.GetText()); 246 EXPECT_EQ(base::string16(), model.GetText());
247 EXPECT_EQ(string16(), model.GetSelectedText()); 247 EXPECT_EQ(base::string16(), model.GetSelectedText());
248 248
249 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_LEFT, true); 249 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_LEFT, true);
250 EXPECT_EQ(0U, model.GetCursorPosition()); 250 EXPECT_EQ(0U, model.GetCursorPosition());
251 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true); 251 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true);
252 EXPECT_EQ(0U, model.GetCursorPosition()); 252 EXPECT_EQ(0U, model.GetCursorPosition());
253 253
254 EXPECT_EQ(string16(), model.GetSelectedText()); 254 EXPECT_EQ(base::string16(), model.GetSelectedText());
255 255
256 EXPECT_FALSE(model.Delete()); 256 EXPECT_FALSE(model.Delete());
257 EXPECT_FALSE(model.Backspace()); 257 EXPECT_FALSE(model.Backspace());
258 } 258 }
259 259
260 TEST_F(TextfieldViewsModelTest, Selection) { 260 TEST_F(TextfieldViewsModelTest, Selection) {
261 TextfieldViewsModel model(NULL); 261 TextfieldViewsModel model(NULL);
262 model.Append(ASCIIToUTF16("HELLO")); 262 model.Append(ASCIIToUTF16("HELLO"));
263 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, false); 263 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, false);
264 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true); 264 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true);
265 EXPECT_STR_EQ("E", model.GetSelectedText()); 265 EXPECT_STR_EQ("E", model.GetSelectedText());
266 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true); 266 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true);
267 EXPECT_STR_EQ("EL", model.GetSelectedText()); 267 EXPECT_STR_EQ("EL", model.GetSelectedText());
268 268
269 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_LEFT, true); 269 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_LEFT, true);
270 EXPECT_STR_EQ("H", model.GetSelectedText()); 270 EXPECT_STR_EQ("H", model.GetSelectedText());
271 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, true); 271 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, true);
272 EXPECT_STR_EQ("ELLO", model.GetSelectedText()); 272 EXPECT_STR_EQ("ELLO", model.GetSelectedText());
273 model.ClearSelection(); 273 model.ClearSelection();
274 EXPECT_EQ(string16(), model.GetSelectedText()); 274 EXPECT_EQ(base::string16(), model.GetSelectedText());
275 275
276 // SelectAll(false) selects towards the end. 276 // SelectAll(false) selects towards the end.
277 model.SelectAll(false); 277 model.SelectAll(false);
278 EXPECT_STR_EQ("HELLO", model.GetSelectedText()); 278 EXPECT_STR_EQ("HELLO", model.GetSelectedText());
279 EXPECT_EQ(gfx::Range(0, 5), model.render_text()->selection()); 279 EXPECT_EQ(gfx::Range(0, 5), model.render_text()->selection());
280 280
281 // SelectAll(true) selects towards the beginning. 281 // SelectAll(true) selects towards the beginning.
282 model.SelectAll(true); 282 model.SelectAll(true);
283 EXPECT_STR_EQ("HELLO", model.GetSelectedText()); 283 EXPECT_STR_EQ("HELLO", model.GetSelectedText());
284 EXPECT_EQ(gfx::Range(5, 0), model.render_text()->selection()); 284 EXPECT_EQ(gfx::Range(5, 0), model.render_text()->selection());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true); 329 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true);
330 EXPECT_EQ(gfx::Range(2, 3), model.render_text()->selection()); 330 EXPECT_EQ(gfx::Range(2, 3), model.render_text()->selection());
331 EXPECT_EQ(WideToUTF16(L"c"), model.GetSelectedText()); 331 EXPECT_EQ(WideToUTF16(L"c"), model.GetSelectedText());
332 332
333 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true); 333 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true);
334 EXPECT_EQ(gfx::Range(2, 10), model.render_text()->selection()); 334 EXPECT_EQ(gfx::Range(2, 10), model.render_text()->selection());
335 EXPECT_EQ(WideToUTF16(L"c\x05E9\x05BC\x05C1\x05B8\x05E0\x05B8" L"d"), 335 EXPECT_EQ(WideToUTF16(L"c\x05E9\x05BC\x05C1\x05B8\x05E0\x05B8" L"d"),
336 model.GetSelectedText()); 336 model.GetSelectedText());
337 337
338 model.ClearSelection(); 338 model.ClearSelection();
339 EXPECT_EQ(string16(), model.GetSelectedText()); 339 EXPECT_EQ(base::string16(), model.GetSelectedText());
340 model.SelectAll(false); 340 model.SelectAll(false);
341 EXPECT_EQ(WideToUTF16(L"abc\x05E9\x05BC\x05C1\x05B8\x05E0\x05B8" L"def"), 341 EXPECT_EQ(WideToUTF16(L"abc\x05E9\x05BC\x05C1\x05B8\x05E0\x05B8" L"def"),
342 model.GetSelectedText()); 342 model.GetSelectedText());
343 #endif 343 #endif
344 344
345 // In case of "aBc", this test shows how to select "aB" or "Bc", assume 'B' is 345 // In case of "aBc", this test shows how to select "aB" or "Bc", assume 'B' is
346 // an RTL character. 346 // an RTL character.
347 model.SetText(WideToUTF16(L"a\x05E9" L"b")); 347 model.SetText(WideToUTF16(L"a\x05E9" L"b"));
348 MoveCursorTo(model, 0); 348 MoveCursorTo(model, 0);
349 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true); 349 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true);
(...skipping 22 matching lines...) Expand all
372 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_LEFT, true); 372 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_LEFT, true);
373 EXPECT_EQ(WideToUTF16(L"a\x05E9"), model.GetSelectedText()); 373 EXPECT_EQ(WideToUTF16(L"a\x05E9"), model.GetSelectedText());
374 374
375 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); 375 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false);
376 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_LEFT, true); 376 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_LEFT, true);
377 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_LEFT, true); 377 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_LEFT, true);
378 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true); 378 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true);
379 EXPECT_EQ(WideToUTF16(L"\x05E9" L"b"), model.GetSelectedText()); 379 EXPECT_EQ(WideToUTF16(L"\x05E9" L"b"), model.GetSelectedText());
380 380
381 model.ClearSelection(); 381 model.ClearSelection();
382 EXPECT_EQ(string16(), model.GetSelectedText()); 382 EXPECT_EQ(base::string16(), model.GetSelectedText());
383 model.SelectAll(false); 383 model.SelectAll(false);
384 EXPECT_EQ(WideToUTF16(L"a\x05E9" L"b"), model.GetSelectedText()); 384 EXPECT_EQ(WideToUTF16(L"a\x05E9" L"b"), model.GetSelectedText());
385 } 385 }
386 386
387 TEST_F(TextfieldViewsModelTest, SelectionAndEdit) { 387 TEST_F(TextfieldViewsModelTest, SelectionAndEdit) {
388 TextfieldViewsModel model(NULL); 388 TextfieldViewsModel model(NULL);
389 model.Append(ASCIIToUTF16("HELLO")); 389 model.Append(ASCIIToUTF16("HELLO"));
390 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, false); 390 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, false);
391 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true); 391 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true);
392 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true); // "EL" 392 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, true); // "EL"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true); 449 model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true);
450 EXPECT_STR_EQ("to Life", model.GetSelectedText()); 450 EXPECT_STR_EQ("to Life", model.GetSelectedText());
451 model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true); 451 model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true);
452 model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true); 452 model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true);
453 model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true); // Now at start. 453 model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true); // Now at start.
454 EXPECT_STR_EQ("The answer to Life", model.GetSelectedText()); 454 EXPECT_STR_EQ("The answer to Life", model.GetSelectedText());
455 // Should be safe to go to the previous word at the beginning. 455 // Should be safe to go to the previous word at the beginning.
456 model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true); 456 model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, true);
457 EXPECT_STR_EQ("The answer to Life", model.GetSelectedText()); 457 EXPECT_STR_EQ("The answer to Life", model.GetSelectedText());
458 model.ReplaceChar('4'); 458 model.ReplaceChar('4');
459 EXPECT_EQ(string16(), model.GetSelectedText()); 459 EXPECT_EQ(base::string16(), model.GetSelectedText());
460 EXPECT_STR_EQ("42", model.GetText()); 460 EXPECT_STR_EQ("42", model.GetText());
461 } 461 }
462 462
463 TEST_F(TextfieldViewsModelTest, SetText) { 463 TEST_F(TextfieldViewsModelTest, SetText) {
464 TextfieldViewsModel model(NULL); 464 TextfieldViewsModel model(NULL);
465 model.Append(ASCIIToUTF16("HELLO")); 465 model.Append(ASCIIToUTF16("HELLO"));
466 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); 466 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false);
467 model.SetText(ASCIIToUTF16("GOODBYE")); 467 model.SetText(ASCIIToUTF16("GOODBYE"));
468 EXPECT_STR_EQ("GOODBYE", model.GetText()); 468 EXPECT_STR_EQ("GOODBYE", model.GetText());
469 // SetText move the cursor to the end of the new text. 469 // SetText move the cursor to the end of the new text.
470 EXPECT_EQ(7U, model.GetCursorPosition()); 470 EXPECT_EQ(7U, model.GetCursorPosition());
471 model.SelectAll(false); 471 model.SelectAll(false);
472 EXPECT_STR_EQ("GOODBYE", model.GetSelectedText()); 472 EXPECT_STR_EQ("GOODBYE", model.GetSelectedText());
473 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); 473 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false);
474 EXPECT_EQ(7U, model.GetCursorPosition()); 474 EXPECT_EQ(7U, model.GetCursorPosition());
475 475
476 model.SetText(ASCIIToUTF16("BYE")); 476 model.SetText(ASCIIToUTF16("BYE"));
477 // Setting shorter string moves the cursor to the end of the new string. 477 // Setting shorter string moves the cursor to the end of the new string.
478 EXPECT_EQ(3U, model.GetCursorPosition()); 478 EXPECT_EQ(3U, model.GetCursorPosition());
479 EXPECT_EQ(string16(), model.GetSelectedText()); 479 EXPECT_EQ(base::string16(), model.GetSelectedText());
480 model.SetText(string16()); 480 model.SetText(base::string16());
481 EXPECT_EQ(0U, model.GetCursorPosition()); 481 EXPECT_EQ(0U, model.GetCursorPosition());
482 } 482 }
483 483
484 TEST_F(TextfieldViewsModelTest, Clipboard) { 484 TEST_F(TextfieldViewsModelTest, Clipboard) {
485 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 485 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
486 const string16 initial_clipboard_text = ASCIIToUTF16("initial text"); 486 const base::string16 initial_clipboard_text = ASCIIToUTF16("initial text");
487 ui::ScopedClipboardWriter(clipboard, ui::CLIPBOARD_TYPE_COPY_PASTE). 487 ui::ScopedClipboardWriter(clipboard, ui::CLIPBOARD_TYPE_COPY_PASTE).
488 WriteText(initial_clipboard_text); 488 WriteText(initial_clipboard_text);
489 489
490 string16 clipboard_text; 490 base::string16 clipboard_text;
491 TextfieldViewsModel model(NULL); 491 TextfieldViewsModel model(NULL);
492 model.Append(ASCIIToUTF16("HELLO WORLD")); 492 model.Append(ASCIIToUTF16("HELLO WORLD"));
493 493
494 // Cut with an empty selection should do nothing. 494 // Cut with an empty selection should do nothing.
495 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); 495 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false);
496 EXPECT_FALSE(model.Cut()); 496 EXPECT_FALSE(model.Cut());
497 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &clipboard_text); 497 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &clipboard_text);
498 EXPECT_EQ(initial_clipboard_text, clipboard_text); 498 EXPECT_EQ(initial_clipboard_text, clipboard_text);
499 EXPECT_STR_EQ("HELLO WORLD", model.GetText()); 499 EXPECT_STR_EQ("HELLO WORLD", model.GetText());
500 EXPECT_EQ(11U, model.GetCursorPosition()); 500 EXPECT_EQ(11U, model.GetCursorPosition());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false); 545 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, false);
546 EXPECT_TRUE(model.Paste()); 546 EXPECT_TRUE(model.Paste());
547 EXPECT_STR_EQ("HELLO HELLO ", model.GetText()); 547 EXPECT_STR_EQ("HELLO HELLO ", model.GetText());
548 EXPECT_EQ(12U, model.GetCursorPosition()); 548 EXPECT_EQ(12U, model.GetCursorPosition());
549 model.render_text()->SetObscured(true); 549 model.render_text()->SetObscured(true);
550 EXPECT_TRUE(model.Paste()); 550 EXPECT_TRUE(model.Paste());
551 EXPECT_STR_EQ("HELLO HELLO HELLO ", model.GetText()); 551 EXPECT_STR_EQ("HELLO HELLO HELLO ", model.GetText());
552 EXPECT_EQ(18U, model.GetCursorPosition()); 552 EXPECT_EQ(18U, model.GetCursorPosition());
553 } 553 }
554 554
555 static void SelectWordTestVerifier(const TextfieldViewsModel& model, 555 static void SelectWordTestVerifier(
556 const string16 &expected_selected_string, size_t expected_cursor_pos) { 556 const TextfieldViewsModel& model,
557 const base::string16 &expected_selected_string,
558 size_t expected_cursor_pos) {
557 EXPECT_EQ(expected_selected_string, model.GetSelectedText()); 559 EXPECT_EQ(expected_selected_string, model.GetSelectedText());
558 EXPECT_EQ(expected_cursor_pos, model.GetCursorPosition()); 560 EXPECT_EQ(expected_cursor_pos, model.GetCursorPosition());
559 } 561 }
560 562
561 TEST_F(TextfieldViewsModelTest, SelectWordTest) { 563 TEST_F(TextfieldViewsModelTest, SelectWordTest) {
562 TextfieldViewsModel model(NULL); 564 TextfieldViewsModel model(NULL);
563 model.Append(ASCIIToUTF16(" HELLO !! WO RLD ")); 565 model.Append(ASCIIToUTF16(" HELLO !! WO RLD "));
564 566
565 // Test when cursor is at the beginning. 567 // Test when cursor is at the beginning.
566 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_LEFT, false); 568 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_LEFT, false);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 EXPECT_TRUE(composition_text_confirmed_or_cleared_); 908 EXPECT_TRUE(composition_text_confirmed_or_cleared_);
907 composition_text_confirmed_or_cleared_ = false; 909 composition_text_confirmed_or_cleared_ = false;
908 EXPECT_STR_EQ("1234567890-678-", model.GetText()); 910 EXPECT_STR_EQ("1234567890-678-", model.GetText());
909 911
910 model.SetCompositionText(composition); 912 model.SetCompositionText(composition);
911 model.Backspace(); 913 model.Backspace();
912 EXPECT_TRUE(composition_text_confirmed_or_cleared_); 914 EXPECT_TRUE(composition_text_confirmed_or_cleared_);
913 composition_text_confirmed_or_cleared_ = false; 915 composition_text_confirmed_or_cleared_ = false;
914 EXPECT_STR_EQ("1234567890-678-", model.GetText()); 916 EXPECT_STR_EQ("1234567890-678-", model.GetText());
915 917
916 model.SetText(string16()); 918 model.SetText(base::string16());
917 model.SetCompositionText(composition); 919 model.SetCompositionText(composition);
918 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_LEFT, false); 920 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_LEFT, false);
919 EXPECT_TRUE(composition_text_confirmed_or_cleared_); 921 EXPECT_TRUE(composition_text_confirmed_or_cleared_);
920 composition_text_confirmed_or_cleared_ = false; 922 composition_text_confirmed_or_cleared_ = false;
921 EXPECT_STR_EQ("678", model.GetText()); 923 EXPECT_STR_EQ("678", model.GetText());
922 EXPECT_EQ(2U, model.GetCursorPosition()); 924 EXPECT_EQ(2U, model.GetCursorPosition());
923 925
924 model.SetCompositionText(composition); 926 model.SetCompositionText(composition);
925 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, false); 927 model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT, false);
926 EXPECT_TRUE(composition_text_confirmed_or_cleared_); 928 EXPECT_TRUE(composition_text_confirmed_or_cleared_);
927 composition_text_confirmed_or_cleared_ = false; 929 composition_text_confirmed_or_cleared_ = false;
928 EXPECT_STR_EQ("676788", model.GetText()); 930 EXPECT_STR_EQ("676788", model.GetText());
929 EXPECT_EQ(6U, model.GetCursorPosition()); 931 EXPECT_EQ(6U, model.GetCursorPosition());
930 932
931 model.SetCompositionText(composition); 933 model.SetCompositionText(composition);
932 model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, false); 934 model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_LEFT, false);
933 EXPECT_TRUE(composition_text_confirmed_or_cleared_); 935 EXPECT_TRUE(composition_text_confirmed_or_cleared_);
934 composition_text_confirmed_or_cleared_ = false; 936 composition_text_confirmed_or_cleared_ = false;
935 EXPECT_STR_EQ("676788678", model.GetText()); 937 EXPECT_STR_EQ("676788678", model.GetText());
936 938
937 model.SetText(string16()); 939 model.SetText(base::string16());
938 model.SetCompositionText(composition); 940 model.SetCompositionText(composition);
939 model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_RIGHT, false); 941 model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_RIGHT, false);
940 EXPECT_TRUE(composition_text_confirmed_or_cleared_); 942 EXPECT_TRUE(composition_text_confirmed_or_cleared_);
941 composition_text_confirmed_or_cleared_ = false; 943 composition_text_confirmed_or_cleared_ = false;
942 944
943 model.SetCompositionText(composition); 945 model.SetCompositionText(composition);
944 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_LEFT, true); 946 model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_LEFT, true);
945 EXPECT_TRUE(composition_text_confirmed_or_cleared_); 947 EXPECT_TRUE(composition_text_confirmed_or_cleared_);
946 composition_text_confirmed_or_cleared_ = false; 948 composition_text_confirmed_or_cleared_ = false;
947 EXPECT_STR_EQ("678678", model.GetText()); 949 EXPECT_STR_EQ("678678", model.GetText());
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 EXPECT_TRUE(model.Undo()); 1509 EXPECT_TRUE(model.Undo());
1508 EXPECT_STR_EQ("ABCDE", model.GetText()); 1510 EXPECT_STR_EQ("ABCDE", model.GetText());
1509 EXPECT_TRUE(model.Redo()); 1511 EXPECT_TRUE(model.Redo());
1510 EXPECT_STR_EQ("1234", model.GetText()); 1512 EXPECT_STR_EQ("1234", model.GetText());
1511 EXPECT_FALSE(model.Redo()); 1513 EXPECT_FALSE(model.Redo());
1512 1514
1513 // TODO(oshima): We need MockInputMethod to test the behavior with IME. 1515 // TODO(oshima): We need MockInputMethod to test the behavior with IME.
1514 } 1516 }
1515 1517
1516 } // namespace views 1518 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield_views_model.cc ('k') | ui/views/controls/tree/tree_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698