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

Unified Diff: net/base/sdch_filter_unittest.cc

Issue 6347033: net: Add namespace net to Sdch* classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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_filter_unittest.cc
diff --git a/net/base/sdch_filter_unittest.cc b/net/base/sdch_filter_unittest.cc
index ccf07cb497f1d6334496061ae3580c580ad320ef..d1c6917cac5dd143395faa14a21a182404e1f7fb 100644
--- a/net/base/sdch_filter_unittest.cc
+++ b/net/base/sdch_filter_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -58,7 +58,7 @@ class SdchFilterTest : public testing::Test {
vcdiff_compressed_data_(kSdchCompressedTestData,
sizeof(kSdchCompressedTestData) - 1),
expanded_(kTestData, sizeof(kTestData) - 1),
- sdch_manager_(new SdchManager) {
+ sdch_manager_(new net::SdchManager) {
sdch_manager_->EnableSdchSupport("");
}
@@ -68,14 +68,14 @@ class SdchFilterTest : public testing::Test {
const std::string vcdiff_compressed_data_;
const std::string expanded_; // Desired final, decompressed data.
- scoped_ptr<SdchManager> sdch_manager_; // A singleton database.
+ scoped_ptr<net::SdchManager> sdch_manager_; // A singleton database.
};
std::string SdchFilterTest::NewSdchCompressedData(
const std::string dictionary) {
std::string client_hash;
std::string server_hash;
- SdchManager::GenerateHash(dictionary, &client_hash, &server_hash);
+ net::SdchManager::GenerateHash(dictionary, &client_hash, &server_hash);
// Build compressed data that refers to our dictionary.
std::string compressed(server_hash);
@@ -90,7 +90,7 @@ std::string SdchFilterTest::NewSdchCompressedData(
TEST_F(SdchFilterTest, Hashing) {
std::string client_hash, server_hash;
std::string dictionary("test contents");
- SdchManager::GenerateHash(dictionary, &client_hash, &server_hash);
+ net::SdchManager::GenerateHash(dictionary, &client_hash, &server_hash);
EXPECT_EQ(client_hash, "lMQBjS3P");
EXPECT_EQ(server_hash, "MyciMVll");
@@ -388,9 +388,11 @@ TEST_F(SdchFilterTest, BasicBadDictionary) {
EXPECT_EQ(0, output_bytes_or_buffer_size);
EXPECT_EQ(Filter::FILTER_ERROR, status);
- EXPECT_FALSE(SdchManager::Global()->IsInSupportedDomain(GURL(url_string)));
- SdchManager::ClearBlacklistings();
- EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(GURL(url_string)));
+ EXPECT_FALSE(
+ net::SdchManager::Global()->IsInSupportedDomain(GURL(url_string)));
+ net::SdchManager::ClearBlacklistings();
+ EXPECT_TRUE(
+ net::SdchManager::Global()->IsInSupportedDomain(GURL(url_string)));
}
TEST_F(SdchFilterTest, DictionaryAddOnce) {
@@ -644,7 +646,7 @@ TEST_F(SdchFilterTest, CrossDomainDictionaryUse) {
const int kInputBufferSize(100);
// Decode with content arriving from the "wrong" domain.
- // This tests SdchManager::CanSet().
+ // This tests net::SdchManager::CanSet().
net::MockFilterContext filter_context(kInputBufferSize);
GURL wrong_domain_url("http://www.wrongdomain.com");
filter_context.SetURL(wrong_domain_url);
@@ -657,10 +659,13 @@ TEST_F(SdchFilterTest, CrossDomainDictionaryUse) {
filter.get(), &output));
EXPECT_EQ(output.size(), 0u); // No output written.
- EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(GURL(url_string)));
- EXPECT_FALSE(SdchManager::Global()->IsInSupportedDomain(wrong_domain_url));
- SdchManager::ClearBlacklistings();
- EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(wrong_domain_url));
+ EXPECT_TRUE(
+ net::SdchManager::Global()->IsInSupportedDomain(GURL(url_string)));
+ EXPECT_FALSE(
+ net::SdchManager::Global()->IsInSupportedDomain(wrong_domain_url));
+ net::SdchManager::ClearBlacklistings();
+ EXPECT_TRUE(
+ net::SdchManager::Global()->IsInSupportedDomain(wrong_domain_url));
}
TEST_F(SdchFilterTest, DictionaryPathValidation) {
@@ -709,9 +714,11 @@ TEST_F(SdchFilterTest, DictionaryPathValidation) {
output_block_size, filter.get(), &output));
EXPECT_EQ(output.size(), 0u); // No output written.
- EXPECT_FALSE(SdchManager::Global()->IsInSupportedDomain(GURL(url_string)));
- SdchManager::ClearBlacklistings();
- EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(GURL(url_string)));
+ EXPECT_FALSE(
+ net::SdchManager::Global()->IsInSupportedDomain(GURL(url_string)));
+ net::SdchManager::ClearBlacklistings();
+ EXPECT_TRUE(
+ net::SdchManager::Global()->IsInSupportedDomain(GURL(url_string)));
}
TEST_F(SdchFilterTest, DictionaryPortValidation) {
@@ -773,9 +780,11 @@ TEST_F(SdchFilterTest, DictionaryPortValidation) {
output_block_size, filter.get(), &output));
EXPECT_EQ(output.size(), 0u); // No output written.
- EXPECT_FALSE(SdchManager::Global()->IsInSupportedDomain(GURL(url_string)));
- SdchManager::ClearBlacklistings();
- EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(GURL(url_string)));
+ EXPECT_FALSE(
+ net::SdchManager::Global()->IsInSupportedDomain(GURL(url_string)));
+ net::SdchManager::ClearBlacklistings();
+ EXPECT_TRUE(
+ net::SdchManager::Global()->IsInSupportedDomain(GURL(url_string)));
}
//------------------------------------------------------------------------------
@@ -1157,79 +1166,80 @@ TEST_F(SdchFilterTest, DomainSupported) {
GURL test_url("http://www.test.com");
GURL google_url("http://www.google.com");
- EXPECT_TRUE(SdchManager::sdch_enabled());
- EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(test_url));
+ EXPECT_TRUE(net::SdchManager::sdch_enabled());
+ EXPECT_TRUE(net::SdchManager::Global()->IsInSupportedDomain(test_url));
sdch_manager_->EnableSdchSupport(".google.com");
- EXPECT_FALSE(SdchManager::Global()->IsInSupportedDomain(test_url));
- EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(google_url));
+ EXPECT_FALSE(net::SdchManager::Global()->IsInSupportedDomain(test_url));
+ EXPECT_TRUE(net::SdchManager::Global()->IsInSupportedDomain(google_url));
}
TEST_F(SdchFilterTest, DomainBlacklisting) {
GURL test_url("http://www.test.com");
GURL google_url("http://www.google.com");
- SdchManager::BlacklistDomain(test_url);
- EXPECT_FALSE(SdchManager::Global()->IsInSupportedDomain(test_url));
- EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(google_url));
+ net::SdchManager::BlacklistDomain(test_url);
+ EXPECT_FALSE(net::SdchManager::Global()->IsInSupportedDomain(test_url));
+ EXPECT_TRUE(net::SdchManager::Global()->IsInSupportedDomain(google_url));
- SdchManager::BlacklistDomain(google_url);
- EXPECT_FALSE(SdchManager::Global()->IsInSupportedDomain(google_url));
+ net::SdchManager::BlacklistDomain(google_url);
+ EXPECT_FALSE(net::SdchManager::Global()->IsInSupportedDomain(google_url));
}
TEST_F(SdchFilterTest, DomainBlacklistingCaseSensitivity) {
GURL test_url("http://www.TesT.com");
GURL test2_url("http://www.tEst.com");
- EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(test_url));
- EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(test2_url));
- SdchManager::BlacklistDomain(test_url);
- EXPECT_FALSE(SdchManager::Global()->IsInSupportedDomain(test2_url));
+ EXPECT_TRUE(net::SdchManager::Global()->IsInSupportedDomain(test_url));
+ EXPECT_TRUE(net::SdchManager::Global()->IsInSupportedDomain(test2_url));
+ net::SdchManager::BlacklistDomain(test_url);
+ EXPECT_FALSE(net::SdchManager::Global()->IsInSupportedDomain(test2_url));
}
TEST_F(SdchFilterTest, BlacklistingReset) {
GURL gurl("http://mytest.DoMain.com");
std::string domain(gurl.host());
- SdchManager::ClearBlacklistings();
- EXPECT_EQ(SdchManager::BlackListDomainCount(domain), 0);
- EXPECT_EQ(SdchManager::BlacklistDomainExponential(domain), 0);
- EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(gurl));
+ net::SdchManager::ClearBlacklistings();
+ EXPECT_EQ(net::SdchManager::BlackListDomainCount(domain), 0);
+ EXPECT_EQ(net::SdchManager::BlacklistDomainExponential(domain), 0);
+ EXPECT_TRUE(net::SdchManager::Global()->IsInSupportedDomain(gurl));
}
TEST_F(SdchFilterTest, BlacklistingSingleBlacklist) {
GURL gurl("http://mytest.DoMain.com");
std::string domain(gurl.host());
- SdchManager::ClearBlacklistings();
+ net::SdchManager::ClearBlacklistings();
- SdchManager::Global()->BlacklistDomain(gurl);
- EXPECT_EQ(SdchManager::BlackListDomainCount(domain), 1);
- EXPECT_EQ(SdchManager::BlacklistDomainExponential(domain), 1);
+ net::SdchManager::Global()->BlacklistDomain(gurl);
+ EXPECT_EQ(net::SdchManager::BlackListDomainCount(domain), 1);
+ EXPECT_EQ(net::SdchManager::BlacklistDomainExponential(domain), 1);
// Check that any domain lookup reduces the blacklist counter.
- EXPECT_FALSE(SdchManager::Global()->IsInSupportedDomain(gurl));
- EXPECT_EQ(SdchManager::BlackListDomainCount(domain), 0);
- EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(gurl));
+ EXPECT_FALSE(net::SdchManager::Global()->IsInSupportedDomain(gurl));
+ EXPECT_EQ(net::SdchManager::BlackListDomainCount(domain), 0);
+ EXPECT_TRUE(net::SdchManager::Global()->IsInSupportedDomain(gurl));
}
TEST_F(SdchFilterTest, BlacklistingExponential) {
GURL gurl("http://mytest.DoMain.com");
std::string domain(gurl.host());
- SdchManager::ClearBlacklistings();
+ net::SdchManager::ClearBlacklistings();
int exponential = 1;
for (int i = 1; i < 100; ++i) {
- SdchManager::Global()->BlacklistDomain(gurl);
- EXPECT_EQ(SdchManager::BlacklistDomainExponential(domain), exponential);
+ net::SdchManager::Global()->BlacklistDomain(gurl);
+ EXPECT_EQ(
+ net::SdchManager::BlacklistDomainExponential(domain), exponential);
- EXPECT_EQ(SdchManager::BlackListDomainCount(domain), exponential);
- EXPECT_FALSE(SdchManager::Global()->IsInSupportedDomain(gurl));
- EXPECT_EQ(SdchManager::BlackListDomainCount(domain), exponential - 1);
+ EXPECT_EQ(net::SdchManager::BlackListDomainCount(domain), exponential);
+ EXPECT_FALSE(net::SdchManager::Global()->IsInSupportedDomain(gurl));
+ EXPECT_EQ(net::SdchManager::BlackListDomainCount(domain), exponential - 1);
// Simulate a large number of domain checks (which eventually remove the
// blacklisting).
- SdchManager::ClearDomainBlacklisting(domain);
- EXPECT_EQ(SdchManager::BlackListDomainCount(domain), 0);
- EXPECT_TRUE(SdchManager::Global()->IsInSupportedDomain(gurl));
+ net::SdchManager::ClearDomainBlacklisting(domain);
+ EXPECT_EQ(net::SdchManager::BlackListDomainCount(domain), 0);
+ EXPECT_TRUE(net::SdchManager::Global()->IsInSupportedDomain(gurl));
// Predict what exponential backoff will be.
exponential = 1 + 2 * exponential;
@@ -1305,7 +1315,7 @@ TEST_F(SdchFilterTest, TooManyDictionaries) {
std::string dictionary_text(NewSdchDictionary(dictionary_domain));
size_t count = 0;
- while (count <= SdchManager::kMaxDictionaryCount + 1) {
+ while (count <= net::SdchManager::kMaxDictionaryCount + 1) {
if (!sdch_manager_->AddSdchDictionary(dictionary_text,
GURL("http://www.google.com")))
break;
@@ -1313,7 +1323,7 @@ TEST_F(SdchFilterTest, TooManyDictionaries) {
dictionary_text += " "; // Create dictionary with different SHA signature.
++count;
}
- EXPECT_EQ(SdchManager::kMaxDictionaryCount, count);
+ EXPECT_EQ(net::SdchManager::kMaxDictionaryCount, count);
}
TEST_F(SdchFilterTest, DictionaryNotTooLarge) {
@@ -1321,7 +1331,7 @@ TEST_F(SdchFilterTest, DictionaryNotTooLarge) {
std::string dictionary_text(NewSdchDictionary(dictionary_domain));
dictionary_text.append(
- SdchManager::kMaxDictionarySize - dictionary_text.size(), ' ');
+ net::SdchManager::kMaxDictionarySize - dictionary_text.size(), ' ');
EXPECT_TRUE(sdch_manager_->AddSdchDictionary(dictionary_text,
GURL("http://" + dictionary_domain)));
}
@@ -1331,14 +1341,14 @@ TEST_F(SdchFilterTest, DictionaryTooLarge) {
std::string dictionary_text(NewSdchDictionary(dictionary_domain));
dictionary_text.append(
- SdchManager::kMaxDictionarySize + 1 - dictionary_text.size(), ' ');
+ net::SdchManager::kMaxDictionarySize + 1 - dictionary_text.size(), ' ');
EXPECT_FALSE(sdch_manager_->AddSdchDictionary(dictionary_text,
GURL("http://" + dictionary_domain)));
}
TEST_F(SdchFilterTest, PathMatch) {
bool (*PathMatch)(const std::string& path, const std::string& restriction) =
- SdchManager::Dictionary::PathMatch;
+ net::SdchManager::Dictionary::PathMatch;
tfarina 2011/01/31 02:23:00 Guys, any glue how to fix this? See trybot errors
// Perfect match is supported.
EXPECT_TRUE(PathMatch("/search", "/search"));
EXPECT_TRUE(PathMatch("/search/", "/search/"));
« no previous file with comments | « net/base/sdch_filter.cc ('k') | net/base/sdch_manager.h » ('j') | net/base/sdch_manager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698