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

Side by Side 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, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/views/controls/textfield/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 944
945 // Paste should work normally. 945 // Paste should work normally.
946 EXPECT_TRUE(textfield_->IsCommandIdEnabled(IDS_APP_PASTE)); 946 EXPECT_TRUE(textfield_->IsCommandIdEnabled(IDS_APP_PASTE));
947 textfield_->ExecuteCommand(IDS_APP_PASTE, 0); 947 textfield_->ExecuteCommand(IDS_APP_PASTE, 0);
948 SendKeyEvent(ui::VKEY_V, false, true); 948 SendKeyEvent(ui::VKEY_V, false, true);
949 SendAlternatePaste(); 949 SendAlternatePaste();
950 EXPECT_STR_EQ("foo", GetClipboardText(ui::CLIPBOARD_TYPE_COPY_PASTE)); 950 EXPECT_STR_EQ("foo", GetClipboardText(ui::CLIPBOARD_TYPE_COPY_PASTE));
951 EXPECT_STR_EQ("foofoofoo", textfield_->text()); 951 EXPECT_STR_EQ("foofoofoo", textfield_->text());
952 } 952 }
953 953
954 // Check that text insertion works appropriately for password and read-only
955 // textfields.
956 TEST_F(TextfieldTest, TextInputType_InsertionTest) {
957 InitTextfield();
958 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
959 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, textfield_->GetTextInputType());
960
961 SendKeyEvent('a');
962 SendKeyEvent(0x05E1);
963 SendKeyEvent('b');
964
965 EXPECT_EQ(WideToUTF16(L"a\x05E1"
966 L"b"),
967 textfield_->text());
968
969 textfield_->SetReadOnly(true);
970 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, textfield_->GetTextInputType());
971 SendKeyEvent('c');
972
973 // No text should be inserted for read only textfields.
974 EXPECT_EQ(WideToUTF16(L"a\x05E1"
975 L"b"),
976 textfield_->text());
977 }
978
954 TEST_F(TextfieldTest, TextInputType) { 979 TEST_F(TextfieldTest, TextInputType) {
955 InitTextfield(); 980 InitTextfield();
956 981
957 // Defaults to TEXT 982 // Defaults to TEXT
958 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, textfield_->GetTextInputType()); 983 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, textfield_->GetTextInputType());
959 984
960 // And can be set. 985 // And can be set.
961 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL); 986 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL);
962 EXPECT_EQ(ui::TEXT_INPUT_TYPE_URL, textfield_->GetTextInputType()); 987 EXPECT_EQ(ui::TEXT_INPUT_TYPE_URL, textfield_->GetTextInputType());
963 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 988 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
(...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after
2690 2715
2691 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 2716 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
2692 ui::AXViewState state_protected; 2717 ui::AXViewState state_protected;
2693 textfield_->GetAccessibleState(&state_protected); 2718 textfield_->GetAccessibleState(&state_protected);
2694 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); 2719 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role);
2695 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); 2720 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value);
2696 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); 2721 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED));
2697 } 2722 }
2698 2723
2699 } // namespace views 2724 } // namespace views
OLDNEW
« 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