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

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

Issue 10412009: Enable disabled omnibox tests on aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/auto_reset.h" 8 #include "base/auto_reset.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 EXPECT_TRUE(last_contents_.empty()); 359 EXPECT_TRUE(last_contents_.empty());
360 } 360 }
361 361
362 TEST_F(NativeTextfieldViewsTest, ModelChangesTestLowerCase) { 362 TEST_F(NativeTextfieldViewsTest, ModelChangesTestLowerCase) {
363 // Check if |model_|'s text is properly lowercased for STYLE_LOWERCASE. 363 // Check if |model_|'s text is properly lowercased for STYLE_LOWERCASE.
364 InitTextfield(Textfield::STYLE_LOWERCASE); 364 InitTextfield(Textfield::STYLE_LOWERCASE);
365 EXPECT_EQ(0U, textfield_->GetCursorPosition()); 365 EXPECT_EQ(0U, textfield_->GetCursorPosition());
366 366
367 last_contents_.clear(); 367 last_contents_.clear();
368 textfield_->SetText(ASCIIToUTF16("THIS IS")); 368 textfield_->SetText(ASCIIToUTF16("THIS IS"));
369 EXPECT_EQ(0U, textfield_->GetCursorPosition()); 369 EXPECT_EQ(7U, textfield_->GetCursorPosition());
370 370
371 EXPECT_STR_EQ("this is", model_->GetText()); 371 EXPECT_STR_EQ("this is", model_->GetText());
372 EXPECT_STR_EQ("THIS IS", textfield_->text()); 372 EXPECT_STR_EQ("THIS IS", textfield_->text());
373 EXPECT_TRUE(last_contents_.empty()); 373 EXPECT_TRUE(last_contents_.empty());
374 374
375 textfield_->AppendText(ASCIIToUTF16(" A TEST")); 375 textfield_->AppendText(ASCIIToUTF16(" A TEST"));
376 EXPECT_EQ(0U, textfield_->GetCursorPosition()); 376 EXPECT_EQ(7U, textfield_->GetCursorPosition());
377 EXPECT_STR_EQ("this is a test", model_->GetText()); 377 EXPECT_STR_EQ("this is a test", model_->GetText());
378 EXPECT_STR_EQ("THIS IS A TEST", textfield_->text()); 378 EXPECT_STR_EQ("THIS IS A TEST", textfield_->text());
379 379
380 EXPECT_TRUE(last_contents_.empty()); 380 EXPECT_TRUE(last_contents_.empty());
381 } 381 }
382 382
383 TEST_F(NativeTextfieldViewsTest, ModelChangesTestLowerCaseI18n) { 383 TEST_F(NativeTextfieldViewsTest, ModelChangesTestLowerCaseI18n) {
384 // Check if lower case conversion works for non-ASCII characters. 384 // Check if lower case conversion works for non-ASCII characters.
385 InitTextfield(Textfield::STYLE_LOWERCASE); 385 InitTextfield(Textfield::STYLE_LOWERCASE);
386 EXPECT_EQ(0U, textfield_->GetCursorPosition()); 386 EXPECT_EQ(0U, textfield_->GetCursorPosition());
387 387
388 last_contents_.clear(); 388 last_contents_.clear();
389 // Zenkaku Japanese "ABCabc" 389 // Zenkaku Japanese "ABCabc"
390 textfield_->SetText(WideToUTF16(L"\xFF21\xFF22\xFF23\xFF41\xFF42\xFF43")); 390 textfield_->SetText(WideToUTF16(L"\xFF21\xFF22\xFF23\xFF41\xFF42\xFF43"));
391 EXPECT_EQ(0U, textfield_->GetCursorPosition()); 391 EXPECT_EQ(6U, textfield_->GetCursorPosition());
392 // Zenkaku Japanese "abcabc" 392 // Zenkaku Japanese "abcabc"
393 EXPECT_EQ(WideToUTF16(L"\xFF41\xFF42\xFF43\xFF41\xFF42\xFF43"), 393 EXPECT_EQ(WideToUTF16(L"\xFF41\xFF42\xFF43\xFF41\xFF42\xFF43"),
394 model_->GetText()); 394 model_->GetText());
395 // Zenkaku Japanese "ABCabc" 395 // Zenkaku Japanese "ABCabc"
396 EXPECT_EQ(WideToUTF16(L"\xFF21\xFF22\xFF23\xFF41\xFF42\xFF43"), 396 EXPECT_EQ(WideToUTF16(L"\xFF21\xFF22\xFF23\xFF41\xFF42\xFF43"),
397 textfield_->text()); 397 textfield_->text());
398 EXPECT_TRUE(last_contents_.empty()); 398 EXPECT_TRUE(last_contents_.empty());
399 399
400 // Zenkaku Japanese "XYZxyz" 400 // Zenkaku Japanese "XYZxyz"
401 textfield_->AppendText(WideToUTF16(L"\xFF38\xFF39\xFF3A\xFF58\xFF59\xFF5A")); 401 textfield_->AppendText(WideToUTF16(L"\xFF38\xFF39\xFF3A\xFF58\xFF59\xFF5A"));
402 EXPECT_EQ(0U, textfield_->GetCursorPosition()); 402 EXPECT_EQ(6U, textfield_->GetCursorPosition());
403 // Zenkaku Japanese "abcabcxyzxyz" 403 // Zenkaku Japanese "abcabcxyzxyz"
404 EXPECT_EQ(WideToUTF16(L"\xFF41\xFF42\xFF43\xFF41\xFF42\xFF43" 404 EXPECT_EQ(WideToUTF16(L"\xFF41\xFF42\xFF43\xFF41\xFF42\xFF43"
405 L"\xFF58\xFF59\xFF5A\xFF58\xFF59\xFF5A"), 405 L"\xFF58\xFF59\xFF5A\xFF58\xFF59\xFF5A"),
406 model_->GetText()); 406 model_->GetText());
407 // Zenkaku Japanese "ABCabcXYZxyz" 407 // Zenkaku Japanese "ABCabcXYZxyz"
408 EXPECT_EQ(WideToUTF16(L"\xFF21\xFF22\xFF23\xFF41\xFF42\xFF43" 408 EXPECT_EQ(WideToUTF16(L"\xFF21\xFF22\xFF23\xFF41\xFF42\xFF43"
409 L"\xFF38\xFF39\xFF3A\xFF58\xFF59\xFF5A"), 409 L"\xFF38\xFF39\xFF3A\xFF58\xFF59\xFF5A"),
410 textfield_->text()); 410 textfield_->text());
411 EXPECT_TRUE(last_contents_.empty()); 411 EXPECT_TRUE(last_contents_.empty());
412 } 412 }
413 413
414 TEST_F(NativeTextfieldViewsTest, ModelChangesTestLowerCaseWithLocale) { 414 TEST_F(NativeTextfieldViewsTest, ModelChangesTestLowerCaseWithLocale) {
415 // Check if lower case conversion honors locale properly. 415 // Check if lower case conversion honors locale properly.
416 std::string locale = l10n_util::GetApplicationLocale(""); 416 std::string locale = l10n_util::GetApplicationLocale("");
417 base::i18n::SetICUDefaultLocale("tr"); 417 base::i18n::SetICUDefaultLocale("tr");
418 418
419 InitTextfield(Textfield::STYLE_LOWERCASE); 419 InitTextfield(Textfield::STYLE_LOWERCASE);
420 EXPECT_EQ(0U, textfield_->GetCursorPosition()); 420 EXPECT_EQ(0U, textfield_->GetCursorPosition());
421 421
422 last_contents_.clear(); 422 last_contents_.clear();
423 // Turkish 'I' should be converted to dotless 'i' (U+0131). 423 // Turkish 'I' should be converted to dotless 'i' (U+0131).
424 textfield_->SetText(WideToUTF16(L"I")); 424 textfield_->SetText(WideToUTF16(L"I"));
425 EXPECT_EQ(0U, textfield_->GetCursorPosition()); 425 EXPECT_EQ(1U, textfield_->GetCursorPosition());
426 EXPECT_EQ(WideToUTF16(L"\x0131"), model_->GetText()); 426 EXPECT_EQ(WideToUTF16(L"\x0131"), model_->GetText());
427 EXPECT_EQ(WideToUTF16(L"I"), textfield_->text()); 427 EXPECT_EQ(WideToUTF16(L"I"), textfield_->text());
428 EXPECT_TRUE(last_contents_.empty()); 428 EXPECT_TRUE(last_contents_.empty());
429 429
430 base::i18n::SetICUDefaultLocale(locale); 430 base::i18n::SetICUDefaultLocale(locale);
431 431
432 // On default (en) locale, 'I' should be converted to 'i'. 432 // On default (en) locale, 'I' should be converted to 'i'.
433 textfield_->SetText(WideToUTF16(L"I")); 433 textfield_->SetText(WideToUTF16(L"I"));
434 EXPECT_EQ(0U, textfield_->GetCursorPosition()); 434 EXPECT_EQ(1U, textfield_->GetCursorPosition());
435 EXPECT_EQ(WideToUTF16(L"i"), model_->GetText()); 435 EXPECT_EQ(WideToUTF16(L"i"), model_->GetText());
436 EXPECT_EQ(WideToUTF16(L"I"), textfield_->text()); 436 EXPECT_EQ(WideToUTF16(L"I"), textfield_->text());
437 EXPECT_TRUE(last_contents_.empty()); 437 EXPECT_TRUE(last_contents_.empty());
438 } 438 }
439 439
440 TEST_F(NativeTextfieldViewsTest, KeyTest) { 440 TEST_F(NativeTextfieldViewsTest, KeyTest) {
441 InitTextfield(Textfield::STYLE_DEFAULT); 441 InitTextfield(Textfield::STYLE_DEFAULT);
442 SendKeyEvent(ui::VKEY_C, true, false); 442 SendKeyEvent(ui::VKEY_C, true, false);
443 EXPECT_STR_EQ("C", textfield_->text()); 443 EXPECT_STR_EQ("C", textfield_->text());
444 EXPECT_STR_EQ("C", last_contents_); 444 EXPECT_STR_EQ("C", last_contents_);
(...skipping 10 matching lines...) Expand all
455 SendKeyEvent(ui::VKEY_1, true, false, true); 455 SendKeyEvent(ui::VKEY_1, true, false, true);
456 SendKeyEvent(ui::VKEY_1, true, false, false); 456 SendKeyEvent(ui::VKEY_1, true, false, false);
457 EXPECT_STR_EQ("cC1!!", textfield_->text()); 457 EXPECT_STR_EQ("cC1!!", textfield_->text());
458 EXPECT_STR_EQ("cC1!!", last_contents_); 458 EXPECT_STR_EQ("cC1!!", last_contents_);
459 } 459 }
460 460
461 TEST_F(NativeTextfieldViewsTest, ControlAndSelectTest) { 461 TEST_F(NativeTextfieldViewsTest, ControlAndSelectTest) {
462 // Insert a test string in a textfield. 462 // Insert a test string in a textfield.
463 InitTextfield(Textfield::STYLE_DEFAULT); 463 InitTextfield(Textfield::STYLE_DEFAULT);
464 textfield_->SetText(ASCIIToUTF16("one two three")); 464 textfield_->SetText(ASCIIToUTF16("one two three"));
465 SendKeyEvent(ui::VKEY_RIGHT, 465 SendKeyEvent(ui::VKEY_HOME, false /* shift */, false /* control */);
466 true /* shift */, false /* control */); 466 SendKeyEvent(ui::VKEY_RIGHT, true, false);
467 SendKeyEvent(ui::VKEY_RIGHT, true, false); 467 SendKeyEvent(ui::VKEY_RIGHT, true, false);
468 SendKeyEvent(ui::VKEY_RIGHT, true, false); 468 SendKeyEvent(ui::VKEY_RIGHT, true, false);
469 469
470 EXPECT_STR_EQ("one", textfield_->GetSelectedText()); 470 EXPECT_STR_EQ("one", textfield_->GetSelectedText());
471 471
472 // Test word select. 472 // Test word select.
473 SendKeyEvent(ui::VKEY_RIGHT, true, true); 473 SendKeyEvent(ui::VKEY_RIGHT, true, true);
474 EXPECT_STR_EQ("one two", textfield_->GetSelectedText()); 474 EXPECT_STR_EQ("one two", textfield_->GetSelectedText());
475 SendKeyEvent(ui::VKEY_RIGHT, true, true); 475 SendKeyEvent(ui::VKEY_RIGHT, true, true);
476 EXPECT_STR_EQ("one two three", textfield_->GetSelectedText()); 476 EXPECT_STR_EQ("one two three", textfield_->GetSelectedText());
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 #else 1652 #else
1653 EXPECT_EQ(500U, textfield_->GetCursorPosition()); 1653 EXPECT_EQ(500U, textfield_->GetCursorPosition());
1654 #endif 1654 #endif
1655 #endif // !defined(OS_WIN) 1655 #endif // !defined(OS_WIN)
1656 1656
1657 // Reset locale. 1657 // Reset locale.
1658 base::i18n::SetICUDefaultLocale(locale); 1658 base::i18n::SetICUDefaultLocale(locale);
1659 } 1659 }
1660 1660
1661 } // namespace views 1661 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/native_textfield_views.cc ('k') | ui/views/controls/textfield/textfield_views_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698