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

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

Issue 2831353002: Allow a LocatedEvent to be passed to MenuButton, so the ink drop animation is centered on the click… (Closed)
Patch Set: Added comments and unit tests per review comments Created 3 years, 8 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/controls/menu/menu_controller.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 adb1a6d3d5fcf475fde5ee011bbbfcceba0b72c6..3e4ff0c5a572ed9a4e63226e7b8fc6a5d44f2610 100644
--- a/ui/views/controls/button/menu_button_unittest.cc
+++ b/ui/views/controls/button/menu_button_unittest.cc
@@ -340,6 +340,39 @@ TEST_F(MenuButtonTest, ActivateDropDownOnMouseClick) {
EXPECT_EQ(Button::STATE_HOVERED, menu_button_listener.last_source_state());
}
+// Tests that the ink drop center point is set from the mouse click point.
+TEST_F(MenuButtonTest, InkDropCenterSetFromClick) {
+ TestMenuButtonListener menu_button_listener;
+ CreateMenuButtonWithMenuButtonListener(&menu_button_listener);
+
+ auto click_point = gfx::Point(6, 8);
sky 2017/04/24 15:07:13 IMO auto here is overkill: gfx::Point click_point
emx 2017/04/24 16:32:07 Oh, yes, of course. :)
+ generator()->MoveMouseTo(click_point);
+ generator()->ClickLeftButton();
+
+ EXPECT_EQ(button(), menu_button_listener.last_source());
+ EXPECT_EQ(
+ click_point,
+ InkDropHostViewTestApi(button()).GetInkDropCenterBasedOnLastEvent());
+}
+
+// Tests that the ink drop center point is set from the PressedLock constructor.
+TEST_F(MenuButtonTest, InkDropCenterSetFromClickWithPressedLock) {
+ TestMenuButtonListener menu_button_listener;
+ CreateMenuButtonWithMenuButtonListener(&menu_button_listener);
+
+ auto click_point = gfx::Point(11, 7);
+ auto click_event =
+ ui::MouseEvent(ui::EventType::ET_MOUSE_PRESSED, click_point, click_point,
+ base::TimeTicks(), 0, 0);
+ std::unique_ptr<MenuButton::PressedLock> pressed_lock(
sky 2017/04/24 15:07:13 There is no need for the unique_ptr here. Declared
emx 2017/04/24 16:32:07 Done.
+ new MenuButton::PressedLock(button(), false, &click_event));
+
+ EXPECT_EQ(Button::STATE_PRESSED, button()->state());
+ EXPECT_EQ(
+ click_point,
+ InkDropHostViewTestApi(button()).GetInkDropCenterBasedOnLastEvent());
+}
+
// Test that the MenuButton stays pressed while there are any PressedLocks.
TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) {
// Similarly for aura-mus-client the location of the cursor is not updated by
« no previous file with comments | « ui/views/controls/button/menu_button.cc ('k') | ui/views/controls/menu/menu_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698