src/net/quic/quic_network_transaction_unittest.cc
// Verify that when multiple alternatives are broken,
// ALTERNATE_PROTOCOL_USAGE_BROKEN is only logged once.
// This is a regression test for crbug/1024613.
Verify that when multiple alternatives are broken,
ALTERNATE_PROTOCOL_USAGE_BROKEN is only logged once.
This is a regression test for crbug/1024613.
Verify that when multiple alternatives are broken ALTERNATE_PROTOCOL_USAGE_BROKEN is only logged once . This is a regression test for crbug / 1024613 .
TEST_P(QuicNetworkTransactionTest, BrokenAlternativeOnlyRecordedOnce) {
  base::HistogramTester histogram_tester;
  MockRead http_reads[] = {
      MockRead("HTTP/1.1 200 OK\r\n"), MockRead(kQuicAlternativeServiceHeader),
      MockRead("hello world"),
      MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ),
      MockRead(ASYNC, OK)};
  StaticSocketDataProvider http_data(http_reads, base::span<MockWrite>());
  socket_factory_.AddSocketDataProvider(&http_data);
  AddCertificate(&ssl_data_);
  socket_factory_.AddSSLSocketDataProvider(&ssl_data_);
  GURL origin1 = request_.url;  
  scoped_refptr<X509Certificate> cert(
      ImportCertFromFile(GetTestCertsDirectory(), "wildcard.pem"));
  ASSERT_TRUE(cert->VerifyNameMatch("mail.example.org"));
  ProofVerifyDetailsChromium verify_details;
  verify_details.cert_verify_result.verified_cert = cert;
  verify_details.cert_verify_result.is_issued_by_known_root = true;
  crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details);
  CreateSession();
  AlternativeService local_alternative(kProtoQUIC, "mail.example.org", 443);
  base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
  AlternativeServiceInfoVector alternative_services;
  alternative_services.push_back(
      AlternativeServiceInfo::CreateQuicAlternativeServiceInfo(
          local_alternative, expiration,
          context_.params()->supported_versions));
  alternative_services.push_back(
      AlternativeServiceInfo::CreateQuicAlternativeServiceInfo(
          local_alternative, expiration,
          context_.params()->supported_versions));
  http_server_properties_->SetAlternativeServices(url::SchemeHostPort(origin1),
                                                  NetworkIsolationKey(),
                                                  alternative_services);
  http_server_properties_->MarkAlternativeServiceBroken(local_alternative,
                                                        NetworkIsolationKey());
  SendRequestAndExpectHttpResponse("hello world");
  histogram_tester.ExpectBucketCount("Net.AlternateProtocolUsage",
                                     ALTERNATE_PROTOCOL_USAGE_BROKEN, 1);
}
TEST_P ( QuicNetworkTransactionTest , BrokenAlternativeOnlyRecordedOnce ) { base :: HistogramTester histogram_tester ; MockRead http_reads [ ] = { MockRead ( " \r \n " ) , MockRead ( kQuicAlternativeServiceHeader ) , MockRead ( " " ) , MockRead ( SYNCHRONOUS , ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ ) , MockRead ( ASYNC , OK ) } ; StaticSocketDataProvider http_data ( http_reads , base :: span < MockWrite > ( ) ) ; socket_factory_ . AddSocketDataProvider ( & http_data ) ; AddCertificate ( & ssl_data_ ) ; socket_factory_ . AddSSLSocketDataProvider ( & ssl_data_ ) ; GURL origin1 = request_ . url ; scoped_refptr < X509Certificate > cert ( ImportCertFromFile ( GetTestCertsDirectory ( ) , " " ) ) ; ASSERT_TRUE ( cert -> VerifyNameMatch ( " " ) ) ; ProofVerifyDetailsChromium verify_details ; verify_details . cert_verify_result . verified_cert = cert ; verify_details . cert_verify_result . is_issued_by_known_root = true ; crypto_client_stream_factory_ . AddProofVerifyDetails ( & verify_details ) ; CreateSession ( ) ; AlternativeService local_alternative ( kProtoQUIC , " " , 443 ) ; base :: Time expiration = base :: Time :: Now ( ) + base :: TimeDelta :: FromDays ( 1 ) ; AlternativeServiceInfoVector alternative_services ; alternative_services . push_back ( AlternativeServiceInfo :: CreateQuicAlternativeServiceInfo ( local_alternative , expiration , context_ . params ( ) -> supported_versions ) ) ; alternative_services . push_back ( AlternativeServiceInfo :: CreateQuicAlternativeServiceInfo ( local_alternative , expiration , context_ . params ( ) -> supported_versions ) ) ; http_server_properties_ -> SetAlternativeServices ( url :: SchemeHostPort ( origin1 ) , NetworkIsolationKey ( ) , alternative_services ) ; http_server_properties_ -> MarkAlternativeServiceBroken ( local_alternative , NetworkIsolationKey ( ) ) ; SendRequestAndExpectHttpResponse ( " " ) ; histogram_tester . ExpectBucketCount ( " " , ALTERNATE_PROTOCOL_USAGE_BROKEN , 1 ) ; }
Verify that when multiple alternatives are broken,
ALTERNATE_PROTOCOL_USAGE_BROKEN is only logged once.
Verify that when multiple alternatives are broken ALTERNATE_PROTOCOL_USAGE_BROKEN is only logged once .
// mail.example.org // Set up alternative service for |origin1|.