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

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

Issue 1920783003: 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@master
Patch Set: 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 "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 widget()->SetCapture(button()); 428 widget()->SetCapture(button());
429 widget()->ReleaseCapture(); 429 widget()->ReleaseCapture();
430 SetDraggedView(nullptr); 430 SetDraggedView(nullptr);
431 EXPECT_TRUE(ink_hidden); 431 EXPECT_TRUE(ink_hidden);
432 EXPECT_EQ(ui::MaterialDesignController::IsModeMaterial() 432 EXPECT_EQ(ui::MaterialDesignController::IsModeMaterial()
433 ? Button::ButtonState::STATE_NORMAL 433 ? Button::ButtonState::STATE_NORMAL
434 : Button::ButtonState::STATE_PRESSED, 434 : Button::ButtonState::STATE_PRESSED,
435 button()->state()); 435 button()->state());
436 } 436 }
437 437
438 TEST_F(CustomButtonTest, InkDropAfterShowingContextMenu) { 438 TEST_F(CustomButtonTest, HideInkDropWhenShowingContextMenu) {
439 TestInkDropDelegate* ink_drop_delegate = new TestInkDropDelegate(); 439 TestInkDropDelegate* ink_drop_delegate = new TestInkDropDelegate();
440 CreateButtonWithInkDrop(base::WrapUnique(ink_drop_delegate)); 440 CreateButtonWithInkDrop(base::WrapUnique(ink_drop_delegate));
441 TestContextMenuController context_menu_controller; 441 TestContextMenuController context_menu_controller;
442 button()->set_context_menu_controller(&context_menu_controller); 442 button()->set_context_menu_controller(&context_menu_controller);
443 button()->set_hide_ink_drop_when_showing_context_menu(true);
443 444
444 ink_drop_delegate->SetHovered(true); 445 ink_drop_delegate->SetHovered(true);
445 ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING); 446 ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING);
446 447
447 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); 448 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE);
448 449
449 EXPECT_FALSE(ink_drop_delegate->is_hovered()); 450 EXPECT_FALSE(ink_drop_delegate->is_hovered());
450 EXPECT_EQ(InkDropState::HIDDEN, ink_drop_delegate->state()); 451 EXPECT_EQ(InkDropState::HIDDEN, ink_drop_delegate->state());
451 } 452 }
452 453
454 TEST_F(CustomButtonTest, DontHideInkDropWhenShowingContextMenu) {
455 TestInkDropDelegate* ink_drop_delegate = new TestInkDropDelegate();
456 CreateButtonWithInkDrop(base::WrapUnique(ink_drop_delegate));
457 TestContextMenuController context_menu_controller;
458 button()->set_context_menu_controller(&context_menu_controller);
459 button()->set_hide_ink_drop_when_showing_context_menu(false);
460
461 ink_drop_delegate->SetHovered(true);
462 ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING);
463
464 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE);
465
466 EXPECT_TRUE(ink_drop_delegate->is_hovered());
467 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop_delegate->state());
468 }
469
453 TEST_F(CustomButtonTest, InkDropAfterTryingToShowContextMenu) { 470 TEST_F(CustomButtonTest, InkDropAfterTryingToShowContextMenu) {
454 TestInkDropDelegate* ink_drop_delegate = new TestInkDropDelegate(); 471 TestInkDropDelegate* ink_drop_delegate = new TestInkDropDelegate();
455 CreateButtonWithInkDrop(base::WrapUnique(ink_drop_delegate)); 472 CreateButtonWithInkDrop(base::WrapUnique(ink_drop_delegate));
456 button()->set_context_menu_controller(nullptr); 473 button()->set_context_menu_controller(nullptr);
457 474
458 ink_drop_delegate->SetHovered(true); 475 ink_drop_delegate->SetHovered(true);
459 ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING); 476 ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING);
460 477
461 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); 478 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE);
462 479
463 EXPECT_TRUE(ink_drop_delegate->is_hovered()); 480 EXPECT_TRUE(ink_drop_delegate->is_hovered());
464 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop_delegate->state()); 481 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop_delegate->state());
465 } 482 }
466 483
467 } // namespace views 484 } // 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