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

Side by Side Diff: ui/views/controls/button/menu_button_unittest.cc

Issue 2832823002: Update avatar button to MD (Closed)
Patch Set: Fixed bad merge that duplicated the GetMinimizeButtonHeight() method in some files Created 3 years, 7 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
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 auto click_point = gfx::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 auto click_point = gfx::Point(11, 7);
364 auto click_event =
365 ui::MouseEvent(ui::EventType::ET_MOUSE_PRESSED, click_point, click_point,
366 base::TimeTicks(), 0, 0);
367 std::unique_ptr<MenuButton::PressedLock> pressed_lock(
368 new MenuButton::PressedLock(button(), false, &click_event));
369
370 EXPECT_EQ(Button::STATE_PRESSED, button()->state());
371 EXPECT_EQ(
372 click_point,
373 InkDropHostViewTestApi(button()).GetInkDropCenterBasedOnLastEvent());
374 }
375
343 // Test that the MenuButton stays pressed while there are any PressedLocks. 376 // Test that the MenuButton stays pressed while there are any PressedLocks.
344 TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) { 377 TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) {
345 // Similarly for aura-mus-client the location of the cursor is not updated by 378 // Similarly for aura-mus-client the location of the cursor is not updated by
346 // EventGenerator so that IsMouseHovered() checks the wrong thing. 379 // EventGenerator so that IsMouseHovered() checks the wrong thing.
347 // https://crbug.com/615033. 380 // https://crbug.com/615033.
348 if (IsMus()) 381 if (IsMus())
349 return; 382 return;
350 383
351 CreateMenuButtonWithNoListener(); 384 CreateMenuButtonWithNoListener();
352 385
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 641
609 generator()->MoveTouch(gfx::Point(10, 30)); 642 generator()->MoveTouch(gfx::Point(10, 30));
610 generator()->ReleaseTouch(); 643 generator()->ReleaseTouch();
611 EXPECT_EQ(Button::STATE_NORMAL, button()->state()); 644 EXPECT_EQ(Button::STATE_NORMAL, button()->state());
612 EXPECT_EQ(nullptr, menu_button_listener.last_source()); 645 EXPECT_EQ(nullptr, menu_button_listener.last_source());
613 } 646 }
614 647
615 #endif // !defined(OS_MACOSX) || defined(USE_AURA) 648 #endif // !defined(OS_MACOSX) || defined(USE_AURA)
616 649
617 } // namespace views 650 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698