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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 2559323002: Add a policy to always show the Cast toolbar icon (Closed)
Patch Set: Address Derek's comments Created 4 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 #if !defined(OS_MACOSX) 222 #if !defined(OS_MACOSX)
223 #include "base/compiler_specific.h" 223 #include "base/compiler_specific.h"
224 #include "chrome/browser/ui/extensions/app_launch_params.h" 224 #include "chrome/browser/ui/extensions/app_launch_params.h"
225 #include "chrome/browser/ui/extensions/application_launch.h" 225 #include "chrome/browser/ui/extensions/application_launch.h"
226 #include "extensions/browser/app_window/app_window.h" 226 #include "extensions/browser/app_window/app_window.h"
227 #include "extensions/browser/app_window/app_window_registry.h" 227 #include "extensions/browser/app_window/app_window_registry.h"
228 #include "extensions/browser/app_window/native_app_window.h" 228 #include "extensions/browser/app_window/native_app_window.h"
229 #include "ui/base/window_open_disposition.h" 229 #include "ui/base/window_open_disposition.h"
230 #endif 230 #endif
231 231
232 #if defined(ENABLE_MEDIA_ROUTER)
233 #if !defined(OS_ANDROID)
234 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
235 #include "chrome/browser/ui/toolbar/media_router_action_controller.h"
236 #endif // !defined(OS_ANDROID)
237 #endif // defined(ENABLE_MEDIA_ROUTER)
238
232 using content::BrowserThread; 239 using content::BrowserThread;
233 using net::URLRequestMockHTTPJob; 240 using net::URLRequestMockHTTPJob;
234 using testing::Mock; 241 using testing::Mock;
235 using testing::Return; 242 using testing::Return;
236 using testing::_; 243 using testing::_;
237 244
238 namespace policy { 245 namespace policy {
239 246
240 namespace { 247 namespace {
241 248
(...skipping 3328 matching lines...) Expand 10 before | Expand all | Expand 10 after
3570 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>; 3577 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>;
3571 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>; 3578 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>;
3572 3579
3573 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { 3580 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) {
3574 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); 3581 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile()));
3575 } 3582 }
3576 3583
3577 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { 3584 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) {
3578 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile())); 3585 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile()));
3579 } 3586 }
3587
3588 #if !defined(OS_ANDROID)
3589 template <bool enable>
3590 class MediaRouterActionPolicyTest : public PolicyTest {
3591 public:
3592 void SetUpInProcessBrowserTestFixture() override {
3593 PolicyTest::SetUpInProcessBrowserTestFixture();
3594 PolicyMap policies;
3595 policies.Set(key::kShowCastIconInToolbar, POLICY_LEVEL_MANDATORY,
3596 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
3597 base::MakeUnique<base::FundamentalValue>(enable), nullptr);
3598 provider_.UpdateChromePolicy(policies);
3599 }
3600
3601 protected:
3602 bool HasMediaRouterActionAtInit() const {
3603 const std::set<std::string>& component_ids =
3604 ComponentToolbarActionsFactory::GetInstance()->GetInitialComponentIds(
3605 browser()->profile());
3606 return base::ContainsKey(
3607 component_ids, ComponentToolbarActionsFactory::kMediaRouterActionId);
3608 }
3609 };
3610
3611 using MediaRouterActionEnabledPolicyTest = MediaRouterActionPolicyTest<true>;
3612 using MediaRouterActionDisabledPolicyTest = MediaRouterActionPolicyTest<false>;
3613
3614 IN_PROC_BROWSER_TEST_F(MediaRouterActionEnabledPolicyTest,
3615 MediaRouterActionEnabled) {
3616 EXPECT_TRUE(
3617 MediaRouterActionController::IsActionShownByPolicy(browser()->profile()));
3618 EXPECT_TRUE(HasMediaRouterActionAtInit());
3619 }
3620
3621 IN_PROC_BROWSER_TEST_F(MediaRouterActionDisabledPolicyTest,
3622 MediaRouterActionDisabled) {
3623 EXPECT_FALSE(
3624 MediaRouterActionController::IsActionShownByPolicy(browser()->profile()));
3625 EXPECT_FALSE(HasMediaRouterActionAtInit());
3626 }
3627 #endif // !defined(OS_ANDROID)
3580 #endif // defined(ENABLE_MEDIA_ROUTER) 3628 #endif // defined(ENABLE_MEDIA_ROUTER)
3581 3629
3582 #if BUILDFLAG(ENABLE_WEBRTC) 3630 #if BUILDFLAG(ENABLE_WEBRTC)
3583 // Sets the proper policy before the browser is started. 3631 // Sets the proper policy before the browser is started.
3584 template <bool enable> 3632 template <bool enable>
3585 class WebRtcUdpPortRangePolicyTest : public PolicyTest { 3633 class WebRtcUdpPortRangePolicyTest : public PolicyTest {
3586 public: 3634 public:
3587 WebRtcUdpPortRangePolicyTest() = default; 3635 WebRtcUdpPortRangePolicyTest() = default;
3588 void SetUpInProcessBrowserTestFixture() override { 3636 void SetUpInProcessBrowserTestFixture() override {
3589 PolicyTest::SetUpInProcessBrowserTestFixture(); 3637 PolicyTest::SetUpInProcessBrowserTestFixture();
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
4320 4368
4321 SetEmptyPolicy(); 4369 SetEmptyPolicy();
4322 // Policy not set. 4370 // Policy not set.
4323 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); 4371 CheckSystemTimezoneAutomaticDetectionPolicyUnset();
4324 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); 4372 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false));
4325 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); 4373 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
4326 } 4374 }
4327 #endif // defined(OS_CHROMEOS) 4375 #endif // defined(OS_CHROMEOS)
4328 4376
4329 } // namespace policy 4377 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698