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

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

Issue 2001843002: Use ink drop hover for focus states on toolbar buttons and location (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: layout Created 4 years, 6 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') | ui/views/controls/button/label_button.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 (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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 case InkDropState::ACTION_TRIGGERED: 107 case InkDropState::ACTION_TRIGGERED:
108 case InkDropState::ALTERNATE_ACTION_TRIGGERED: 108 case InkDropState::ALTERNATE_ACTION_TRIGGERED:
109 case InkDropState::DEACTIVATED: 109 case InkDropState::DEACTIVATED:
110 break; 110 break;
111 } 111 }
112 } 112 }
113 113
114 void SnapToActivated() override { *ink_shown_ = true; } 114 void SnapToActivated() override { *ink_shown_ = true; }
115 115
116 void SetHovered(bool is_hovered) override {} 116 void SetHovered(bool is_hovered) override {}
117 InkDrop* GetInkDrop() override { return nullptr; }
117 118
118 private: 119 private:
119 bool* ink_shown_; 120 bool* ink_shown_;
120 bool* ink_hidden_; 121 bool* ink_hidden_;
121 122
122 DISALLOW_COPY_AND_ASSIGN(TestInkDropDelegateThatTracksVisibilty); 123 DISALLOW_COPY_AND_ASSIGN(TestInkDropDelegateThatTracksVisibilty);
123 }; 124 };
124 125
125 // A test Button class that owns a TestInkDropDelegate. 126 // A test Button class that owns a TestInkDropDelegate.
126 class TestButtonWithInkDrop : public TestCustomButton { 127 class TestButtonWithInkDrop : public TestCustomButton {
127 public: 128 public:
128 TestButtonWithInkDrop(std::unique_ptr<InkDropDelegate> ink_drop_delegate) 129 TestButtonWithInkDrop(std::unique_ptr<InkDropDelegate> ink_drop_delegate)
129 : TestCustomButton(), ink_drop_delegate_(std::move(ink_drop_delegate)) { 130 : TestCustomButton() {
130 set_ink_drop_delegate(ink_drop_delegate_.get()); 131 set_ink_drop_delegate(std::move(ink_drop_delegate));
131 } 132 }
132 ~TestButtonWithInkDrop() override {} 133 ~TestButtonWithInkDrop() override {}
133 134
134 private: 135 private:
135 std::unique_ptr<views::InkDropDelegate> ink_drop_delegate_;
136
137 DISALLOW_COPY_AND_ASSIGN(TestButtonWithInkDrop); 136 DISALLOW_COPY_AND_ASSIGN(TestButtonWithInkDrop);
138 }; 137 };
139 138
140 } // namespace 139 } // namespace
141 140
142 class CustomButtonTest : public ViewsTestBase { 141 class CustomButtonTest : public ViewsTestBase {
143 public: 142 public:
144 CustomButtonTest() {} 143 CustomButtonTest() {}
145 ~CustomButtonTest() override {} 144 ~CustomButtonTest() override {}
146 145
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING); 477 ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING);
479 478
480 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); 479 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE);
481 480
482 EXPECT_TRUE(ink_drop_delegate->is_hovered()); 481 EXPECT_TRUE(ink_drop_delegate->is_hovered());
483 EXPECT_EQ(InkDropState::ACTION_PENDING, 482 EXPECT_EQ(InkDropState::ACTION_PENDING,
484 ink_drop_delegate->GetTargetInkDropState()); 483 ink_drop_delegate->GetTargetInkDropState());
485 } 484 }
486 485
487 } // namespace views 486 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/custom_button.cc ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698