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

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

Issue 873513002: [Views] Make MenuButton track its desired state while pressed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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/controls/button/menu_button.cc ('k') | ui/views/widget/desktop_aura/desktop_native_widget_aura.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/menu_button_unittest.cc
diff --git a/ui/views/controls/button/menu_button_unittest.cc b/ui/views/controls/button/menu_button_unittest.cc
index d3fbb1beb756d9c1e4090865927aef424f2ec0c2..2a17acf190be9f96e68b5fc118f4d6d1a14e375d 100644
--- a/ui/views/controls/button/menu_button_unittest.cc
+++ b/ui/views/controls/button/menu_button_unittest.cc
@@ -348,6 +348,31 @@ TEST_F(MenuButtonTest, MenuButtonPressedLock) {
// ...And it should respond to mouse movement again.
generator.MoveMouseTo(gfx::Point(10, 10));
EXPECT_EQ(Button::STATE_HOVERED, button()->state());
+
+ // Test that the button returns to the appropriate state after the press; if
+ // the mouse ends over the button, the button should be hovered.
+ pressed_lock1.reset(new MenuButton::PressedLock(button()));
+ EXPECT_EQ(Button::STATE_PRESSED, button()->state());
+ pressed_lock1.reset();
+ EXPECT_EQ(Button::STATE_HOVERED, button()->state());
+
+ // If the button is disabled before the pressed lock, it should be disabled
+ // after the pressed lock.
+ button()->SetState(Button::STATE_DISABLED);
+ pressed_lock1.reset(new MenuButton::PressedLock(button()));
+ EXPECT_EQ(Button::STATE_PRESSED, button()->state());
+ pressed_lock1.reset();
+ EXPECT_EQ(Button::STATE_DISABLED, button()->state());
+
+ generator.MoveMouseTo(gfx::Point(300, 10));
+
+ // Edge case: the button is disabled, a pressed lock is added, and then the
+ // button is re-enabled. It should be enabled after the lock is removed.
+ pressed_lock1.reset(new MenuButton::PressedLock(button()));
+ EXPECT_EQ(Button::STATE_PRESSED, button()->state());
+ button()->SetState(Button::STATE_NORMAL);
+ pressed_lock1.reset();
+ EXPECT_EQ(Button::STATE_NORMAL, button()->state());
}
// Test that the MenuButton does not become pressed if it can be dragged, until
« no previous file with comments | « ui/views/controls/button/menu_button.cc ('k') | ui/views/widget/desktop_aura/desktop_native_widget_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698