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

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

Issue 2033433006: MacViews: Modify insertText handlers to correctly handle space key and simplify menu event dispatch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix failing interactive_ui_tests. Created 4 years, 6 months 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
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 74136c0c15e898ad393c6e5d0a23fba8938d5364..a911e292dcedcc07c19fcbbb2dd9e5933ebbe998 100644
--- a/ui/views/controls/button/custom_button_unittest.cc
+++ b/ui/views/controls/button/custom_button_unittest.cc
@@ -131,6 +131,8 @@ class CustomButtonTest : public ViewsTestBase {
widget_->dragged_view_ = dragged_view;
}
+ void SimulateKeyEvent(ui::KeyEvent* event) { widget()->OnKeyEvent(event); }
+
private:
std::unique_ptr<Widget> widget_;
TestCustomButton* button_;
@@ -522,4 +524,24 @@ TEST_F(CustomButtonTest, InkDropStaysHiddenWhileDragging) {
SetDraggedView(nullptr);
}
+// Todo(karandeepb): On Mac, a button should get clicked on a Space key press
+// (and not release). Modify this test after fixing crbug.com/607429.
+// Test that Space Key behaves correctly on a focused button.
+TEST_F(CustomButtonTest, ClickOnSpace) {
+ // Give focus to the button.
+ button()->SetFocusForPlatform();
+ button()->RequestFocus();
+ EXPECT_EQ(button(), widget()->GetFocusManager()->GetFocusedView());
+
+ ui::KeyEvent space_press(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, ui::EF_NONE);
+ SimulateKeyEvent(&space_press);
+ EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state());
+ EXPECT_FALSE(button()->pressed());
+
+ ui::KeyEvent space_release(ui::ET_KEY_RELEASED, ui::VKEY_SPACE, ui::EF_NONE);
+ SimulateKeyEvent(&space_release);
+ EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state());
+ EXPECT_TRUE(button()->pressed());
+}
+
} // namespace views
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698