summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 15:12:05 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 15:12:05 +0000
commit5c288bc4e2f4671fd835424f180937e37303e2c7 (patch)
tree0356782130f22e18117395e3ca8d6c556200308e /net/http
parent0f16f9d6e6e6f0ad70bbae44f578dcb0cb41341e (diff)
downloadchromium_src-5c288bc4e2f4671fd835424f180937e37303e2c7.zip
chromium_src-5c288bc4e2f4671fd835424f180937e37303e2c7.tar.gz
chromium_src-5c288bc4e2f4671fd835424f180937e37303e2c7.tar.bz2
Minor cleanup of unit tests for spdy_session_ool.
Fixed the comments from Wan-Teh in CL http://codereview.chromium.org/7349023/ BUG=89094 R=wtc TEST=net unit tests. Review URL: http://codereview.chromium.org/7471056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94094 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_network_transaction_unittest.cc67
1 files changed, 36 insertions, 31 deletions
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 2e76b4b..2a942dc 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -8704,35 +8704,32 @@ TEST_F(HttpNetworkTransactionTest, ClientAuthCertCache_Proxy_Fail) {
}
}
-void IPPoolingPreloadHostCache(MockCachingHostResolver* host_resolver,
- SpdySessionPoolPeer* pool_peer) {
- const int kTestPort = 443;
- struct TestHosts {
- std::string name;
- std::string iplist;
- } test_hosts[] = {
- { "www.google.com", "127.0.0.1"},
- };
-
- // Preload cache entries into HostCache.
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_hosts); i++) {
- host_resolver->rules()->AddIPLiteralRule(test_hosts[i].name,
- test_hosts[i].iplist, "");
-
- AddressList addresses;
- // This test requires that the HostResolver cache be populated. Normal
- // code would have done this already, but we do it manually.
- HostResolver::RequestInfo info(HostPortPair(test_hosts[i].name, kTestPort));
- host_resolver->Resolve(
- info, &addresses, NULL, NULL, BoundNetLog());
-
- // Setup a HostPortProxyPair
- HostPortProxyPair pair = HostPortProxyPair(
- HostPortPair(test_hosts[i].name, kTestPort), ProxyServer::Direct());
-
- const addrinfo* address = addresses.head();
- pool_peer->AddAlias(address, pair);
- }
+void IPPoolingAddAlias(MockCachingHostResolver* host_resolver,
+ SpdySessionPoolPeer* pool_peer,
+ std::string host,
+ int port,
+ std::string iplist) {
+ // Create a host resolver dependency that returns address |iplist| for
+ // resolutions of |host|.
+ host_resolver->rules()->AddIPLiteralRule(host, iplist, "");
+
+ // Setup a HostPortProxyPair.
+ HostPortPair host_port_pair(host, port);
+ HostPortProxyPair pair = HostPortProxyPair(host_port_pair,
+ ProxyServer::Direct());
+
+ // Resolve the host and port.
+ AddressList addresses;
+ HostResolver::RequestInfo info(host_port_pair);
+ host_resolver->Resolve(info, &addresses, NULL, NULL, BoundNetLog());
+
+ // Add the first address as an alias. It would have been better to call
+ // MockClientSocket::GetPeerAddress but that returns 192.0.2.33 whereas
+ // MockHostResolver returns 127.0.0.1 (MockHostResolverBase::Reset). So we use
+ // the first address (127.0.0.1) returned by MockHostResolver as an alias for
+ // the |pair|.
+ const addrinfo* address = addresses.head();
+ pool_peer->AddAlias(address, pair);
}
TEST_F(HttpNetworkTransactionTest, UseIPConnectionPooling) {
@@ -8813,7 +8810,11 @@ TEST_F(HttpNetworkTransactionTest, UseIPConnectionPooling) {
AddressList ignored;
host_resolver.Resolve(resolve_info, &ignored, NULL, NULL, BoundNetLog());
- IPPoolingPreloadHostCache(&host_resolver, &pool_peer);
+ // MockHostResolver returns 127.0.0.1, port 443 for https://www.google.com/
+ // and https://www.gmail.com/. Add 127.0.0.1 as alias for host_port_pair:
+ // (www.google.com, 443).
+ IPPoolingAddAlias(&host_resolver, &pool_peer, "www.google.com", 443,
+ "127.0.0.1");
HttpRequestInfo request2;
request2.method = "GET";
@@ -8967,7 +8968,11 @@ TEST_F(HttpNetworkTransactionTest,
request2.load_flags = 0;
HttpNetworkTransaction trans2(session);
- IPPoolingPreloadHostCache(host_resolver.GetMockHostResolver(), &pool_peer);
+ // MockHostResolver returns 127.0.0.1, port 443 for https://www.google.com/
+ // and https://www.gmail.com/. Add 127.0.0.1 as alias for host_port_pair:
+ // (www.google.com, 443).
+ IPPoolingAddAlias(host_resolver.GetMockHostResolver(), &pool_peer,
+ "www.google.com", 443, "127.0.0.1");
rv = trans2.Start(&request2, &callback, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);