net/socket/tcp_socket_unittest.cc
// Test listening and accepting with a socket bound to an IPv4 address.
Test listening and accepting with a socket bound to an IPv4 address.
Test listening and accepting with a socket bound to an IPv4 address .
TEST_F(TCPSocketTest, Accept) {
  ASSERT_NO_FATAL_FAILURE(SetUpListenIPv4());
  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 , Accept ) { ASSERT_NO_FATAL_FAILURE ( SetUpListenIPv4 ( ) ) ; 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 IPv4 address.
Test listening and accepting with a socket bound to an IPv4 address .
// TODO(yzshen): Switch to use TCPSocket when it supports client socket // operations. // Both sockets should be on the loopback network interface.