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

Unified Diff: chrome/browser/net/connection_tester_unittest.cc

Issue 5961005: Create a URLRequestContext for PAC fetching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 10 years 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
« no previous file with comments | « chrome/browser/net/connection_tester.cc ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/connection_tester_unittest.cc
diff --git a/chrome/browser/net/connection_tester_unittest.cc b/chrome/browser/net/connection_tester_unittest.cc
index 409c676ea01c36e6a2f8fafb323c0f468cc003ee..0ee05d20875427286471b16bfeebe95635dfc924 100644
--- a/chrome/browser/net/connection_tester_unittest.cc
+++ b/chrome/browser/net/connection_tester_unittest.cc
@@ -4,10 +4,21 @@
#include "chrome/browser/net/connection_tester.h"
-#include "chrome/browser/io_thread.h"
+#include "chrome/browser/browser_thread.h"
#include "chrome/test/testing_pref_service.h"
+#include "net/base/cert_verifier.h"
+#include "net/base/cookie_monster.h"
+#include "net/base/dnsrr_resolver.h"
#include "net/base/mock_host_resolver.h"
+#include "net/base/ssl_config_service_defaults.h"
+#include "net/ftp/ftp_network_layer.h"
+#include "net/http/http_auth_handler_factory.h"
+#include "net/http/http_network_layer.h"
+#include "net/proxy/proxy_config_service_fixed.h"
+#include "net/socket/client_socket_factory.h"
+#include "net/spdy/spdy_session_pool.h"
#include "net/test/test_server.h"
+#include "net/url_request/url_request_context.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -76,30 +87,63 @@ class ConnectionTesterTest : public PlatformTest {
ConnectionTesterTest()
: test_server_(net::TestServer::TYPE_HTTP,
FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))),
+ client_socket_factory_(net::ClientSocketFactory::GetDefaultFactory()),
+ proxy_script_fetcher_context_(new URLRequestContext),
message_loop_(MessageLoop::TYPE_IO),
- pref_service(new TestingPrefService()),
- io_thread_(pref_service.get(), NULL) {
- scoped_refptr<net::RuleBasedHostResolverProc> catchall_resolver(
- new net::RuleBasedHostResolverProc(NULL));
-
- catchall_resolver->AddRule("*", "127.0.0.1");
-
- scoped_host_resolver_proc_.Init(catchall_resolver);
+ io_thread_(BrowserThread::IO, &message_loop_) {
+ InitializeRequestContext();
}
protected:
- net::ScopedDefaultHostResolverProc scoped_host_resolver_proc_;
net::TestServer test_server_;
ConnectionTesterDelegate test_delegate_;
+ net::ClientSocketFactory* const client_socket_factory_;
+ net::MockHostResolver host_resolver_;
+ net::CertVerifier cert_verifier_;
+ net::DnsRRResolver dnsrr_resolver_;
+ scoped_refptr<net::ProxyService> proxy_service_;
+ scoped_refptr<net::SSLConfigService> ssl_config_service_;
+ scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_;
+ net::HttpAuthHandlerRegistryFactory http_auth_handler_factory_;
+ scoped_refptr<URLRequestContext> proxy_script_fetcher_context_;
+
+ private:
+ void InitializeRequestContext() {
+ proxy_script_fetcher_context_->set_host_resolver(&host_resolver_);
+ proxy_script_fetcher_context_->set_cert_verifier(&cert_verifier_);
+ proxy_script_fetcher_context_->set_dnsrr_resolver(&dnsrr_resolver_);
+ proxy_script_fetcher_context_->set_http_auth_handler_factory(
+ &http_auth_handler_factory_);
+ proxy_service_ = net::ProxyService::CreateDirect();
+ proxy_script_fetcher_context_->set_proxy_service(proxy_service_);
+ ssl_config_service_ = net::SSLConfigService::CreateSystemSSLConfigService();
+ proxy_script_fetcher_context_->set_http_transaction_factory(
+ new net::HttpNetworkLayer(
+ client_socket_factory_,
+ &host_resolver_,
+ &cert_verifier_,
+ &dnsrr_resolver_,
+ NULL /* DNS cert provenance checker */,
+ NULL /* ssl_host_info_factory */,
+ proxy_service_.get(),
+ ssl_config_service_,
+ new net::SpdySessionPool(ssl_config_service_),
+ &http_auth_handler_factory_,
+ NULL /* NetworkDelegate */,
+ NULL /* NetLog */));
+ // In-memory cookie store.
+ proxy_script_fetcher_context_->set_cookie_store(
+ new net::CookieMonster(NULL, NULL));
+ }
+
MessageLoop message_loop_;
- scoped_ptr<PrefService> pref_service;
- IOThread io_thread_; // Needed for creating ProxyScriptFetchers.
+ BrowserThread io_thread_;
};
TEST_F(ConnectionTesterTest, RunAllTests) {
ASSERT_TRUE(test_server_.Start());
- ConnectionTester tester(&test_delegate_, &io_thread_);
+ ConnectionTester tester(&test_delegate_, proxy_script_fetcher_context_);
// Start the test suite on URL "echoall".
// TODO(eroman): Is this URL right?
@@ -124,7 +168,7 @@ TEST_F(ConnectionTesterTest, DeleteWhileInProgress) {
ASSERT_TRUE(test_server_.Start());
scoped_ptr<ConnectionTester> tester(
- new ConnectionTester(&test_delegate_, &io_thread_));
+ new ConnectionTester(&test_delegate_, proxy_script_fetcher_context_));
// Start the test suite on URL "echoall".
// TODO(eroman): Is this URL right?
@@ -153,4 +197,3 @@ TEST_F(ConnectionTesterTest, DeleteWhileInProgress) {
}
} // namespace
-
« no previous file with comments | « chrome/browser/net/connection_tester.cc ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698