Chromium Code Reviews| Index: chrome/browser/policy/policy_browsertest.cc |
| diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc |
| index 446d632117e4ad244b1fc732ff7684d9c0610125..686dc01269944736a64bc24956cc7bbce7ca4f8e 100644 |
| --- a/chrome/browser/policy/policy_browsertest.cc |
| +++ b/chrome/browser/policy/policy_browsertest.cc |
| @@ -118,6 +118,7 @@ |
| #include "components/strings/grit/components_strings.h" |
| #include "components/translate/core/browser/language_state.h" |
| #include "components/translate/core/browser/translate_infobar_delegate.h" |
| +#include "components/user_prefs/user_prefs.h" |
| #include "components/variations/service/variations_service.h" |
| #include "components/version_info/version_info.h" |
| #include "content/public/browser/browser_child_process_host_iterator.h" |
| @@ -3739,6 +3740,49 @@ IN_PROC_BROWSER_TEST_F(MediaRouterDisabledPolicyTest, MediaRouterDisabled) { |
| } |
| #endif // defined(ENABLE_MEDIA_ROUTER) |
| +#if defined(ENABLE_WEBRTC) |
| +// Sets the proper policy before the browser is started. |
| +template <bool enable> |
| +class WebRtcUdpPortRangePolicyTest : public PolicyTest { |
| + public: |
| + void SetUpInProcessBrowserTestFixture() override { |
| + PolicyTest::SetUpInProcessBrowserTestFixture(); |
| + PolicyMap policies; |
| + if (enable) { |
| + policies.Set(key::kWebRtcUdpPortRange, POLICY_LEVEL_MANDATORY, |
| + POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| + base::WrapUnique(new base::StringValue("10000-10100")), |
| + nullptr); |
| + } |
| + provider_.UpdateChromePolicy(policies); |
| + } |
| +}; |
|
sky
2016/08/08 15:20:38
nit: private: DISALLOW...
Guido Urdaneta
2016/08/08 16:27:11
Done.
|
| + |
| +using WebRtcUdpPortRangeEnabledPolicyTest = WebRtcUdpPortRangePolicyTest<true>; |
| +using WebRtcUdpPortRangeDisabledPolicyTest = |
| + WebRtcUdpPortRangePolicyTest<false>; |
| + |
| +IN_PROC_BROWSER_TEST_F(WebRtcUdpPortRangeEnabledPolicyTest, |
| + WebRtcUdpPortRangeEnabled) { |
| + std::string port_range; |
| + const PrefService::Preference* pref = |
| + user_prefs::UserPrefs::Get(browser()->profile()) |
| + ->FindPreference(prefs::kWebRTCUDPPortRange); |
| + pref->GetValue()->GetAsString(&port_range); |
| + EXPECT_EQ("10000-10100", port_range); |
|
sky
2016/08/08 15:20:38
Document where this string comes from.
Guido Urdaneta
2016/08/08 16:27:11
Done. Using a constant now.
|
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(WebRtcUdpPortRangeDisabledPolicyTest, |
| + WebRtcUdpPortRangeDisabled) { |
| + std::string port_range; |
| + const PrefService::Preference* pref = |
| + user_prefs::UserPrefs::Get(browser()->profile()) |
| + ->FindPreference(prefs::kWebRTCUDPPortRange); |
| + pref->GetValue()->GetAsString(&port_range); |
| + EXPECT_TRUE(port_range.empty()); |
| +} |
| +#endif // defined(ENABLE_WEBRTC) |
| + |
| #if !defined(OS_CHROMEOS) |
| // Similar to PolicyTest but sets the proper policy before the browser is |
| // started. |