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

Side by Side Diff: chrome/browser/ui/views/media_router/media_router_ui_browsertest.cc

Issue 2744883002: Migrate the pref to always show the Cast icon (Closed)
Patch Set: Created 3 years, 9 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 | « chrome/browser/prefs/browser_prefs.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/extensions/browser_action_test_util.h" 8 #include "chrome/browser/extensions/browser_action_test_util.h"
9 #include "chrome/browser/media/router/media_router_ui_service.h" 9 #include "chrome/browser/media/router/media_router_ui_service.h"
10 #include "chrome/browser/prefs/browser_prefs.h"
10 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti l.h" 11 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti l.h"
11 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_commands.h" 13 #include "chrome/browser/ui/browser_commands.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" 15 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
15 #include "chrome/browser/ui/toolbar/media_router_action.h" 16 #include "chrome/browser/ui/toolbar/media_router_action.h"
16 #include "chrome/browser/ui/toolbar/media_router_action_controller.h" 17 #include "chrome/browser/ui/toolbar/media_router_action_controller.h"
17 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" 18 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h"
18 #include "chrome/browser/ui/views/frame/browser_view.h" 19 #include "chrome/browser/ui/views/frame/browser_view.h"
19 #include "chrome/browser/ui/views/toolbar/app_menu.h" 20 #include "chrome/browser/ui/views/toolbar/app_menu.h"
20 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" 21 #include "chrome/browser/ui/views/toolbar/app_menu_button.h"
21 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" 22 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
22 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" 23 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h"
23 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 24 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
24 #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller_im pl.h" 25 #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller_im pl.h"
25 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
26 #include "chrome/test/base/in_process_browser_test.h" 27 #include "chrome/test/base/in_process_browser_test.h"
27 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
28 #include "content/public/browser/navigation_entry.h" 29 #include "content/public/browser/navigation_entry.h"
29 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
30 #include "content/public/common/context_menu_params.h" 31 #include "content/public/common/context_menu_params.h"
31 #include "content/public/test/test_navigation_observer.h" 32 #include "content/public/test/test_navigation_observer.h"
32 #include "content/public/test/test_utils.h" 33 #include "content/public/test/test_utils.h"
33 #include "ui/views/widget/widget.h" 34 #include "ui/views/widget/widget.h"
34 35
36 namespace {
37 constexpr char kToolbarMigratedComponentActionStatus[] =
38 "toolbar_migrated_component_action_status";
39 }
40
35 namespace media_router { 41 namespace media_router {
36 42
37 class MediaRouterUIBrowserTest : public InProcessBrowserTest { 43 class MediaRouterUIBrowserTest : public InProcessBrowserTest {
38 public: 44 public:
39 MediaRouterUIBrowserTest() 45 MediaRouterUIBrowserTest()
40 : issue_(IssueInfo("title notification", 46 : issue_(IssueInfo("title notification",
41 IssueInfo::Action::DISMISS, 47 IssueInfo::Action::DISMISS,
42 IssueInfo::Severity::NOTIFICATION)) {} 48 IssueInfo::Severity::NOTIFICATION)) {}
43 ~MediaRouterUIBrowserTest() override {} 49 ~MediaRouterUIBrowserTest() override {}
44 50
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 MediaRouterActionController::SetAlwaysShowActionPref(browser()->profile(), 110 MediaRouterActionController::SetAlwaysShowActionPref(browser()->profile(),
105 always_show); 111 always_show);
106 } 112 }
107 113
108 AppMenuButton* GetAppMenuButton() { 114 AppMenuButton* GetAppMenuButton() {
109 return BrowserView::GetBrowserViewForBrowser(browser()) 115 return BrowserView::GetBrowserViewForBrowser(browser())
110 ->toolbar() 116 ->toolbar()
111 ->app_menu_button(); 117 ->app_menu_button();
112 } 118 }
113 119
120 // Sets the old preference to show the toolbar action icon to |always_show|,
121 // and migrates the preference.
122 void MigrateToolbarIconPref(bool always_show) {
123 {
124 DictionaryPrefUpdate update(browser()->profile()->GetPrefs(),
125 kToolbarMigratedComponentActionStatus);
126 update->SetBoolean(ComponentToolbarActionsFactory::kMediaRouterActionId,
127 always_show);
128 }
129 chrome::MigrateObsoleteProfilePrefs(browser()->profile());
130 }
131
114 protected: 132 protected:
115 ToolbarActionsBar* toolbar_actions_bar_ = nullptr; 133 ToolbarActionsBar* toolbar_actions_bar_ = nullptr;
116 134
117 Issue issue_; 135 Issue issue_;
118 136
119 // A vector of MediaRoutes that includes a local route. 137 // A vector of MediaRoutes that includes a local route.
120 std::vector<MediaRoute> routes_; 138 std::vector<MediaRoute> routes_;
121 139
122 MediaRouterActionController* action_controller_ = nullptr; 140 MediaRouterActionController* action_controller_ = nullptr;
123 }; 141 };
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 EXPECT_TRUE(ActionExists()); 335 EXPECT_TRUE(ActionExists());
318 action_controller_->OnRoutesUpdated(std::vector<MediaRoute>(), 336 action_controller_->OnRoutesUpdated(std::vector<MediaRoute>(),
319 std::vector<MediaRoute::Id>()); 337 std::vector<MediaRoute::Id>());
320 EXPECT_FALSE(ActionExists()); 338 EXPECT_FALSE(ActionExists());
321 action_controller_->OnRoutesUpdated(routes_, std::vector<MediaRoute::Id>()); 339 action_controller_->OnRoutesUpdated(routes_, std::vector<MediaRoute::Id>());
322 EXPECT_TRUE(ActionExists()); 340 EXPECT_TRUE(ActionExists());
323 browser2->window()->Close(); 341 browser2->window()->Close();
324 EXPECT_TRUE(ActionExists()); 342 EXPECT_TRUE(ActionExists());
325 } 343 }
326 344
345 IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, MigrateToolbarIconShownPref) {
346 MigrateToolbarIconPref(true);
347 EXPECT_TRUE(MediaRouterActionController::GetAlwaysShowActionPref(
348 browser()->profile()));
349 }
350
351 IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest,
352 MigrateToolbarIconUnshownPref) {
353 MigrateToolbarIconPref(false);
354 EXPECT_FALSE(MediaRouterActionController::GetAlwaysShowActionPref(
355 browser()->profile()));
356 }
357
327 } // namespace media_router 358 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/prefs/browser_prefs.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698