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

Side by Side 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: Addressed 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/button/menu_button.h" 5 #include "ui/views/controls/button/menu_button.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 CreateMenuButtonWithMenuButtonListener(&menu_button_listener); 333 CreateMenuButtonWithMenuButtonListener(&menu_button_listener);
334 334
335 generator()->ClickLeftButton(); 335 generator()->ClickLeftButton();
336 336
337 // Check that MenuButton has notified the listener, while it was in pressed 337 // Check that MenuButton has notified the listener, while it was in pressed
338 // state. 338 // state.
339 EXPECT_EQ(button(), menu_button_listener.last_source()); 339 EXPECT_EQ(button(), menu_button_listener.last_source());
340 EXPECT_EQ(Button::STATE_HOVERED, menu_button_listener.last_source_state()); 340 EXPECT_EQ(Button::STATE_HOVERED, menu_button_listener.last_source_state());
341 } 341 }
342 342
343 // Tests that the ink drop center point is set from the mouse click point.
344 TEST_F(MenuButtonTest, InkDropCenterSetFromClick) {
345 TestMenuButtonListener menu_button_listener;
346 CreateMenuButtonWithMenuButtonListener(&menu_button_listener);
347
348 gfx::Point click_point(6, 8);
349 generator()->MoveMouseTo(click_point);
350 generator()->ClickLeftButton();
351
352 EXPECT_EQ(button(), menu_button_listener.last_source());
353 EXPECT_EQ(
354 click_point,
355 InkDropHostViewTestApi(button()).GetInkDropCenterBasedOnLastEvent());
356 }
357
358 // Tests that the ink drop center point is set from the PressedLock constructor.
359 TEST_F(MenuButtonTest, InkDropCenterSetFromClickWithPressedLock) {
360 TestMenuButtonListener menu_button_listener;
361 CreateMenuButtonWithMenuButtonListener(&menu_button_listener);
362
363 gfx::Point click_point(11, 7);
364 ui::MouseEvent click_event(ui::EventType::ET_MOUSE_PRESSED, click_point,
365 click_point, base::TimeTicks(), 0, 0);
366 MenuButton::PressedLock pressed_lock(button(), false, &click_event);
367
368 EXPECT_EQ(Button::STATE_PRESSED, button()->state());
369 EXPECT_EQ(
370 click_point,
371 InkDropHostViewTestApi(button()).GetInkDropCenterBasedOnLastEvent());
372 }
373
343 // Test that the MenuButton stays pressed while there are any PressedLocks. 374 // Test that the MenuButton stays pressed while there are any PressedLocks.
344 TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) { 375 TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) {
345 // Similarly for aura-mus-client the location of the cursor is not updated by 376 // Similarly for aura-mus-client the location of the cursor is not updated by
346 // EventGenerator so that IsMouseHovered() checks the wrong thing. 377 // EventGenerator so that IsMouseHovered() checks the wrong thing.
347 // https://crbug.com/615033. 378 // https://crbug.com/615033.
348 if (IsMus()) 379 if (IsMus())
349 return; 380 return;
350 381
351 CreateMenuButtonWithNoListener(); 382 CreateMenuButtonWithNoListener();
352 383
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 639
609 generator()->MoveTouch(gfx::Point(10, 30)); 640 generator()->MoveTouch(gfx::Point(10, 30));
610 generator()->ReleaseTouch(); 641 generator()->ReleaseTouch();
611 EXPECT_EQ(Button::STATE_NORMAL, button()->state()); 642 EXPECT_EQ(Button::STATE_NORMAL, button()->state());
612 EXPECT_EQ(nullptr, menu_button_listener.last_source()); 643 EXPECT_EQ(nullptr, menu_button_listener.last_source());
613 } 644 }
614 645
615 #endif // !defined(OS_MACOSX) || defined(USE_AURA) 646 #endif // !defined(OS_MACOSX) || defined(USE_AURA)
616 647
617 } // namespace views 648 } // namespace views
OLDNEW
« 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