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

Side by Side Diff: chrome/browser/net/chrome_network_delegate_unittest.cc

Issue 1056003003: Policy: Ignore ForceSafeSearch if ForceGoogleSafeSearch or ForceYoutubeSafetyMode are enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update test Created 5 years, 8 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 "chrome/browser/net/chrome_network_delegate.h" 5 #include "chrome/browser/net/chrome_network_delegate.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 net::NetworkDelegate* network_delegate_; 211 net::NetworkDelegate* network_delegate_;
212 net::TestDelegate delegate_; 212 net::TestDelegate delegate_;
213 }; 213 };
214 214
215 TEST_F(ChromeNetworkDelegateSafeSearchTest, SafeSearch) { 215 TEST_F(ChromeNetworkDelegateSafeSearchTest, SafeSearch) {
216 scoped_ptr<net::NetworkDelegate> delegate(CreateNetworkDelegate()); 216 scoped_ptr<net::NetworkDelegate> delegate(CreateNetworkDelegate());
217 SetDelegate(delegate.get()); 217 SetDelegate(delegate.get());
218 218
219 // Loop over all combinations of the three policies. 219 // Loop over all combinations of the three policies.
220 for (int i = 0; i < 8; i++) { 220 for (int i = 0; i < 8; i++) {
221 bool safe_search = i % 2; 221 bool safe_search = i % 2;
Thiemo Nagel 2015/04/14 14:39:58 For full test coverage, these bools most be conver
Marc Treib 2015/04/14 14:47:38 See above: There really is no tri-state logic here
222 bool google_safe_search = (i / 2) % 2; 222 bool google_safe_search = (i / 2) % 2;
223 bool youtube_safety_mode = i / 4; 223 bool youtube_safety_mode = i / 4;
224 SetSafeSearch(safe_search, google_safe_search, youtube_safety_mode); 224 SetSafeSearch(safe_search, google_safe_search, youtube_safety_mode);
225 225
226 // The old "SafeSearch" policy implies both Google and YouTube. 226 // The legacy "SafeSearch" policy implies both Google and YouTube, but it is
227 bool expect_google_safe_search = safe_search || google_safe_search; 227 // ignored if either of the new policies are enabled.
228 bool expect_youtube_safety_mode = safe_search || youtube_safety_mode; 228 bool expect_google_safe_search = google_safe_search ||
229 (!google_safe_search && !youtube_safety_mode && safe_search);
230 bool expect_youtube_safety_mode = youtube_safety_mode ||
231 (!google_safe_search && !youtube_safety_mode && safe_search);
229 QueryURL(expect_google_safe_search, expect_youtube_safety_mode); 232 QueryURL(expect_google_safe_search, expect_youtube_safety_mode);
230 } 233 }
231 } 234 }
232 235
233 // Privacy Mode disables Channel Id if cookies are blocked (cr223191) 236 // Privacy Mode disables Channel Id if cookies are blocked (cr223191)
234 class ChromeNetworkDelegatePrivacyModeTest : public testing::Test { 237 class ChromeNetworkDelegatePrivacyModeTest : public testing::Test {
235 public: 238 public:
236 ChromeNetworkDelegatePrivacyModeTest() 239 ChromeNetworkDelegatePrivacyModeTest()
237 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), 240 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
238 #if defined(ENABLE_EXTENSIONS) 241 #if defined(ENABLE_EXTENSIONS)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 kBlockedFirstPartySite)); 342 kBlockedFirstPartySite));
340 343
341 cookie_settings_->SetCookieSetting( 344 cookie_settings_->SetCookieSetting(
342 ContentSettingsPattern::FromURL(kBlockedFirstPartySite), 345 ContentSettingsPattern::FromURL(kBlockedFirstPartySite),
343 ContentSettingsPattern::Wildcard(), 346 ContentSettingsPattern::Wildcard(),
344 CONTENT_SETTING_BLOCK); 347 CONTENT_SETTING_BLOCK);
345 // Privacy mode is disabled as kAllowedSite is still getting cookies 348 // Privacy mode is disabled as kAllowedSite is still getting cookies
346 EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite, 349 EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite,
347 kBlockedFirstPartySite)); 350 kBlockedFirstPartySite));
348 } 351 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698