| 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 ca6091f22972dd1bae9c1471cc3a2ab46f5cc46a..948cfcf8921fb732d987e98996f85a30ccc07b90 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) {
|
| @@ -688,6 +689,66 @@ 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
|
| + // connection to the the server, in this test we require confirmation
|
| + // 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),
|
| + DEFAULT_PRIORITY);
|
| + 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.
|
|
|
|
|