Chromium Code Reviews| 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 c6e4fba368c5df158a3a96dcd860b39c0e45603f..e2df564b5ae89a1928f7b21b8e12bf4fe54756fc 100644 |
| --- a/ui/views/controls/textfield/textfield_unittest.cc |
| +++ b/ui/views/controls/textfield/textfield_unittest.cc |
| @@ -1838,8 +1838,8 @@ TEST_F(TextfieldTest, UndoRedoTest) { |
| } |
| // Most platforms support Ctrl+Y as an alternative to Ctrl+Shift+Z, but on Mac |
| -// that is bound to "Show full history", so is not mapped as an editing |
| -// command. So, on Mac, send Cmd+Shift+Z. |
| +// Ctrl+Y is bound to "Yank" and Cmd+Y is bound to "Show full history". So, on |
| +// Mac, send Cmd+Shift+Z. |
|
tapted
2016/07/06 01:46:37
The "So, on Mac.." doesn't fit any more... somethi
karandeepb
2016/07/19 07:04:40
Done.
|
| #if !defined(OS_MACOSX) |
| // Test that Ctrl+Y works for Redo, as well as Ctrl+Shift+Z. |
| @@ -1859,6 +1859,56 @@ TEST_F(TextfieldTest, RedoWithCtrlY) { |
| #endif // !defined(OS_MACOSX) |
| +// Non-Mac platforms don't have a key binding for Yank. Since this test is only |
| +// run on Mac, it uses some Mac specific key bindings. |
| +#if defined(OS_MACOSX) |
| + |
| +TEST_F(TextfieldTest, Yank) { |
|
tapted
2016/07/06 01:46:37
Same as before - we should test "Yank" in textfiel
karandeepb
2016/07/19 07:04:40
Done.
|
| + InitTextfields(2); |
| + textfield_->SetText(ASCIIToUTF16("abcdef")); |
| + textfield_->SelectRange(gfx::Range(2, 4)); |
| + |
| + // Press Ctrl+Y to yank. |
| + SendKeyPress(ui::VKEY_Y, ui::EF_CONTROL_DOWN); |
| + |
| + // Initially the kill buffer should be empty. Hence yanking should delete the |
| + // selected text. |
| + EXPECT_STR_EQ("abef", textfield_->text()); |
| + EXPECT_EQ(gfx::Range(2), textfield_->GetSelectedRange()); |
| + |
| + // Press Ctrl+K to delete to end of paragraph. This should place the deleted |
| + // text in the kill buffer. |
| + SendKeyPress(ui::VKEY_K, ui::EF_CONTROL_DOWN); |
| + |
| + EXPECT_STR_EQ("ab", textfield_->text()); |
| + EXPECT_EQ(gfx::Range(2), textfield_->GetSelectedRange()); |
| + |
| + // Yank twice. |
| + SendKeyPress(ui::VKEY_Y, ui::EF_CONTROL_DOWN); |
| + SendKeyPress(ui::VKEY_Y, ui::EF_CONTROL_DOWN); |
| + EXPECT_STR_EQ("abefef", textfield_->text()); |
| + EXPECT_EQ(gfx::Range(6), textfield_->GetSelectedRange()); |
| + |
| + // Verify pressing backspace does not modify the kill buffer. |
| + SendKeyEvent(ui::VKEY_BACK); |
| + SendKeyPress(ui::VKEY_Y, ui::EF_CONTROL_DOWN); |
| + EXPECT_STR_EQ("abefeef", textfield_->text()); |
| + EXPECT_EQ(gfx::Range(7), textfield_->GetSelectedRange()); |
| + |
| + // Move focus to next textfield. |
| + widget_->GetFocusManager()->AdvanceFocus(false); |
| + EXPECT_EQ(2, GetFocusedView()->id()); |
| + Textfield* textfield2 = static_cast<Textfield*>(GetFocusedView()); |
| + EXPECT_STR_EQ("", textfield2->text()); |
| + |
| + // Verify yanked text persists across multiple textfields. |
| + SendKeyPress(ui::VKEY_Y, ui::EF_CONTROL_DOWN); |
| + EXPECT_STR_EQ("ef", textfield2->text()); |
| + EXPECT_EQ(gfx::Range(2), textfield2->GetSelectedRange()); |
| +} |
| + |
| +#endif |
|
tapted
2016/07/06 01:46:37
nit: // defined(OS_MACOSX)
karandeepb
2016/07/19 07:04:40
Done.
|
| + |
| TEST_F(TextfieldTest, CutCopyPaste) { |
| InitTextfield(); |