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

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

Issue 2736863002: Migrate the pref to always show the Cast icon (Closed)
Patch Set: Group ifdefs 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 MediaRouterActionController::SetAlwaysShowActionPref(browser()->profile(), 115 MediaRouterActionController::SetAlwaysShowActionPref(browser()->profile(),
110 always_show); 116 always_show);
111 } 117 }
112 118
113 AppMenuButton* GetAppMenuButton() { 119 AppMenuButton* GetAppMenuButton() {
114 return BrowserView::GetBrowserViewForBrowser(browser()) 120 return BrowserView::GetBrowserViewForBrowser(browser())
115 ->toolbar() 121 ->toolbar()
116 ->app_menu_button(); 122 ->app_menu_button();
117 } 123 }
118 124
125 // Sets the old preference to show the toolbar action icon to |always_show|,
126 // and migrates the preference.
127 void MigrateToolbarIconPref(bool always_show) {
128 {
129 DictionaryPrefUpdate update(browser()->profile()->GetPrefs(),
130 kToolbarMigratedComponentActionStatus);
131 update->SetBoolean(ComponentToolbarActionsFactory::kMediaRouterActionId,
132 always_show);
133 }
134 chrome::MigrateObsoleteProfilePrefs(browser()->profile());
135 }
136
119 protected: 137 protected:
120 ToolbarActionsBar* toolbar_actions_bar_ = nullptr; 138 ToolbarActionsBar* toolbar_actions_bar_ = nullptr;
121 139
122 Issue issue_; 140 Issue issue_;
123 141
124 // A vector of MediaRoutes that includes a local route. 142 // A vector of MediaRoutes that includes a local route.
125 std::vector<MediaRoute> routes_; 143 std::vector<MediaRoute> routes_;
126 144
127 MediaRouterActionController* action_controller_ = nullptr; 145 MediaRouterActionController* action_controller_ = nullptr;
128 }; 146 };
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 // The action should get hidden in the overflow menu. 362 // The action should get hidden in the overflow menu.
345 EXPECT_FALSE( 363 EXPECT_FALSE(
346 toolbar_actions_bar_->IsActionVisibleOnMainBar(GetMediaRouterAction())); 364 toolbar_actions_bar_->IsActionVisibleOnMainBar(GetMediaRouterAction()));
347 GetActionContextMenu()->ActivatedAt(command_index); 365 GetActionContextMenu()->ActivatedAt(command_index);
348 366
349 // The action should be back on the main bar. 367 // The action should be back on the main bar.
350 EXPECT_TRUE( 368 EXPECT_TRUE(
351 toolbar_actions_bar_->IsActionVisibleOnMainBar(GetMediaRouterAction())); 369 toolbar_actions_bar_->IsActionVisibleOnMainBar(GetMediaRouterAction()));
352 } 370 }
353 371
372 IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest, MigrateToolbarIconShownPref) {
373 MigrateToolbarIconPref(true);
374 EXPECT_TRUE(MediaRouterActionController::GetAlwaysShowActionPref(
375 browser()->profile()));
376 }
377
378 IN_PROC_BROWSER_TEST_F(MediaRouterUIBrowserTest,
379 MigrateToolbarIconUnshownPref) {
380 MigrateToolbarIconPref(false);
381 EXPECT_FALSE(MediaRouterActionController::GetAlwaysShowActionPref(
382 browser()->profile()));
383 }
384
354 } // namespace media_router 385 } // 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