OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file contains some tests for TCPClientSocket. | 5 // This file contains some tests for TCPClientSocket. |
6 // transport_client_socket_unittest.cc contans some other tests that | 6 // transport_client_socket_unittest.cc contans some other tests that |
7 // are common for TCP and other types of sockets. | 7 // are common for TCP and other types of sockets. |
8 | 8 |
9 #include "net/socket/tcp_client_socket.h" | 9 #include "net/socket/tcp_client_socket.h" |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 TCPClientSocket socket( | 34 TCPClientSocket socket( |
35 AddressList::CreateFromIPAddress(server_address.address(), | 35 AddressList::CreateFromIPAddress(server_address.address(), |
36 server_address.port()), | 36 server_address.port()), |
37 NULL, NetLog::Source()); | 37 NULL, NetLog::Source()); |
38 | 38 |
39 EXPECT_EQ(OK, socket.Bind(IPEndPoint(lo_address, 0))); | 39 EXPECT_EQ(OK, socket.Bind(IPEndPoint(lo_address, 0))); |
40 | 40 |
41 TestOldCompletionCallback connect_callback; | 41 TestOldCompletionCallback connect_callback; |
42 EXPECT_EQ(ERR_IO_PENDING, socket.Connect(&connect_callback)); | 42 EXPECT_EQ(ERR_IO_PENDING, socket.Connect(&connect_callback)); |
43 | 43 |
44 TestOldCompletionCallback accept_callback; | 44 TestCompletionCallback accept_callback; |
45 scoped_ptr<StreamSocket> accepted_socket; | 45 scoped_ptr<StreamSocket> accepted_socket; |
46 int result = server.Accept(&accepted_socket, &accept_callback); | 46 int result = server.Accept(&accepted_socket, accept_callback.callback()); |
47 if (result == ERR_IO_PENDING) | 47 if (result == ERR_IO_PENDING) |
48 result = accept_callback.WaitForResult(); | 48 result = accept_callback.WaitForResult(); |
49 ASSERT_EQ(OK, result); | 49 ASSERT_EQ(OK, result); |
50 | 50 |
51 EXPECT_EQ(OK, connect_callback.WaitForResult()); | 51 EXPECT_EQ(OK, connect_callback.WaitForResult()); |
52 } | 52 } |
53 | 53 |
54 // Try to bind socket to the loopback interface and connect to an | 54 // Try to bind socket to the loopback interface and connect to an |
55 // external address, verify that connection fails. | 55 // external address, verify that connection fails. |
56 TEST(TCPClientSocketTest, BindLoopbackToExternal) { | 56 TEST(TCPClientSocketTest, BindLoopbackToExternal) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 int result = socket.Connect(&connect_callback); | 101 int result = socket.Connect(&connect_callback); |
102 if (result == ERR_IO_PENDING) | 102 if (result == ERR_IO_PENDING) |
103 result = connect_callback.WaitForResult(); | 103 result = connect_callback.WaitForResult(); |
104 | 104 |
105 EXPECT_NE(OK, result); | 105 EXPECT_NE(OK, result); |
106 } | 106 } |
107 | 107 |
108 } // namespace | 108 } // namespace |
109 | 109 |
110 } // namespace net | 110 } // namespace net |
OLD | NEW |