Chromium Code Reviews| 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); |