Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Unified Diff: net/quic/quic_network_transaction_unittest.cc

Issue 17247006: Fix QUIC alternate protocol behavior so that that main job does not wait (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« net/quic/quic_client_session.cc ('K') | « net/quic/quic_client_session.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0edf99bbbff8b1283efea4346fd4f676e984393f..63a5a4096353ca2f274588c0c1ebd9631423f34a 100644
--- a/net/quic/quic_network_transaction_unittest.cc
+++ b/net/quic/quic_network_transaction_unittest.cc
@@ -211,10 +211,14 @@ class QuicNetworkTransactionTest : public PlatformTest {
}
void CreateSession() {
+ CreateSessionWithFactory(&socket_factory_);
+ }
+
+ void CreateSessionWithFactory(ClientSocketFactory* socket_factory) {
params_.enable_quic = true;
params_.quic_clock = clock_;
params_.quic_random = &random_generator_;
- params_.client_socket_factory = &socket_factory_;
+ params_.client_socket_factory = socket_factory;
params_.quic_crypto_client_stream_factory = &crypto_client_stream_factory_;
params_.host_resolver = &host_resolver_;
params_.cert_verifier = &cert_verifier_;
@@ -487,6 +491,65 @@ TEST_F(QuicNetworkTransactionTest, UseAlternateProtocolForQuic) {
SendRequestAndExpectQuicResponse("hello!");
}
+TEST_F(QuicNetworkTransactionTest, HungAlternateProtocol) {
+ HttpStreamFactory::EnableNpnSpdy(); // Enables QUIC too.
+ crypto_client_stream_factory_.set_handshake_mode(
+ MockCryptoClientStream::COLD_START);
+
+ MockWrite http_writes[] = {
+ MockWrite(SYNCHRONOUS, 0, "GET / HTTP/1.1\r\n"),
+ MockWrite(SYNCHRONOUS, 1, "Host: www.google.com\r\n"),
+ MockWrite(SYNCHRONOUS, 2, "Connection: keep-alive\r\n\r\n")
+ };
+
+ MockRead http_reads[] = {
+ MockRead(SYNCHRONOUS, 3, "HTTP/1.1 200 OK\r\n"),
+ MockRead(SYNCHRONOUS, 4, kQuicAlternateProtocolHttpHeader),
+ MockRead(SYNCHRONOUS, 5, "hello world"),
+ MockRead(SYNCHRONOUS, OK, 6)
+ };
+
+ DeterministicMockClientSocketFactory socket_factory;
+
+ DeterministicSocketData http_data(http_reads, arraysize(http_reads),
+ http_writes, arraysize(http_writes));
+ socket_factory.AddSocketDataProvider(&http_data);
+
+ // The QUIC transaction will not be allowed to complete.
+ MockWrite quic_writes[] = {
+ MockWrite(ASYNC, ERR_IO_PENDING, 0)
+ };
+ MockRead quic_reads[] = {
+ MockRead(ASYNC, ERR_IO_PENDING, 1),
+ };
+ DeterministicSocketData quic_data(quic_reads, arraysize(quic_reads),
+ quic_writes, arraysize(quic_writes));
+ socket_factory.AddSocketDataProvider(&quic_data);
+
+ // The HTTP transaction will complete.
+ DeterministicSocketData http_data2(http_reads, arraysize(http_reads),
+ http_writes, arraysize(http_writes));
+ socket_factory.AddSocketDataProvider(&http_data2);
+
+ CreateSessionWithFactory(&socket_factory);
+
+ // Run the first request.
+ http_data.StopAfter(arraysize(http_reads) + arraysize(http_writes));
+ SendRequestAndExpectHttpResponse("hello world");
+ ASSERT_TRUE(http_data.at_read_eof());
+ ASSERT_TRUE(http_data.at_write_eof());
+
+ // Now run the second request in which the QUIC socket hangs,
+ // and verify the the transaction continues over HTTP.
+ http_data2.StopAfter(arraysize(http_reads) + arraysize(http_writes));
+ SendRequestAndExpectHttpResponse("hello world");
+
+ ASSERT_TRUE(http_data2.at_read_eof());
+ ASSERT_TRUE(http_data2.at_write_eof());
+ ASSERT_TRUE(!quic_data.at_read_eof());
+ ASSERT_TRUE(!quic_data.at_write_eof());
+}
+
TEST_F(QuicNetworkTransactionTest, DontUseAlternateProtocolForQuicHttps) {
HttpStreamFactory::EnableNpnSpdy(); // Enables QUIC too.
« net/quic/quic_client_session.cc ('K') | « net/quic/quic_client_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698