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

Unified Diff: net/http/http_network_layer_unittest.cc

Issue 6402002: Simplify HttpCache/HttpNetworkLayer/HttpNetworkSession interaction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits. 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
« no previous file with comments | « net/http/http_network_layer.cc ('k') | net/proxy/proxy_script_fetcher_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_network_layer_unittest.cc
diff --git a/net/http/http_network_layer_unittest.cc b/net/http/http_network_layer_unittest.cc
index 2720c104739a5cd75b05b69cc562d6e90ff4ab04..f76ffbb3618601b7deef1f5b18547882948f5cb4 100644
--- a/net/http/http_network_layer_unittest.cc
+++ b/net/http/http_network_layer_unittest.cc
@@ -7,9 +7,11 @@
#include "net/base/net_log.h"
#include "net/base/ssl_config_service_defaults.h"
#include "net/http/http_network_layer.h"
+#include "net/http/http_network_session.h"
#include "net/http/http_transaction_unittest.h"
#include "net/proxy/proxy_service.h"
#include "net/socket/socket_test_util.h"
+#include "net/spdy/spdy_session_pool.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -21,115 +23,127 @@ class HttpNetworkLayerTest : public PlatformTest {
};
TEST_F(HttpNetworkLayerTest, CreateAndDestroy) {
+ MockClientSocketFactory mock_socket_factory;
MockHostResolver host_resolver;
- net::CertVerifier cert_verifier;
- net::HttpNetworkLayer factory(
- NULL,
- &host_resolver,
- &cert_verifier,
- NULL /* dnsrr_resolver */,
- NULL /* dns_cert_checker */,
- NULL /* ssl_host_info_factory */,
- net::ProxyService::CreateDirect(),
- new net::SSLConfigServiceDefaults,
- NULL,
- NULL,
- NULL);
-
- scoped_ptr<net::HttpTransaction> trans;
+ CertVerifier cert_verifier;
+ scoped_refptr<HttpNetworkSession> network_session(
+ new HttpNetworkSession(
+ &host_resolver,
+ &cert_verifier,
+ NULL /* dnsrr_resolver */,
+ NULL /* dns_cert_checker */,
+ NULL /* ssl_host_info_factory */,
+ ProxyService::CreateDirect(),
+ &mock_socket_factory,
+ new SSLConfigServiceDefaults,
+ new SpdySessionPool(NULL),
+ NULL,
+ NULL,
+ NULL));
+
+ HttpNetworkLayer factory(network_session);
+
+ scoped_ptr<HttpTransaction> trans;
int rv = factory.CreateTransaction(&trans);
- EXPECT_EQ(net::OK, rv);
+ EXPECT_EQ(OK, rv);
EXPECT_TRUE(trans.get() != NULL);
}
TEST_F(HttpNetworkLayerTest, Suspend) {
+ MockClientSocketFactory mock_socket_factory;
MockHostResolver host_resolver;
- net::CertVerifier cert_verifier;
- net::HttpNetworkLayer factory(
- NULL,
- &host_resolver,
- &cert_verifier,
- NULL /* dnsrr_resolver */,
- NULL /* dns_cert_checker */,
- NULL /* ssl_host_info_factory */,
- net::ProxyService::CreateDirect(),
- new net::SSLConfigServiceDefaults,
- NULL,
- NULL,
- NULL);
-
- scoped_ptr<net::HttpTransaction> trans;
+ CertVerifier cert_verifier;
+ scoped_refptr<HttpNetworkSession> network_session(
+ new HttpNetworkSession(
+ &host_resolver,
+ &cert_verifier,
+ NULL /* dnsrr_resolver */,
+ NULL /* dns_cert_checker */,
+ NULL /* ssl_host_info_factory */,
+ ProxyService::CreateDirect(),
+ &mock_socket_factory,
+ new SSLConfigServiceDefaults,
+ new SpdySessionPool(NULL),
+ NULL,
+ NULL,
+ NULL));
+ HttpNetworkLayer factory(network_session);
+
+ scoped_ptr<HttpTransaction> trans;
int rv = factory.CreateTransaction(&trans);
- EXPECT_EQ(net::OK, rv);
+ EXPECT_EQ(OK, rv);
trans.reset();
factory.Suspend(true);
rv = factory.CreateTransaction(&trans);
- EXPECT_EQ(net::ERR_NETWORK_IO_SUSPENDED, rv);
+ EXPECT_EQ(ERR_NETWORK_IO_SUSPENDED, rv);
ASSERT_TRUE(trans == NULL);
factory.Suspend(false);
rv = factory.CreateTransaction(&trans);
- EXPECT_EQ(net::OK, rv);
+ EXPECT_EQ(OK, rv);
}
TEST_F(HttpNetworkLayerTest, GET) {
- net::MockClientSocketFactory mock_socket_factory;
- net::MockRead data_reads[] = {
- net::MockRead("HTTP/1.0 200 OK\r\n\r\n"),
- net::MockRead("hello world"),
- net::MockRead(false, net::OK),
+ MockClientSocketFactory mock_socket_factory;
+ MockRead data_reads[] = {
+ MockRead("HTTP/1.0 200 OK\r\n\r\n"),
+ MockRead("hello world"),
+ MockRead(false, OK),
};
- net::MockWrite data_writes[] = {
- net::MockWrite("GET / HTTP/1.1\r\n"
+ MockWrite data_writes[] = {
+ MockWrite("GET / HTTP/1.1\r\n"
"Host: www.google.com\r\n"
"Connection: keep-alive\r\n"
"User-Agent: Foo/1.0\r\n\r\n"),
};
- net::StaticSocketDataProvider data(data_reads, arraysize(data_reads),
+ StaticSocketDataProvider data(data_reads, arraysize(data_reads),
data_writes, arraysize(data_writes));
mock_socket_factory.AddSocketDataProvider(&data);
MockHostResolver host_resolver;
- net::CertVerifier cert_verifier;
- net::HttpNetworkLayer factory(
- &mock_socket_factory,
- &host_resolver,
- &cert_verifier,
- NULL /* dnsrr_resolver */,
- NULL /* dns_cert_checker */,
- NULL /* ssl_host_info_factory */,
- net::ProxyService::CreateDirect(),
- new net::SSLConfigServiceDefaults,
- NULL,
- NULL,
- NULL);
+ CertVerifier cert_verifier;
+ scoped_refptr<HttpNetworkSession> network_session(
+ new HttpNetworkSession(
+ &host_resolver,
+ &cert_verifier,
+ NULL /* dnsrr_resolver */,
+ NULL /* dns_cert_checker */,
+ NULL /* ssl_host_info_factory */,
+ ProxyService::CreateDirect(),
+ &mock_socket_factory,
+ new SSLConfigServiceDefaults,
+ new SpdySessionPool(NULL),
+ NULL,
+ NULL,
+ NULL));
+ HttpNetworkLayer factory(network_session);
TestCompletionCallback callback;
- scoped_ptr<net::HttpTransaction> trans;
+ scoped_ptr<HttpTransaction> trans;
int rv = factory.CreateTransaction(&trans);
- EXPECT_EQ(net::OK, rv);
+ EXPECT_EQ(OK, rv);
- net::HttpRequestInfo request_info;
+ HttpRequestInfo request_info;
request_info.url = GURL("http://www.google.com/");
request_info.method = "GET";
- request_info.extra_headers.SetHeader(net::HttpRequestHeaders::kUserAgent,
+ request_info.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent,
"Foo/1.0");
- request_info.load_flags = net::LOAD_NORMAL;
+ request_info.load_flags = LOAD_NORMAL;
- rv = trans->Start(&request_info, &callback, net::BoundNetLog());
- if (rv == net::ERR_IO_PENDING)
+ rv = trans->Start(&request_info, &callback, BoundNetLog());
+ if (rv == ERR_IO_PENDING)
rv = callback.WaitForResult();
- ASSERT_EQ(net::OK, rv);
+ ASSERT_EQ(OK, rv);
std::string contents;
rv = ReadTransaction(trans.get(), &contents);
- EXPECT_EQ(net::OK, rv);
+ EXPECT_EQ(OK, rv);
EXPECT_EQ("hello world", contents);
}
« no previous file with comments | « net/http/http_network_layer.cc ('k') | net/proxy/proxy_script_fetcher_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698