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

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: 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(OS_ANDROID)
imcheng 2016/12/15 19:57:38 #if defined(ENABLE_MEDIA_ROUTER)
takumif 2016/12/15 22:04:14 Done.
233 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
234 #include "chrome/browser/ui/toolbar/media_router_action_controller.h"
235 #endif
236
232 using content::BrowserThread; 237 using content::BrowserThread;
233 using net::URLRequestMockHTTPJob; 238 using net::URLRequestMockHTTPJob;
234 using testing::Mock; 239 using testing::Mock;
235 using testing::Return; 240 using testing::Return;
236 using testing::_; 241 using testing::_;
237 242
238 namespace policy { 243 namespace policy {
239 244
240 namespace { 245 namespace {
241 246
(...skipping 3236 matching lines...) Expand 10 before | Expand all | Expand 10 after
3478 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>; 3483 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>;
3479 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>; 3484 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>;
3480 3485
3481 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { 3486 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) {
3482 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); 3487 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile()));
3483 } 3488 }
3484 3489
3485 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { 3490 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) {
3486 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile())); 3491 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile()));
3487 } 3492 }
3493
3494 #if !defined(OS_ANDROID)
3495 template <bool enable>
3496 class MediaRouterActionPolicyTest : public PolicyTest {
3497 public:
3498 void SetUpInProcessBrowserTestFixture() override {
3499 PolicyTest::SetUpInProcessBrowserTestFixture();
3500 PolicyMap policies;
3501 policies.Set(key::kShowCastIconInToolbar, POLICY_LEVEL_MANDATORY,
3502 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
3503 base::MakeUnique<base::FundamentalValue>(enable), nullptr);
3504 provider_.UpdateChromePolicy(policies);
3505 }
3506
3507 protected:
3508 bool HasMediaRouterActionAtInit() const {
3509 const std::set<std::string>& component_ids =
3510 ComponentToolbarActionsFactory::GetInstance()->GetInitialComponentIds(
3511 browser()->profile());
3512 return base::ContainsKey(
3513 component_ids, ComponentToolbarActionsFactory::kMediaRouterActionId);
3514 }
3515 };
3516
3517 using MediaRouterActionEnabledPolicyTest = MediaRouterActionPolicyTest<true>;
3518 using MediaRouterActionDisabledPolicyTest = MediaRouterActionPolicyTest<false>;
3519
3520 IN_PROC_BROWSER_TEST_F(MediaRouterActionEnabledPolicyTest,
3521 MediaRouterActionEnabled) {
3522 EXPECT_TRUE(
3523 MediaRouterActionController::IsActionShownByPolicy(browser()->profile()));
3524 EXPECT_TRUE(HasMediaRouterActionAtInit());
3525 }
3526
3527 IN_PROC_BROWSER_TEST_F(MediaRouterActionDisabledPolicyTest,
3528 MediaRouterActionDisabled) {
3529 EXPECT_FALSE(
3530 MediaRouterActionController::IsActionShownByPolicy(browser()->profile()));
3531 EXPECT_FALSE(HasMediaRouterActionAtInit());
3532 }
3533 #endif // !defined(OS_ANDROID)
3488 #endif // defined(ENABLE_MEDIA_ROUTER) 3534 #endif // defined(ENABLE_MEDIA_ROUTER)
3489 3535
3490 #if BUILDFLAG(ENABLE_WEBRTC) 3536 #if BUILDFLAG(ENABLE_WEBRTC)
3491 // Sets the proper policy before the browser is started. 3537 // Sets the proper policy before the browser is started.
3492 template <bool enable> 3538 template <bool enable>
3493 class WebRtcUdpPortRangePolicyTest : public PolicyTest { 3539 class WebRtcUdpPortRangePolicyTest : public PolicyTest {
3494 public: 3540 public:
3495 WebRtcUdpPortRangePolicyTest() = default; 3541 WebRtcUdpPortRangePolicyTest() = default;
3496 void SetUpInProcessBrowserTestFixture() override { 3542 void SetUpInProcessBrowserTestFixture() override {
3497 PolicyTest::SetUpInProcessBrowserTestFixture(); 3543 PolicyTest::SetUpInProcessBrowserTestFixture();
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
4228 4274
4229 SetEmptyPolicy(); 4275 SetEmptyPolicy();
4230 // Policy not set. 4276 // Policy not set.
4231 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); 4277 CheckSystemTimezoneAutomaticDetectionPolicyUnset();
4232 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); 4278 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false));
4233 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); 4279 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
4234 } 4280 }
4235 #endif // defined(OS_CHROMEOS) 4281 #endif // defined(OS_CHROMEOS)
4236 4282
4237 } // namespace policy 4283 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698