summaryrefslogtreecommitdiffstats
path: root/net/base
diff options
context:
space:
mode:
Diffstat (limited to 'net/base')
-rw-r--r--net/base/cookie_monster_store_test.cc176
-rw-r--r--net/base/cookie_monster_store_test.h177
-rw-r--r--net/base/cookie_monster_unittest.cc1
-rw-r--r--net/base/filter_unittest.cc14
-rw-r--r--net/base/gzip_filter_unittest.cc20
-rw-r--r--net/base/listen_socket_unittest.cc74
-rw-r--r--net/base/listen_socket_unittest.h37
-rw-r--r--net/base/mock_filter_context.cc48
-rw-r--r--net/base/mock_filter_context.h (renamed from net/base/filter_unittest.h)49
-rw-r--r--net/base/net_test_suite.cc46
-rw-r--r--net/base/net_test_suite.h48
-rw-r--r--net/base/sdch_filter_unittest.cc44
12 files changed, 446 insertions, 288 deletions
diff --git a/net/base/cookie_monster_store_test.cc b/net/base/cookie_monster_store_test.cc
new file mode 100644
index 0000000..e785a38
--- /dev/null
+++ b/net/base/cookie_monster_store_test.cc
@@ -0,0 +1,176 @@
+// 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.
+
+#include "net/base/cookie_monster_store_test.h"
+
+#include "base/message_loop.h"
+#include "base/stringprintf.h"
+#include "base/time.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+MockPersistentCookieStore::MockPersistentCookieStore()
+ : load_return_value_(true) {
+}
+
+MockPersistentCookieStore::~MockPersistentCookieStore() {}
+
+void MockPersistentCookieStore::SetLoadExpectation(
+ bool return_value,
+ const std::vector<net::CookieMonster::CanonicalCookie*>& result) {
+ load_return_value_ = return_value;
+ load_result_ = result;
+}
+
+bool MockPersistentCookieStore::Load(
+ std::vector<net::CookieMonster::CanonicalCookie*>* out_cookies) {
+ bool ok = load_return_value_;
+ if (ok)
+ *out_cookies = load_result_;
+ return ok;
+}
+
+void MockPersistentCookieStore::AddCookie(
+ const net::CookieMonster::CanonicalCookie& cookie) {
+ commands_.push_back(
+ CookieStoreCommand(CookieStoreCommand::ADD, cookie));
+}
+
+void MockPersistentCookieStore::UpdateCookieAccessTime(
+ const net::CookieMonster::CanonicalCookie& cookie) {
+ commands_.push_back(CookieStoreCommand(
+ CookieStoreCommand::UPDATE_ACCESS_TIME, cookie));
+}
+
+void MockPersistentCookieStore::DeleteCookie(
+ const net::CookieMonster::CanonicalCookie& cookie) {
+ commands_.push_back(
+ CookieStoreCommand(CookieStoreCommand::REMOVE, cookie));
+}
+
+void MockPersistentCookieStore::Flush(Task* completion_task) {
+ if (completion_task)
+ MessageLoop::current()->PostTask(FROM_HERE, completion_task);
+}
+
+// No files are created so nothing to clear either
+void
+MockPersistentCookieStore::SetClearLocalStateOnExit(bool clear_local_state) {
+}
+
+MockCookieMonsterDelegate::MockCookieMonsterDelegate() {}
+
+void MockCookieMonsterDelegate::OnCookieChanged(
+ const net::CookieMonster::CanonicalCookie& cookie,
+ bool removed) {
+ CookieNotification notification(cookie, removed);
+ changes_.push_back(notification);
+ }
+
+MockCookieMonsterDelegate::~MockCookieMonsterDelegate() {}
+
+void AddCookieToList(
+ const std::string& key,
+ const std::string& cookie_line,
+ const base::Time& creation_time,
+ std::vector<net::CookieMonster::CanonicalCookie*>* out_list) {
+
+ // Parse the cookie line.
+ net::CookieMonster::ParsedCookie pc(cookie_line);
+ EXPECT_TRUE(pc.IsValid());
+
+ // This helper is simplistic in interpreting a parsed cookie, in order to
+ // avoid duplicated CookieMonster's CanonPath() and CanonExpiration()
+ // functions. Would be nice to export them, and re-use here.
+ EXPECT_FALSE(pc.HasMaxAge());
+ EXPECT_TRUE(pc.HasPath());
+ base::Time cookie_expires = pc.HasExpires() ?
+ net::CookieMonster::ParseCookieTime(pc.Expires()) : base::Time();
+ std::string cookie_path = pc.Path();
+
+ scoped_ptr<net::CookieMonster::CanonicalCookie> cookie(
+ new net::CookieMonster::CanonicalCookie(
+ pc.Name(), pc.Value(), key, cookie_path,
+ pc.IsSecure(), pc.IsHttpOnly(),
+ creation_time, creation_time,
+ !cookie_expires.is_null(),
+ cookie_expires));
+
+ out_list->push_back(cookie.release());
+}
+
+MockSimplePersistentCookieStore::MockSimplePersistentCookieStore() {}
+
+MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() {}
+
+bool MockSimplePersistentCookieStore::Load(
+ std::vector<net::CookieMonster::CanonicalCookie*>* out_cookies) {
+ for (CanonicalCookieMap::const_iterator it = cookies_.begin();
+ it != cookies_.end(); it++)
+ out_cookies->push_back(
+ new net::CookieMonster::CanonicalCookie(it->second));
+ return true;
+}
+
+void MockSimplePersistentCookieStore::AddCookie(
+ const net::CookieMonster::CanonicalCookie& cookie) {
+ int64 creation_time = cookie.CreationDate().ToInternalValue();
+ EXPECT_TRUE(cookies_.find(creation_time) == cookies_.end());
+ cookies_[creation_time] = cookie;
+}
+
+void MockSimplePersistentCookieStore::UpdateCookieAccessTime(
+ const net::CookieMonster::CanonicalCookie& cookie) {
+ int64 creation_time = cookie.CreationDate().ToInternalValue();
+ ASSERT_TRUE(cookies_.find(creation_time) != cookies_.end());
+ cookies_[creation_time].SetLastAccessDate(base::Time::Now());
+}
+
+void MockSimplePersistentCookieStore::DeleteCookie(
+ const net::CookieMonster::CanonicalCookie& cookie) {
+ int64 creation_time = cookie.CreationDate().ToInternalValue();
+ CanonicalCookieMap::iterator it = cookies_.find(creation_time);
+ ASSERT_TRUE(it != cookies_.end());
+ cookies_.erase(it);
+}
+
+void MockSimplePersistentCookieStore::Flush(Task* completion_task) {
+ if (completion_task)
+ MessageLoop::current()->PostTask(FROM_HERE, completion_task);
+}
+
+void MockSimplePersistentCookieStore::SetClearLocalStateOnExit(
+ bool clear_local_state) {
+}
+
+net::CookieMonster* CreateMonsterFromStoreForGC(
+ int num_cookies,
+ int num_old_cookies,
+ int days_old) {
+ base::Time current(base::Time::Now());
+ base::Time past_creation(base::Time::Now() - base::TimeDelta::FromDays(1000));
+ scoped_refptr<MockSimplePersistentCookieStore> store(
+ new MockSimplePersistentCookieStore);
+ // Must expire to be persistent
+ for (int i = 0; i < num_old_cookies; i++) {
+ net::CookieMonster::CanonicalCookie cc(
+ "a", "1", base::StringPrintf("h%05d.izzle", i), "/path", false, false,
+ past_creation + base::TimeDelta::FromMicroseconds(i),
+ current - base::TimeDelta::FromDays(days_old),
+ true, current + base::TimeDelta::FromDays(30));
+ store->AddCookie(cc);
+ }
+ for (int i = num_old_cookies; i < num_cookies; i++) {
+ net::CookieMonster::CanonicalCookie cc(
+ "a", "1", base::StringPrintf("h%05d.izzle", i), "/path", false, false,
+ past_creation + base::TimeDelta::FromMicroseconds(i), current,
+ true, current + base::TimeDelta::FromDays(30));
+ store->AddCookie(cc);
+ }
+
+ return new net::CookieMonster(store, NULL);
+}
+
+} // namespace net
diff --git a/net/base/cookie_monster_store_test.h b/net/base/cookie_monster_store_test.h
index 84ead74..951c055 100644
--- a/net/base/cookie_monster_store_test.h
+++ b/net/base/cookie_monster_store_test.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 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.
@@ -7,12 +7,13 @@
// that need to test out CookieMonster interactions with the backing store.
// It should only be included by test code.
-#include "base/message_loop.h"
-#include "base/time.h"
#include "net/base/cookie_monster.h"
-#include "testing/gtest/include/gtest/gtest.h"
-namespace {
+namespace base {
+class Time;
+}
+
+namespace net {
// Describes a call to one of the 3 functions of PersistentCookieStore.
struct CookieStoreCommand {
@@ -39,52 +40,32 @@ class MockPersistentCookieStore
public:
typedef std::vector<CookieStoreCommand> CommandList;
- MockPersistentCookieStore() : load_return_value_(true) {
+ MockPersistentCookieStore();
+ virtual ~MockPersistentCookieStore();
+
+ void SetLoadExpectation(
+ bool return_value,
+ const std::vector<net::CookieMonster::CanonicalCookie*>& result);
+
+ const CommandList& commands() const {
+ return commands_;
}
virtual bool Load(
- std::vector<net::CookieMonster::CanonicalCookie*>* out_cookies) {
- bool ok = load_return_value_;
- if (ok)
- *out_cookies = load_result_;
- return ok;
- }
+ std::vector<net::CookieMonster::CanonicalCookie*>* out_cookies);
- virtual void AddCookie(const net::CookieMonster::CanonicalCookie& cookie) {
- commands_.push_back(
- CookieStoreCommand(CookieStoreCommand::ADD, cookie));
- }
+ virtual void AddCookie(const net::CookieMonster::CanonicalCookie& cookie);
virtual void UpdateCookieAccessTime(
- const net::CookieMonster::CanonicalCookie& cookie) {
- commands_.push_back(CookieStoreCommand(
- CookieStoreCommand::UPDATE_ACCESS_TIME, cookie));
- }
+ const net::CookieMonster::CanonicalCookie& cookie);
virtual void DeleteCookie(
- const net::CookieMonster::CanonicalCookie& cookie) {
- commands_.push_back(
- CookieStoreCommand(CookieStoreCommand::REMOVE, cookie));
- }
+ const net::CookieMonster::CanonicalCookie& cookie);
- virtual void Flush(Task* completion_task) {
- if (completion_task)
- MessageLoop::current()->PostTask(FROM_HERE, completion_task);
- }
+ virtual void Flush(Task* completion_task);
// No files are created so nothing to clear either
- virtual void SetClearLocalStateOnExit(bool clear_local_state) {}
-
- void SetLoadExpectation(
- bool return_value,
- const std::vector<net::CookieMonster::CanonicalCookie*>& result) {
- load_return_value_ = return_value;
- load_result_ = result;
- }
-
- const CommandList& commands() const {
- return commands_;
- }
+ virtual void SetClearLocalStateOnExit(bool clear_local_state);
private:
CommandList commands_;
@@ -102,21 +83,18 @@ class MockCookieMonsterDelegate : public net::CookieMonster::Delegate {
typedef std::pair<net::CookieMonster::CanonicalCookie, bool>
CookieNotification;
- MockCookieMonsterDelegate() {}
-
- virtual void OnCookieChanged(
- const net::CookieMonster::CanonicalCookie& cookie,
- bool removed) {
- CookieNotification notification(cookie, removed);
- changes_.push_back(notification);
- }
+ MockCookieMonsterDelegate();
const std::vector<CookieNotification>& changes() const { return changes_; }
void reset() { changes_.clear(); }
+ virtual void OnCookieChanged(
+ const net::CookieMonster::CanonicalCookie& cookie,
+ bool removed);
+
private:
- virtual ~MockCookieMonsterDelegate() {}
+ virtual ~MockCookieMonsterDelegate();
std::vector<CookieNotification> changes_;
@@ -124,84 +102,40 @@ class MockCookieMonsterDelegate : public net::CookieMonster::Delegate {
};
// Helper to build a list of CanonicalCookie*s.
-static void AddCookieToList(
+void AddCookieToList(
const std::string& key,
const std::string& cookie_line,
const base::Time& creation_time,
- std::vector<net::CookieMonster::CanonicalCookie*>* out_list) {
-
- // Parse the cookie line.
- net::CookieMonster::ParsedCookie pc(cookie_line);
- EXPECT_TRUE(pc.IsValid());
-
- // This helper is simplistic in interpreting a parsed cookie, in order to
- // avoid duplicated CookieMonster's CanonPath() and CanonExpiration()
- // functions. Would be nice to export them, and re-use here.
- EXPECT_FALSE(pc.HasMaxAge());
- EXPECT_TRUE(pc.HasPath());
- base::Time cookie_expires = pc.HasExpires() ?
- net::CookieMonster::ParseCookieTime(pc.Expires()) : base::Time();
- std::string cookie_path = pc.Path();
-
- scoped_ptr<net::CookieMonster::CanonicalCookie> cookie(
- new net::CookieMonster::CanonicalCookie(
- pc.Name(), pc.Value(), key, cookie_path,
- pc.IsSecure(), pc.IsHttpOnly(),
- creation_time, creation_time,
- !cookie_expires.is_null(),
- cookie_expires));
-
- out_list->push_back(cookie.release());
-}
+ std::vector<net::CookieMonster::CanonicalCookie*>* out_list);
// Just act like a backing database. Keep cookie information from
// Add/Update/Delete and regurgitate it when Load is called.
class MockSimplePersistentCookieStore
: public net::CookieMonster::PersistentCookieStore {
- private:
- typedef std::map<int64, net::CookieMonster::CanonicalCookie>
- CanonicalCookieMap;
-
public:
+ MockSimplePersistentCookieStore();
+ virtual ~MockSimplePersistentCookieStore();
+
virtual bool Load(
- std::vector<net::CookieMonster::CanonicalCookie*>* out_cookies) {
- for (CanonicalCookieMap::const_iterator it = cookies_.begin();
- it != cookies_.end(); it++)
- out_cookies->push_back(
- new net::CookieMonster::CanonicalCookie(it->second));
- return true;
- }
+ std::vector<net::CookieMonster::CanonicalCookie*>* out_cookies);
virtual void AddCookie(
- const net::CookieMonster::CanonicalCookie& cookie) {
- int64 creation_time = cookie.CreationDate().ToInternalValue();
- EXPECT_TRUE(cookies_.find(creation_time) == cookies_.end());
- cookies_[creation_time] = cookie;
- }
+ const net::CookieMonster::CanonicalCookie& cookie);
virtual void UpdateCookieAccessTime(
- const net::CookieMonster::CanonicalCookie& cookie) {
- int64 creation_time = cookie.CreationDate().ToInternalValue();
- ASSERT_TRUE(cookies_.find(creation_time) != cookies_.end());
- cookies_[creation_time].SetLastAccessDate(base::Time::Now());
- }
+ const net::CookieMonster::CanonicalCookie& cookie);
virtual void DeleteCookie(
- const net::CookieMonster::CanonicalCookie& cookie) {
- int64 creation_time = cookie.CreationDate().ToInternalValue();
- CanonicalCookieMap::iterator it = cookies_.find(creation_time);
- ASSERT_TRUE(it != cookies_.end());
- cookies_.erase(it);
- }
+ const net::CookieMonster::CanonicalCookie& cookie);
- virtual void Flush(Task* completion_task) {
- if (completion_task)
- MessageLoop::current()->PostTask(FROM_HERE, completion_task);
- }
+ virtual void Flush(Task* completion_task);
- virtual void SetClearLocalStateOnExit(bool clear_local_state) {}
+ virtual void SetClearLocalStateOnExit(bool clear_local_state);
private:
+ typedef std::map<int64, net::CookieMonster::CanonicalCookie>
+ CanonicalCookieMap;
+
CanonicalCookieMap cookies_;
};
@@ -213,32 +147,9 @@ class MockSimplePersistentCookieStore
// Do two SetCookies(). Return whether each of the two SetCookies() took
// longer than |gc_perf_micros| to complete, and how many cookie were
// left in the store afterwards.
-static net::CookieMonster* CreateMonsterFromStoreForGC(
+net::CookieMonster* CreateMonsterFromStoreForGC(
int num_cookies,
int num_old_cookies,
- int days_old) {
- base::Time current(base::Time::Now());
- base::Time past_creation(base::Time::Now() - base::TimeDelta::FromDays(1000));
- scoped_refptr<MockSimplePersistentCookieStore> store(
- new MockSimplePersistentCookieStore);
- // Must expire to be persistent
- for (int i = 0; i < num_old_cookies; i++) {
- net::CookieMonster::CanonicalCookie cc(
- "a", "1", StringPrintf("h%05d.izzle", i), "/path", false, false,
- past_creation + base::TimeDelta::FromMicroseconds(i),
- current - base::TimeDelta::FromDays(days_old),
- true, current + base::TimeDelta::FromDays(30));
- store->AddCookie(cc);
- }
- for (int i = num_old_cookies; i < num_cookies; i++) {
- net::CookieMonster::CanonicalCookie cc(
- "a", "1", StringPrintf("h%05d.izzle", i), "/path", false, false,
- past_creation + base::TimeDelta::FromMicroseconds(i), current,
- true, current + base::TimeDelta::FromDays(30));
- store->AddCookie(cc);
- }
-
- return new net::CookieMonster(store, NULL);
-}
+ int days_old);
-} // namespace
+} // namespace net
diff --git a/net/base/cookie_monster_unittest.cc b/net/base/cookie_monster_unittest.cc
index f431674..caaad67 100644
--- a/net/base/cookie_monster_unittest.cc
+++ b/net/base/cookie_monster_unittest.cc
@@ -7,6 +7,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/message_loop.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "base/string_util.h"
diff --git a/net/base/filter_unittest.cc b/net/base/filter_unittest.cc
index 75fee20..c65c3de 100644
--- a/net/base/filter_unittest.cc
+++ b/net/base/filter_unittest.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "net/base/filter.h"
-#include "net/base/filter_unittest.h"
+#include "net/base/mock_filter_context.h"
#include "testing/gtest/include/gtest/gtest.h"
class FilterTest : public testing::Test {
@@ -36,7 +36,7 @@ TEST(FilterTest, ContentTypeId) {
// Check various fixups that modify content encoding lists.
TEST(FilterTest, ApacheGzip) {
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetSdchResponse(false);
// Check that redundant gzip mime type removes only solo gzip encoding.
@@ -85,7 +85,7 @@ TEST(FilterTest, SdchEncoding) {
// Handle content encodings including SDCH.
const std::string kTextHtmlMime("text/html");
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetSdchResponse(true);
std::vector<Filter::FilterType> encoding_types;
@@ -123,7 +123,7 @@ TEST(FilterTest, MissingSdchEncoding) {
// Handle interesting case where entire SDCH encoding assertion "got lost."
const std::string kTextHtmlMime("text/html");
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetSdchResponse(true);
std::vector<Filter::FilterType> encoding_types;
@@ -159,7 +159,7 @@ TEST(FilterTest, MissingSdchEncoding) {
TEST(FilterTest, Svgz) {
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
// Check that svgz files are only decompressed when not downloading.
const std::string kSvgzMime("image/svg+xml");
@@ -208,7 +208,7 @@ TEST(FilterTest, Svgz) {
TEST(FilterTest, UnsupportedMimeGzip) {
// From issue 8170 - handling files with Content-Encoding: x-gzip
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
std::vector<Filter::FilterType> encoding_types;
const std::string kTarMime("application/x-tar");
const std::string kCpioMime("application/x-cpio");
@@ -296,7 +296,7 @@ TEST(FilterTest, SupportedMimeGzip) {
// From issue 16430 - Files with supported mime types should be decompressed,
// even though these files end in .gz/.tgz.
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
std::vector<Filter::FilterType> encoding_types;
const std::string kGzUrl("http://ignore.com/foo.gz");
const std::string kUrl("http://ignore.com/foo");
diff --git a/net/base/gzip_filter_unittest.cc b/net/base/gzip_filter_unittest.cc
index 8ca1f4d..758418c 100644
--- a/net/base/gzip_filter_unittest.cc
+++ b/net/base/gzip_filter_unittest.cc
@@ -20,8 +20,8 @@
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/scoped_ptr.h"
-#include "net/base/filter_unittest.h"
#include "net/base/gzip_filter.h"
+#include "net/base/mock_filter_context.h"
#include "net/base/io_buffer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -243,7 +243,7 @@ TEST_F(GZipUnitTest, DecodeDeflate) {
// Decode the compressed data with filter
std::vector<Filter::FilterType> filter_types;
filter_types.push_back(Filter::FILTER_TYPE_DEFLATE);
- MockFilterContext filter_context(kDefaultBufferSize);
+ net::MockFilterContext filter_context(kDefaultBufferSize);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
ASSERT_TRUE(filter.get());
memcpy(filter->stream_buffer()->data(), deflate_encode_buffer_,
@@ -264,7 +264,7 @@ TEST_F(GZipUnitTest, DecodeGZip) {
// Decode the compressed data with filter
std::vector<Filter::FilterType> filter_types;
filter_types.push_back(Filter::FILTER_TYPE_GZIP);
- MockFilterContext filter_context(kDefaultBufferSize);
+ net::MockFilterContext filter_context(kDefaultBufferSize);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
ASSERT_TRUE(filter.get());
memcpy(filter->stream_buffer()->data(), gzip_encode_buffer_,
@@ -286,7 +286,7 @@ TEST_F(GZipUnitTest, DecodeGZip) {
TEST_F(GZipUnitTest, DecodeWithSmallBuffer) {
std::vector<Filter::FilterType> filter_types;
filter_types.push_back(Filter::FILTER_TYPE_DEFLATE);
- MockFilterContext filter_context(kSmallBufferSize);
+ net::MockFilterContext filter_context(kSmallBufferSize);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
ASSERT_TRUE(filter.get());
DecodeAndCompareWithFilter(filter.get(), source_buffer(), source_len(),
@@ -301,7 +301,7 @@ TEST_F(GZipUnitTest, DecodeWithSmallBuffer) {
TEST_F(GZipUnitTest, DecodeWithOneByteBuffer) {
std::vector<Filter::FilterType> filter_types;
filter_types.push_back(Filter::FILTER_TYPE_GZIP);
- MockFilterContext filter_context(1);
+ net::MockFilterContext filter_context(1);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
ASSERT_TRUE(filter.get());
DecodeAndCompareWithFilter(filter.get(), source_buffer(), source_len(),
@@ -313,7 +313,7 @@ TEST_F(GZipUnitTest, DecodeWithOneByteBuffer) {
TEST_F(GZipUnitTest, DecodeWithSmallOutputBuffer) {
std::vector<Filter::FilterType> filter_types;
filter_types.push_back(Filter::FILTER_TYPE_DEFLATE);
- MockFilterContext filter_context(kDefaultBufferSize);
+ net::MockFilterContext filter_context(kDefaultBufferSize);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
ASSERT_TRUE(filter.get());
DecodeAndCompareWithFilter(filter.get(), source_buffer(), source_len(),
@@ -326,7 +326,7 @@ TEST_F(GZipUnitTest, DecodeWithSmallOutputBuffer) {
TEST_F(GZipUnitTest, DecodeWithOneByteInputAndOutputBuffer) {
std::vector<Filter::FilterType> filter_types;
filter_types.push_back(Filter::FILTER_TYPE_GZIP);
- MockFilterContext filter_context(1);
+ net::MockFilterContext filter_context(1);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
ASSERT_TRUE(filter.get());
DecodeAndCompareWithFilter(filter.get(), source_buffer(), source_len(),
@@ -345,7 +345,7 @@ TEST_F(GZipUnitTest, DecodeCorruptedData) {
// Decode the corrupted data with filter
std::vector<Filter::FilterType> filter_types;
filter_types.push_back(Filter::FILTER_TYPE_DEFLATE);
- MockFilterContext filter_context(kDefaultBufferSize);
+ net::MockFilterContext filter_context(kDefaultBufferSize);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
ASSERT_TRUE(filter.get());
char corrupt_decode_buffer[kDefaultBufferSize];
@@ -372,7 +372,7 @@ TEST_F(GZipUnitTest, DecodeMissingData) {
// Decode the corrupted data with filter
std::vector<Filter::FilterType> filter_types;
filter_types.push_back(Filter::FILTER_TYPE_DEFLATE);
- MockFilterContext filter_context(kDefaultBufferSize);
+ net::MockFilterContext filter_context(kDefaultBufferSize);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
ASSERT_TRUE(filter.get());
char corrupt_decode_buffer[kDefaultBufferSize];
@@ -396,7 +396,7 @@ TEST_F(GZipUnitTest, DecodeCorruptedHeader) {
// Decode the corrupted data with filter
std::vector<Filter::FilterType> filter_types;
filter_types.push_back(Filter::FILTER_TYPE_GZIP);
- MockFilterContext filter_context(kDefaultBufferSize);
+ net::MockFilterContext filter_context(kDefaultBufferSize);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
ASSERT_TRUE(filter.get());
char corrupt_decode_buffer[kDefaultBufferSize];
diff --git a/net/base/listen_socket_unittest.cc b/net/base/listen_socket_unittest.cc
index 53fc79b..75beeec 100644
--- a/net/base/listen_socket_unittest.cc
+++ b/net/base/listen_socket_unittest.cc
@@ -19,8 +19,12 @@ static const int kMaxQueueSize = 20;
static const char kLoopback[] = "127.0.0.1";
static const int kDefaultTimeoutMs = 5000;
-ListenSocket* ListenSocketTester::DoListen() {
- return ListenSocket::Listen(kLoopback, kTestPort, this);
+ListenSocketTester::ListenSocketTester()
+ : thread_(NULL),
+ loop_(NULL),
+ server_(NULL),
+ connection_(NULL),
+ cv_(&lock_) {
}
void ListenSocketTester::SetUp() {
@@ -121,36 +125,6 @@ void ListenSocketTester::SendFromTester() {
ReportAction(ListenSocketTestAction(ACTION_SEND));
}
-void ListenSocketTester::DidAccept(ListenSocket *server,
- ListenSocket *connection) {
- connection_ = connection;
- connection_->AddRef();
- ReportAction(ListenSocketTestAction(ACTION_ACCEPT));
-}
-
-void ListenSocketTester::DidRead(ListenSocket *connection,
- const char* data,
- int len) {
- std::string str(data, len);
- ReportAction(ListenSocketTestAction(ACTION_READ, str));
-}
-
-void ListenSocketTester::DidClose(ListenSocket *sock) {
- ReportAction(ListenSocketTestAction(ACTION_CLOSE));
-}
-
-bool ListenSocketTester::Send(SOCKET sock, const std::string& str) {
- int len = static_cast<int>(str.length());
- int send_len = HANDLE_EINTR(send(sock, str.data(), len, 0));
- if (send_len == SOCKET_ERROR) {
- LOG(ERROR) << "send failed: " << errno;
- return false;
- } else if (send_len != len) {
- return false;
- }
- return true;
-}
-
void ListenSocketTester::TestClientSend() {
ASSERT_TRUE(Send(test_socket_, kHelloWorld));
NextAction();
@@ -200,6 +174,42 @@ void ListenSocketTester::TestServerSend() {
ASSERT_STREQ(buf, kHelloWorld);
}
+bool ListenSocketTester::Send(SOCKET sock, const std::string& str) {
+ int len = static_cast<int>(str.length());
+ int send_len = HANDLE_EINTR(send(sock, str.data(), len, 0));
+ if (send_len == SOCKET_ERROR) {
+ LOG(ERROR) << "send failed: " << errno;
+ return false;
+ } else if (send_len != len) {
+ return false;
+ }
+ return true;
+}
+
+void ListenSocketTester::DidAccept(ListenSocket *server,
+ ListenSocket *connection) {
+ connection_ = connection;
+ connection_->AddRef();
+ ReportAction(ListenSocketTestAction(ACTION_ACCEPT));
+}
+
+void ListenSocketTester::DidRead(ListenSocket *connection,
+ const char* data,
+ int len) {
+ std::string str(data, len);
+ ReportAction(ListenSocketTestAction(ACTION_READ, str));
+}
+
+void ListenSocketTester::DidClose(ListenSocket *sock) {
+ ReportAction(ListenSocketTestAction(ACTION_CLOSE));
+}
+
+ListenSocketTester::~ListenSocketTester() {}
+
+ListenSocket* ListenSocketTester::DoListen() {
+ return ListenSocket::Listen(kLoopback, kTestPort, this);
+}
+
class ListenSocketTest: public PlatformTest {
public:
diff --git a/net/base/listen_socket_unittest.h b/net/base/listen_socket_unittest.h
index f283cb0..f54fc31 100644
--- a/net/base/listen_socket_unittest.h
+++ b/net/base/listen_socket_unittest.h
@@ -68,24 +68,11 @@ class ListenSocketTester :
public ListenSocket::ListenSocketDelegate,
public base::RefCountedThreadSafe<ListenSocketTester> {
- protected:
- friend class base::RefCountedThreadSafe<ListenSocketTester>;
-
- virtual ~ListenSocketTester() {}
-
- virtual ListenSocket* DoListen();
-
public:
- ListenSocketTester()
- : thread_(NULL),
- loop_(NULL),
- server_(NULL),
- connection_(NULL),
- cv_(&lock_) {
- }
+ ListenSocketTester();
- virtual void SetUp();
- virtual void TearDown();
+ void SetUp();
+ void TearDown();
void ReportAction(const ListenSocketTestAction& action);
void NextAction();
@@ -96,10 +83,6 @@ class ListenSocketTester :
void Shutdown();
void Listen();
void SendFromTester();
- virtual void DidAccept(ListenSocket *server, ListenSocket *connection);
- virtual void DidRead(ListenSocket *connection, const char* data, int len);
- virtual void DidClose(ListenSocket *sock);
- virtual bool Send(SOCKET sock, const std::string& str);
// verify the send/read from client to server
void TestClientSend();
// verify send/read of a longer string
@@ -107,6 +90,13 @@ class ListenSocketTester :
// verify a send/read from server to client
void TestServerSend();
+ virtual bool Send(SOCKET sock, const std::string& str);
+
+ // ListenSocket::ListenSocketDelegate:
+ virtual void DidAccept(ListenSocket *server, ListenSocket *connection);
+ virtual void DidRead(ListenSocket *connection, const char* data, int len);
+ virtual void DidClose(ListenSocket *sock);
+
scoped_ptr<base::Thread> thread_;
MessageLoopForIO* loop_;
ListenSocket* server_;
@@ -119,6 +109,13 @@ class ListenSocketTester :
base::Lock lock_; // protects |queue_| and wraps |cv_|
base::ConditionVariable cv_;
std::deque<ListenSocketTestAction> queue_;
+
+ protected:
+ friend class base::RefCountedThreadSafe<ListenSocketTester>;
+
+ virtual ~ListenSocketTester();
+
+ virtual ListenSocket* DoListen();
};
#endif // NET_BASE_LISTEN_SOCKET_UNITTEST_H_
diff --git a/net/base/mock_filter_context.cc b/net/base/mock_filter_context.cc
new file mode 100644
index 0000000..a453ed8
--- /dev/null
+++ b/net/base/mock_filter_context.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2010 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.
+
+#include "net/base/mock_filter_context.h"
+
+namespace net {
+
+MockFilterContext::MockFilterContext(int buffer_size)
+ : buffer_size_(buffer_size),
+ is_cached_content_(false),
+ is_download_(false),
+ is_sdch_response_(false),
+ response_code_(-1) {
+}
+
+MockFilterContext::~MockFilterContext() {}
+
+bool MockFilterContext::GetMimeType(std::string* mime_type) const {
+ *mime_type = mime_type_;
+ return true;
+}
+
+// What URL was used to access this data?
+// Return false if gurl is not present.
+bool MockFilterContext::GetURL(GURL* gurl) const {
+ *gurl = gurl_;
+ return true;
+}
+
+// What was this data requested from a server?
+base::Time MockFilterContext::GetRequestTime() const {
+ return request_time_;
+}
+
+bool MockFilterContext::IsCachedContent() const { return is_cached_content_; }
+
+bool MockFilterContext::IsDownload() const { return is_download_; }
+
+bool MockFilterContext::IsSdchResponse() const { return is_sdch_response_; }
+
+int64 MockFilterContext::GetByteReadCount() const { return 0; }
+
+int MockFilterContext::GetResponseCode() const { return response_code_; }
+
+int MockFilterContext::GetInputStreamBufferSize() const { return buffer_size_; }
+
+} // namespace net
diff --git a/net/base/filter_unittest.h b/net/base/mock_filter_context.h
index a45e353..3b746e0 100644
--- a/net/base/filter_unittest.h
+++ b/net/base/mock_filter_context.h
@@ -1,10 +1,9 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
-//
-#ifndef NET_BASE_FILTER_UNITTEST_H_
-#define NET_BASE_FILTER_UNITTEST_H_
+#ifndef NET_BASE_MOCK_FILTER_CONTEXT_H_
+#define NET_BASE_MOCK_FILTER_CONTEXT_H_
#pragma once
#include <string>
@@ -12,16 +11,12 @@
#include "googleurl/src/gurl.h"
#include "net/base/filter.h"
-//------------------------------------------------------------------------------
+namespace net {
+
class MockFilterContext : public FilterContext {
public:
- explicit MockFilterContext(int buffer_size)
- : buffer_size_(buffer_size),
- is_cached_content_(false),
- is_download_(false),
- is_sdch_response_(false),
- response_code_(-1) {
- }
+ explicit MockFilterContext(int buffer_size);
+ virtual ~MockFilterContext();
void SetBufferSize(int buffer_size) { buffer_size_ = buffer_size; }
void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; }
@@ -34,39 +29,31 @@ class MockFilterContext : public FilterContext {
is_sdch_response_ = is_sdch_response;
}
- virtual bool GetMimeType(std::string* mime_type) const {
- *mime_type = mime_type_;
- return true;
- }
+ virtual bool GetMimeType(std::string* mime_type) const;
// What URL was used to access this data?
// Return false if gurl is not present.
- virtual bool GetURL(GURL* gurl) const {
- *gurl = gurl_;
- return true;
- }
+ virtual bool GetURL(GURL* gurl) const;
// What was this data requested from a server?
- virtual base::Time GetRequestTime() const {
- return request_time_;
- }
+ virtual base::Time GetRequestTime() const;
// Is data supplied from cache, or fresh across the net?
- virtual bool IsCachedContent() const { return is_cached_content_; }
+ virtual bool IsCachedContent() const;
// Is this a download?
- virtual bool IsDownload() const { return is_download_; }
+ virtual bool IsDownload() const;
// Was this data flagged as a response to a request with an SDCH dictionary?
- virtual bool IsSdchResponse() const { return is_sdch_response_; }
+ virtual bool IsSdchResponse() const;
// How many bytes were fed to filter(s) so far?
- virtual int64 GetByteReadCount() const { return 0; }
+ virtual int64 GetByteReadCount() const;
- virtual int GetResponseCode() const { return response_code_; }
+ virtual int GetResponseCode() const;
// What is the desirable input buffer size for these filters?
- virtual int GetInputStreamBufferSize() const { return buffer_size_; }
+ virtual int GetInputStreamBufferSize() const;
virtual void RecordPacketStats(StatisticSelector statistic) const {}
@@ -83,4 +70,6 @@ class MockFilterContext : public FilterContext {
DISALLOW_COPY_AND_ASSIGN(MockFilterContext);
};
-#endif // NET_BASE_FILTER_UNITTEST_H_
+} // namespace net
+
+#endif // NET_BASE_MOCK_FILTER_CONTEXT_H_
diff --git a/net/base/net_test_suite.cc b/net/base/net_test_suite.cc
new file mode 100644
index 0000000..a37bc5b
--- /dev/null
+++ b/net/base/net_test_suite.cc
@@ -0,0 +1,46 @@
+// 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.
+
+#include "net/base/net_test_suite.h"
+
+#include "base/message_loop.h"
+#if defined(USE_NSS)
+#include "net/ocsp/nss_ocsp.h"
+#endif
+
+NetTestSuite::NetTestSuite(int argc, char** argv)
+ : TestSuite(argc, argv) {
+}
+
+NetTestSuite::~NetTestSuite() {}
+
+void NetTestSuite::Initialize() {
+ TestSuite::Initialize();
+ InitializeTestThread();
+}
+
+void NetTestSuite::Shutdown() {
+#if defined(USE_NSS)
+ net::ShutdownOCSP();
+#endif
+
+ // We want to destroy this here before the TestSuite continues to tear down
+ // the environment.
+ message_loop_.reset();
+
+ TestSuite::Shutdown();
+}
+
+void NetTestSuite::InitializeTestThread() {
+ network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock());
+
+ host_resolver_proc_ = new net::RuleBasedHostResolverProc(NULL);
+ scoped_host_resolver_proc_.Init(host_resolver_proc_.get());
+ // In case any attempts are made to resolve host names, force them all to
+ // be mapped to localhost. This prevents DNS queries from being sent in
+ // the process of running these unit tests.
+ host_resolver_proc_->AddRule("*", "127.0.0.1");
+
+ message_loop_.reset(new MessageLoopForIO());
+}
diff --git a/net/base/net_test_suite.h b/net/base/net_test_suite.h
index 8ebc4e7..274d067 100644
--- a/net/base/net_test_suite.h
+++ b/net/base/net_test_suite.h
@@ -6,53 +6,33 @@
#define NET_BASE_NET_TEST_SUITE_H_
#pragma once
-#include "base/message_loop.h"
#include "base/ref_counted.h"
#include "base/test/test_suite.h"
#include "build/build_config.h"
#include "net/base/mock_host_resolver.h"
-#if defined(USE_NSS)
-#include "net/ocsp/nss_ocsp.h"
-#endif
+
+class MessageLoop;
+
+namespace net {
+class NetworkChangeNotifier;
+}
class NetTestSuite : public base::TestSuite {
public:
- NetTestSuite(int argc, char** argv) : TestSuite(argc, argv) {
- }
+ NetTestSuite(int argc, char** argv);
+ virtual ~NetTestSuite();
+
+ virtual void Initialize();
- virtual void Initialize() {
- TestSuite::Initialize();
- InitializeTestThread();
- }
+ virtual void Shutdown();
+
+ protected:
// Called from within Initialize(), but separate so that derived classes
// can initialize the NetTestSuite instance only and not
// TestSuite::Initialize(). TestSuite::Initialize() performs some global
// initialization that can only be done once.
- void InitializeTestThread() {
- network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock());
-
- host_resolver_proc_ = new net::RuleBasedHostResolverProc(NULL);
- scoped_host_resolver_proc_.Init(host_resolver_proc_.get());
- // In case any attempts are made to resolve host names, force them all to
- // be mapped to localhost. This prevents DNS queries from being sent in
- // the process of running these unit tests.
- host_resolver_proc_->AddRule("*", "127.0.0.1");
-
- message_loop_.reset(new MessageLoopForIO());
- }
-
- virtual void Shutdown() {
-#if defined(USE_NSS)
- net::ShutdownOCSP();
-#endif
-
- // We want to destroy this here before the TestSuite continues to tear down
- // the environment.
- message_loop_.reset();
-
- TestSuite::Shutdown();
- }
+ void InitializeTestThread();
private:
scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
diff --git a/net/base/sdch_filter_unittest.cc b/net/base/sdch_filter_unittest.cc
index 675a135..ccf07cb 100644
--- a/net/base/sdch_filter_unittest.cc
+++ b/net/base/sdch_filter_unittest.cc
@@ -17,8 +17,8 @@
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "net/base/filter.h"
-#include "net/base/filter_unittest.h"
#include "net/base/io_buffer.h"
+#include "net/base/mock_filter_context.h"
#include "net/base/sdch_filter.h"
#include "net/url_request/url_request_http_job.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -158,7 +158,7 @@ TEST_F(SdchFilterTest, EmptyInputOk) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(30);
char output_buffer[20];
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
std::string url_string("http://ignore.com");
filter_context.SetURL(GURL(url_string));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -179,7 +179,7 @@ TEST_F(SdchFilterTest, PassThroughWhenTentative) {
filter_types.push_back(Filter::FILTER_TYPE_GZIP_HELPING_SDCH);
const int kInputBufferSize(30);
char output_buffer[20];
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
// Response code needs to be 200 to allow a pass through.
filter_context.SetResponseCode(200);
std::string url_string("http://ignore.com");
@@ -219,7 +219,7 @@ TEST_F(SdchFilterTest, RefreshBadReturnCode) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH_POSSIBLE);
const int kInputBufferSize(30);
char output_buffer[20];
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
// Response code needs to be 200 to allow a pass through.
filter_context.SetResponseCode(403);
// Meta refresh will only appear for html content
@@ -262,7 +262,7 @@ TEST_F(SdchFilterTest, ErrorOnBadReturnCode) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH_POSSIBLE);
const int kInputBufferSize(30);
char output_buffer[20];
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
// Response code needs to be 200 to allow a pass through.
filter_context.SetResponseCode(403);
// Meta refresh will only appear for html content, so set to something else
@@ -301,7 +301,7 @@ TEST_F(SdchFilterTest, ErrorOnBadReturnCodeWithHtml) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH_POSSIBLE);
const int kInputBufferSize(30);
char output_buffer[20];
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
// Response code needs to be 200 to allow a pass through.
filter_context.SetResponseCode(403);
// Meta refresh will only appear for html content
@@ -344,7 +344,7 @@ TEST_F(SdchFilterTest, BasicBadDictionary) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(30);
char output_buffer[20];
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
std::string url_string("http://ignore.com");
filter_context.SetURL(GURL(url_string));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -432,7 +432,7 @@ TEST_F(SdchFilterTest, BasicDictionary) {
// Decode with a large buffer (larger than test input, or compressed data).
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(url);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -471,7 +471,7 @@ TEST_F(SdchFilterTest, NoDecodeHttps) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL("https://" + kSampleDomain));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -503,7 +503,7 @@ TEST_F(SdchFilterTest, NoDecodeFtp) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL("ftp://" + kSampleDomain));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -531,7 +531,7 @@ TEST_F(SdchFilterTest, NoDecodeFileColon) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL("file://" + kSampleDomain));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -559,7 +559,7 @@ TEST_F(SdchFilterTest, NoDecodeAboutColon) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL("about://" + kSampleDomain));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -587,7 +587,7 @@ TEST_F(SdchFilterTest, NoDecodeJavaScript) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL("javascript://" + kSampleDomain));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -615,7 +615,7 @@ TEST_F(SdchFilterTest, CanStillDecodeHttp) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL("http://" + kSampleDomain));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -645,7 +645,7 @@ TEST_F(SdchFilterTest, CrossDomainDictionaryUse) {
// Decode with content arriving from the "wrong" domain.
// This tests SdchManager::CanSet().
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
GURL wrong_domain_url("http://www.wrongdomain.com");
filter_context.SetURL(wrong_domain_url);
scoped_ptr<Filter> filter((Filter::Factory(filter_types, filter_context)));
@@ -686,7 +686,7 @@ TEST_F(SdchFilterTest, DictionaryPathValidation) {
const int kInputBufferSize(100);
// Test decode the path data, arriving from a valid path.
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL(url_string + path));
scoped_ptr<Filter> filter((Filter::Factory(filter_types, filter_context)));
@@ -740,7 +740,7 @@ TEST_F(SdchFilterTest, DictionaryPortValidation) {
const int kInputBufferSize(100);
// Test decode the port data, arriving from a valid port.
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL(url_string + ":" + port));
scoped_ptr<Filter> filter((Filter::Factory(filter_types, filter_context)));
@@ -863,7 +863,7 @@ TEST_F(SdchFilterTest, FilterChaining) {
CHECK_GT(kLargeInputBufferSize, gzip_compressed_sdch.size());
CHECK_GT(kLargeInputBufferSize, sdch_compressed.size());
CHECK_GT(kLargeInputBufferSize, expanded_.size());
- MockFilterContext filter_context(kLargeInputBufferSize);
+ net::MockFilterContext filter_context(kLargeInputBufferSize);
filter_context.SetURL(url);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -933,7 +933,7 @@ TEST_F(SdchFilterTest, DefaultGzipIfSdch) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetMimeType("anything/mime");
filter_context.SetSdchResponse(true);
Filter::FixupEncodingTypes(filter_context, &filter_types);
@@ -993,7 +993,7 @@ TEST_F(SdchFilterTest, AcceptGzipSdchIfGzip) {
filter_types.push_back(Filter::FILTER_TYPE_GZIP);
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetMimeType("anything/mime");
filter_context.SetSdchResponse(true);
Filter::FixupEncodingTypes(filter_context, &filter_types);
@@ -1052,7 +1052,7 @@ TEST_F(SdchFilterTest, DefaultSdchGzipIfEmpty) {
std::vector<Filter::FilterType> filter_types;
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetMimeType("anything/mime");
filter_context.SetSdchResponse(true);
Filter::FixupEncodingTypes(filter_context, &filter_types);
@@ -1115,7 +1115,7 @@ TEST_F(SdchFilterTest, AcceptGzipGzipSdchIfGzip) {
filter_types.push_back(Filter::FILTER_TYPE_GZIP);
const int kInputBufferSize(100);
- MockFilterContext filter_context(kInputBufferSize);
+ net::MockFilterContext filter_context(kInputBufferSize);
filter_context.SetMimeType("anything/mime");
filter_context.SetSdchResponse(true);
Filter::FixupEncodingTypes(filter_context, &filter_types);