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

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

Issue 2677153002: Use TaskScheduler instead of blocking pool in render_widget_host_impl.cc. (Closed)
Patch Set: ScopedTaskSchedulers Created 3 years, 10 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/message_loop/message_loop.h"
6 #include "base/run_loop.h" 7 #include "base/run_loop.h"
7 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
8 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/scoped_task_scheduler.h"
9 #include "chrome/browser/sessions/session_tab_helper.h" 11 #include "chrome/browser/sessions/session_tab_helper.h"
10 #include "chrome/browser/ui/toolbar/test_toolbar_action_view_controller.h" 12 #include "chrome/browser/ui/toolbar/test_toolbar_action_view_controller.h"
11 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" 13 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
12 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" 14 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h"
13 #include "chrome/test/base/testing_profile.h" 15 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/test/test_browser_thread.h" 16 #include "content/public/test/test_browser_thread.h"
15 #include "content/public/test/test_web_contents_factory.h" 17 #include "content/public/test/test_web_contents_factory.h"
16 #include "ui/accessibility/ax_node_data.h" 18 #include "ui/accessibility/ax_node_data.h"
17 #include "ui/events/test/event_generator.h" 19 #include "ui/events/test/event_generator.h"
18 #include "ui/views/test/views_test_base.h" 20 #include "ui/views/test/views_test_base.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 93
92 DISALLOW_COPY_AND_ASSIGN(OpenMenuListener); 94 DISALLOW_COPY_AND_ASSIGN(OpenMenuListener);
93 }; 95 };
94 96
95 } // namespace 97 } // namespace
96 98
97 class ToolbarActionViewUnitTest : public views::ViewsTestBase { 99 class ToolbarActionViewUnitTest : public views::ViewsTestBase {
98 public: 100 public:
99 ToolbarActionViewUnitTest() 101 ToolbarActionViewUnitTest()
100 : widget_(nullptr), 102 : widget_(nullptr),
101 ui_thread_(content::BrowserThread::UI, message_loop()) {} 103 ui_thread_(content::BrowserThread::UI, message_loop()),
104 scoped_task_scheduler_(base::MessageLoop::current()) {}
102 ~ToolbarActionViewUnitTest() override {} 105 ~ToolbarActionViewUnitTest() override {}
103 106
104 void SetUp() override { 107 void SetUp() override {
105 views::ViewsTestBase::SetUp(); 108 views::ViewsTestBase::SetUp();
106 109
107 widget_ = new views::Widget; 110 widget_ = new views::Widget;
108 views::Widget::InitParams params = 111 views::Widget::InitParams params =
109 CreateParams(views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 112 CreateParams(views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
110 params.bounds = gfx::Rect(0, 0, 200, 200); 113 params.bounds = gfx::Rect(0, 0, 200, 200);
111 widget_->Init(params); 114 widget_->Init(params);
112 } 115 }
113 void TearDown() override { 116 void TearDown() override {
114 if (!widget_->IsClosed()) 117 if (!widget_->IsClosed())
115 widget_->Close(); 118 widget_->Close();
116 views::ViewsTestBase::TearDown(); 119 views::ViewsTestBase::TearDown();
117 } 120 }
118 121
119 views::Widget* widget() { return widget_; } 122 views::Widget* widget() { return widget_; }
120 123
121 private: 124 private:
122 // The widget managed by this test. 125 // The widget managed by this test.
123 views::Widget* widget_; 126 views::Widget* widget_;
124 127
125 // Web contents need a fake ui thread. 128 // Web contents need a UI thread and a TaskScheduler.
126 content::TestBrowserThread ui_thread_; 129 content::TestBrowserThread ui_thread_;
130 base::test::ScopedTaskScheduler scoped_task_scheduler_;
127 131
128 DISALLOW_COPY_AND_ASSIGN(ToolbarActionViewUnitTest); 132 DISALLOW_COPY_AND_ASSIGN(ToolbarActionViewUnitTest);
129 }; 133 };
130 134
131 // A MenuButton subclass that provides access to some MenuButton internals. 135 // A MenuButton subclass that provides access to some MenuButton internals.
132 class TestToolbarActionView : public ToolbarActionView { 136 class TestToolbarActionView : public ToolbarActionView {
133 public: 137 public:
134 TestToolbarActionView(ToolbarActionViewController* view_controller, 138 TestToolbarActionView(ToolbarActionViewController* view_controller,
135 Delegate* delegate) 139 Delegate* delegate)
136 : ToolbarActionView(view_controller, delegate) {} 140 : ToolbarActionView(view_controller, delegate) {}
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // If the view isn't visible, the overflow button should be pressed for 281 // If the view isn't visible, the overflow button should be pressed for
278 // popups. 282 // popups.
279 view.SetVisible(false); 283 view.SetVisible(false);
280 controller.ShowPopup(true); 284 controller.ShowPopup(true);
281 EXPECT_EQ(views::Button::STATE_NORMAL, view.state()); 285 EXPECT_EQ(views::Button::STATE_NORMAL, view.state());
282 EXPECT_EQ(views::Button::STATE_PRESSED, overflow_button.state()); 286 EXPECT_EQ(views::Button::STATE_PRESSED, overflow_button.state());
283 controller.HidePopup(); 287 controller.HidePopup();
284 EXPECT_EQ(views::Button::STATE_NORMAL, view.state()); 288 EXPECT_EQ(views::Button::STATE_NORMAL, view.state());
285 EXPECT_EQ(views::Button::STATE_NORMAL, overflow_button.state()); 289 EXPECT_EQ(views::Button::STATE_NORMAL, overflow_button.state());
286 } 290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698