OLD | NEW |
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/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
13 #include "net/base/test_completion_callback.h" | 13 #include "net/base/test_completion_callback.h" |
14 #include "net/base/winsock_init.h" | 14 #include "net/base/winsock_init.h" |
15 #include "net/dns/mock_host_resolver.h" | 15 #include "net/dns/mock_host_resolver.h" |
| 16 #include "net/log/captured_net_log_entry.h" |
16 #include "net/log/net_log.h" | 17 #include "net/log/net_log.h" |
17 #include "net/log/net_log_unittest.h" | 18 #include "net/log/net_log_unittest.h" |
| 19 #include "net/log/test_net_log.h" |
18 #include "net/socket/client_socket_factory.h" | 20 #include "net/socket/client_socket_factory.h" |
19 #include "net/socket/tcp_listen_socket.h" | 21 #include "net/socket/tcp_listen_socket.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "testing/platform_test.h" | 23 #include "testing/platform_test.h" |
22 | 24 |
23 namespace net { | 25 namespace net { |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
27 const char kServerReply[] = "HTTP/1.1 404 Not Found"; | 29 const char kServerReply[] = "HTTP/1.1 404 Not Found"; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 INSTANTIATE_TEST_CASE_P(StreamSocket, | 180 INSTANTIATE_TEST_CASE_P(StreamSocket, |
179 TransportClientSocketTest, | 181 TransportClientSocketTest, |
180 ::testing::Values(TCP)); | 182 ::testing::Values(TCP)); |
181 | 183 |
182 TEST_P(TransportClientSocketTest, Connect) { | 184 TEST_P(TransportClientSocketTest, Connect) { |
183 TestCompletionCallback callback; | 185 TestCompletionCallback callback; |
184 EXPECT_FALSE(sock_->IsConnected()); | 186 EXPECT_FALSE(sock_->IsConnected()); |
185 | 187 |
186 int rv = sock_->Connect(callback.callback()); | 188 int rv = sock_->Connect(callback.callback()); |
187 | 189 |
188 TestNetLog::CapturedEntryList net_log_entries; | 190 CapturedNetLogEntry::List net_log_entries; |
189 net_log_.GetEntries(&net_log_entries); | 191 net_log_.GetEntries(&net_log_entries); |
190 EXPECT_TRUE( | 192 EXPECT_TRUE( |
191 LogContainsBeginEvent(net_log_entries, 0, NetLog::TYPE_SOCKET_ALIVE)); | 193 LogContainsBeginEvent(net_log_entries, 0, NetLog::TYPE_SOCKET_ALIVE)); |
192 EXPECT_TRUE( | 194 EXPECT_TRUE( |
193 LogContainsBeginEvent(net_log_entries, 1, NetLog::TYPE_TCP_CONNECT)); | 195 LogContainsBeginEvent(net_log_entries, 1, NetLog::TYPE_TCP_CONNECT)); |
194 if (rv != OK) { | 196 if (rv != OK) { |
195 ASSERT_EQ(rv, ERR_IO_PENDING); | 197 ASSERT_EQ(rv, ERR_IO_PENDING); |
196 rv = callback.WaitForResult(); | 198 rv = callback.WaitForResult(); |
197 EXPECT_EQ(rv, OK); | 199 EXPECT_EQ(rv, OK); |
198 } | 200 } |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 443 |
442 // It's possible the read is blocked because it's already read all the data. | 444 // It's possible the read is blocked because it's already read all the data. |
443 // Close the server socket, so there will at least be a 0-byte read. | 445 // Close the server socket, so there will at least be a 0-byte read. |
444 CloseServerSocket(); | 446 CloseServerSocket(); |
445 | 447 |
446 rv = callback.WaitForResult(); | 448 rv = callback.WaitForResult(); |
447 EXPECT_GE(rv, 0); | 449 EXPECT_GE(rv, 0); |
448 } | 450 } |
449 | 451 |
450 } // namespace net | 452 } // namespace net |
OLD | NEW |