| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 CHECK_EQ(rv, OK); | 95 CHECK_EQ(rv, OK); |
| 96 sock_.reset(new TCPClientSocket(addr, &net_log_)); | 96 sock_.reset(new TCPClientSocket(addr, &net_log_)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 TEST_F(TCPClientSocketTest, Connect) { | 99 TEST_F(TCPClientSocketTest, Connect) { |
| 100 TestCompletionCallback callback; | 100 TestCompletionCallback callback; |
| 101 EXPECT_FALSE(sock_->IsConnected()); | 101 EXPECT_FALSE(sock_->IsConnected()); |
| 102 | 102 |
| 103 int rv = sock_->Connect(&callback); | 103 int rv = sock_->Connect(&callback); |
| 104 EXPECT_TRUE(net::LogContainsBeginEvent( | 104 EXPECT_TRUE(net::LogContainsBeginEvent( |
| 105 net_log_.entries(), 0, net::NetLog::TYPE_TCP_CONNECT)); | 105 net_log_.entries(), 0, net::NetLog::TYPE_SOCKET_ALIVE)); |
| 106 EXPECT_TRUE(net::LogContainsBeginEvent( |
| 107 net_log_.entries(), 1, net::NetLog::TYPE_TCP_CONNECT)); |
| 106 if (rv != OK) { | 108 if (rv != OK) { |
| 107 ASSERT_EQ(rv, ERR_IO_PENDING); | 109 ASSERT_EQ(rv, ERR_IO_PENDING); |
| 108 EXPECT_FALSE(net::LogContainsEndEvent( | |
| 109 net_log_.entries(), -1, net::NetLog::TYPE_TCP_CONNECT)); | |
| 110 | |
| 111 rv = callback.WaitForResult(); | 110 rv = callback.WaitForResult(); |
| 112 EXPECT_EQ(rv, OK); | 111 EXPECT_EQ(rv, OK); |
| 113 } | 112 } |
| 114 | 113 |
| 115 EXPECT_TRUE(sock_->IsConnected()); | 114 EXPECT_TRUE(sock_->IsConnected()); |
| 116 EXPECT_TRUE(net::LogContainsEndEvent( | 115 EXPECT_TRUE(net::LogContainsEndEvent( |
| 117 net_log_.entries(), -1, net::NetLog::TYPE_TCP_CONNECT)); | 116 net_log_.entries(), -1, net::NetLog::TYPE_TCP_CONNECT)); |
| 118 | 117 |
| 119 sock_->Disconnect(); | 118 sock_->Disconnect(); |
| 120 EXPECT_FALSE(sock_->IsConnected()); | 119 EXPECT_FALSE(sock_->IsConnected()); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 // Close the server socket, so there will at least be a 0-byte read. | 338 // Close the server socket, so there will at least be a 0-byte read. |
| 340 CloseServerSocket(); | 339 CloseServerSocket(); |
| 341 | 340 |
| 342 rv = callback.WaitForResult(); | 341 rv = callback.WaitForResult(); |
| 343 EXPECT_GE(rv, 0); | 342 EXPECT_GE(rv, 0); |
| 344 } | 343 } |
| 345 | 344 |
| 346 } // namespace | 345 } // namespace |
| 347 | 346 |
| 348 } // namespace net | 347 } // namespace net |
| OLD | NEW |