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

Unified Diff: ui/views/controls/textfield/textfield_unittest.cc

Issue 2096363002: MacViews: Fix text input for password textfields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@password_text_fix
Patch Set: Address review comments. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield_unittest.cc
diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc
index 03c8e580bf48f8e1387d10c588a320bbabae80f5..1236c9575d7843b52f7f33eabec61f3b14d73560 100644
--- a/ui/views/controls/textfield/textfield_unittest.cc
+++ b/ui/views/controls/textfield/textfield_unittest.cc
@@ -951,6 +951,31 @@ TEST_F(TextfieldTest, PasswordTest) {
EXPECT_STR_EQ("foofoofoo", textfield_->text());
}
+// Check that text insertion works appropriately for password and read-only
+// textfields.
+TEST_F(TextfieldTest, TextInputType_InsertionTest) {
+ InitTextfield();
+ textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
+ EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, textfield_->GetTextInputType());
+
+ SendKeyEvent('a');
msw 2016/06/29 17:26:40 Use ui::VKEY_A here, etc. below for 'b' and 'c' (v
karandeepb 2016/06/30 06:03:24 Done.
+ SendKeyEvent(0x05E1);
+ SendKeyEvent('b');
+
+ EXPECT_EQ(WideToUTF16(L"a\x05E1"
+ L"b"),
+ textfield_->text());
+
+ textfield_->SetReadOnly(true);
+ EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, textfield_->GetTextInputType());
+ SendKeyEvent('c');
+
+ // No text should be inserted for read only textfields.
+ EXPECT_EQ(WideToUTF16(L"a\x05E1"
+ L"b"),
+ textfield_->text());
+}
+
TEST_F(TextfieldTest, TextInputType) {
InitTextfield();
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698