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

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: Rebase. 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
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 948
949 // Paste should work normally. 949 // Paste should work normally.
950 EXPECT_TRUE(textfield_->IsCommandIdEnabled(IDS_APP_PASTE)); 950 EXPECT_TRUE(textfield_->IsCommandIdEnabled(IDS_APP_PASTE));
951 textfield_->ExecuteCommand(IDS_APP_PASTE, 0); 951 textfield_->ExecuteCommand(IDS_APP_PASTE, 0);
952 SendKeyEvent(ui::VKEY_V, false, true); 952 SendKeyEvent(ui::VKEY_V, false, true);
953 SendAlternatePaste(); 953 SendAlternatePaste();
954 EXPECT_STR_EQ("foo", GetClipboardText(ui::CLIPBOARD_TYPE_COPY_PASTE)); 954 EXPECT_STR_EQ("foo", GetClipboardText(ui::CLIPBOARD_TYPE_COPY_PASTE));
955 EXPECT_STR_EQ("foofoofoo", textfield_->text()); 955 EXPECT_STR_EQ("foofoofoo", textfield_->text());
956 } 956 }
957 957
958 // Check that text insertion works appropriately for password and read-only
959 // textfields.
960 TEST_F(TextfieldTest, TextInputType_InsertionTest) {
961 InitTextfield();
962 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
963 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, textfield_->GetTextInputType());
964
965 SendKeyEvent(ui::VKEY_A);
966 SendKeyEvent(kHebrewLetterSamekh);
967 SendKeyEvent(ui::VKEY_B);
968
969 EXPECT_EQ(WideToUTF16(L"a\x05E1"
970 L"b"),
971 textfield_->text());
972
973 textfield_->SetReadOnly(true);
974 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, textfield_->GetTextInputType());
975 SendKeyEvent(ui::VKEY_C);
976
977 // No text should be inserted for read only textfields.
978 EXPECT_EQ(WideToUTF16(L"a\x05E1"
979 L"b"),
980 textfield_->text());
981 }
982
958 TEST_F(TextfieldTest, TextInputType) { 983 TEST_F(TextfieldTest, TextInputType) {
959 InitTextfield(); 984 InitTextfield();
960 985
961 // Defaults to TEXT 986 // Defaults to TEXT
962 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, textfield_->GetTextInputType()); 987 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, textfield_->GetTextInputType());
963 988
964 // And can be set. 989 // And can be set.
965 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL); 990 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL);
966 EXPECT_EQ(ui::TEXT_INPUT_TYPE_URL, textfield_->GetTextInputType()); 991 EXPECT_EQ(ui::TEXT_INPUT_TYPE_URL, textfield_->GetTextInputType());
967 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 992 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after
2674 2699
2675 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 2700 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
2676 ui::AXViewState state_protected; 2701 ui::AXViewState state_protected;
2677 textfield_->GetAccessibleState(&state_protected); 2702 textfield_->GetAccessibleState(&state_protected);
2678 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); 2703 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role);
2679 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); 2704 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value);
2680 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); 2705 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED));
2681 } 2706 }
2682 2707
2683 } // namespace views 2708 } // namespace views
OLDNEW
« 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