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

Unified Diff: chrome/browser/net/chrome_network_delegate_unittest.cc

Issue 2401743003: Recommit and fix of "Added a ForceYouTubeRestrict policy and deprecated the old ForceYouTubeSafetyM… (Closed)
Patch Set: Rebase Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/net/chrome_network_delegate.cc ('k') | chrome/browser/net/safe_search_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/chrome_network_delegate_unittest.cc
diff --git a/chrome/browser/net/chrome_network_delegate_unittest.cc b/chrome/browser/net/chrome_network_delegate_unittest.cc
index 47e3ca8ac17fed75767fd20b88403d37379ca2f2..af4db9dabd9b4206dad1ba493bbdc9c233219663 100644
--- a/chrome/browser/net/chrome_network_delegate_unittest.cc
+++ b/chrome/browser/net/chrome_network_delegate_unittest.cc
@@ -402,7 +402,7 @@ class ChromeNetworkDelegateSafeSearchTest :
&enable_referrers_,
nullptr,
&force_google_safe_search_,
- &force_youtube_safety_mode_,
+ &force_youtube_restrict_,
nullptr,
profile_.GetTestingPrefService());
}
@@ -413,23 +413,20 @@ class ChromeNetworkDelegateSafeSearchTest :
new ChromeNetworkDelegate(forwarder(), &enable_referrers_,
metrics::UpdateUsagePrefCallbackType()));
network_delegate->set_force_google_safe_search(&force_google_safe_search_);
- network_delegate->set_force_youtube_safety_mode(
- &force_youtube_safety_mode_);
+ network_delegate->set_force_youtube_restrict(&force_youtube_restrict_);
return std::move(network_delegate);
}
- void SetSafeSearch(bool google_safe_search,
- bool youtube_safety_mode) {
+ void SetSafeSearch(bool google_safe_search, int youtube_restrict) {
force_google_safe_search_.SetValue(google_safe_search);
- force_youtube_safety_mode_.SetValue(youtube_safety_mode);
+ force_youtube_restrict_.SetValue(youtube_restrict);
}
// Does a request to an arbitrary URL and verifies that the SafeSearch
// enforcement utility functions were called/not called as expected.
- void QueryURL(bool expect_google_safe_search,
- bool expect_youtube_safety_mode) {
+ void QueryURL(bool expect_google_safe_search, bool expect_youtube_restrict) {
safe_search_util::ClearForceGoogleSafeSearchCountForTesting();
- safe_search_util::ClearForceYouTubeSafetyModeCountForTesting();
+ safe_search_util::ClearForceYouTubeRestrictCountForTesting();
std::unique_ptr<net::URLRequest> request(context_.CreateRequest(
GURL("http://anyurl.com"), net::DEFAULT_PRIORITY, &delegate_));
@@ -438,27 +435,33 @@ class ChromeNetworkDelegateSafeSearchTest :
base::RunLoop().RunUntilIdle();
EXPECT_EQ(expect_google_safe_search ? 1 : 0,
- safe_search_util::GetForceGoogleSafeSearchCountForTesting());
- EXPECT_EQ(expect_youtube_safety_mode ? 1 : 0,
- safe_search_util::GetForceYouTubeSafetyModeCountForTesting());
+ safe_search_util::GetForceGoogleSafeSearchCountForTesting());
+ EXPECT_EQ(expect_youtube_restrict ? 1 : 0,
+ safe_search_util::GetForceYouTubeRestrictCountForTesting());
}
private:
BooleanPrefMember force_google_safe_search_;
- BooleanPrefMember force_youtube_safety_mode_;
+ IntegerPrefMember force_youtube_restrict_;
};
TEST_F(ChromeNetworkDelegateSafeSearchTest, SafeSearch) {
std::unique_ptr<net::NetworkDelegate> delegate(CreateNetworkDelegate());
SetDelegate(delegate.get());
+ static_assert(safe_search_util::YOUTUBE_RESTRICT_OFF == 0 &&
+ safe_search_util::YOUTUBE_RESTRICT_MODERATE == 1 &&
+ safe_search_util::YOUTUBE_RESTRICT_STRICT == 2 &&
+ safe_search_util::YOUTUBE_RESTRICT_COUNT == 3,
+ "This test relies on mapping ints to enum values.");
+
// Loop over all combinations of the two policies.
- for (int i = 0; i < 4; i++) {
- bool google_safe_search = i % 2;
- bool youtube_safety_mode = i / 2;
- SetSafeSearch(google_safe_search, youtube_safety_mode);
+ for (int i = 0; i < 6; i++) {
+ bool google_safe_search = (i / 3) != 0;
+ int youtube_restrict = i % 3;
+ SetSafeSearch(google_safe_search, youtube_restrict);
- QueryURL(google_safe_search, youtube_safety_mode);
+ QueryURL(google_safe_search, youtube_restrict != 0);
}
}
« no previous file with comments | « chrome/browser/net/chrome_network_delegate.cc ('k') | chrome/browser/net/safe_search_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698