summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-25 23:48:06 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-25 23:48:06 +0000
commit472ce96a4b839814ed93c26d35d07c78de019b17 (patch)
tree8355f2a490ce20c4be7485f40505544e3d602a26 /net/http
parentb597956cd427a3b830a498c69602753ce6117119 (diff)
downloadchromium_src-472ce96a4b839814ed93c26d35d07c78de019b17.zip
chromium_src-472ce96a4b839814ed93c26d35d07c78de019b17.tar.gz
chromium_src-472ce96a4b839814ed93c26d35d07c78de019b17.tar.bz2
Clean up net unit testing code.
- Move code included from blah_unittest.h (where blah_unittest.cc has actual unittests) into their own files, often completely out-of-lining the definitions. - Remove anonymous namespaces from headers. - Reorder method declarations. - Make other unit test link against net_test_support instead of reaching in and including .h files in their targets directly. BUG=68682 TEST=compiles Review URL: http://codereview.chromium.org/6264013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72562 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_auth_handler_factory_unittest.cc3
-rw-r--r--net/http/http_auth_handler_negotiate_unittest.cc3
-rw-r--r--net/http/http_auth_unittest.cc3
-rw-r--r--net/http/http_transaction_unittest.cc232
-rw-r--r--net/http/http_transaction_unittest.h217
-rw-r--r--net/http/mock_allow_url_security_manager.cc22
-rw-r--r--net/http/mock_allow_url_security_manager.h29
-rw-r--r--net/http/url_security_manager.h19
8 files changed, 315 insertions, 213 deletions
diff --git a/net/http/http_auth_handler_factory_unittest.cc b/net/http/http_auth_handler_factory_unittest.cc
index fb6e370..3145c4b 100644
--- a/net/http/http_auth_handler_factory_unittest.cc
+++ b/net/http/http_auth_handler_factory_unittest.cc
@@ -7,6 +7,7 @@
#include "net/base/net_errors.h"
#include "net/http/http_auth_handler.h"
#include "net/http/http_auth_handler_factory.h"
+#include "net/http/mock_allow_url_security_manager.h"
#include "net/http/url_security_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -97,7 +98,7 @@ TEST(HttpAuthHandlerFactoryTest, RegistryFactory) {
TEST(HttpAuthHandlerFactoryTest, DefaultFactory) {
scoped_ptr<HostResolver> host_resolver(new MockHostResolver());
- URLSecurityManagerAllow url_security_manager;
+ MockAllowURLSecurityManager url_security_manager;
scoped_ptr<HttpAuthHandlerRegistryFactory> http_auth_handler_factory(
HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
http_auth_handler_factory->SetURLSecurityManager(
diff --git a/net/http/http_auth_handler_negotiate_unittest.cc b/net/http/http_auth_handler_negotiate_unittest.cc
index 684ff55..bb57151 100644
--- a/net/http/http_auth_handler_negotiate_unittest.cc
+++ b/net/http/http_auth_handler_negotiate_unittest.cc
@@ -10,6 +10,7 @@
#include "net/base/net_errors.h"
#include "net/base/test_completion_callback.h"
#include "net/http/http_request_info.h"
+#include "net/http/mock_allow_url_security_manager.h"
#if defined(OS_WIN)
#include "net/http/mock_sspi_library_win.h"
#elif defined(OS_POSIX)
@@ -36,7 +37,7 @@ class HttpAuthHandlerNegotiateTest : public PlatformTest {
resolver_->rules()->AddIPLiteralRule("alias", "10.0.0.2",
"canonical.example.com");
- url_security_manager_.reset(new URLSecurityManagerAllow());
+ url_security_manager_.reset(new MockAllowURLSecurityManager());
factory_.reset(new HttpAuthHandlerNegotiate::Factory());
factory_->set_url_security_manager(url_security_manager_.get());
factory_->set_library(auth_library_);
diff --git a/net/http/http_auth_unittest.cc b/net/http/http_auth_unittest.cc
index f45d215..6788be2 100644
--- a/net/http/http_auth_unittest.cc
+++ b/net/http/http_auth_unittest.cc
@@ -17,6 +17,7 @@
#include "net/http/http_auth_handler_mock.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
+#include "net/http/mock_allow_url_security_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
@@ -115,7 +116,7 @@ TEST(HttpAuthTest, ChooseBestChallenge) {
};
GURL origin("http://www.example.com");
std::set<HttpAuth::Scheme> disabled_schemes;
- URLSecurityManagerAllow url_security_manager;
+ MockAllowURLSecurityManager url_security_manager;
scoped_ptr<HostResolver> host_resolver(new MockHostResolver());
scoped_ptr<HttpAuthHandlerRegistryFactory> http_auth_handler_factory(
HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
diff --git a/net/http/http_transaction_unittest.cc b/net/http/http_transaction_unittest.cc
index 518c1f8..fabfb01 100644
--- a/net/http/http_transaction_unittest.cc
+++ b/net/http/http_transaction_unittest.cc
@@ -1,10 +1,11 @@
-// 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.
#include "net/http/http_transaction_unittest.h"
-#include "base/hash_tables.h"
+#include <algorithm>
+
#include "base/message_loop.h"
#include "base/string_util.h"
#include "net/base/net_errors.h"
@@ -16,6 +17,11 @@
#include "net/http/http_transaction.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace {
+typedef base::hash_map<std::string, const MockTransaction*> MockTransactionMap;
+static MockTransactionMap mock_transactions;
+} // namespace
+
//-----------------------------------------------------------------------------
// mock transaction data
@@ -104,18 +110,6 @@ static const MockTransaction* const kBuiltinMockTransactions[] = {
&kRangeGET_Transaction
};
-typedef base::hash_map<std::string, const MockTransaction*>
-MockTransactionMap;
-static MockTransactionMap mock_transactions;
-
-void AddMockTransaction(const MockTransaction* trans) {
- mock_transactions[GURL(trans->url).spec()] = trans;
-}
-
-void RemoveMockTransaction(const MockTransaction* trans) {
- mock_transactions.erase(GURL(trans->url).spec());
-}
-
const MockTransaction* FindMockTransaction(const GURL& url) {
// look for overrides:
MockTransactionMap::const_iterator it = mock_transactions.find(url.spec());
@@ -130,12 +124,222 @@ const MockTransaction* FindMockTransaction(const GURL& url) {
return NULL;
}
+void AddMockTransaction(const MockTransaction* trans) {
+ mock_transactions[GURL(trans->url).spec()] = trans;
+}
+
+void RemoveMockTransaction(const MockTransaction* trans) {
+ mock_transactions.erase(GURL(trans->url).spec());
+}
+
+MockHttpRequest::MockHttpRequest(const MockTransaction& t) {
+ url = GURL(t.url);
+ method = t.method;
+ extra_headers.AddHeadersFromString(t.request_headers);
+ load_flags = t.load_flags;
+}
//-----------------------------------------------------------------------------
// static
int TestTransactionConsumer::quit_counter_ = 0;
+TestTransactionConsumer::TestTransactionConsumer(
+ net::HttpTransactionFactory* factory)
+ : state_(IDLE),
+ trans_(NULL),
+ error_(net::OK) {
+ // Disregard the error code.
+ factory->CreateTransaction(&trans_);
+ ++quit_counter_;
+}
+
+TestTransactionConsumer::~TestTransactionConsumer() {
+}
+
+void TestTransactionConsumer::Start(const net::HttpRequestInfo* request,
+ const net::BoundNetLog& net_log) {
+ state_ = STARTING;
+ int result = trans_->Start(request, this, net_log);
+ if (result != net::ERR_IO_PENDING)
+ DidStart(result);
+}
+
+void TestTransactionConsumer::DidStart(int result) {
+ if (result != net::OK) {
+ DidFinish(result);
+ } else {
+ Read();
+ }
+}
+
+void TestTransactionConsumer::DidRead(int result) {
+ if (result <= 0) {
+ DidFinish(result);
+ } else {
+ content_.append(read_buf_->data(), result);
+ Read();
+ }
+}
+
+void TestTransactionConsumer::DidFinish(int result) {
+ state_ = DONE;
+ error_ = result;
+ if (--quit_counter_ == 0)
+ MessageLoop::current()->Quit();
+}
+
+void TestTransactionConsumer::Read() {
+ state_ = READING;
+ read_buf_ = new net::IOBuffer(1024);
+ int result = trans_->Read(read_buf_, 1024, this);
+ if (result != net::ERR_IO_PENDING)
+ DidRead(result);
+}
+
+void TestTransactionConsumer::RunWithParams(const Tuple1<int>& params) {
+ int result = params.a;
+ switch (state_) {
+ case STARTING:
+ DidStart(result);
+ break;
+ case READING:
+ DidRead(result);
+ break;
+ default:
+ NOTREACHED();
+ }
+}
+
+
+MockNetworkTransaction::MockNetworkTransaction() :
+ ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), data_cursor_(0) {
+}
+
+MockNetworkTransaction::~MockNetworkTransaction() {}
+
+int MockNetworkTransaction::Start(const net::HttpRequestInfo* request,
+ net::CompletionCallback* callback,
+ const net::BoundNetLog& net_log) {
+ const MockTransaction* t = FindMockTransaction(request->url);
+ if (!t)
+ return net::ERR_FAILED;
+
+ std::string resp_status = t->status;
+ std::string resp_headers = t->response_headers;
+ std::string resp_data = t->data;
+ if (t->handler)
+ (t->handler)(request, &resp_status, &resp_headers, &resp_data);
+
+ std::string header_data = base::StringPrintf(
+ "%s\n%s\n", resp_status.c_str(), resp_headers.c_str());
+ std::replace(header_data.begin(), header_data.end(), '\n', '\0');
+
+ response_.request_time = base::Time::Now();
+ if (!t->request_time.is_null())
+ response_.request_time = t->request_time;
+
+ response_.was_cached = false;
+
+ response_.response_time = base::Time::Now();
+ if (!t->response_time.is_null())
+ response_.response_time = t->response_time;
+
+ response_.headers = new net::HttpResponseHeaders(header_data);
+ response_.ssl_info.cert_status = t->cert_status;
+ data_ = resp_data;
+ test_mode_ = t->test_mode;
+
+ if (test_mode_ & TEST_MODE_SYNC_NET_START)
+ return net::OK;
+
+ CallbackLater(callback, net::OK);
+ return net::ERR_IO_PENDING;
+}
+
+int MockNetworkTransaction::RestartIgnoringLastError(
+ net::CompletionCallback* callback) {
+ return net::ERR_FAILED;
+}
+
+int MockNetworkTransaction::RestartWithCertificate(
+ net::X509Certificate* client_cert,
+ net::CompletionCallback* callback) {
+ return net::ERR_FAILED;
+}
+
+int MockNetworkTransaction::RestartWithAuth(const string16& username,
+ const string16& password,
+ net::CompletionCallback* callback) {
+ return net::ERR_FAILED;
+}
+
+bool MockNetworkTransaction::IsReadyToRestartForAuth() {
+ return false;
+}
+
+int MockNetworkTransaction::Read(net::IOBuffer* buf, int buf_len,
+ net::CompletionCallback* callback) {
+ int data_len = static_cast<int>(data_.size());
+ int num = std::min(buf_len, data_len - data_cursor_);
+ if (num) {
+ memcpy(buf->data(), data_.data() + data_cursor_, num);
+ data_cursor_ += num;
+ }
+ if (test_mode_ & TEST_MODE_SYNC_NET_READ)
+ return num;
+
+ CallbackLater(callback, num);
+ return net::ERR_IO_PENDING;
+}
+
+void MockNetworkTransaction::StopCaching() {}
+
+const net::HttpResponseInfo* MockNetworkTransaction::GetResponseInfo() const {
+ return &response_;
+}
+
+net::LoadState MockNetworkTransaction::GetLoadState() const {
+ if (data_cursor_)
+ return net::LOAD_STATE_READING_RESPONSE;
+ return net::LOAD_STATE_IDLE;
+}
+
+uint64 MockNetworkTransaction::GetUploadProgress() const {
+ return 0;
+}
+
+void MockNetworkTransaction::CallbackLater(net::CompletionCallback* callback,
+ int result) {
+ MessageLoop::current()->PostTask(FROM_HERE, task_factory_.NewRunnableMethod(
+ &MockNetworkTransaction::RunCallback, callback, result));
+}
+
+void MockNetworkTransaction::RunCallback(net::CompletionCallback* callback,
+ int result) {
+ callback->Run(result);
+}
+
+MockNetworkLayer::MockNetworkLayer() : transaction_count_(0) {}
+
+MockNetworkLayer::~MockNetworkLayer() {}
+
+int MockNetworkLayer::CreateTransaction(
+ scoped_ptr<net::HttpTransaction>* trans) {
+ transaction_count_++;
+ trans->reset(new MockNetworkTransaction());
+ return net::OK;
+}
+
+net::HttpCache* MockNetworkLayer::GetCache() {
+ return NULL;
+}
+
+net::HttpNetworkSession* MockNetworkLayer::GetSession() {
+ return NULL;
+}
+
+void MockNetworkLayer::Suspend(bool suspend) {}
//-----------------------------------------------------------------------------
// helpers
diff --git a/net/http/http_transaction_unittest.h b/net/http/http_transaction_unittest.h
index 3149534..0a11bb5 100644
--- a/net/http/http_transaction_unittest.h
+++ b/net/http/http_transaction_unittest.h
@@ -8,15 +8,11 @@
#include "net/http/http_transaction.h"
-#include <algorithm>
#include <string>
#include "base/callback.h"
#include "base/compiler_specific.h"
-#include "base/message_loop.h"
#include "base/string16.h"
-#include "base/string_util.h"
-#include "base/stringprintf.h"
#include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
@@ -27,6 +23,10 @@
#include "net/http/http_response_headers.h"
#include "net/http/http_response_info.h"
+namespace net {
+class IOBuffer;
+}
+
//-----------------------------------------------------------------------------
// mock transaction data
@@ -97,12 +97,7 @@ struct ScopedMockTransaction : MockTransaction {
class MockHttpRequest : public net::HttpRequestInfo {
public:
- explicit MockHttpRequest(const MockTransaction& t) {
- url = GURL(t.url);
- method = t.method;
- extra_headers.AddHeadersFromString(t.request_headers);
- load_flags = t.load_flags;
- }
+ explicit MockHttpRequest(const MockTransaction& t);
};
//-----------------------------------------------------------------------------
@@ -110,25 +105,11 @@ class MockHttpRequest : public net::HttpRequestInfo {
class TestTransactionConsumer : public CallbackRunner< Tuple1<int> > {
public:
- explicit TestTransactionConsumer(net::HttpTransactionFactory* factory)
- : state_(IDLE),
- trans_(NULL),
- error_(net::OK) {
- // Disregard the error code.
- factory->CreateTransaction(&trans_);
- ++quit_counter_;
- }
-
- ~TestTransactionConsumer() {
- }
+ explicit TestTransactionConsumer(net::HttpTransactionFactory* factory);
+ virtual ~TestTransactionConsumer();
void Start(const net::HttpRequestInfo* request,
- const net::BoundNetLog& net_log) {
- state_ = STARTING;
- int result = trans_->Start(request, this, net_log);
- if (result != net::ERR_IO_PENDING)
- DidStart(result);
- }
+ const net::BoundNetLog& net_log);
bool is_done() const { return state_ == DONE; }
int error() const { return error_; }
@@ -139,60 +120,22 @@ class TestTransactionConsumer : public CallbackRunner< Tuple1<int> > {
const std::string& content() const { return content_; }
private:
- // Callback implementation:
- virtual void RunWithParams(const Tuple1<int>& params) {
- int result = params.a;
- switch (state_) {
- case STARTING:
- DidStart(result);
- break;
- case READING:
- DidRead(result);
- break;
- default:
- NOTREACHED();
- }
- }
-
- void DidStart(int result) {
- if (result != net::OK) {
- DidFinish(result);
- } else {
- Read();
- }
- }
-
- void DidRead(int result) {
- if (result <= 0) {
- DidFinish(result);
- } else {
- content_.append(read_buf_->data(), result);
- Read();
- }
- }
-
- void DidFinish(int result) {
- state_ = DONE;
- error_ = result;
- if (--quit_counter_ == 0)
- MessageLoop::current()->Quit();
- }
-
- void Read() {
- state_ = READING;
- read_buf_ = new net::IOBuffer(1024);
- int result = trans_->Read(read_buf_, 1024, this);
- if (result != net::ERR_IO_PENDING)
- DidRead(result);
- }
-
enum State {
IDLE,
STARTING,
READING,
DONE
- } state_;
+ };
+
+ void DidStart(int result);
+ void DidRead(int result);
+ void DidFinish(int result);
+ void Read();
+
+ // Callback implementation:
+ virtual void RunWithParams(const Tuple1<int>& params);
+ State state_;
scoped_ptr<net::HttpTransaction> trans_;
std::string content_;
scoped_refptr<net::IOBuffer> read_buf_;
@@ -210,107 +153,38 @@ class TestTransactionConsumer : public CallbackRunner< Tuple1<int> > {
// HttpCache implementation.
class MockNetworkTransaction : public net::HttpTransaction {
public:
- MockNetworkTransaction() :
- ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), data_cursor_(0) {
- }
+ MockNetworkTransaction();
+ virtual ~MockNetworkTransaction();
virtual int Start(const net::HttpRequestInfo* request,
net::CompletionCallback* callback,
- const net::BoundNetLog& net_log) {
- const MockTransaction* t = FindMockTransaction(request->url);
- if (!t)
- return net::ERR_FAILED;
-
- std::string resp_status = t->status;
- std::string resp_headers = t->response_headers;
- std::string resp_data = t->data;
- if (t->handler)
- (t->handler)(request, &resp_status, &resp_headers, &resp_data);
-
- std::string header_data = base::StringPrintf(
- "%s\n%s\n", resp_status.c_str(), resp_headers.c_str());
- std::replace(header_data.begin(), header_data.end(), '\n', '\0');
-
- response_.request_time = base::Time::Now();
- if (!t->request_time.is_null())
- response_.request_time = t->request_time;
-
- response_.was_cached = false;
+ const net::BoundNetLog& net_log);
- response_.response_time = base::Time::Now();
- if (!t->response_time.is_null())
- response_.response_time = t->response_time;
-
- response_.headers = new net::HttpResponseHeaders(header_data);
- response_.ssl_info.cert_status = t->cert_status;
- data_ = resp_data;
- test_mode_ = t->test_mode;
-
- if (test_mode_ & TEST_MODE_SYNC_NET_START)
- return net::OK;
-
- CallbackLater(callback, net::OK);
- return net::ERR_IO_PENDING;
- }
-
- virtual int RestartIgnoringLastError(net::CompletionCallback* callback) {
- return net::ERR_FAILED;
- }
+ virtual int RestartIgnoringLastError(net::CompletionCallback* callback);
virtual int RestartWithCertificate(net::X509Certificate* client_cert,
- net::CompletionCallback* callback) {
- return net::ERR_FAILED;
- }
+ net::CompletionCallback* callback);
virtual int RestartWithAuth(const string16& username,
const string16& password,
- net::CompletionCallback* callback) {
- return net::ERR_FAILED;
- }
+ net::CompletionCallback* callback);
- virtual bool IsReadyToRestartForAuth() {
- return false;
- }
+ virtual bool IsReadyToRestartForAuth();
virtual int Read(net::IOBuffer* buf, int buf_len,
- net::CompletionCallback* callback) {
- int data_len = static_cast<int>(data_.size());
- int num = std::min(buf_len, data_len - data_cursor_);
- if (num) {
- memcpy(buf->data(), data_.data() + data_cursor_, num);
- data_cursor_ += num;
- }
- if (test_mode_ & TEST_MODE_SYNC_NET_READ)
- return num;
-
- CallbackLater(callback, num);
- return net::ERR_IO_PENDING;
- }
+ net::CompletionCallback* callback);
- virtual void StopCaching() {}
+ virtual void StopCaching();
- virtual const net::HttpResponseInfo* GetResponseInfo() const {
- return &response_;
- }
+ virtual const net::HttpResponseInfo* GetResponseInfo() const;
- virtual net::LoadState GetLoadState() const {
- if (data_cursor_)
- return net::LOAD_STATE_READING_RESPONSE;
- return net::LOAD_STATE_IDLE;
- }
+ virtual net::LoadState GetLoadState() const;
- virtual uint64 GetUploadProgress() const {
- return 0;
- }
+ virtual uint64 GetUploadProgress() const;
private:
- void CallbackLater(net::CompletionCallback* callback, int result) {
- MessageLoop::current()->PostTask(FROM_HERE, task_factory_.NewRunnableMethod(
- &MockNetworkTransaction::RunCallback, callback, result));
- }
- void RunCallback(net::CompletionCallback* callback, int result) {
- callback->Run(result);
- }
+ void CallbackLater(net::CompletionCallback* callback, int result);
+ void RunCallback(net::CompletionCallback* callback, int result);
ScopedRunnableMethodFactory<MockNetworkTransaction> task_factory_;
net::HttpResponseInfo response_;
@@ -321,32 +195,21 @@ class MockNetworkTransaction : public net::HttpTransaction {
class MockNetworkLayer : public net::HttpTransactionFactory {
public:
- MockNetworkLayer() : transaction_count_(0) {
- }
-
- virtual int CreateTransaction(scoped_ptr<net::HttpTransaction>* trans) {
- transaction_count_++;
- trans->reset(new MockNetworkTransaction());
- return net::OK;
- }
-
- virtual net::HttpCache* GetCache() {
- return NULL;
- }
-
- virtual net::HttpNetworkSession* GetSession() {
- return NULL;
- }
-
- virtual void Suspend(bool suspend) {}
+ MockNetworkLayer();
+ virtual ~MockNetworkLayer();
int transaction_count() const { return transaction_count_; }
+ // net::HttpTransactionFactory:
+ virtual int CreateTransaction(scoped_ptr<net::HttpTransaction>* trans);
+ virtual net::HttpCache* GetCache();
+ virtual net::HttpNetworkSession* GetSession();
+ virtual void Suspend(bool suspend);
+
private:
int transaction_count_;
};
-
//-----------------------------------------------------------------------------
// helpers
diff --git a/net/http/mock_allow_url_security_manager.cc b/net/http/mock_allow_url_security_manager.cc
new file mode 100644
index 0000000..e8b2c4f
--- /dev/null
+++ b/net/http/mock_allow_url_security_manager.cc
@@ -0,0 +1,22 @@
+// 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/http/mock_allow_url_security_manager.h"
+
+namespace net {
+
+MockAllowURLSecurityManager::MockAllowURLSecurityManager() {}
+
+MockAllowURLSecurityManager::~MockAllowURLSecurityManager() {}
+
+bool MockAllowURLSecurityManager::CanUseDefaultCredentials(
+ const GURL& auth_origin) const {
+ return true;
+}
+
+bool MockAllowURLSecurityManager::CanDelegate(const GURL& auth_origin) const {
+ return true;
+}
+
+} // namespace net
diff --git a/net/http/mock_allow_url_security_manager.h b/net/http/mock_allow_url_security_manager.h
new file mode 100644
index 0000000..32f572e
--- /dev/null
+++ b/net/http/mock_allow_url_security_manager.h
@@ -0,0 +1,29 @@
+// 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.
+
+#ifndef NET_HTTP_MOCK_ALLOW_URL_SECURITY_MANAGER_H_
+#define NET_HTTP_MOCK_ALLOW_URL_SECURITY_MANAGER_H_
+#pragma once
+
+#include "net/http/url_security_manager.h"
+
+namespace net {
+
+// An URLSecurityManager which is very permissive and which should only be used
+// in unit testing.
+class MockAllowURLSecurityManager : public URLSecurityManager {
+ public:
+ MockAllowURLSecurityManager();
+ virtual ~MockAllowURLSecurityManager();
+
+ virtual bool CanUseDefaultCredentials(const GURL& auth_origin) const;
+ virtual bool CanDelegate(const GURL& auth_origin) const;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MockAllowURLSecurityManager);
+};
+
+} // namespace net
+
+#endif // NET_HTTP_MOCK_ALLOW_URL_SECURITY_MANAGER_H_
diff --git a/net/http/url_security_manager.h b/net/http/url_security_manager.h
index c6a5ec9..119d6bd 100644
--- a/net/http/url_security_manager.h
+++ b/net/http/url_security_manager.h
@@ -74,25 +74,6 @@ class URLSecurityManagerWhitelist : public URLSecurityManager {
DISALLOW_COPY_AND_ASSIGN(URLSecurityManagerWhitelist);
};
-#if defined(UNIT_TEST)
-// An URLSecurityManager which is very permissive.
-class URLSecurityManagerAllow : public URLSecurityManager {
- public:
- URLSecurityManagerAllow() {}
- virtual ~URLSecurityManagerAllow() {}
-
- virtual bool CanUseDefaultCredentials(const GURL& auth_origin) const {
- return true;
- }
- virtual bool CanDelegate(const GURL& auth_origin) const {
- return true;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(URLSecurityManagerAllow);
-};
-#endif // defined(UNIT_TEST)
-
} // namespace net
#endif // NET_HTTP_URL_SECURITY_MANAGER_H_