| 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" |
| 11 #include "net/base/listen_socket.h" | 11 #include "net/base/listen_socket.h" |
| 12 #include "net/base/net_log.h" | 12 #include "net/base/net_log.h" |
| 13 #include "net/base/net_log_unittest.h" | 13 #include "net/base/net_log_unittest.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "net/base/test_completion_callback.h" | 15 #include "net/base/test_completion_callback.h" |
| 16 #include "net/base/winsock_init.h" | 16 #include "net/base/winsock_init.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "testing/platform_test.h" | 18 #include "testing/platform_test.h" |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 const char kServerReply[] = "HTTP/1.1 404 Not Found"; | 24 const char kServerReply[] = "HTTP/1.1 404 Not Found"; |
| 25 | 25 |
| 26 class TCPClientSocketTest | 26 class TCPClientSocketTest |
| 27 : public PlatformTest, public ListenSocket::ListenSocketDelegate { | 27 : public PlatformTest, public ListenSocket::ListenSocketDelegate { |
| 28 public: | 28 public: |
| 29 TCPClientSocketTest() : net_log_(CapturingNetLog::kUnbounded) { | 29 TCPClientSocketTest() |
| 30 : listen_port_(0), |
| 31 net_log_(CapturingNetLog::kUnbounded) { |
| 30 } | 32 } |
| 31 | 33 |
| 32 // Implement ListenSocketDelegate methods | 34 // Implement ListenSocketDelegate methods |
| 33 virtual void DidAccept(ListenSocket* server, ListenSocket* connection) { | 35 virtual void DidAccept(ListenSocket* server, ListenSocket* connection) { |
| 34 connected_sock_ = connection; | 36 connected_sock_ = connection; |
| 35 } | 37 } |
| 36 virtual void DidRead(ListenSocket*, const char* str, int len) { | 38 virtual void DidRead(ListenSocket*, const char* str, int len) { |
| 37 // TODO(dkegel): this might not be long enough to tickle some bugs. | 39 // TODO(dkegel): this might not be long enough to tickle some bugs. |
| 38 connected_sock_->Send(kServerReply, | 40 connected_sock_->Send(kServerReply, |
| 39 arraysize(kServerReply) - 1, | 41 arraysize(kServerReply) - 1, |
| (...skipping 299 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. | 341 // Close the server socket, so there will at least be a 0-byte read. |
| 340 CloseServerSocket(); | 342 CloseServerSocket(); |
| 341 | 343 |
| 342 rv = callback.WaitForResult(); | 344 rv = callback.WaitForResult(); |
| 343 EXPECT_GE(rv, 0); | 345 EXPECT_GE(rv, 0); |
| 344 } | 346 } |
| 345 | 347 |
| 346 } // namespace | 348 } // namespace |
| 347 | 349 |
| 348 } // namespace net | 350 } // namespace net |
| OLD | NEW |