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 deb63130a8b2b82f52b7068e78fb295396571aeb..006e8951e19c38b065804f2ca4e2d36c0cf4d272 100644 |
| --- a/chrome/browser/policy/policy_browsertest.cc |
| +++ b/chrome/browser/policy/policy_browsertest.cc |
| @@ -883,13 +883,13 @@ class PolicyTest : public InProcessBrowserTest { |
| void ApplySafeSearchPolicy( |
| std::unique_ptr<base::FundamentalValue> legacy_safe_search, |
| std::unique_ptr<base::FundamentalValue> google_safe_search, |
| - std::unique_ptr<base::FundamentalValue> youtube_safety_mode) { |
| + std::unique_ptr<base::FundamentalValue> youtube_restrict) { |
| PolicyMap policies; |
| SetPolicy(&policies, key::kForceSafeSearch, std::move(legacy_safe_search)); |
| SetPolicy(&policies, key::kForceGoogleSafeSearch, |
| std::move(google_safe_search)); |
| - SetPolicy(&policies, key::kForceYouTubeSafetyMode, |
| - std::move(youtube_safety_mode)); |
| + SetPolicy(&policies, key::kForceYouTubeRestrict, |
| + std::move(youtube_restrict)); |
| UpdateProviderPolicy(policies); |
| } |
| @@ -1180,20 +1180,27 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ForceSafeSearch) { |
| // First check that nothing happens. |
| CheckSafeSearch(false); |
| - // Go over all combinations of (undefined,true,false) for the three policies. |
| - for (int i = 0; i < 3 * 3 * 3; i++) { |
| - int legacy = i % 3; |
| - int google = (i / 3) % 3; |
| - int youtube = i / (3 * 3); |
| + // Go over all combinations of (undefined,true,false) resp. |
| + // (undefined, off, moderate, strict) for the three policies. |
| + for (int i = 0; i < 3 * 3 * 4; i++) { |
| + int val = i; |
| + int legacy = val % 3; val /= 3; |
| + int google = val % 3; val /= 3; |
| + int youtube = val % 4; |
| // Override the default SafeSearch setting using policies. |
| + static_assert(safe_search_util::YOUTUBE_OFF == 0 && |
| + safe_search_util::YOUTUBE_MODERATE == 1 && |
| + safe_search_util::YOUTUBE_STRICT == 2, |
| + "Adjust 'youtube' to match YTRM enum"); |
| + |
| ApplySafeSearchPolicy( |
| - legacy == 0 ? nullptr |
| - : base::WrapUnique(new base::FundamentalValue(legacy == 1)), |
| - google == 0 ? nullptr |
| - : base::WrapUnique(new base::FundamentalValue(google == 1)), |
| - youtube == 0 ? nullptr : base::WrapUnique( |
| - new base::FundamentalValue(youtube == 1))); |
| + legacy == 0 ? nullptr |
| + : base::WrapUnique(new base::FundamentalValue(legacy == 1)), |
| + google == 0 ? nullptr |
| + : base::WrapUnique(new base::FundamentalValue(google == 1)), |
| + youtube == 0 ? nullptr // subtracting 1 gives 0,1,2, see above |
|
Marc Treib
2016/09/05 09:58:10
misaligned
ljusten (tachyonic)
2016/09/05 15:24:32
Done.
|
| + : base::WrapUnique(new base::FundamentalValue(youtube - 1))); |
| // The legacy policy should only have an effect if both google and youtube |
| // are undefined. |
| @@ -1207,9 +1214,14 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ForceSafeSearch) { |
| prefs->GetBoolean(prefs::kForceGoogleSafeSearch)); |
| EXPECT_EQ(youtube != 0 || legacy_in_effect, |
| - prefs->IsManagedPreference(prefs::kForceYouTubeSafetyMode)); |
| - EXPECT_EQ(youtube == 1 || legacy_enabled, |
| - prefs->GetBoolean(prefs::kForceYouTubeSafetyMode)); |
| + prefs->IsManagedPreference(prefs::kForceYouTubeRestrict)); |
| + EXPECT_EQ(youtube != 0, |
| + prefs->GetInteger(prefs::kForceYouTubeRestrict) == youtube - 1); |
| + |
| + // The legacy safe search policy should result in Moderate strictness |
| + if (youtube == 0 && legacy_enabled) |
|
Marc Treib
2016/09/05 09:58:10
nit: braces
ljusten (tachyonic)
2016/09/05 15:24:32
Done.
|
| + EXPECT_EQ(prefs->GetInteger(prefs::kForceYouTubeRestrict), |
| + safe_search_util::YOUTUBE_MODERATE); |
| CheckSafeSearch(google == 1 || legacy_enabled); |
| } |