| Index: net/quic/quic_network_transaction_unittest.cc
|
| diff --git a/net/quic/quic_network_transaction_unittest.cc b/net/quic/quic_network_transaction_unittest.cc
|
| index 79408a8a3c3af6f5e4cfeee6dc9cbcb2e1a503cf..4465226b0688687f3ff3d40a58787007d9b27379 100644
|
| --- a/net/quic/quic_network_transaction_unittest.cc
|
| +++ b/net/quic/quic_network_transaction_unittest.cc
|
| @@ -134,8 +134,6 @@ class QuicNetworkTransactionTest
|
| PlatformTest::TearDown();
|
| NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
|
| base::MessageLoop::current()->RunUntilIdle();
|
| - HttpStreamFactory::set_use_alternate_protocols(false);
|
| - HttpStreamFactory::SetNextProtos(std::vector<NextProto>());
|
| }
|
|
|
| scoped_ptr<QuicEncryptedPacket> ConstructConnectionClosePacket(
|
| @@ -191,10 +189,16 @@ class QuicNetworkTransactionTest
|
| }
|
|
|
| void CreateSession() {
|
| - CreateSessionWithFactory(&socket_factory_);
|
| + CreateSessionWithFactory(&socket_factory_, false);
|
| }
|
|
|
| - void CreateSessionWithFactory(ClientSocketFactory* socket_factory) {
|
| + void CreateSessionWithNextProtos() {
|
| + CreateSessionWithFactory(&socket_factory_, true);
|
| + }
|
| +
|
| + // If |use_next_protos| is true, enables SPDY and QUIC.
|
| + void CreateSessionWithFactory(ClientSocketFactory* socket_factory,
|
| + bool use_next_protos) {
|
| params_.enable_quic = true;
|
| params_.quic_clock = clock_;
|
| params_.quic_random = &random_generator_;
|
| @@ -209,6 +213,11 @@ class QuicNetworkTransactionTest
|
| params_.http_server_properties = http_server_properties.GetWeakPtr();
|
| params_.quic_supported_versions = SupportedVersions(GetParam());
|
|
|
| + if (use_next_protos) {
|
| + params_.use_alternate_protocols = true;
|
| + params_.next_protos = NextProtosSpdy3();
|
| + }
|
| +
|
| session_ = new HttpNetworkSession(params_);
|
| session_->quic_stream_factory()->set_require_confirmation(false);
|
| }
|
| @@ -448,8 +457,6 @@ TEST_P(QuicNetworkTransactionTest, DoNotForceQuicForHttps) {
|
| }
|
|
|
| TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolForQuic) {
|
| - HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too.
|
| -
|
| MockRead http_reads[] = {
|
| MockRead("HTTP/1.1 200 OK\r\n"),
|
| MockRead(kQuicAlternateProtocolHttpHeader),
|
| @@ -480,7 +487,7 @@ TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolForQuic) {
|
| // the alternate-protocol job will "win".
|
| AddHangingNonAlternateProtocolSocketData();
|
|
|
| - CreateSession();
|
| + CreateSessionWithNextProtos();
|
|
|
| SendRequestAndExpectHttpResponse("hello world");
|
| SendRequestAndExpectQuicResponse("hello!");
|
| @@ -490,7 +497,6 @@ TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolForQuicForHttps) {
|
| params_.origin_to_force_quic_on =
|
| HostPortPair::FromString("www.google.com:443");
|
| params_.enable_quic_https = true;
|
| - HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too.
|
|
|
| MockRead http_reads[] = {
|
| MockRead("HTTP/1.1 200 OK\r\n"),
|
| @@ -522,14 +528,13 @@ TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolForQuicForHttps) {
|
| // the alternate-protocol job will "win".
|
| AddHangingNonAlternateProtocolSocketData();
|
|
|
| - CreateSession();
|
| + CreateSessionWithNextProtos();
|
|
|
| // TODO(rtenneti): Test QUIC over HTTPS, GetSSLInfo().
|
| SendRequestAndExpectHttpResponse("hello world");
|
| }
|
|
|
| TEST_P(QuicNetworkTransactionTest, HungAlternateProtocol) {
|
| - HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too.
|
| crypto_client_stream_factory_.set_handshake_mode(
|
| MockCryptoClientStream::COLD_START);
|
|
|
| @@ -568,7 +573,7 @@ TEST_P(QuicNetworkTransactionTest, HungAlternateProtocol) {
|
| http_writes, arraysize(http_writes));
|
| socket_factory.AddSocketDataProvider(&http_data2);
|
|
|
| - CreateSessionWithFactory(&socket_factory);
|
| + CreateSessionWithFactory(&socket_factory, true);
|
|
|
| // Run the first request.
|
| http_data.StopAfter(arraysize(http_reads) + arraysize(http_writes));
|
| @@ -588,8 +593,6 @@ TEST_P(QuicNetworkTransactionTest, HungAlternateProtocol) {
|
| }
|
|
|
| TEST_P(QuicNetworkTransactionTest, ZeroRTTWithHttpRace) {
|
| - HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too.
|
| -
|
| MockQuicData mock_quic_data;
|
| mock_quic_data.AddWrite(
|
| ConstructRequestHeadersPacket(1, kStreamId5, true, true,
|
| @@ -608,14 +611,12 @@ TEST_P(QuicNetworkTransactionTest, ZeroRTTWithHttpRace) {
|
| // the alternate-protocol job will "win".
|
| AddHangingNonAlternateProtocolSocketData();
|
|
|
| - CreateSession();
|
| + CreateSessionWithNextProtos();
|
| AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
|
| SendRequestAndExpectQuicResponse("hello!");
|
| }
|
|
|
| TEST_P(QuicNetworkTransactionTest, ZeroRTTWithNoHttpRace) {
|
| - HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too.
|
| -
|
| MockQuicData mock_quic_data;
|
| mock_quic_data.AddWrite(
|
| ConstructRequestHeadersPacket(1, kStreamId5, true, true,
|
| @@ -643,7 +644,7 @@ TEST_P(QuicNetworkTransactionTest, ZeroRTTWithNoHttpRace) {
|
| NULL,
|
| net_log_.bound());
|
|
|
| - CreateSession();
|
| + CreateSessionWithNextProtos();
|
| AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
|
| SendRequestAndExpectQuicResponse("hello!");
|
| }
|
| @@ -651,7 +652,6 @@ TEST_P(QuicNetworkTransactionTest, ZeroRTTWithNoHttpRace) {
|
| TEST_P(QuicNetworkTransactionTest, ZeroRTTWithProxy) {
|
| proxy_service_.reset(
|
| ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
|
| - HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too.
|
|
|
| // Since we are using a proxy, the QUIC job will not succeed.
|
| MockWrite http_writes[] = {
|
| @@ -685,14 +685,12 @@ TEST_P(QuicNetworkTransactionTest, ZeroRTTWithProxy) {
|
| NULL,
|
| net_log_.bound());
|
|
|
| - CreateSession();
|
| + CreateSessionWithNextProtos();
|
| AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
|
| SendRequestAndExpectHttpResponse("hello world");
|
| }
|
|
|
| TEST_P(QuicNetworkTransactionTest, ZeroRTTWithConfirmationRequired) {
|
| - HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too.
|
| -
|
| MockQuicData mock_quic_data;
|
| mock_quic_data.AddWrite(
|
| ConstructRequestHeadersPacket(1, kStreamId5, true, true,
|
| @@ -722,7 +720,7 @@ TEST_P(QuicNetworkTransactionTest, ZeroRTTWithConfirmationRequired) {
|
| host_resolver_.Resolve(info, DEFAULT_PRIORITY, &address,
|
| CompletionCallback(), NULL, net_log_.bound());
|
|
|
| - CreateSession();
|
| + CreateSessionWithNextProtos();
|
| session_->quic_stream_factory()->set_require_confirmation(true);
|
| AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
|
|
|
| @@ -738,8 +736,6 @@ TEST_P(QuicNetworkTransactionTest, ZeroRTTWithConfirmationRequired) {
|
| }
|
|
|
| TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocol) {
|
| - HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too.
|
| -
|
| // Alternate-protocol job
|
| scoped_ptr<QuicEncryptedPacket> close(ConstructConnectionClosePacket(1));
|
| MockRead quic_reads[] = {
|
| @@ -762,15 +758,13 @@ TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocol) {
|
| NULL, 0);
|
| socket_factory_.AddSocketDataProvider(&http_data);
|
|
|
| - CreateSession();
|
| + CreateSessionWithNextProtos();
|
| AddQuicAlternateProtocolMapping(MockCryptoClientStream::COLD_START);
|
| SendRequestAndExpectHttpResponse("hello from http");
|
| ExpectBrokenAlternateProtocolMapping();
|
| }
|
|
|
| TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocolReadError) {
|
| - HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too.
|
| -
|
| // Alternate-protocol job
|
| MockRead quic_reads[] = {
|
| MockRead(ASYNC, ERR_SOCKET_NOT_CONNECTED),
|
| @@ -791,7 +785,7 @@ TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocolReadError) {
|
| NULL, 0);
|
| socket_factory_.AddSocketDataProvider(&http_data);
|
|
|
| - CreateSession();
|
| + CreateSessionWithNextProtos();
|
|
|
| AddQuicAlternateProtocolMapping(MockCryptoClientStream::COLD_START);
|
| SendRequestAndExpectHttpResponse("hello from http");
|
| @@ -799,8 +793,6 @@ TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocolReadError) {
|
| }
|
|
|
| TEST_P(QuicNetworkTransactionTest, FailedZeroRttBrokenAlternateProtocol) {
|
| - HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too.
|
| -
|
| // Alternate-protocol job
|
| MockRead quic_reads[] = {
|
| MockRead(ASYNC, ERR_SOCKET_NOT_CONNECTED),
|
| @@ -823,7 +815,7 @@ TEST_P(QuicNetworkTransactionTest, FailedZeroRttBrokenAlternateProtocol) {
|
| NULL, 0);
|
| socket_factory_.AddSocketDataProvider(&http_data);
|
|
|
| - CreateSession();
|
| + CreateSessionWithNextProtos();
|
|
|
| AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
|
|
|
| @@ -836,8 +828,6 @@ TEST_P(QuicNetworkTransactionTest, FailedZeroRttBrokenAlternateProtocol) {
|
| }
|
|
|
| TEST_P(QuicNetworkTransactionTest, NoBrokenAlternateProtocolOnConnectFailure) {
|
| - HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too.
|
| -
|
| // Alternate-protocol job will fail before creating a QUIC session.
|
| StaticSocketDataProvider quic_data(NULL, 0, NULL, 0);
|
| quic_data.set_connect_data(MockConnect(SYNCHRONOUS,
|
| @@ -856,15 +846,13 @@ TEST_P(QuicNetworkTransactionTest, NoBrokenAlternateProtocolOnConnectFailure) {
|
| NULL, 0);
|
| socket_factory_.AddSocketDataProvider(&http_data);
|
|
|
| - CreateSession();
|
| + CreateSessionWithNextProtos();
|
| AddQuicAlternateProtocolMapping(MockCryptoClientStream::COLD_START);
|
| SendRequestAndExpectHttpResponse("hello from http");
|
| ExpectQuicAlternateProtocolMapping();
|
| }
|
|
|
| TEST_P(QuicNetworkTransactionTest, ConnectionCloseDuringConnect) {
|
| - HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too.
|
| -
|
| MockQuicData mock_quic_data;
|
| mock_quic_data.AddRead(ConstructConnectionClosePacket(1));
|
| mock_quic_data.AddWrite(
|
| @@ -900,7 +888,7 @@ TEST_P(QuicNetworkTransactionTest, ConnectionCloseDuringConnect) {
|
| NULL,
|
| net_log_.bound());
|
|
|
| - CreateSession();
|
| + CreateSessionWithNextProtos();
|
| AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT);
|
| SendRequestAndExpectHttpResponse("hello world");
|
| }
|
|
|