| Index: net/base/sdch_manager_unittest.cc
|
| diff --git a/net/base/sdch_manager_unittest.cc b/net/base/sdch_manager_unittest.cc
|
| index d986879aaa4c9b9928039f3290731e5ca49f0b0f..77175209c37863a440c12cbc6ca45b66269855c7 100644
|
| --- a/net/base/sdch_manager_unittest.cc
|
| +++ b/net/base/sdch_manager_unittest.cc
|
| @@ -18,7 +18,8 @@ namespace net {
|
| //------------------------------------------------------------------------------
|
| // Provide sample data and compression results with a sample VCDIFF dictionary.
|
| // Note an SDCH dictionary has extra meta-data before the VCDIFF dictionary.
|
| -static const char kTestVcdiffDictionary[] = "DictionaryFor"
|
| +static const char kTestVcdiffDictionary[] =
|
| + "DictionaryFor"
|
| "SdchCompression1SdchCompression2SdchCompression3SdchCompression\n";
|
|
|
| //------------------------------------------------------------------------------
|
| @@ -71,8 +72,7 @@ class SdchManagerTest : public testing::Test {
|
|
|
| // Attempt to add a dictionary to the manager and probe for success or
|
| // failure.
|
| - bool AddSdchDictionary(const std::string& dictionary_text,
|
| - const GURL& gurl) {
|
| + bool AddSdchDictionary(const std::string& dictionary_text, const GURL& gurl) {
|
| std::string list;
|
| sdch_manager_->GetAvailDictionaryList(gurl, &list);
|
| sdch_manager_->AddSdchDictionary(dictionary_text, gurl);
|
| @@ -189,22 +189,21 @@ TEST_F(SdchManagerTest, CanSetExactMatchDictionary) {
|
| std::string dictionary_text(NewSdchDictionary(dictionary_domain));
|
|
|
| // Perfect match should work.
|
| - EXPECT_TRUE(AddSdchDictionary(dictionary_text,
|
| - GURL("http://" + dictionary_domain)));
|
| + EXPECT_TRUE(
|
| + AddSdchDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
|
| }
|
|
|
| TEST_F(SdchManagerTest, CanAdvertiseDictionaryOverHTTP) {
|
| std::string dictionary_domain("x.y.z.google.com");
|
| std::string dictionary_text(NewSdchDictionary(dictionary_domain));
|
|
|
| - EXPECT_TRUE(AddSdchDictionary(dictionary_text,
|
| - GURL("http://" + dictionary_domain)));
|
| + EXPECT_TRUE(
|
| + AddSdchDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
|
|
|
| std::string dictionary_list;
|
| // HTTP target URL can advertise dictionary.
|
| sdch_manager()->GetAvailDictionaryList(
|
| - GURL("http://" + dictionary_domain + "/test"),
|
| - &dictionary_list);
|
| + GURL("http://" + dictionary_domain + "/test"), &dictionary_list);
|
| EXPECT_FALSE(dictionary_list.empty());
|
| }
|
|
|
| @@ -212,14 +211,13 @@ TEST_F(SdchManagerTest, CanNotAdvertiseDictionaryOverHTTPS) {
|
| std::string dictionary_domain("x.y.z.google.com");
|
| std::string dictionary_text(NewSdchDictionary(dictionary_domain));
|
|
|
| - EXPECT_TRUE(AddSdchDictionary(dictionary_text,
|
| - GURL("http://" + dictionary_domain)));
|
| + EXPECT_TRUE(
|
| + AddSdchDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
|
|
|
| std::string dictionary_list;
|
| // HTTPS target URL should NOT advertise dictionary.
|
| sdch_manager()->GetAvailDictionaryList(
|
| - GURL("https://" + dictionary_domain + "/test"),
|
| - &dictionary_list);
|
| + GURL("https://" + dictionary_domain + "/test"), &dictionary_list);
|
| EXPECT_TRUE(dictionary_list.empty());
|
| }
|
|
|
| @@ -228,11 +226,11 @@ TEST_F(SdchManagerTest, CanUseHTTPSDictionaryOverHTTPSIfEnabled) {
|
| std::string dictionary_text(NewSdchDictionary(dictionary_domain));
|
|
|
| SdchManager::EnableSecureSchemeSupport(false);
|
| - EXPECT_FALSE(AddSdchDictionary(dictionary_text,
|
| - GURL("https://" + dictionary_domain)));
|
| + EXPECT_FALSE(
|
| + AddSdchDictionary(dictionary_text, GURL("https://" + dictionary_domain)));
|
| SdchManager::EnableSecureSchemeSupport(true);
|
| - EXPECT_TRUE(AddSdchDictionary(dictionary_text,
|
| - GURL("https://" + dictionary_domain)));
|
| + EXPECT_TRUE(
|
| + AddSdchDictionary(dictionary_text, GURL("https://" + dictionary_domain)));
|
|
|
| GURL target_url("https://" + dictionary_domain + "/test");
|
| std::string dictionary_list;
|
| @@ -254,8 +252,8 @@ TEST_F(SdchManagerTest, CanNotUseHTTPDictionaryOverHTTPS) {
|
| std::string dictionary_domain("x.y.z.google.com");
|
| std::string dictionary_text(NewSdchDictionary(dictionary_domain));
|
|
|
| - EXPECT_TRUE(AddSdchDictionary(dictionary_text,
|
| - GURL("http://" + dictionary_domain)));
|
| + EXPECT_TRUE(
|
| + AddSdchDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
|
|
|
| GURL target_url("https://" + dictionary_domain + "/test");
|
| std::string dictionary_list;
|
| @@ -278,8 +276,8 @@ TEST_F(SdchManagerTest, CanNotUseHTTPSDictionaryOverHTTP) {
|
| std::string dictionary_text(NewSdchDictionary(dictionary_domain));
|
|
|
| SdchManager::EnableSecureSchemeSupport(true);
|
| - EXPECT_TRUE(AddSdchDictionary(dictionary_text,
|
| - GURL("https://" + dictionary_domain)));
|
| + EXPECT_TRUE(
|
| + AddSdchDictionary(dictionary_text, GURL("https://" + dictionary_domain)));
|
|
|
| GURL target_url("http://" + dictionary_domain + "/test");
|
| std::string dictionary_list;
|
| @@ -301,8 +299,8 @@ TEST_F(SdchManagerTest, FailToSetDomainMismatchDictionary) {
|
| std::string dictionary_text(NewSdchDictionary(dictionary_domain));
|
|
|
| // Fail the "domain match" requirement.
|
| - EXPECT_FALSE(AddSdchDictionary(dictionary_text,
|
| - GURL("http://y.z.google.com")));
|
| + EXPECT_FALSE(
|
| + AddSdchDictionary(dictionary_text, GURL("http://y.z.google.com")));
|
| }
|
|
|
| TEST_F(SdchManagerTest, FailToSetDotHostPrefixDomainDictionary) {
|
| @@ -310,8 +308,8 @@ 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(AddSdchDictionary(dictionary_text,
|
| - GURL("http://w.x.y.z.google.com")));
|
| + EXPECT_FALSE(
|
| + AddSdchDictionary(dictionary_text, GURL("http://w.x.y.z.google.com")));
|
| }
|
|
|
| TEST_F(SdchManagerTest, FailToSetDotHostPrefixDomainDictionaryTrailingDot) {
|
| @@ -319,8 +317,8 @@ TEST_F(SdchManagerTest, FailToSetDotHostPrefixDomainDictionaryTrailingDot) {
|
| std::string dictionary_text(NewSdchDictionary(dictionary_domain));
|
|
|
| // Fail the HD with D being the domain and H having a dot requirement.
|
| - EXPECT_FALSE(AddSdchDictionary(dictionary_text,
|
| - GURL("http://w.x.y.z.google.com.")));
|
| + EXPECT_FALSE(
|
| + AddSdchDictionary(dictionary_text, GURL("http://w.x.y.z.google.com.")));
|
| }
|
|
|
| TEST_F(SdchManagerTest, FailToSetRepeatPrefixWithDotDictionary) {
|
| @@ -342,7 +340,8 @@ 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(AddSdchDictionary(dictionary_text, GURL("http://www.google.com")));
|
| + EXPECT_TRUE(
|
| + AddSdchDictionary(dictionary_text, GURL("http://www.google.com")));
|
| }
|
|
|
| TEST_F(SdchManagerTest,
|
| @@ -354,8 +353,8 @@ TEST_F(SdchManagerTest,
|
|
|
| // 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(AddSdchDictionary(dictionary_text,
|
| - GURL("http://www.google.com.")));
|
| + EXPECT_TRUE(
|
| + AddSdchDictionary(dictionary_text, GURL("http://www.google.com.")));
|
| }
|
|
|
| TEST_F(SdchManagerTest, CannotSetLeadingDotDomainDictionary) {
|
| @@ -388,8 +387,8 @@ TEST_F(SdchManagerTest, CanStillSetExactMatchDictionary) {
|
| std::string dictionary_text(NewSdchDictionary(dictionary_domain));
|
|
|
| // Perfect match should *STILL* work.
|
| - EXPECT_TRUE(AddSdchDictionary(dictionary_text,
|
| - GURL("http://" + dictionary_domain)));
|
| + EXPECT_TRUE(
|
| + AddSdchDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
|
| }
|
|
|
| // Make sure the DOS protection precludes the addition of too many dictionaries.
|
| @@ -398,8 +397,8 @@ TEST_F(SdchManagerTest, TooManyDictionaries) {
|
| std::string dictionary_text(NewSdchDictionary(dictionary_domain));
|
|
|
| for (size_t count = 0; count < SdchManager::kMaxDictionaryCount; ++count) {
|
| - EXPECT_TRUE(AddSdchDictionary(dictionary_text,
|
| - GURL("http://www.google.com")));
|
| + EXPECT_TRUE(
|
| + AddSdchDictionary(dictionary_text, GURL("http://www.google.com")));
|
| dictionary_text += " "; // Create dictionary with different SHA signature.
|
| }
|
| EXPECT_FALSE(
|
| @@ -411,9 +410,9 @@ TEST_F(SdchManagerTest, DictionaryNotTooLarge) {
|
| std::string dictionary_text(NewSdchDictionary(dictionary_domain));
|
|
|
| dictionary_text.append(
|
| - SdchManager::kMaxDictionarySize - dictionary_text.size(), ' ');
|
| - EXPECT_TRUE(AddSdchDictionary(dictionary_text,
|
| - GURL("http://" + dictionary_domain)));
|
| + SdchManager::kMaxDictionarySize - dictionary_text.size(), ' ');
|
| + EXPECT_TRUE(
|
| + AddSdchDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
|
| }
|
|
|
| TEST_F(SdchManagerTest, DictionaryTooLarge) {
|
| @@ -422,8 +421,8 @@ TEST_F(SdchManagerTest, DictionaryTooLarge) {
|
|
|
| dictionary_text.append(
|
| SdchManager::kMaxDictionarySize + 1 - dictionary_text.size(), ' ');
|
| - EXPECT_FALSE(AddSdchDictionary(dictionary_text,
|
| - GURL("http://" + dictionary_domain)));
|
| + EXPECT_FALSE(
|
| + AddSdchDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
|
| }
|
|
|
| TEST_F(SdchManagerTest, PathMatch) {
|
| @@ -517,28 +516,24 @@ TEST_F(SdchManagerTest, CanUseMultipleManagers) {
|
| GURL("http://" + dictionary_domain_1)));
|
| scoped_refptr<SdchManager::Dictionary> dictionary;
|
| sdch_manager()->GetVcdiffDictionary(
|
| - server_hash_1,
|
| - GURL("http://" + dictionary_domain_1 + "/random_url"),
|
| + server_hash_1, GURL("http://" + dictionary_domain_1 + "/random_url"),
|
| &dictionary);
|
| EXPECT_TRUE(dictionary.get());
|
|
|
| - second_manager.AddSdchDictionary(
|
| - dictionary_text_2, GURL("http://" + dictionary_domain_2));
|
| + second_manager.AddSdchDictionary(dictionary_text_2,
|
| + GURL("http://" + dictionary_domain_2));
|
| second_manager.GetVcdiffDictionary(
|
| - server_hash_2,
|
| - GURL("http://" + dictionary_domain_2 + "/random_url"),
|
| + server_hash_2, GURL("http://" + dictionary_domain_2 + "/random_url"),
|
| &dictionary);
|
| EXPECT_TRUE(dictionary.get());
|
|
|
| sdch_manager()->GetVcdiffDictionary(
|
| - server_hash_2,
|
| - GURL("http://" + dictionary_domain_2 + "/random_url"),
|
| + server_hash_2, GURL("http://" + dictionary_domain_2 + "/random_url"),
|
| &dictionary);
|
| EXPECT_FALSE(dictionary.get());
|
|
|
| second_manager.GetVcdiffDictionary(
|
| - server_hash_1,
|
| - GURL("http://" + dictionary_domain_1 + "/random_url"),
|
| + server_hash_1, GURL("http://" + dictionary_domain_1 + "/random_url"),
|
| &dictionary);
|
| EXPECT_FALSE(dictionary.get());
|
| }
|
| @@ -569,12 +564,11 @@ TEST_F(SdchManagerTest, ClearDictionaryData) {
|
|
|
| SdchManager::GenerateHash(dictionary_text, &tmp_hash, &server_hash);
|
|
|
| - EXPECT_TRUE(AddSdchDictionary(dictionary_text,
|
| - GURL("http://" + dictionary_domain)));
|
| + EXPECT_TRUE(
|
| + AddSdchDictionary(dictionary_text, GURL("http://" + dictionary_domain)));
|
| scoped_refptr<SdchManager::Dictionary> dictionary;
|
| sdch_manager()->GetVcdiffDictionary(
|
| - server_hash,
|
| - GURL("http://" + dictionary_domain + "/random_url"),
|
| + server_hash, GURL("http://" + dictionary_domain + "/random_url"),
|
| &dictionary);
|
| EXPECT_TRUE(dictionary.get());
|
|
|
| @@ -586,8 +580,7 @@ TEST_F(SdchManagerTest, ClearDictionaryData) {
|
|
|
| dictionary = NULL;
|
| sdch_manager()->GetVcdiffDictionary(
|
| - server_hash,
|
| - GURL("http://" + dictionary_domain + "/random_url"),
|
| + server_hash, GURL("http://" + dictionary_domain + "/random_url"),
|
| &dictionary);
|
| EXPECT_FALSE(dictionary.get());
|
| EXPECT_TRUE(sdch_manager()->IsInSupportedDomain(blacklist_url));
|
|
|