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

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

Issue 9117012: Rename visual style "password" to "obscured" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright Created 8 years, 11 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) 2011 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"
11 #include "base/callback.h" 11 #include "base/callback.h"
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 SendKeyEvent(ui::VKEY_RIGHT, false, true, false); 492 SendKeyEvent(ui::VKEY_RIGHT, false, true, false);
493 SendKeyEvent(ui::VKEY_DELETE, true, true, false); 493 SendKeyEvent(ui::VKEY_DELETE, true, true, false);
494 #if defined(OS_WIN) 494 #if defined(OS_WIN)
495 EXPECT_STR_EQ(" two three four", textfield_->text()); 495 EXPECT_STR_EQ(" two three four", textfield_->text());
496 #else 496 #else
497 EXPECT_STR_EQ(" two", textfield_->text()); 497 EXPECT_STR_EQ(" two", textfield_->text());
498 #endif 498 #endif
499 } 499 }
500 500
501 TEST_F(NativeTextfieldViewsTest, PasswordTest) { 501 TEST_F(NativeTextfieldViewsTest, PasswordTest) {
502 InitTextfield(Textfield::STYLE_PASSWORD); 502 InitTextfield(Textfield::STYLE_OBSCURED);
503 503
504 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, GetTextInputType()); 504 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, GetTextInputType());
505 505
506 last_contents_.clear(); 506 last_contents_.clear();
507 textfield_->SetText(ASCIIToUTF16("my password")); 507 textfield_->SetText(ASCIIToUTF16("my password"));
508 // Just to make sure the text() and callback returns 508 // Just to make sure the text() and callback returns
509 // the actual text instead of "*". 509 // the actual text instead of "*".
510 EXPECT_STR_EQ("my password", textfield_->text()); 510 EXPECT_STR_EQ("my password", textfield_->text());
511 EXPECT_TRUE(last_contents_.empty()); 511 EXPECT_TRUE(last_contents_.empty());
512 } 512 }
513 513
514 TEST_F(NativeTextfieldViewsTest, InputTypeSetsPassword) { 514 TEST_F(NativeTextfieldViewsTest, InputTypeSetsObscured) {
515 InitTextfield(Textfield::STYLE_DEFAULT); 515 InitTextfield(Textfield::STYLE_DEFAULT);
516 516
517 // Defaults to TEXT 517 // Defaults to TEXT
518 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType()); 518 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType());
519 519
520 // Setting to passwords also sets password state of textfield. 520 // Setting to TEXT_INPUT_TYPE_PASSWORD also sets obscured state of textfield.
521 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 521 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
522 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, GetTextInputType()); 522 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, GetTextInputType());
523 EXPECT_TRUE(textfield_->IsPassword()); 523 EXPECT_TRUE(textfield_->IsObscured());
524 } 524 }
525 525
526 TEST_F(NativeTextfieldViewsTest, PasswordSetsInputType) { 526 TEST_F(NativeTextfieldViewsTest, ObscuredSetsInputType) {
527 InitTextfield(Textfield::STYLE_DEFAULT); 527 InitTextfield(Textfield::STYLE_DEFAULT);
528 528
529 // Defaults to TEXT 529 // Defaults to TEXT
530 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType()); 530 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType());
531 531
532 textfield_->SetPassword(true); 532 textfield_->SetObscured(true);
533 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, GetTextInputType()); 533 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, GetTextInputType());
534 534
535 textfield_->SetPassword(false); 535 textfield_->SetObscured(false);
536 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType()); 536 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType());
537 } 537 }
538 538
539 TEST_F(NativeTextfieldViewsTest, TextInputType) { 539 TEST_F(NativeTextfieldViewsTest, TextInputType) {
540 InitTextfield(Textfield::STYLE_DEFAULT); 540 InitTextfield(Textfield::STYLE_DEFAULT);
541 541
542 // Defaults to TEXT 542 // Defaults to TEXT
543 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType()); 543 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType());
544 544
545 // And can be set. 545 // And can be set.
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 EXPECT_EQ(1, on_before_user_action_); 1107 EXPECT_EQ(1, on_before_user_action_);
1108 EXPECT_EQ(1, on_after_user_action_); 1108 EXPECT_EQ(1, on_after_user_action_);
1109 1109
1110 input_method_->Clear(); 1110 input_method_->Clear();
1111 textfield_->SetReadOnly(true); 1111 textfield_->SetReadOnly(true);
1112 EXPECT_TRUE(input_method_->text_input_type_changed()); 1112 EXPECT_TRUE(input_method_->text_input_type_changed());
1113 EXPECT_FALSE(textfield_->GetTextInputClient()); 1113 EXPECT_FALSE(textfield_->GetTextInputClient());
1114 1114
1115 textfield_->SetReadOnly(false); 1115 textfield_->SetReadOnly(false);
1116 input_method_->Clear(); 1116 input_method_->Clear();
1117 textfield_->SetPassword(true); 1117 textfield_->SetObscured(true);
1118 EXPECT_TRUE(input_method_->text_input_type_changed()); 1118 EXPECT_TRUE(input_method_->text_input_type_changed());
1119 EXPECT_TRUE(textfield_->GetTextInputClient()); 1119 EXPECT_TRUE(textfield_->GetTextInputClient());
1120 } 1120 }
1121 1121
1122 TEST_F(NativeTextfieldViewsTest, UndoRedoTest) { 1122 TEST_F(NativeTextfieldViewsTest, UndoRedoTest) {
1123 InitTextfield(Textfield::STYLE_DEFAULT); 1123 InitTextfield(Textfield::STYLE_DEFAULT);
1124 SendKeyEvent(ui::VKEY_A); 1124 SendKeyEvent(ui::VKEY_A);
1125 EXPECT_STR_EQ("a", textfield_->text()); 1125 EXPECT_STR_EQ("a", textfield_->text());
1126 SendKeyEvent(ui::VKEY_Z, false, true); 1126 SendKeyEvent(ui::VKEY_Z, false, true);
1127 EXPECT_STR_EQ("", textfield_->text()); 1127 EXPECT_STR_EQ("", textfield_->text());
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 #else 1568 #else
1569 EXPECT_EQ(500U, textfield_->GetCursorPosition()); 1569 EXPECT_EQ(500U, textfield_->GetCursorPosition());
1570 #endif 1570 #endif
1571 #endif // !defined(OS_WIN) 1571 #endif // !defined(OS_WIN)
1572 1572
1573 // Reset locale. 1573 // Reset locale.
1574 base::i18n::SetICUDefaultLocale(locale); 1574 base::i18n::SetICUDefaultLocale(locale);
1575 } 1575 }
1576 1576
1577 } // namespace views 1577 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/native_textfield_views.cc ('k') | ui/views/controls/textfield/native_textfield_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698