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

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: 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
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 7c26892d4c69602992fa9cac1f8a0edd8ec1ba22..793f6331e69f3a0fc87c020fb8bc5cb05f80afa7 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');
+ 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();
« ui/views/cocoa/bridged_content_view.mm ('K') | « 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