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

Side by Side Diff: net/socket/transport_client_socket_unittest.cc

Issue 10408067: [net] Switch TestURLRequestContext to use MockCachingHostResolver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to trunk. Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_script_fetcher_impl_unittest.cc ('k') | net/socket_stream/socket_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/socket/tcp_client_socket.h" 5 #include "net/socket/tcp_client_socket.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "net/base/address_list.h" 10 #include "net/base/address_list.h"
11 #include "net/base/host_resolver.h"
12 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
12 #include "net/base/mock_host_resolver.h"
13 #include "net/base/net_log.h" 13 #include "net/base/net_log.h"
14 #include "net/base/net_log_unittest.h" 14 #include "net/base/net_log_unittest.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "net/base/tcp_listen_socket.h" 16 #include "net/base/tcp_listen_socket.h"
17 #include "net/base/test_completion_callback.h" 17 #include "net/base/test_completion_callback.h"
18 #include "net/base/winsock_init.h" 18 #include "net/base/winsock_init.h"
19 #include "net/socket/client_socket_factory.h" 19 #include "net/socket/client_socket_factory.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 #include "testing/platform_test.h" 21 #include "testing/platform_test.h"
22 22
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 for (port = kMinPort; port < kMaxPort; port++) { 115 for (port = kMinPort; port < kMaxPort; port++) {
116 sock = TCPListenSocket::CreateAndListen("127.0.0.1", port, this); 116 sock = TCPListenSocket::CreateAndListen("127.0.0.1", port, this);
117 if (sock.get()) 117 if (sock.get())
118 break; 118 break;
119 } 119 }
120 ASSERT_TRUE(sock != NULL); 120 ASSERT_TRUE(sock != NULL);
121 listen_sock_ = sock; 121 listen_sock_ = sock;
122 listen_port_ = port; 122 listen_port_ = port;
123 123
124 AddressList addr; 124 AddressList addr;
125 scoped_ptr<HostResolver> resolver( 125 // MockHostResolver resolves everything to 127.0.0.1.
126 CreateSystemHostResolver(HostResolver::kDefaultParallelism, 126 scoped_ptr<HostResolver> resolver(new MockHostResolver());
127 HostResolver::kDefaultRetryAttempts,
128 NULL));
129 HostResolver::RequestInfo info(HostPortPair("localhost", listen_port_)); 127 HostResolver::RequestInfo info(HostPortPair("localhost", listen_port_));
130 TestCompletionCallback callback; 128 TestCompletionCallback callback;
131 int rv = resolver->Resolve(info, &addr, callback.callback(), NULL, 129 int rv = resolver->Resolve(info, &addr, callback.callback(), NULL,
132 BoundNetLog()); 130 BoundNetLog());
133 CHECK_EQ(ERR_IO_PENDING, rv); 131 CHECK_EQ(ERR_IO_PENDING, rv);
134 rv = callback.WaitForResult(); 132 rv = callback.WaitForResult();
135 CHECK_EQ(rv, OK); 133 CHECK_EQ(rv, OK);
136 sock_.reset( 134 sock_.reset(
137 socket_factory_->CreateTransportClientSocket(addr, 135 socket_factory_->CreateTransportClientSocket(addr,
138 &net_log_, 136 &net_log_,
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 440
443 // It's possible the read is blocked because it's already read all the data. 441 // It's possible the read is blocked because it's already read all the data.
444 // Close the server socket, so there will at least be a 0-byte read. 442 // Close the server socket, so there will at least be a 0-byte read.
445 CloseServerSocket(); 443 CloseServerSocket();
446 444
447 rv = callback.WaitForResult(); 445 rv = callback.WaitForResult();
448 EXPECT_GE(rv, 0); 446 EXPECT_GE(rv, 0);
449 } 447 }
450 448
451 } // namespace net 449 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_script_fetcher_impl_unittest.cc ('k') | net/socket_stream/socket_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698