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

Unified Diff: ui/views/controls/button/custom_button_unittest.cc

Issue 1437523005: Custom buttons should only handle accelerators when focused. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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)
« ui/views/controls/button/custom_button.cc ('K') | « ui/views/controls/button/custom_button.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698