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

Unified Diff: ui/views/view_unittest.cc

Issue 8748001: Make text input type and password visibility bit independent in Textfield (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view_unittest.cc
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index 79ef2fdc2aecd8be2c4266a359c3f320b23d27fe..e16934958340b1b2a4ba4d2e2302073294feaf33 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -953,13 +953,20 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
EXPECT_EQ(kNormalText, result);
+ // We don't let you copy from an obscured field, clipboard should not change.
password->SelectAll();
::SendMessage(password->GetTestingHandle(), WM_COPY, 0, 0);
result.clear();
clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
- // We don't let you copy from an obscured field, clipboard should not have
- // changed.
EXPECT_EQ(kNormalText, result);
+ // But copying is allowed when STYLE_OBSCURED is clear, even if the text input
+ // type is still PASSWORD.
+ password->SetObscured(false);
+ ::SendMessage(password->GetTestingHandle(), WM_COPY, 0, 0);
+ result.clear();
+ clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
+ EXPECT_EQ(kPasswordText, result);
+ password->SetObscured(true);
oshima 2012/01/30 23:56:24 can you add tests in native_textfied_views as well
//
// Test Paste.
@@ -968,13 +975,16 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
// text in the Textfield class is synced to the text of the HWND on
// WM_KEYDOWN messages that we are not simulating here.
- // Attempting to copy kNormalText in a read-only text-field should fail.
+ // Attempting to replace the text in a read-only text-field should fail.
read_only->SelectAll();
::SendMessage(read_only->GetTestingHandle(), WM_KEYDOWN, 0, 0);
wchar_t buffer[1024] = { 0 };
::GetWindowText(read_only->GetTestingHandle(), buffer, 1024);
EXPECT_EQ(kReadOnlyText, string16(buffer));
+ // Pasting into a password field should work.
+ normal->SelectAll();
+ ::SendMessage(normal->GetTestingHandle(), WM_COPY, 0, 0);
password->SelectAll();
::SendMessage(password->GetTestingHandle(), WM_PASTE, 0, 0);
::GetWindowText(password->GetTestingHandle(), buffer, 1024);
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698