src/net/socket/tcp_socket_unittest.cc
TEST_F(TCPSocketTest, AcceptIPv6) {
  bool initialized = false;
  ASSERT_NO_FATAL_FAILURE(SetUpListenIPv6(&initialized));
  if (!initialized)
    return;

  TestCompletionCallback connect_callback;
  TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
                                    nullptr, NetLogSource());
  int connect_result = connecting_socket.Connect(connect_callback.callback());

  TestCompletionCallback accept_callback;
  std::unique_ptr<TCPSocket> accepted_socket;
  IPEndPoint accepted_address;
  int result = socket_.Accept(&accepted_socket, &accepted_address,
                              accept_callback.callback());
  ASSERT_THAT(accept_callback.GetResult(result), IsOk());

  EXPECT_TRUE(accepted_socket.get());

  // Both sockets should be on the loopback network interface.
  EXPECT_EQ(accepted_address.address(), local_address_.address());

  EXPECT_THAT(connect_callback.GetResult(connect_result), IsOk());
}
// Test listening and accepting with a socket bound to an IPv6 address.
Test listening and accepting with a socket bound to an IPv6 address.
Test listening and accepting with a socket bound to an IPv6 address .
TEST_F(TCPSocketTest, AcceptIPv6) {
  bool initialized = false;
  ASSERT_NO_FATAL_FAILURE(SetUpListenIPv6(&initialized));
  if (!initialized)
    return;
  TestCompletionCallback connect_callback;
  TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
                                    nullptr, NetLogSource());
  int connect_result = connecting_socket.Connect(connect_callback.callback());
  TestCompletionCallback accept_callback;
  std::unique_ptr<TCPSocket> accepted_socket;
  IPEndPoint accepted_address;
  int result = socket_.Accept(&accepted_socket, &accepted_address,
                              accept_callback.callback());
  ASSERT_THAT(accept_callback.GetResult(result), IsOk());
  EXPECT_TRUE(accepted_socket.get());
  EXPECT_EQ(accepted_address.address(), local_address_.address());
  EXPECT_THAT(connect_callback.GetResult(connect_result), IsOk());
}
TEST_F ( TCPSocketTest , AcceptIPv6 ) { bool initialized = false ; ASSERT_NO_FATAL_FAILURE ( SetUpListenIPv6 ( & initialized ) ) ; if ( ! initialized ) return ; TestCompletionCallback connect_callback ; TCPClientSocket connecting_socket ( local_address_list ( ) , nullptr , nullptr , nullptr , NetLogSource ( ) ) ; int connect_result = connecting_socket . Connect ( connect_callback . callback ( ) ) ; TestCompletionCallback accept_callback ; std :: unique_ptr < TCPSocket > accepted_socket ; IPEndPoint accepted_address ; int result = socket_ . Accept ( & accepted_socket , & accepted_address , accept_callback . callback ( ) ) ; ASSERT_THAT ( accept_callback . GetResult ( result ) , IsOk ( ) ) ; EXPECT_TRUE ( accepted_socket . get ( ) ) ; EXPECT_EQ ( accepted_address . address ( ) , local_address_ . address ( ) ) ; EXPECT_THAT ( connect_callback . GetResult ( connect_result ) , IsOk ( ) ) ; }
Test listening and accepting with a socket bound to an IPv6 address.
Test listening and accepting with a socket bound to an IPv6 address .
// Both sockets should be on the loopback network interface.