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

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

Issue 2603373002: Show/hide ink drop highlight when button enable state changes. (Closed)
Patch Set: Created 3 years, 11 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 (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 "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 458
459 button()->OnBlur(); 459 button()->OnBlur();
460 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); 460 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState());
461 461
462 button()->OnMouseReleased(ui::MouseEvent( 462 button()->OnMouseReleased(ui::MouseEvent(
463 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), 463 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(),
464 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 464 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
465 EXPECT_TRUE(button()->pressed()); 465 EXPECT_TRUE(button()->pressed());
466 } 466 }
467 467
468 TEST_F(CustomButtonTest, HideInkDropHighlightOnDisable) {
469 TestInkDrop* ink_drop = new TestInkDrop();
470 CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false);
471
472 ui::test::EventGenerator generator(widget()->GetNativeWindow());
473 generator.MoveMouseToInHost(10, 10);
474 EXPECT_TRUE(ink_drop->is_hovered());
475 button()->SetEnabled(false);
476 EXPECT_FALSE(ink_drop->is_hovered());
477 button()->SetEnabled(true);
478 EXPECT_TRUE(ink_drop->is_hovered());
479 }
480
468 TEST_F(CustomButtonTest, InkDropAfterTryingToShowContextMenu) { 481 TEST_F(CustomButtonTest, InkDropAfterTryingToShowContextMenu) {
469 TestInkDrop* ink_drop = new TestInkDrop(); 482 TestInkDrop* ink_drop = new TestInkDrop();
470 CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false); 483 CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false);
471 button()->set_context_menu_controller(nullptr); 484 button()->set_context_menu_controller(nullptr);
472 485
473 ink_drop->SetHovered(true); 486 ink_drop->SetHovered(true);
474 ink_drop->AnimateToState(InkDropState::ACTION_PENDING); 487 ink_drop->AnimateToState(InkDropState::ACTION_PENDING);
475 488
476 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); 489 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE);
477 490
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state()); 656 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state());
644 EXPECT_FALSE(button()->pressed()); 657 EXPECT_FALSE(button()->pressed());
645 658
646 ui::KeyEvent space_release(ui::ET_KEY_RELEASED, ui::VKEY_SPACE, ui::EF_NONE); 659 ui::KeyEvent space_release(ui::ET_KEY_RELEASED, ui::VKEY_SPACE, ui::EF_NONE);
647 SimulateKeyEvent(&space_release); 660 SimulateKeyEvent(&space_release);
648 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); 661 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state());
649 EXPECT_TRUE(button()->pressed()); 662 EXPECT_TRUE(button()->pressed());
650 } 663 }
651 664
652 } // namespace views 665 } // namespace views
OLDNEW
« ui/views/controls/button/custom_button.cc ('K') | « 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