Chromium Code Reviews| Index: ui/views/controls/button/custom_button_unittest.cc |
| diff --git a/ui/views/controls/button/custom_button_unittest.cc b/ui/views/controls/button/custom_button_unittest.cc |
| index e6e2ffc269aacdb3cf8cf7e16c0e7f7f31821558..f9fa35c4ffa326aa495b0077bb9039b21cb08858 100644 |
| --- a/ui/views/controls/button/custom_button_unittest.cc |
| +++ b/ui/views/controls/button/custom_button_unittest.cc |
| @@ -204,6 +204,22 @@ TEST_F(CustomButtonTest, NotifyAction) { |
| EXPECT_FALSE(button()->notified()); |
| } |
| +TEST_F(CustomButtonTest, HandleAcceleratorWhenFocused) { |
| + // Shouldn't handle accelerators when not focused. |
|
msw
2015/11/10 22:48:34
Update the test for the behavior I explained in my
meacer
2015/11/11 00:32:59
Added TestWidget class here.
|
| + button()->GetFocusManager()->ClearFocus(); |
| + button()->AcceleratorPressed(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); |
| + EXPECT_FALSE(button()->notified()); |
| + // Should handle accelerators when focused. |
| + button()->GetFocusManager()->SetFocusedView(button()); |
| + button()->AcceleratorPressed(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); |
| + EXPECT_TRUE(button()->notified()); |
| + // Focus lost again. |
| + button()->Reset(); |
| + button()->GetFocusManager()->ClearFocus(); |
| + button()->AcceleratorPressed(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); |
| + EXPECT_FALSE(button()->notified()); |
| +} |
| + |
| // No touch on desktop Mac. Tracked in http://crbug.com/445520. |
| #if !defined(OS_MACOSX) || defined(USE_AURA) |