Chromium Code Reviews| 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 0722b58121f16f8dfa538ded06e0587bf0ef577b..ac421ec3d312fb6d83dfb7094301b945194c2daf 100644 |
| --- a/net/quic/quic_network_transaction_unittest.cc |
| +++ b/net/quic/quic_network_transaction_unittest.cc |
| @@ -232,6 +232,7 @@ class QuicNetworkTransactionTest : public PlatformTest { |
| params_.http_server_properties = http_server_properties.GetWeakPtr(); |
| session_ = new HttpNetworkSession(params_); |
| + session_->quic_stream_factory()->set_require_confirmation(false); |
| } |
| void CheckWasQuicResponse(const scoped_ptr<HttpNetworkTransaction>& trans) { |
| @@ -687,6 +688,65 @@ TEST_F(QuicNetworkTransactionTest, ZeroRTTWithNoHttpRace) { |
| SendRequestAndExpectQuicResponse("hello!"); |
| } |
| +TEST_F(QuicNetworkTransactionTest, ZeroRTTWithConfirmationRequired) { |
| + HttpStreamFactory::EnableNpnSpdy(); // Enables QUIC too. |
| + |
| + scoped_ptr<QuicEncryptedPacket> req( |
| + ConstructDataPacket(1, 3, true, true, 0, |
| + GetRequestString("GET", "http", "/"))); |
| + scoped_ptr<QuicEncryptedPacket> ack(ConstructAckPacket(1, 0)); |
| + |
| + MockWrite quic_writes[] = { |
| + MockWrite(SYNCHRONOUS, req->data(), req->length()), |
| + MockWrite(SYNCHRONOUS, ack->data(), ack->length()), |
| + }; |
| + |
| + scoped_ptr<QuicEncryptedPacket> resp( |
| + ConstructDataPacket( |
| + 1, 3, false, true, 0, GetResponseString("200 OK", "hello!"))); |
| + MockRead quic_reads[] = { |
| + MockRead(SYNCHRONOUS, resp->data(), resp->length()), |
| + MockRead(ASYNC, OK), // EOF |
| + }; |
| + |
| + DelayedSocketData quic_data( |
| + 1, // wait for one write to finish before reading. |
| + quic_reads, arraysize(quic_reads), |
| + quic_writes, arraysize(quic_writes)); |
| + |
| + socket_factory_.AddSocketDataProvider(&quic_data); |
| + |
| + // The non-alternate protocol job needs to hang in order to guarantee that |
| + // the alternate-protocol job will "win". |
| + AddHangingNonAlternateProtocolSocketData(); |
| + |
| + // In order for a new QUIC session to be established via alternate-protocol |
| + // without racing an HTTP connection, we need the host resolution to happen |
| + // synchronously. Of course, even though QUIC *could* perform a 0-RTT |
| + // connecto the the server, in this test we require confirmation |
|
ramant (doing other things)
2013/08/19 18:39:05
nit: connecto the -> connection to
Ryan Hamilton
2013/08/19 18:51:18
Done.
|
| + // before encrypting so the HTTP job will still start. |
| + host_resolver_.set_synchronous_mode(true); |
| + host_resolver_.rules()->AddIPLiteralRule("www.google.com", "192.168.0.1", ""); |
| + HostResolver::RequestInfo info(HostPortPair("www.google.com", 80)); |
| + AddressList address; |
| + host_resolver_.Resolve(info, &address, CompletionCallback(), NULL, |
| + net_log_.bound()); |
| + |
| + CreateSession(); |
| + session_->quic_stream_factory()->set_require_confirmation(true); |
| + AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
| + |
| + scoped_ptr<HttpNetworkTransaction> trans( |
| + new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); |
| + TestCompletionCallback callback; |
| + int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); |
| + EXPECT_EQ(ERR_IO_PENDING, rv); |
| + |
| + crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( |
| + QuicSession::HANDSHAKE_CONFIRMED); |
| + EXPECT_EQ(OK, callback.WaitForResult()); |
| +} |
| + |
| TEST_F(QuicNetworkTransactionTest, BrokenAlternateProtocol) { |
| HttpStreamFactory::EnableNpnSpdy(); // Enables QUIC too. |