| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/threading/thread_task_runner_handle.h" | 6 #include "base/threading/thread_task_runner_handle.h" |
| 7 #include "chrome/browser/extensions/browser_action_test_util.h" | 7 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 8 #include "chrome/browser/media/router/media_router_ui_service.h" | 8 #include "chrome/browser/media/router/media_router_ui_service.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "content/public/test/test_navigation_observer.h" | 26 #include "content/public/test/test_navigation_observer.h" |
| 27 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
| 28 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
| 29 | 29 |
| 30 namespace media_router { | 30 namespace media_router { |
| 31 | 31 |
| 32 class MediaRouterUIBrowserTest : public InProcessBrowserTest { | 32 class MediaRouterUIBrowserTest : public InProcessBrowserTest { |
| 33 public: | 33 public: |
| 34 MediaRouterUIBrowserTest() {} | 34 MediaRouterUIBrowserTest() |
| 35 : issue_(IssueInfo("title notification", |
| 36 IssueInfo::Action::DISMISS, |
| 37 IssueInfo::Severity::NOTIFICATION)) {} |
| 35 ~MediaRouterUIBrowserTest() override {} | 38 ~MediaRouterUIBrowserTest() override {} |
| 36 | 39 |
| 37 void SetUpOnMainThread() override { | 40 void SetUpOnMainThread() override { |
| 38 InProcessBrowserTest::SetUpOnMainThread(); | 41 InProcessBrowserTest::SetUpOnMainThread(); |
| 39 | 42 |
| 40 BrowserActionsContainer* browser_actions_container = | 43 BrowserActionsContainer* browser_actions_container = |
| 41 BrowserView::GetBrowserViewForBrowser(browser()) | 44 BrowserView::GetBrowserViewForBrowser(browser()) |
| 42 ->toolbar() | 45 ->toolbar() |
| 43 ->browser_actions(); | 46 ->browser_actions(); |
| 44 ASSERT_TRUE(browser_actions_container); | 47 ASSERT_TRUE(browser_actions_container); |
| 45 toolbar_actions_bar_ = browser_actions_container->toolbar_actions_bar(); | 48 toolbar_actions_bar_ = browser_actions_container->toolbar_actions_bar(); |
| 46 | 49 |
| 47 action_controller_ = | 50 action_controller_ = |
| 48 MediaRouterUIService::Get(browser()->profile())->action_controller(); | 51 MediaRouterUIService::Get(browser()->profile())->action_controller(); |
| 49 | 52 |
| 50 issue_.reset(new Issue( | |
| 51 "title notification", "message notification", | |
| 52 media_router::IssueAction(media_router::IssueAction::TYPE_DISMISS), | |
| 53 std::vector<media_router::IssueAction>(), "route_id", | |
| 54 media_router::Issue::NOTIFICATION, false, -1)); | |
| 55 | |
| 56 routes_ = {MediaRoute("routeId1", MediaSource("sourceId"), "sinkId1", | 53 routes_ = {MediaRoute("routeId1", MediaSource("sourceId"), "sinkId1", |
| 57 "description", true, std::string(), true)}; | 54 "description", true, std::string(), true)}; |
| 58 } | 55 } |
| 59 | 56 |
| 60 void OpenMediaRouterDialogAndWaitForNewWebContents() { | 57 void OpenMediaRouterDialogAndWaitForNewWebContents() { |
| 61 content::TestNavigationObserver nav_observer(NULL); | 58 content::TestNavigationObserver nav_observer(NULL); |
| 62 nav_observer.StartWatchingNewWebContents(); | 59 nav_observer.StartWatchingNewWebContents(); |
| 63 | 60 |
| 64 AppMenuButton* app_menu_button = | 61 AppMenuButton* app_menu_button = |
| 65 BrowserView::GetBrowserViewForBrowser(browser()) | 62 BrowserView::GetBrowserViewForBrowser(browser()) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 void SetAlwaysShowActionPref(bool always_show) { | 98 void SetAlwaysShowActionPref(bool always_show) { |
| 102 return ToolbarActionsModel::Get(browser()->profile()) | 99 return ToolbarActionsModel::Get(browser()->profile()) |
| 103 ->component_migration_helper() | 100 ->component_migration_helper() |
| 104 ->SetComponentActionPref( | 101 ->SetComponentActionPref( |
| 105 ComponentToolbarActionsFactory::kMediaRouterActionId, always_show); | 102 ComponentToolbarActionsFactory::kMediaRouterActionId, always_show); |
| 106 } | 103 } |
| 107 | 104 |
| 108 protected: | 105 protected: |
| 109 ToolbarActionsBar* toolbar_actions_bar_ = nullptr; | 106 ToolbarActionsBar* toolbar_actions_bar_ = nullptr; |
| 110 | 107 |
| 111 std::unique_ptr<Issue> issue_; | 108 Issue issue_; |
| 112 | 109 |
| 113 // A vector of MediaRoutes that includes a local route. | 110 // A vector of MediaRoutes that includes a local route. |
| 114 std::vector<MediaRoute> routes_; | 111 std::vector<MediaRoute> routes_; |
| 115 | 112 |
| 116 MediaRouterActionController* action_controller_ = nullptr; | 113 MediaRouterActionController* action_controller_ = nullptr; |
| 117 }; | 114 }; |
| 118 | 115 |
| 119 // TODO(crbug.com/658005): Fails on multiple platforms. | 116 // TODO(crbug.com/658005): Fails on multiple platforms. |
| 120 IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, | 117 IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, |
| 121 DISABLED_OpenDialogWithMediaRouterAction) { | 118 DISABLED_OpenDialogWithMediaRouterAction) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 143 | 140 |
| 144 // The navigation should have removed the previously created dialog. | 141 // The navigation should have removed the previously created dialog. |
| 145 // We expect a new dialog WebContents to be created by calling this. | 142 // We expect a new dialog WebContents to be created by calling this. |
| 146 OpenMediaRouterDialogAndWaitForNewWebContents(); | 143 OpenMediaRouterDialogAndWaitForNewWebContents(); |
| 147 | 144 |
| 148 SetAlwaysShowActionPref(false); | 145 SetAlwaysShowActionPref(false); |
| 149 } | 146 } |
| 150 | 147 |
| 151 IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, | 148 IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, |
| 152 EphemeralToolbarIconForRoutesAndIssues) { | 149 EphemeralToolbarIconForRoutesAndIssues) { |
| 153 action_controller_->OnIssueUpdated(issue_.get()); | 150 action_controller_->OnIssue(issue_); |
| 154 EXPECT_TRUE(ActionExists()); | 151 EXPECT_TRUE(ActionExists()); |
| 155 action_controller_->OnIssueUpdated(nullptr); | 152 action_controller_->OnIssuesCleared(); |
| 156 EXPECT_FALSE(ActionExists()); | 153 EXPECT_FALSE(ActionExists()); |
| 157 | 154 |
| 158 action_controller_->OnRoutesUpdated(routes_, std::vector<MediaRoute::Id>()); | 155 action_controller_->OnRoutesUpdated(routes_, std::vector<MediaRoute::Id>()); |
| 159 EXPECT_TRUE(ActionExists()); | 156 EXPECT_TRUE(ActionExists()); |
| 160 action_controller_->OnRoutesUpdated(std::vector<MediaRoute>(), | 157 action_controller_->OnRoutesUpdated(std::vector<MediaRoute>(), |
| 161 std::vector<MediaRoute::Id>()); | 158 std::vector<MediaRoute::Id>()); |
| 162 EXPECT_FALSE(ActionExists()); | 159 EXPECT_FALSE(ActionExists()); |
| 163 | 160 |
| 164 SetAlwaysShowActionPref(true); | 161 SetAlwaysShowActionPref(true); |
| 165 EXPECT_TRUE(ActionExists()); | 162 EXPECT_TRUE(ActionExists()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 action_controller_->OnRoutesUpdated(std::vector<MediaRoute>(), | 210 action_controller_->OnRoutesUpdated(std::vector<MediaRoute>(), |
| 214 std::vector<MediaRoute::Id>()); | 211 std::vector<MediaRoute::Id>()); |
| 215 EXPECT_FALSE(ActionExists()); | 212 EXPECT_FALSE(ActionExists()); |
| 216 action_controller_->OnRoutesUpdated(routes_, std::vector<MediaRoute::Id>()); | 213 action_controller_->OnRoutesUpdated(routes_, std::vector<MediaRoute::Id>()); |
| 217 EXPECT_TRUE(ActionExists()); | 214 EXPECT_TRUE(ActionExists()); |
| 218 browser2->window()->Close(); | 215 browser2->window()->Close(); |
| 219 EXPECT_TRUE(ActionExists()); | 216 EXPECT_TRUE(ActionExists()); |
| 220 } | 217 } |
| 221 | 218 |
| 222 } // namespace media_router | 219 } // namespace media_router |
| OLD | NEW |