OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "net/base/address_list.h" | 8 #include "net/base/address_list.h" |
9 #include "net/base/host_resolver.h" | 9 #include "net/base/host_resolver.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 81 matching lines...) Loading... |
92 HostResolver::RequestInfo info("localhost", listen_port_); | 92 HostResolver::RequestInfo info("localhost", listen_port_); |
93 int rv = resolver->Resolve(info, &addr, NULL, NULL, NULL); | 93 int rv = resolver->Resolve(info, &addr, NULL, NULL, NULL); |
94 CHECK(rv == OK); | 94 CHECK(rv == OK); |
95 sock_.reset(new TCPClientSocket(addr)); | 95 sock_.reset(new TCPClientSocket(addr)); |
96 } | 96 } |
97 | 97 |
98 TEST_F(TCPClientSocketTest, Connect) { | 98 TEST_F(TCPClientSocketTest, Connect) { |
99 TestCompletionCallback callback; | 99 TestCompletionCallback callback; |
100 EXPECT_FALSE(sock_->IsConnected()); | 100 EXPECT_FALSE(sock_->IsConnected()); |
101 | 101 |
102 scoped_refptr<LoadLog> log(new LoadLog); | 102 scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded)); |
103 int rv = sock_->Connect(&callback, log); | 103 int rv = sock_->Connect(&callback, log); |
104 EXPECT_TRUE(net::LogContains( | 104 EXPECT_TRUE(net::LogContains( |
105 *log, 0, net::LoadLog::TYPE_TCP_CONNECT, net::LoadLog::PHASE_BEGIN)); | 105 *log, 0, net::LoadLog::TYPE_TCP_CONNECT, net::LoadLog::PHASE_BEGIN)); |
106 if (rv != OK) { | 106 if (rv != OK) { |
107 ASSERT_EQ(rv, ERR_IO_PENDING); | 107 ASSERT_EQ(rv, ERR_IO_PENDING); |
108 EXPECT_FALSE(net::LogContains( | 108 EXPECT_FALSE(net::LogContains( |
109 *log, -1, net::LoadLog::TYPE_TCP_CONNECT, net::LoadLog::PHASE_END)); | 109 *log, -1, net::LoadLog::TYPE_TCP_CONNECT, net::LoadLog::PHASE_END)); |
110 | 110 |
111 rv = callback.WaitForResult(); | 111 rv = callback.WaitForResult(); |
112 EXPECT_EQ(rv, OK); | 112 EXPECT_EQ(rv, OK); |
(...skipping 226 matching lines...) Loading... |
339 // Close the server socket, so there will at least be a 0-byte read. | 339 // Close the server socket, so there will at least be a 0-byte read. |
340 CloseServerSocket(); | 340 CloseServerSocket(); |
341 | 341 |
342 rv = callback.WaitForResult(); | 342 rv = callback.WaitForResult(); |
343 EXPECT_GE(rv, 0); | 343 EXPECT_GE(rv, 0); |
344 } | 344 } |
345 | 345 |
346 } // namespace | 346 } // namespace |
347 | 347 |
348 } // namespace net | 348 } // namespace net |
OLD | NEW |