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

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: Rebase Created 3 years, 11 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
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 #if !defined(OS_MACOSX) 220 #if !defined(OS_MACOSX)
221 #include "base/compiler_specific.h" 221 #include "base/compiler_specific.h"
222 #include "chrome/browser/ui/extensions/app_launch_params.h" 222 #include "chrome/browser/ui/extensions/app_launch_params.h"
223 #include "chrome/browser/ui/extensions/application_launch.h" 223 #include "chrome/browser/ui/extensions/application_launch.h"
224 #include "extensions/browser/app_window/app_window.h" 224 #include "extensions/browser/app_window/app_window.h"
225 #include "extensions/browser/app_window/app_window_registry.h" 225 #include "extensions/browser/app_window/app_window_registry.h"
226 #include "extensions/browser/app_window/native_app_window.h" 226 #include "extensions/browser/app_window/native_app_window.h"
227 #include "ui/base/window_open_disposition.h" 227 #include "ui/base/window_open_disposition.h"
228 #endif 228 #endif
229 229
230 #if defined(ENABLE_MEDIA_ROUTER)
pastarmovj 2017/01/24 23:03:46 nit: you can combine the two if-defs in one.
takumif 2017/01/26 23:12:35 Done.
231 #if !defined(OS_ANDROID)
232 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
233 #include "chrome/browser/ui/toolbar/media_router_action_controller.h"
234 #endif // !defined(OS_ANDROID)
235 #endif // defined(ENABLE_MEDIA_ROUTER)
236
230 using content::BrowserThread; 237 using content::BrowserThread;
231 using net::URLRequestMockHTTPJob; 238 using net::URLRequestMockHTTPJob;
232 using testing::Mock; 239 using testing::Mock;
233 using testing::Return; 240 using testing::Return;
234 using testing::_; 241 using testing::_;
235 242
236 namespace policy { 243 namespace policy {
237 244
238 namespace { 245 namespace {
239 246
(...skipping 3334 matching lines...) Expand 10 before | Expand all | Expand 10 after
3574 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>; 3581 using MediaRouterEnabledPolicyTest = MediaRouterPolicyTest<true>;
3575 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>; 3582 using MediaRouterDisabledPolicyTest = MediaRouterPolicyTest<false>;
3576 3583
3577 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) { 3584 IN_PROC_BROWSER_TEST_F(MediaRouterEnabledPolicyTest, MediaRouterEnabled) {
3578 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile())); 3585 EXPECT_TRUE(media_router::MediaRouterEnabled(browser()->profile()));
3579 } 3586 }
3580 3587
3581 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { 3588 IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) {
3582 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile())); 3589 EXPECT_FALSE(media_router::MediaRouterEnabled(browser()->profile()));
3583 } 3590 }
3591
3592 #if !defined(OS_ANDROID)
3593 template <bool enable>
3594 class MediaRouterActionPolicyTest : public PolicyTest {
3595 public:
3596 void SetUpInProcessBrowserTestFixture() override {
3597 PolicyTest::SetUpInProcessBrowserTestFixture();
3598 PolicyMap policies;
3599 policies.Set(key::kShowCastIconInToolbar, POLICY_LEVEL_MANDATORY,
3600 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
3601 base::MakeUnique<base::FundamentalValue>(enable), nullptr);
3602 provider_.UpdateChromePolicy(policies);
3603 }
3604
3605 protected:
3606 bool HasMediaRouterActionAtInit() const {
3607 const std::set<std::string>& component_ids =
3608 ComponentToolbarActionsFactory::GetInstance()->GetInitialComponentIds(
3609 browser()->profile());
3610 return base::ContainsKey(
3611 component_ids, ComponentToolbarActionsFactory::kMediaRouterActionId);
3612 }
3613 };
3614
3615 using MediaRouterActionEnabledPolicyTest = MediaRouterActionPolicyTest<true>;
3616 using MediaRouterActionDisabledPolicyTest = MediaRouterActionPolicyTest<false>;
3617
3618 IN_PROC_BROWSER_TEST_F(MediaRouterActionEnabledPolicyTest,
3619 MediaRouterActionEnabled) {
3620 EXPECT_TRUE(
3621 MediaRouterActionController::IsActionShownByPolicy(browser()->profile()));
3622 EXPECT_TRUE(HasMediaRouterActionAtInit());
3623 }
3624
3625 IN_PROC_BROWSER_TEST_F(MediaRouterActionDisabledPolicyTest,
3626 MediaRouterActionDisabled) {
3627 EXPECT_FALSE(
3628 MediaRouterActionController::IsActionShownByPolicy(browser()->profile()));
3629 EXPECT_FALSE(HasMediaRouterActionAtInit());
3630 }
3631 #endif // !defined(OS_ANDROID)
3584 #endif // defined(ENABLE_MEDIA_ROUTER) 3632 #endif // defined(ENABLE_MEDIA_ROUTER)
3585 3633
3586 #if BUILDFLAG(ENABLE_WEBRTC) 3634 #if BUILDFLAG(ENABLE_WEBRTC)
3587 // Sets the proper policy before the browser is started. 3635 // Sets the proper policy before the browser is started.
3588 template <bool enable> 3636 template <bool enable>
3589 class WebRtcUdpPortRangePolicyTest : public PolicyTest { 3637 class WebRtcUdpPortRangePolicyTest : public PolicyTest {
3590 public: 3638 public:
3591 WebRtcUdpPortRangePolicyTest() = default; 3639 WebRtcUdpPortRangePolicyTest() = default;
3592 void SetUpInProcessBrowserTestFixture() override { 3640 void SetUpInProcessBrowserTestFixture() override {
3593 PolicyTest::SetUpInProcessBrowserTestFixture(); 3641 PolicyTest::SetUpInProcessBrowserTestFixture();
(...skipping 726 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