| Index: net/spdy/spdy_session_spdy3_unittest.cc
|
| diff --git a/net/spdy/spdy_session_spdy3_unittest.cc b/net/spdy/spdy_session_spdy3_unittest.cc
|
| index c6c9fc5195dd42b251fae1dfc59172b85f609534..a9e6008aafa8781bd4e02f716eb15960761e7406 100644
|
| --- a/net/spdy/spdy_session_spdy3_unittest.cc
|
| +++ b/net/spdy/spdy_session_spdy3_unittest.cc
|
| @@ -1192,4 +1192,106 @@ TEST_F(SpdySessionSpdy3Test, UpdateStreamsSendWindowSize) {
|
| spdy_stream2 = NULL;
|
| }
|
|
|
| +TEST_F(SpdySessionSpdy3Test, OutOfOrderSynStreams) {
|
| + // Construct the request.
|
| + MockConnect connect_data(SYNCHRONOUS, OK);
|
| + scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 3, HIGHEST));
|
| + scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 5, LOWEST));
|
| + MockWrite writes[] = {
|
| + CreateMockWrite(*req1, 1),
|
| + CreateMockWrite(*req2, 2),
|
| + };
|
| +
|
| + scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 3));
|
| + scoped_ptr<SpdyFrame> body1(ConstructSpdyBodyFrame(3, true));
|
| + scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 5));
|
| + scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(5, true));
|
| + MockRead reads[] = {
|
| + CreateMockRead(*resp1, 3),
|
| + CreateMockRead(*body1, 4),
|
| + CreateMockRead(*resp2, 5),
|
| + CreateMockRead(*body2, 6),
|
| + MockRead(ASYNC, 0, 7) // EOF
|
| + };
|
| +
|
| + SpdySessionDependencies session_deps;
|
| + session_deps.host_resolver->set_synchronous_mode(true);
|
| +
|
| + StaticSocketDataProvider data(reads, arraysize(reads),
|
| + writes, arraysize(writes));
|
| + data.set_connect_data(connect_data);
|
| + session_deps.socket_factory->AddSocketDataProvider(&data);
|
| +
|
| + SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
|
| + session_deps.socket_factory->AddSSLSocketDataProvider(&ssl);
|
| +
|
| + scoped_refptr<HttpNetworkSession> http_session(
|
| + SpdySessionDependencies::SpdyCreateSession(&session_deps));
|
| +
|
| + const std::string kTestHost("www.foo.com");
|
| + const int kTestPort = 80;
|
| + HostPortPair test_host_port_pair(kTestHost, kTestPort);
|
| + HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct());
|
| +
|
| + SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool());
|
| +
|
| + // Create a session.
|
| + EXPECT_FALSE(spdy_session_pool->HasSession(pair));
|
| + scoped_refptr<SpdySession> session =
|
| + spdy_session_pool->Get(pair, BoundNetLog());
|
| + ASSERT_TRUE(spdy_session_pool->HasSession(pair));
|
| +
|
| + scoped_refptr<TransportSocketParams> transport_params(
|
| + new TransportSocketParams(test_host_port_pair,
|
| + MEDIUM,
|
| + false,
|
| + false));
|
| + scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
|
| + EXPECT_EQ(OK, connection->Init(test_host_port_pair.ToString(),
|
| + transport_params, MEDIUM, CompletionCallback(),
|
| + http_session->GetTransportSocketPool(
|
| + HttpNetworkSession::NORMAL_SOCKET_POOL),
|
| + BoundNetLog()));
|
| + EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK));
|
| +
|
| + scoped_refptr<SpdyStream> spdy_stream1;
|
| + TestCompletionCallback callback1;
|
| + GURL url1("http://www.google.com");
|
| + EXPECT_EQ(OK, session->CreateStream(url1, LOWEST, &spdy_stream1,
|
| + BoundNetLog(), callback1.callback()));
|
| + EXPECT_EQ(1u, spdy_stream1->stream_id());
|
| +
|
| + scoped_refptr<SpdyStream> spdy_stream2;
|
| + TestCompletionCallback callback2;
|
| + GURL url2("http://www.google.com");
|
| + EXPECT_EQ(OK, session->CreateStream(url2, HIGHEST, &spdy_stream2,
|
| + BoundNetLog(), callback2.callback()));
|
| + EXPECT_EQ(3u, spdy_stream2->stream_id());
|
| +
|
| + linked_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
|
| + (*headers)[":method"] = "GET";
|
| + (*headers)[":scheme"] = url1.scheme();
|
| + (*headers)[":host"] = url1.host();
|
| + (*headers)[":path"] = url1.path();
|
| + (*headers)[":version"] = "HTTP/1.1";
|
| + spdy_stream1->set_spdy_headers(headers);
|
| + EXPECT_TRUE(spdy_stream1->HasUrl());
|
| +
|
| + spdy_stream2->set_spdy_headers(headers);
|
| + EXPECT_TRUE(spdy_stream2->HasUrl());
|
| +
|
| + spdy_stream1->SendRequest(false);
|
| + spdy_stream2->SendRequest(false);
|
| + MessageLoop::current()->RunAllPending();
|
| +
|
| + EXPECT_EQ(5u, spdy_stream1->stream_id());
|
| + EXPECT_EQ(3u, spdy_stream2->stream_id());
|
| +
|
| + spdy_stream1->Cancel();
|
| + spdy_stream1 = NULL;
|
| +
|
| + spdy_stream2->Cancel();
|
| + spdy_stream2 = NULL;
|
| +}
|
| +
|
| } // namespace net
|
|
|