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

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

Issue 1927983002: Fixed Back/Forward buttons to not hide ink drop when long press shows drop down menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Changed base::WrapUnique() to make_scoped_ptr(). Created 4 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
« no previous file with comments | « ui/views/controls/button/custom_button.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/custom_button.h" 5 #include "ui/views/controls/button/custom_button.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/base/layout.h" 10 #include "ui/base/layout.h"
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 widget()->SetCapture(button()); 426 widget()->SetCapture(button());
427 widget()->ReleaseCapture(); 427 widget()->ReleaseCapture();
428 SetDraggedView(nullptr); 428 SetDraggedView(nullptr);
429 EXPECT_TRUE(ink_hidden); 429 EXPECT_TRUE(ink_hidden);
430 EXPECT_EQ(ui::MaterialDesignController::IsModeMaterial() 430 EXPECT_EQ(ui::MaterialDesignController::IsModeMaterial()
431 ? Button::ButtonState::STATE_NORMAL 431 ? Button::ButtonState::STATE_NORMAL
432 : Button::ButtonState::STATE_PRESSED, 432 : Button::ButtonState::STATE_PRESSED,
433 button()->state()); 433 button()->state());
434 } 434 }
435 435
436 TEST_F(CustomButtonTest, InkDropAfterShowingContextMenu) { 436 TEST_F(CustomButtonTest, HideInkDropWhenShowingContextMenu) {
437 TestInkDropDelegate* ink_drop_delegate = new TestInkDropDelegate(); 437 TestInkDropDelegate* ink_drop_delegate = new TestInkDropDelegate();
438 CreateButtonWithInkDrop(make_scoped_ptr(ink_drop_delegate)); 438 CreateButtonWithInkDrop(make_scoped_ptr(ink_drop_delegate));
439 TestContextMenuController context_menu_controller; 439 TestContextMenuController context_menu_controller;
440 button()->set_context_menu_controller(&context_menu_controller); 440 button()->set_context_menu_controller(&context_menu_controller);
441 button()->set_hide_ink_drop_when_showing_context_menu(true);
441 442
442 ink_drop_delegate->SetHovered(true); 443 ink_drop_delegate->SetHovered(true);
443 ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING); 444 ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING);
444 445
445 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); 446 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE);
446 447
447 EXPECT_FALSE(ink_drop_delegate->is_hovered()); 448 EXPECT_FALSE(ink_drop_delegate->is_hovered());
448 EXPECT_EQ(InkDropState::HIDDEN, ink_drop_delegate->state()); 449 EXPECT_EQ(InkDropState::HIDDEN, ink_drop_delegate->state());
449 } 450 }
450 451
452 TEST_F(CustomButtonTest, DontHideInkDropWhenShowingContextMenu) {
453 TestInkDropDelegate* ink_drop_delegate = new TestInkDropDelegate();
454 CreateButtonWithInkDrop(make_scoped_ptr(ink_drop_delegate));
455 TestContextMenuController context_menu_controller;
456 button()->set_context_menu_controller(&context_menu_controller);
457 button()->set_hide_ink_drop_when_showing_context_menu(false);
458
459 ink_drop_delegate->SetHovered(true);
460 ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING);
461
462 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE);
463
464 EXPECT_TRUE(ink_drop_delegate->is_hovered());
465 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop_delegate->state());
466 }
467
451 TEST_F(CustomButtonTest, InkDropAfterTryingToShowContextMenu) { 468 TEST_F(CustomButtonTest, InkDropAfterTryingToShowContextMenu) {
452 TestInkDropDelegate* ink_drop_delegate = new TestInkDropDelegate(); 469 TestInkDropDelegate* ink_drop_delegate = new TestInkDropDelegate();
453 CreateButtonWithInkDrop(make_scoped_ptr(ink_drop_delegate)); 470 CreateButtonWithInkDrop(make_scoped_ptr(ink_drop_delegate));
454 button()->set_context_menu_controller(nullptr); 471 button()->set_context_menu_controller(nullptr);
455 472
456 ink_drop_delegate->SetHovered(true); 473 ink_drop_delegate->SetHovered(true);
457 ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING); 474 ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING);
458 475
459 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); 476 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE);
460 477
461 EXPECT_TRUE(ink_drop_delegate->is_hovered()); 478 EXPECT_TRUE(ink_drop_delegate->is_hovered());
462 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop_delegate->state()); 479 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop_delegate->state());
463 } 480 }
464 481
465 } // namespace views 482 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/custom_button.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698