src/net/socket/transport_connect_job_unittest.cc
// Test the case of the IPv6 address stalling, and falling back to the IPv4
// socket which finishes first.
Test the case of the IPv6 address stalling, and falling back to the IPv4
socket which finishes first.
Test the case of the IPv6 address stalling and falling back to the IPv4 socket which finishes first .
TEST_F(TransportConnectJobTest, IPv6FallbackSocketIPv4FinishesFirst) {
  MockTransportClientSocketFactory::ClientSocketType case_types[] = {
      MockTransportClientSocketFactory::MOCK_STALLED_FAILING_CLIENT_SOCKET,
      MockTransportClientSocketFactory::MOCK_PENDING_CLIENT_SOCKET};
  client_socket_factory_.set_client_socket_types(case_types, 2);
  host_resolver_.rules()->AddIPLiteralRule(kHostName, "2:abcd::3:4:ff,2.2.2.2",
                                           std::string());
  TestConnectJobDelegate test_delegate;
  TransportConnectJob transport_connect_job(
      DEFAULT_PRIORITY, SocketTag(), &common_connect_job_params_,
      DefaultParams(), &test_delegate, nullptr );
  test_delegate.StartJobExpectingResult(&transport_connect_job, OK,
                                        false );
  IPEndPoint endpoint;
  test_delegate.socket()->GetLocalAddress(&endpoint);
  EXPECT_TRUE(endpoint.address().IsIPv4());
  ConnectionAttempts attempts;
  test_delegate.socket()->GetConnectionAttempts(&attempts);
  ASSERT_EQ(1u, attempts.size());
  EXPECT_THAT(attempts[0].result, test::IsError(ERR_CONNECTION_FAILED));
  EXPECT_TRUE(attempts[0].endpoint.address().IsIPv6());
  EXPECT_EQ(2, client_socket_factory_.allocation_count());
}
TEST_F ( TransportConnectJobTest , IPv6FallbackSocketIPv4FinishesFirst ) { MockTransportClientSocketFactory :: ClientSocketType case_types [ ] = { MockTransportClientSocketFactory :: MOCK_STALLED_FAILING_CLIENT_SOCKET , MockTransportClientSocketFactory :: MOCK_PENDING_CLIENT_SOCKET } ; client_socket_factory_ . set_client_socket_types ( case_types , 2 ) ; host_resolver_ . rules ( ) -> AddIPLiteralRule ( kHostName , " " , std :: string ( ) ) ; TestConnectJobDelegate test_delegate ; TransportConnectJob transport_connect_job ( DEFAULT_PRIORITY , SocketTag ( ) , & common_connect_job_params_ , DefaultParams ( ) , & test_delegate , nullptr ) ; test_delegate . StartJobExpectingResult ( & transport_connect_job , OK , false ) ; IPEndPoint endpoint ; test_delegate . socket ( ) -> GetLocalAddress ( & endpoint ) ; EXPECT_TRUE ( endpoint . address ( ) . IsIPv4 ( ) ) ; ConnectionAttempts attempts ; test_delegate . socket ( ) -> GetConnectionAttempts ( & attempts ) ; ASSERT_EQ ( 1u , attempts . size ( ) ) ; EXPECT_THAT ( attempts [ 0 ] . result , test :: IsError ( ERR_CONNECTION_FAILED ) ) ; EXPECT_TRUE ( attempts [ 0 ] . endpoint . address ( ) . IsIPv6 ( ) ) ; EXPECT_EQ ( 2 , client_socket_factory_ . allocation_count ( ) ) ; }
Test the case of the IPv6 address stalling, and falling back to the IPv4
socket which finishes first.
Test the case of the IPv6 address stalling and falling back to the IPv4 socket which finishes first .
// This is the IPv6 socket. It stalls, but presents one failed connection // attempt on GetConnectionAttempts. // This is the IPv4 socket. // Resolve an AddressList with a IPv6 address first and then a IPv4 address. /* net_log */ /* expect_sync_result */ // Check that the failed connection attempt on the main socket is collected.