Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/extensions/browser_action_test_util.h" | |
| 5 #include "chrome/browser/ui/browser_commands.h" | 6 #include "chrome/browser/ui/browser_commands.h" |
| 6 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 7 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 7 #include "chrome/browser/ui/toolbar/media_router_action.h" | 8 #include "chrome/browser/ui/toolbar/media_router_action.h" |
| 8 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" | 9 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" |
| 9 #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller_im pl.h" | 10 #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller_im pl.h" |
| 10 #include "chrome/browser/ui/webui/media_router/media_router_test.h" | 11 #include "chrome/browser/ui/webui/media_router/media_router_test.h" |
| 11 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
| 12 #include "content/public/browser/site_instance.h" | 13 #include "content/public/browser/site_instance.h" |
| 13 #include "content/public/test/test_utils.h" | 14 #include "content/public/test/test_utils.h" |
| 14 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 27 | 28 |
| 28 MOCK_CONST_METHOD0(GetCurrentWebContents, WebContents*()); | 29 MOCK_CONST_METHOD0(GetCurrentWebContents, WebContents*()); |
| 29 MOCK_METHOD0(UpdateState, void()); | 30 MOCK_METHOD0(UpdateState, void()); |
| 30 MOCK_CONST_METHOD0(IsMenuRunning, bool()); | 31 MOCK_CONST_METHOD0(IsMenuRunning, bool()); |
| 31 MOCK_METHOD1(OnPopupShown, void(bool by_user)); | 32 MOCK_METHOD1(OnPopupShown, void(bool by_user)); |
| 32 MOCK_METHOD0(OnPopupClosed, void()); | 33 MOCK_METHOD0(OnPopupClosed, void()); |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 class TestMediaRouterAction : public MediaRouterAction { | 36 class TestMediaRouterAction : public MediaRouterAction { |
| 36 public: | 37 public: |
| 37 explicit TestMediaRouterAction(Browser* browser) | 38 explicit TestMediaRouterAction(Browser* browser, |
|
Peter Kasting
2015/12/03 04:48:53
Nit: No explicit
apacible
2015/12/03 21:53:10
Done.
| |
| 38 : MediaRouterAction(browser), | 39 ToolbarActionsBar* toolbar_actions_bar) |
| 40 : MediaRouterAction(browser, toolbar_actions_bar), | |
| 39 controller_(nullptr), | 41 controller_(nullptr), |
| 40 platform_delegate_(nullptr) {} | 42 platform_delegate_(nullptr) {} |
| 41 ~TestMediaRouterAction() override {} | 43 ~TestMediaRouterAction() override {} |
| 42 | 44 |
| 43 void SetMediaRouterDialogController( | 45 void SetMediaRouterDialogController( |
| 44 MediaRouterDialogControllerImpl* controller) { | 46 MediaRouterDialogControllerImpl* controller) { |
| 45 DCHECK(controller); | 47 DCHECK(controller); |
| 46 controller_ = controller; | 48 controller_ = controller; |
| 47 } | 49 } |
| 48 | 50 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 idle_icon_(ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 102 idle_icon_(ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 101 IDR_MEDIA_ROUTER_IDLE_ICON)), | 103 IDR_MEDIA_ROUTER_IDLE_ICON)), |
| 102 warning_icon_(ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 104 warning_icon_(ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 103 IDR_MEDIA_ROUTER_WARNING_ICON)) {} | 105 IDR_MEDIA_ROUTER_WARNING_ICON)) {} |
| 104 | 106 |
| 105 ~MediaRouterActionUnitTest() override {} | 107 ~MediaRouterActionUnitTest() override {} |
| 106 | 108 |
| 107 // MediaRouterTest: | 109 // MediaRouterTest: |
| 108 void SetUp() override { | 110 void SetUp() override { |
| 109 MediaRouterTest::SetUp(); | 111 MediaRouterTest::SetUp(); |
| 110 action_.reset(new TestMediaRouterAction(browser())); | 112 browser_action_test_util_.reset(new BrowserActionTestUtil(browser(), |
|
Peter Kasting
2015/12/03 04:48:53
Can we instantiate these in the constructor rather
apacible
2015/12/03 21:53:10
To use browser(), we have to wait for BrowserWithT
Peter Kasting
2015/12/03 22:00:19
Ah. Might be nice to just comment "browser() will
apacible
2015/12/07 21:52:43
Done.
| |
| 113 false)); | |
|
Peter Kasting
2015/12/03 04:48:53
Tiny nit: Personally I'd find wrapping after "rese
apacible
2015/12/03 21:53:10
Done.
| |
| 114 action_.reset(new TestMediaRouterAction( | |
| 115 browser(), | |
| 116 browser_action_test_util_->GetToolbarActionsBar())); | |
| 111 } | 117 } |
| 112 | 118 |
| 113 void TearDown() override { | 119 void TearDown() override { |
| 114 action_.reset(); | 120 action_.reset(); |
| 121 browser_action_test_util_.reset(); | |
|
Peter Kasting
2015/12/03 04:48:53
Why do we need to explicitly reset these here?
apacible
2015/12/03 21:53:10
Removed.
Peter Kasting
2015/12/03 22:00:19
We're still resetting |action_|. Is that necessar
apacible
2015/12/07 21:52:43
Yes. As it turns out, we still need to reset |brow
| |
| 115 MediaRouterTest::TearDown(); | 122 MediaRouterTest::TearDown(); |
| 116 } | 123 } |
| 117 | 124 |
| 118 TestMediaRouterAction* action() { return action_.get(); } | 125 TestMediaRouterAction* action() { return action_.get(); } |
| 119 const media_router::Issue* fake_issue_notification() { | 126 const media_router::Issue* fake_issue_notification() { |
| 120 return &fake_issue_notification_; | 127 return &fake_issue_notification_; |
| 121 } | 128 } |
| 122 const media_router::Issue* fake_issue_warning() { | 129 const media_router::Issue* fake_issue_warning() { |
| 123 return &fake_issue_warning_; | 130 return &fake_issue_warning_; |
| 124 } | 131 } |
| 125 const media_router::Issue* fake_issue_fatal() { | 132 const media_router::Issue* fake_issue_fatal() { |
| 126 return &fake_issue_fatal_; | 133 return &fake_issue_fatal_; |
| 127 } | 134 } |
| 128 const gfx::Image active_icon() { return active_icon_; } | 135 const gfx::Image active_icon() { return active_icon_; } |
| 129 const gfx::Image error_icon() { return error_icon_; } | 136 const gfx::Image error_icon() { return error_icon_; } |
| 130 const gfx::Image idle_icon() { return idle_icon_; } | 137 const gfx::Image idle_icon() { return idle_icon_; } |
| 131 const gfx::Image warning_icon() { return warning_icon_; } | 138 const gfx::Image warning_icon() { return warning_icon_; } |
| 132 | 139 |
| 133 private: | 140 private: |
| 134 scoped_ptr<TestMediaRouterAction> action_; | 141 scoped_ptr<TestMediaRouterAction> action_; |
| 135 | 142 |
| 143 // A BrowserActionTestUtil object constructed with the associated | |
| 144 // ToolbarActionsBar. | |
| 145 scoped_ptr<BrowserActionTestUtil> browser_action_test_util_; | |
| 146 | |
| 136 // Fake Issues. | 147 // Fake Issues. |
| 137 const media_router::Issue fake_issue_notification_; | 148 const media_router::Issue fake_issue_notification_; |
| 138 const media_router::Issue fake_issue_warning_; | 149 const media_router::Issue fake_issue_warning_; |
| 139 const media_router::Issue fake_issue_fatal_; | 150 const media_router::Issue fake_issue_fatal_; |
| 140 | 151 |
| 141 // Fake Sources, used for the Routes. | 152 // Fake Sources, used for the Routes. |
| 142 const media_router::MediaSource fake_source1_; | 153 const media_router::MediaSource fake_source1_; |
| 143 const media_router::MediaSource fake_source2_; | 154 const media_router::MediaSource fake_source2_; |
| 144 | 155 |
| 145 // Cached images. | 156 // Cached images. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 | 303 |
| 293 EXPECT_CALL(*mock_delegate, OnPopupClosed()).Times(1); | 304 EXPECT_CALL(*mock_delegate, OnPopupClosed()).Times(1); |
| 294 dialog_controller_->HideMediaRouterDialog(); | 305 dialog_controller_->HideMediaRouterDialog(); |
| 295 | 306 |
| 296 EXPECT_CALL(*mock_delegate, OnPopupShown(true)).Times(1); | 307 EXPECT_CALL(*mock_delegate, OnPopupShown(true)).Times(1); |
| 297 dialog_controller_->CreateMediaRouterDialog(); | 308 dialog_controller_->CreateMediaRouterDialog(); |
| 298 | 309 |
| 299 EXPECT_CALL(*mock_delegate, OnPopupClosed()).Times(1); | 310 EXPECT_CALL(*mock_delegate, OnPopupClosed()).Times(1); |
| 300 dialog_controller_->HideMediaRouterDialog(); | 311 dialog_controller_->HideMediaRouterDialog(); |
| 301 } | 312 } |
| OLD | NEW |