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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_action_view_unittest.cc

Issue 2041033002: Moved ButtonInkDropDelegate logic into InkDropHostView and deleted InkDropDelegates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed merge conflict in custom_button.cc 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/sessions/session_tab_helper.h" 9 #include "chrome/browser/sessions/session_tab_helper.h"
10 #include "chrome/browser/ui/toolbar/test_toolbar_action_view_controller.h" 10 #include "chrome/browser/ui/toolbar/test_toolbar_action_view_controller.h"
11 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" 11 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
12 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" 12 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h"
13 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/test/test_browser_thread.h" 14 #include "content/public/test/test_browser_thread.h"
15 #include "content/public/test/test_web_contents_factory.h" 15 #include "content/public/test/test_web_contents_factory.h"
16 #include "ui/accessibility/ax_view_state.h" 16 #include "ui/accessibility/ax_view_state.h"
17 #include "ui/events/test/event_generator.h" 17 #include "ui/events/test/event_generator.h"
18 #include "ui/views/animation/test/test_ink_drop_delegate.h"
19 #include "ui/views/test/views_test_base.h" 18 #include "ui/views/test/views_test_base.h"
20 19
21 namespace { 20 namespace {
22 21
23 // A test delegate for a toolbar action view. 22 // A test delegate for a toolbar action view.
24 class TestToolbarActionViewDelegate : public ToolbarActionView::Delegate { 23 class TestToolbarActionViewDelegate : public ToolbarActionView::Delegate {
25 public: 24 public:
26 TestToolbarActionViewDelegate() : shown_in_menu_(false), 25 TestToolbarActionViewDelegate() : shown_in_menu_(false),
27 overflow_reference_view_(nullptr), 26 overflow_reference_view_(nullptr),
28 web_contents_(nullptr) {} 27 web_contents_(nullptr) {}
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 TestToolbarActionView(ToolbarActionViewController* view_controller, 134 TestToolbarActionView(ToolbarActionViewController* view_controller,
136 Delegate* delegate) 135 Delegate* delegate)
137 : ToolbarActionView(view_controller, delegate) {} 136 : ToolbarActionView(view_controller, delegate) {}
138 137
139 ~TestToolbarActionView() override {} 138 ~TestToolbarActionView() override {}
140 139
141 private: 140 private:
142 DISALLOW_COPY_AND_ASSIGN(TestToolbarActionView); 141 DISALLOW_COPY_AND_ASSIGN(TestToolbarActionView);
143 }; 142 };
144 143
145 // Verifies there is no crash when a ToolbarActionView with an InkDropDelegate 144 // Verifies there is no crash when a ToolbarActionView with an InkDrop is
146 // is destroyed while holding a |pressed_lock_|. 145 // destroyed while holding a |pressed_lock_|.
147 TEST_F(ToolbarActionViewUnitTest, 146 TEST_F(ToolbarActionViewUnitTest,
148 NoCrashWhenDestroyingToolbarActionViewThatHasAPressedLock) { 147 NoCrashWhenDestroyingToolbarActionViewThatHasAPressedLock) {
149 TestToolbarActionViewController controller("fake controller"); 148 TestToolbarActionViewController controller("fake controller");
150 TestToolbarActionViewDelegate action_view_delegate; 149 TestToolbarActionViewDelegate action_view_delegate;
151 150
152 // Create a new toolbar action view. 151 // Create a new toolbar action view.
153 std::unique_ptr<ToolbarActionView> view( 152 std::unique_ptr<ToolbarActionView> view(
154 new ToolbarActionView(&controller, &action_view_delegate)); 153 new ToolbarActionView(&controller, &action_view_delegate));
155 view->set_owned_by_client(); 154 view->set_owned_by_client();
156 view->SetBoundsRect(gfx::Rect(0, 0, 200, 20)); 155 view->SetBoundsRect(gfx::Rect(0, 0, 200, 20));
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // If the view isn't visible, the overflow button should be pressed for 277 // If the view isn't visible, the overflow button should be pressed for
279 // popups. 278 // popups.
280 view.SetVisible(false); 279 view.SetVisible(false);
281 controller.ShowPopup(true); 280 controller.ShowPopup(true);
282 EXPECT_EQ(views::Button::STATE_NORMAL, view.state()); 281 EXPECT_EQ(views::Button::STATE_NORMAL, view.state());
283 EXPECT_EQ(views::Button::STATE_PRESSED, overflow_button.state()); 282 EXPECT_EQ(views::Button::STATE_PRESSED, overflow_button.state());
284 controller.HidePopup(); 283 controller.HidePopup();
285 EXPECT_EQ(views::Button::STATE_NORMAL, view.state()); 284 EXPECT_EQ(views::Button::STATE_NORMAL, view.state());
286 EXPECT_EQ(views::Button::STATE_NORMAL, overflow_button.state()); 285 EXPECT_EQ(views::Button::STATE_NORMAL, overflow_button.state());
287 } 286 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_action_view.cc ('k') | chrome/browser/ui/views/toolbar/toolbar_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698