| 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 0a9b767754ef38ed307214bcce70ea9366aa1c00..0499a7baa872b5331bc1555bfe3dd661d5244a31 100644
|
| --- a/ui/views/controls/textfield/textfield_unittest.cc
|
| +++ b/ui/views/controls/textfield/textfield_unittest.cc
|
| @@ -2081,10 +2081,23 @@ TEST_F(TextfieldTest, Yank) {
|
| Textfield* textfield2 = static_cast<Textfield*>(GetFocusedView());
|
| EXPECT_TRUE(textfield2->text().empty());
|
|
|
| - // Verify yanked text persists across multiple textfields.
|
| + // Verify yanked text persists across multiple textfields and that yanking
|
| + // into a password textfield works.
|
| + textfield2->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
|
| SendKeyPress(ui::VKEY_Y, ui::EF_CONTROL_DOWN);
|
| EXPECT_STR_EQ("ef", textfield2->text());
|
| EXPECT_EQ(gfx::Range(2), textfield2->GetSelectedRange());
|
| +
|
| + // Verify deletion in a password textfield does not modify the kill buffer.
|
| + textfield2->SetText(ASCIIToUTF16("hello"));
|
| + textfield2->SelectRange(gfx::Range(0));
|
| + SendKeyPress(ui::VKEY_K, ui::EF_CONTROL_DOWN);
|
| + EXPECT_TRUE(textfield2->text().empty());
|
| +
|
| + textfield_->RequestFocus();
|
| + textfield_->SelectRange(gfx::Range(0));
|
| + SendKeyPress(ui::VKEY_Y, ui::EF_CONTROL_DOWN);
|
| + EXPECT_STR_EQ("efabefeef", textfield_->text());
|
| }
|
|
|
| #endif // defined(OS_MACOSX)
|
| @@ -2720,6 +2733,46 @@ TEST_F(TextfieldTest, DISABLED_SelectionClipboard) {
|
| EXPECT_STR_EQ("other", GetClipboardText(ui::CLIPBOARD_TYPE_SELECTION));
|
| EXPECT_EQ(ui::CLIPBOARD_TYPE_LAST, GetAndResetCopiedToClipboard());
|
| }
|
| +
|
| +// Verify that the selection clipboard is not updated for selections on a
|
| +// password textfield. Disabled due to http://crbug.com/396477.
|
| +TEST_F(TextfieldTest, DISABLED_SelectionClipboard_Password) {
|
| + InitTextfields(2);
|
| + textfield_->SetText(ASCIIToUTF16("abcd"));
|
| +
|
| + // Select-all should update the selection clipboard for a non-password
|
| + // textfield.
|
| + SendKeyEvent(ui::VKEY_A, false, true);
|
| + EXPECT_EQ(gfx::Range(0, 4), textfield_->GetSelectedRange());
|
| + EXPECT_STR_EQ("abcd", GetClipboardText(ui::CLIPBOARD_TYPE_SELECTION));
|
| + EXPECT_EQ(ui::CLIPBOARD_TYPE_SELECTION, GetAndResetCopiedToClipboard());
|
| +
|
| + // Move focus to the next textfield.
|
| + widget_->GetFocusManager()->AdvanceFocus(false);
|
| + EXPECT_EQ(2, GetFocusedView()->id());
|
| + Textfield* textfield2 = static_cast<Textfield*>(GetFocusedView());
|
| +
|
| + // Select-all should not modify the selection clipboard for a password
|
| + // textfield.
|
| + textfield2->SetText(ASCIIToUTF16("1234"));
|
| + textfield2->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
|
| + SendKeyEvent(ui::VKEY_A, false, true);
|
| + EXPECT_EQ(gfx::Range(0, 4), textfield2->GetSelectedRange());
|
| + EXPECT_STR_EQ("abcd", GetClipboardText(ui::CLIPBOARD_TYPE_SELECTION));
|
| + EXPECT_EQ(ui::CLIPBOARD_TYPE_LAST, GetAndResetCopiedToClipboard());
|
| +
|
| + // Shift-Left/Right should not modify the selection clipboard for a password
|
| + // textfield.
|
| + SendKeyEvent(ui::VKEY_LEFT, true, false);
|
| + EXPECT_EQ(gfx::Range(0, 3), textfield2->GetSelectedRange());
|
| + EXPECT_STR_EQ("abcd", GetClipboardText(ui::CLIPBOARD_TYPE_SELECTION));
|
| + EXPECT_EQ(ui::CLIPBOARD_TYPE_LAST, GetAndResetCopiedToClipboard());
|
| +
|
| + SendKeyEvent(ui::VKEY_RIGHT, true, false);
|
| + EXPECT_EQ(gfx::Range(0, 4), textfield2->GetSelectedRange());
|
| + EXPECT_STR_EQ("abcd", GetClipboardText(ui::CLIPBOARD_TYPE_SELECTION));
|
| + EXPECT_EQ(ui::CLIPBOARD_TYPE_LAST, GetAndResetCopiedToClipboard());
|
| +}
|
| #endif
|
|
|
| // Long_Press gesture in Textfield can initiate a drag and drop now.
|
|
|