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

Unified Diff: net/spdy/spdy_stream_spdy3_unittest.cc

Issue 15740018: [SPDY] Change SpdyStream::QueueStreamData() To SendStreamData() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 7 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
« no previous file with comments | « net/spdy/spdy_stream_spdy2_unittest.cc ('k') | net/spdy/spdy_stream_test_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_stream_spdy3_unittest.cc
diff --git a/net/spdy/spdy_stream_spdy3_unittest.cc b/net/spdy/spdy_stream_spdy3_unittest.cc
index b08dcd103b099e2deb514f07c880aa118e1c6518..db8f612e8b5de35c8f0afff40e476072a33ea1cc 100644
--- a/net/spdy/spdy_stream_spdy3_unittest.cc
+++ b/net/spdy/spdy_stream_spdy3_unittest.cc
@@ -150,7 +150,7 @@ TEST_F(SpdyStreamSpdy3Test, SendDataAfterOpen) {
EXPECT_EQ("HTTP/1.1", delegate.GetResponseHeaderValue(":version"));
EXPECT_EQ(std::string(kPostBody, kPostBodyLength),
delegate.TakeReceivedData());
- EXPECT_EQ(static_cast<int>(kPostBodyLength), delegate.data_sent());
+ EXPECT_TRUE(data.at_write_eof());
}
TEST_F(SpdyStreamSpdy3Test, SendHeaderAndDataAfterOpen) {
@@ -226,9 +226,8 @@ TEST_F(SpdyStreamSpdy3Test, SendHeaderAndDataAfterOpen) {
EXPECT_TRUE(delegate.send_headers_completed());
EXPECT_EQ("101", delegate.GetResponseHeaderValue(":status"));
- EXPECT_EQ(1, delegate.headers_sent());
EXPECT_EQ(std::string(), delegate.TakeReceivedData());
- EXPECT_EQ(6, delegate.data_sent());
+ EXPECT_TRUE(data.at_write_eof());
}
TEST_F(SpdyStreamSpdy3Test, PushedStream) {
@@ -347,7 +346,7 @@ TEST_F(SpdyStreamSpdy3Test, StreamError) {
EXPECT_EQ("HTTP/1.1", delegate.GetResponseHeaderValue(":version"));
EXPECT_EQ(std::string(kPostBody, kPostBodyLength),
delegate.TakeReceivedData());
- EXPECT_EQ(static_cast<int>(kPostBodyLength), delegate.data_sent());
+ EXPECT_TRUE(data.at_write_eof());
// Check that the NetLog was filled reasonably.
net::CapturingNetLog::CapturedEntryList entries;
@@ -365,6 +364,133 @@ TEST_F(SpdyStreamSpdy3Test, StreamError) {
EXPECT_EQ(static_cast<int>(stream_id), stream_id2);
}
+// Make sure that large blocks of data are properly split up into
+// frame-sized chunks for a request/response (i.e., an HTTP-like)
+// stream.
+TEST_F(SpdyStreamSpdy3Test, SendLargeDataAfterOpenRequestResponse) {
+ GURL url(kStreamUrl);
+
+ session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_);
+
+ scoped_ptr<SpdyFrame> req(
+ ConstructSpdyPost(kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0));
+ std::string chunk_data(kMaxSpdyFrameChunkSize, 'x');
+ scoped_ptr<SpdyFrame> chunk(
+ ConstructSpdyBodyFrame(
+ 1, chunk_data.data(), chunk_data.length(), false));
+ MockWrite writes[] = {
+ CreateMockWrite(*req, 0),
+ CreateMockWrite(*chunk, 1),
+ CreateMockWrite(*chunk, 2),
+ CreateMockWrite(*chunk, 3),
+ };
+
+ scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0));
+ MockRead reads[] = {
+ CreateMockRead(*resp, 4),
+ MockRead(ASYNC, 0, 0, 5), // EOF
+ };
+
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ MockConnect connect_data(SYNCHRONOUS, OK);
+ data.set_connect_data(connect_data);
+
+ session_deps_.socket_factory->AddSocketDataProvider(&data);
+
+ scoped_refptr<SpdySession> session(CreateSpdySession());
+
+ InitializeSpdySession(session, host_port_pair_);
+
+ base::WeakPtr<SpdyStream> stream =
+ CreateStreamSynchronously(session, url, LOWEST, BoundNetLog());
+ ASSERT_TRUE(stream.get() != NULL);
+
+ std::string body_data(3 * kMaxSpdyFrameChunkSize, 'x');
+ StreamDelegateWithBody delegate(stream, body_data);
+ stream->SetDelegate(&delegate);
+
+ EXPECT_FALSE(stream->HasUrl());
+
+ stream->set_spdy_headers(
+ spdy_util_.ConstructPostHeaderBlock(kStreamUrl, kPostBodyLength));
+ EXPECT_TRUE(stream->HasUrl());
+ EXPECT_EQ(kStreamUrl, stream->GetUrl().spec());
+
+ EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true));
+
+ EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate.WaitForClose());
+
+ EXPECT_TRUE(delegate.send_headers_completed());
+ EXPECT_EQ("200", delegate.GetResponseHeaderValue(":status"));
+ EXPECT_EQ("HTTP/1.1", delegate.GetResponseHeaderValue(":version"));
+ EXPECT_EQ(std::string(), delegate.TakeReceivedData());
+ EXPECT_TRUE(data.at_write_eof());
+}
+
+// Make sure that large blocks of data are properly split up into
+// frame-sized chunks for a bidirectional (i.e., non-HTTP-like)
+// stream.
+TEST_F(SpdyStreamSpdy3Test, SendLargeDataAfterOpenBidirectional) {
+ GURL url(kStreamUrl);
+
+ session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_);
+
+ scoped_ptr<SpdyFrame> req(
+ ConstructSpdyPost(kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0));
+ std::string chunk_data(kMaxSpdyFrameChunkSize, 'x');
+ scoped_ptr<SpdyFrame> chunk(
+ ConstructSpdyBodyFrame(
+ 1, chunk_data.data(), chunk_data.length(), false));
+ MockWrite writes[] = {
+ CreateMockWrite(*req, 0),
+ CreateMockWrite(*chunk, 2),
+ CreateMockWrite(*chunk, 3),
+ CreateMockWrite(*chunk, 4),
+ };
+
+ scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0));
+ MockRead reads[] = {
+ CreateMockRead(*resp, 1),
+ MockRead(ASYNC, 0, 0, 5), // EOF
+ };
+
+ OrderedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
+ MockConnect connect_data(SYNCHRONOUS, OK);
+ data.set_connect_data(connect_data);
+
+ session_deps_.socket_factory->AddSocketDataProvider(&data);
+
+ scoped_refptr<SpdySession> session(CreateSpdySession());
+
+ InitializeSpdySession(session, host_port_pair_);
+
+ base::WeakPtr<SpdyStream> stream =
+ CreateStreamSynchronously(session, url, LOWEST, BoundNetLog());
+ ASSERT_TRUE(stream.get() != NULL);
+
+ std::string body_data(3 * kMaxSpdyFrameChunkSize, 'x');
+ StreamDelegateSendImmediate delegate(
+ stream, scoped_ptr<SpdyHeaderBlock>(), body_data);
+ stream->SetDelegate(&delegate);
+
+ EXPECT_FALSE(stream->HasUrl());
+
+ stream->set_spdy_headers(
+ spdy_util_.ConstructPostHeaderBlock(kStreamUrl, kPostBodyLength));
+ EXPECT_TRUE(stream->HasUrl());
+ EXPECT_EQ(kStreamUrl, stream->GetUrl().spec());
+
+ EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true));
+
+ EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate.WaitForClose());
+
+ EXPECT_TRUE(delegate.send_headers_completed());
+ EXPECT_EQ("200", delegate.GetResponseHeaderValue(":status"));
+ EXPECT_EQ("HTTP/1.1", delegate.GetResponseHeaderValue(":version"));
+ EXPECT_EQ(std::string(), delegate.TakeReceivedData());
+ EXPECT_TRUE(data.at_write_eof());
+}
+
// Call IncreaseSendWindowSize on a stream with a large enough delta
// to overflow an int32. The SpdyStream should handle that case
// gracefully.
@@ -530,7 +656,7 @@ void SpdyStreamSpdy3Test::RunResumeAfterUnstallRequestResponseTest(
EXPECT_EQ("200", delegate.GetResponseHeaderValue(":status"));
EXPECT_EQ("HTTP/1.1", delegate.GetResponseHeaderValue(":version"));
EXPECT_EQ(std::string(), delegate.TakeReceivedData());
- EXPECT_EQ(static_cast<int>(kPostBodyLength), delegate.body_data_sent());
+ EXPECT_TRUE(data.at_write_eof());
}
TEST_F(SpdyStreamSpdy3Test, ResumeAfterSendWindowSizeIncreaseRequestResponse) {
@@ -622,19 +748,15 @@ void SpdyStreamSpdy3Test::RunResumeAfterUnstallBidirectionalTest(
EXPECT_EQ("HTTP/1.1", delegate.GetResponseHeaderValue(":version"));
EXPECT_EQ(std::string(kPostBody, kPostBodyLength),
delegate.TakeReceivedData());
- EXPECT_EQ(static_cast<int>(kPostBodyLength), delegate.data_sent());
+ EXPECT_TRUE(data.at_write_eof());
}
-// TODO(akalin): Re-enable these when http://crbug.com/242288 is
-// fixed.
-TEST_F(SpdyStreamSpdy3Test,
- DISABLED_ResumeAfterSendWindowSizeIncreaseBidirectional) {
+TEST_F(SpdyStreamSpdy3Test, ResumeAfterSendWindowSizeIncreaseBidirectional) {
RunResumeAfterUnstallBidirectionalTest(
base::Bind(&IncreaseStreamSendWindowSize));
}
-TEST_F(SpdyStreamSpdy3Test,
- DISABLED_ResumeAfterSendWindowSizeAdjustBidirectional) {
+TEST_F(SpdyStreamSpdy3Test, ResumeAfterSendWindowSizeAdjustBidirectional) {
RunResumeAfterUnstallBidirectionalTest(
base::Bind(&AdjustStreamSendWindowSize));
}
« no previous file with comments | « net/spdy/spdy_stream_spdy2_unittest.cc ('k') | net/spdy/spdy_stream_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698