| Index: net/socket/tcp_socket_unittest.cc
|
| diff --git a/net/socket/tcp_socket_unittest.cc b/net/socket/tcp_socket_unittest.cc
|
| index d9da13c660cc5f7910de744af5932ff324f575d0..27b8169736448d8412a6db6fefc92d0991a6bcc7 100644
|
| --- a/net/socket/tcp_socket_unittest.cc
|
| +++ b/net/socket/tcp_socket_unittest.cc
|
| @@ -11,6 +11,7 @@
|
| #include <string>
|
| #include <vector>
|
|
|
| +#include "base/files/file_util.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/time/time.h"
|
| #include "net/base/address_list.h"
|
| @@ -21,6 +22,9 @@
|
| #include "net/base/test_completion_callback.h"
|
| #include "net/log/net_log_source.h"
|
| #include "net/socket/socket_performance_watcher.h"
|
| +#if defined(OS_POSIX)
|
| +#include "net/socket/socket_posix.h"
|
| +#endif
|
| #include "net/socket/tcp_client_socket.h"
|
| #include "net/test/gtest_util.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| @@ -226,6 +230,26 @@ TEST_F(TCPSocketTest, AcceptAsync) {
|
| TestAcceptAsync();
|
| }
|
|
|
| +#if defined(OS_POSIX)
|
| +// Test AdoptConnectedSocket() for TCPSocketPosix
|
| +TEST_F(TCPSocketTest, AdoptConnectedSocket) {
|
| + SocketDescriptor socket_fd =
|
| + CreatePlatformSocket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
| + ASSERT_GE(socket_fd, 0);
|
| + ASSERT_TRUE(base::SetNonBlocking(socket_fd));
|
| + IPEndPoint address(IPAddress::IPv4Localhost(), 0);
|
| + SockaddrStorage storage;
|
| + ASSERT_TRUE(address.ToSockAddr(storage.addr, &storage.addr_len));
|
| + ASSERT_GE(bind(socket_fd, storage.addr, storage.addr_len), 0);
|
| + ASSERT_GE(listen(socket_fd, kListenBacklog), 0);
|
| +
|
| + ASSERT_THAT(socket_.AdoptConnectedSocket(socket_fd, IPEndPoint()), IsOk());
|
| + ASSERT_THAT(socket_.GetLocalAddress(&local_address_), IsOk());
|
| +
|
| + TestAcceptAsync();
|
| +}
|
| +#endif
|
| +
|
| #if defined(OS_WIN)
|
| // Test Accept() for AdoptListenSocket.
|
| TEST_F(TCPSocketTest, AcceptForAdoptedListenSocket) {
|
|
|