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

Unified Diff: net/base/sdch_manager_unittest.cc

Issue 423813002: Sdch view for net-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create Dictionary JSON directly in SdchManager::SdchInfoToValue Created 6 years, 4 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
Index: net/base/sdch_manager_unittest.cc
diff --git a/net/base/sdch_manager_unittest.cc b/net/base/sdch_manager_unittest.cc
index 26893bd1b94f21f2e6c9286a33ae270ef9841b02..e2efa5410d15bc7bd505d6f2bf9a04093b82f82a 100644
--- a/net/base/sdch_manager_unittest.cc
+++ b/net/base/sdch_manager_unittest.cc
@@ -140,16 +140,18 @@ TEST_F(SdchManagerTest, CanSetExactMatchDictionary) {
std::string dictionary_text(NewSdchDictionary(dictionary_domain));
// Perfect match should work.
- EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text,
- GURL("http://" + dictionary_domain)));
+ SdchManager::ProblemCodes problem;
+ EXPECT_TRUE(sdch_manager()->AddSdchDictionary(
+ dictionary_text, GURL("http://" + dictionary_domain), &problem));
}
TEST_F(SdchManagerTest, CanAdvertiseDictionaryOverHTTP) {
std::string dictionary_domain("x.y.z.google.com");
std::string dictionary_text(NewSdchDictionary(dictionary_domain));
- EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text,
- GURL("http://" + dictionary_domain)));
+ SdchManager::ProblemCodes problem;
+ EXPECT_TRUE(sdch_manager()->AddSdchDictionary(
+ dictionary_text, GURL("http://" + dictionary_domain), &problem));
std::string dictionary_list;
// HTTP target URL can advertise dictionary.
@@ -163,8 +165,9 @@ TEST_F(SdchManagerTest, CanNotAdvertiseDictionaryOverHTTPS) {
std::string dictionary_domain("x.y.z.google.com");
std::string dictionary_text(NewSdchDictionary(dictionary_domain));
- EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text,
- GURL("http://" + dictionary_domain)));
+ SdchManager::ProblemCodes problem;
+ EXPECT_TRUE(sdch_manager()->AddSdchDictionary(
+ dictionary_text, GURL("http://" + dictionary_domain), &problem));
std::string dictionary_list;
// HTTPS target URL should NOT advertise dictionary.
@@ -178,11 +181,12 @@ TEST_F(SdchManagerTest, CanUseHTTPSDictionaryOverHTTPSIfEnabled) {
std::string dictionary_domain("x.y.z.google.com");
std::string dictionary_text(NewSdchDictionary(dictionary_domain));
+ SdchManager::ProblemCodes problem;
EXPECT_FALSE(sdch_manager()->AddSdchDictionary(
- dictionary_text, GURL("https://" + dictionary_domain)));
+ dictionary_text, GURL("https://" + dictionary_domain), &problem));
SdchManager::EnableSecureSchemeSupport(true);
EXPECT_TRUE(sdch_manager()->AddSdchDictionary(
- dictionary_text, GURL("https://" + dictionary_domain)));
+ dictionary_text, GURL("https://" + dictionary_domain), &problem));
GURL target_url("https://" + dictionary_domain + "/test");
std::string dictionary_list;
@@ -204,8 +208,9 @@ TEST_F(SdchManagerTest, CanNotUseHTTPDictionaryOverHTTPS) {
std::string dictionary_domain("x.y.z.google.com");
std::string dictionary_text(NewSdchDictionary(dictionary_domain));
- EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text,
- GURL("http://" + dictionary_domain)));
+ SdchManager::ProblemCodes problem;
+ EXPECT_TRUE(sdch_manager()->AddSdchDictionary(
+ dictionary_text, GURL("http://" + dictionary_domain), &problem));
GURL target_url("https://" + dictionary_domain + "/test");
std::string dictionary_list;
@@ -228,8 +233,9 @@ TEST_F(SdchManagerTest, CanNotUseHTTPSDictionaryOverHTTP) {
std::string dictionary_text(NewSdchDictionary(dictionary_domain));
SdchManager::EnableSecureSchemeSupport(true);
- EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text,
- GURL("https://" + dictionary_domain)));
+ SdchManager::ProblemCodes problem;
+ EXPECT_TRUE(sdch_manager()->AddSdchDictionary(
+ dictionary_text, GURL("https://" + dictionary_domain), &problem));
GURL target_url("http://" + dictionary_domain + "/test");
std::string dictionary_list;
@@ -251,8 +257,10 @@ TEST_F(SdchManagerTest, FailToSetDomainMismatchDictionary) {
std::string dictionary_text(NewSdchDictionary(dictionary_domain));
// Fail the "domain match" requirement.
- EXPECT_FALSE(sdch_manager()->AddSdchDictionary(dictionary_text,
- GURL("http://y.z.google.com")));
+ SdchManager::ProblemCodes problem;
+ EXPECT_FALSE(sdch_manager()->AddSdchDictionary(
+ dictionary_text, GURL("http://y.z.google.com"), &problem));
+ EXPECT_EQ(SdchManager::DICTIONARY_DOMAIN_NOT_MATCHING_SOURCE_URL, problem);
}
TEST_F(SdchManagerTest, FailToSetDotHostPrefixDomainDictionary) {
@@ -260,8 +268,10 @@ TEST_F(SdchManagerTest, FailToSetDotHostPrefixDomainDictionary) {
std::string dictionary_text(NewSdchDictionary(dictionary_domain));
// Fail the HD with D being the domain and H having a dot requirement.
- EXPECT_FALSE(sdch_manager()->AddSdchDictionary(dictionary_text,
- GURL("http://w.x.y.z.google.com")));
+ SdchManager::ProblemCodes problem;
+ EXPECT_FALSE(sdch_manager()->AddSdchDictionary(
+ dictionary_text, GURL("http://w.x.y.z.google.com"), &problem));
+ EXPECT_EQ(SdchManager::DICTIONARY_REFERER_URL_HAS_DOT_IN_PREFIX, problem);
}
TEST_F(SdchManagerTest, FailToSetRepeatPrefixWithDotDictionary) {
@@ -271,8 +281,10 @@ TEST_F(SdchManagerTest, FailToSetRepeatPrefixWithDotDictionary) {
std::string dictionary_text(NewSdchDictionary(dictionary_domain));
// Fail the HD with D being the domain and H having a dot requirement.
- EXPECT_FALSE(sdch_manager()->AddSdchDictionary(dictionary_text,
- GURL("http://www.google.com.www.google.com")));
+ SdchManager::ProblemCodes problem;
+ EXPECT_FALSE(sdch_manager()->AddSdchDictionary(
+ dictionary_text, GURL("http://www.google.com.www.google.com"), &problem));
+ EXPECT_EQ(SdchManager::DICTIONARY_REFERER_URL_HAS_DOT_IN_PREFIX, problem);
}
TEST_F(SdchManagerTest, CanSetLeadingDotDomainDictionary) {
@@ -283,8 +295,9 @@ TEST_F(SdchManagerTest, CanSetLeadingDotDomainDictionary) {
// Verify that a leading dot in the domain is acceptable, as long as the host
// name does not contain any dots preceding the matched domain name.
- EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text,
- GURL("http://www.google.com")));
+ SdchManager::ProblemCodes problem;
+ EXPECT_TRUE(sdch_manager()->AddSdchDictionary(
+ dictionary_text, GURL("http://www.google.com"), &problem));
}
// Make sure the order of the tests is not helping us or confusing things.
@@ -294,8 +307,9 @@ TEST_F(SdchManagerTest, CanStillSetExactMatchDictionary) {
std::string dictionary_text(NewSdchDictionary(dictionary_domain));
// Perfect match should *STILL* work.
- EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text,
- GURL("http://" + dictionary_domain)));
+ SdchManager::ProblemCodes problem;
+ EXPECT_TRUE(sdch_manager()->AddSdchDictionary(
+ dictionary_text, GURL("http://" + dictionary_domain), &problem));
}
// Make sure the DOS protection precludes the addition of too many dictionaries.
@@ -303,10 +317,11 @@ TEST_F(SdchManagerTest, TooManyDictionaries) {
std::string dictionary_domain(".google.com");
std::string dictionary_text(NewSdchDictionary(dictionary_domain));
+ SdchManager::ProblemCodes problem;
size_t count = 0;
while (count <= SdchManager::kMaxDictionaryCount + 1) {
- if (!sdch_manager()->AddSdchDictionary(dictionary_text,
- GURL("http://www.google.com")))
+ if (!sdch_manager()->AddSdchDictionary(
+ dictionary_text, GURL("http://www.google.com"), &problem))
break;
dictionary_text += " "; // Create dictionary with different SHA signature.
@@ -321,8 +336,9 @@ TEST_F(SdchManagerTest, DictionaryNotTooLarge) {
dictionary_text.append(
SdchManager::kMaxDictionarySize - dictionary_text.size(), ' ');
- EXPECT_TRUE(sdch_manager()->AddSdchDictionary(dictionary_text,
- GURL("http://" + dictionary_domain)));
+ SdchManager::ProblemCodes problem;
+ EXPECT_TRUE(sdch_manager()->AddSdchDictionary(
+ dictionary_text, GURL("http://" + dictionary_domain), &problem));
}
TEST_F(SdchManagerTest, DictionaryTooLarge) {
@@ -331,8 +347,10 @@ TEST_F(SdchManagerTest, DictionaryTooLarge) {
dictionary_text.append(
SdchManager::kMaxDictionarySize + 1 - dictionary_text.size(), ' ');
- EXPECT_FALSE(sdch_manager()->AddSdchDictionary(dictionary_text,
- GURL("http://" + dictionary_domain)));
+ SdchManager::ProblemCodes problem;
+ EXPECT_FALSE(sdch_manager()->AddSdchDictionary(
+ dictionary_text, GURL("http://" + dictionary_domain), &problem));
+ EXPECT_EQ(SdchManager::DICTIONARY_IS_TOO_LARGE, problem);
}
TEST_F(SdchManagerTest, PathMatch) {
@@ -422,8 +440,9 @@ TEST_F(SdchManagerTest, CanUseMultipleManagers) {
// Confirm that if you add directories to one manager, you
// can't get them from the other.
+ SdchManager::ProblemCodes problem;
EXPECT_TRUE(sdch_manager()->AddSdchDictionary(
- dictionary_text_1, GURL("http://" + dictionary_domain_1)));
+ dictionary_text_1, GURL("http://" + dictionary_domain_1), &problem));
scoped_refptr<SdchManager::Dictionary> dictionary;
sdch_manager()->GetVcdiffDictionary(
server_hash_1,
@@ -432,7 +451,7 @@ TEST_F(SdchManagerTest, CanUseMultipleManagers) {
EXPECT_TRUE(dictionary);
EXPECT_TRUE(second_manager.AddSdchDictionary(
- dictionary_text_2, GURL("http://" + dictionary_domain_2)));
+ dictionary_text_2, GURL("http://" + dictionary_domain_2), &problem));
second_manager.GetVcdiffDictionary(
server_hash_2,
GURL("http://" + dictionary_domain_2 + "/random_url"),
@@ -474,8 +493,9 @@ TEST_F(SdchManagerTest, ClearDictionaryData) {
SdchManager::GenerateHash(dictionary_text, &tmp_hash, &server_hash);
+ SdchManager::ProblemCodes problem;
EXPECT_TRUE(sdch_manager()->AddSdchDictionary(
- dictionary_text, GURL("http://" + dictionary_domain)));
+ dictionary_text, GURL("http://" + dictionary_domain), &problem));
scoped_refptr<SdchManager::Dictionary> dictionary;
sdch_manager()->GetVcdiffDictionary(
server_hash,

Powered by Google App Engine
This is Rietveld 408576698