Index: net/spdy/spdy_network_transaction_unittest.cc |
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc |
index f11cb656a9c372d94858c70ed960ad29a97e504a..a1971ecceea89ec7516118e9f2cf73fb1e56da7a 100644 |
--- a/net/spdy/spdy_network_transaction_unittest.cc |
+++ b/net/spdy/spdy_network_transaction_unittest.cc |
@@ -1699,27 +1699,8 @@ TEST_P(SpdyNetworkTransactionTest, Put) { |
CreateMockWrite(*req), |
}; |
+ scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
- const SpdyHeaderInfo kSynReplyHeader = { |
- SYN_REPLY, // Kind = SynReply |
- 1, // Stream ID |
- 0, // Associated stream ID |
- ConvertRequestPriorityToSpdyPriority( |
- LOWEST, spdy_util_.spdy_version()), |
- kSpdyCredentialSlotUnused, |
- CONTROL_FLAG_NONE, // Control Flags |
- false, // Compressed |
- RST_STREAM_INVALID, // Status |
- NULL, // Data |
- 0, // Length |
- DATA_FLAG_NONE // Data Flags |
- }; |
- scoped_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); |
- (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; |
- (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; |
- (*reply_headers)["content-length"] = "1234"; |
- scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyFrame( |
- kSynReplyHeader, reply_headers.Pass())); |
MockRead reads[] = { |
CreateMockRead(*resp), |
CreateMockRead(*body), |
@@ -1766,28 +1747,8 @@ TEST_P(SpdyNetworkTransactionTest, Head) { |
CreateMockWrite(*req), |
}; |
+ scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
- const SpdyHeaderInfo kSynReplyHeader = { |
- SYN_REPLY, // Kind = SynReply |
- 1, // Stream ID |
- 0, // Associated stream ID |
- ConvertRequestPriorityToSpdyPriority( |
- LOWEST, spdy_util_.spdy_version()), |
- kSpdyCredentialSlotUnused, |
- CONTROL_FLAG_NONE, // Control Flags |
- false, // Compressed |
- RST_STREAM_INVALID, // Status |
- NULL, // Data |
- 0, // Length |
- DATA_FLAG_NONE // Data Flags |
- }; |
- scoped_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); |
- (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; |
- (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; |
- (*reply_headers)["content-length"] = "1234"; |
- scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyFrame( |
- kSynReplyHeader, |
- reply_headers.Pass())); |
MockRead reads[] = { |
CreateMockRead(*resp), |
CreateMockRead(*body), |
@@ -3371,23 +3332,8 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeaders) { |
// Verify that various SynReply headers parse vary fields correctly |
// through the HTTP layer, and the response matches the request. |
TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { |
- static const SpdyHeaderInfo syn_reply_info = { |
- SYN_REPLY, // Syn Reply |
- 1, // Stream ID |
- 0, // Associated Stream ID |
- ConvertRequestPriorityToSpdyPriority( |
- LOWEST, spdy_util_.spdy_version()), |
- kSpdyCredentialSlotUnused, |
- CONTROL_FLAG_NONE, // Control Flags |
- false, // Compressed |
- RST_STREAM_INVALID, // Status |
- NULL, // Data |
- 0, // Data Length |
- DATA_FLAG_NONE // Data Flags |
- }; |
// Modify the following data to change/add test cases: |
struct SynReplyTests { |
- const SpdyHeaderInfo* syn_reply; |
bool vary_matches; |
int num_headers[2]; |
const char* extra_headers[2][16]; |
@@ -3395,7 +3341,6 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { |
// Test the case of a multi-valued cookie. When the value is delimited |
// with NUL characters, it needs to be unfolded into multiple headers. |
{ |
- &syn_reply_info, |
true, |
{ 1, 4 }, |
{ { "cookie", "val1,val2", |
@@ -3409,7 +3354,6 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { |
} |
} |
}, { // Multiple vary fields. |
- &syn_reply_info, |
true, |
{ 2, 5 }, |
{ { "friend", "barney", |
@@ -3425,7 +3369,6 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { |
} |
} |
}, { // Test a '*' vary field. |
- &syn_reply_info, |
false, |
{ 1, 4 }, |
{ { "cookie", "val1,val2", |
@@ -3439,7 +3382,6 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { |
} |
} |
}, { // Multiple comma-separated vary fields. |
- &syn_reply_info, |
true, |
{ 2, 4 }, |
{ { "friend", "barney", |
@@ -3468,12 +3410,12 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { |
}; |
// Construct the reply. |
+ SpdyHeaderBlock reply_headers; |
+ AppendToHeaderBlock(test_cases[i].extra_headers[1], |
+ test_cases[i].num_headers[1], |
+ &reply_headers); |
scoped_ptr<SpdyFrame> frame_reply( |
- spdy_util_.ConstructSpdyFrame(*test_cases[i].syn_reply, |
- test_cases[i].extra_headers[1], |
- test_cases[i].num_headers[1], |
- NULL, |
- 0)); |
+ spdy_util_.ConstructSpdyReply(1, reply_headers)); |
scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
MockRead reads[] = { |
@@ -3528,10 +3470,6 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { |
} |
// Construct the expected header reply string. |
- SpdyHeaderBlock reply_headers; |
- AppendToHeaderBlock(test_cases[i].extra_headers[1], |
- test_cases[i].num_headers[1], |
- &reply_headers); |
std::string expected_reply = |
spdy_util_.ConstructSpdyReplyString(reply_headers); |
EXPECT_EQ(expected_reply, lines) << i; |
@@ -3540,21 +3478,6 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { |
// Verify that we don't crash on invalid SynReply responses. |
TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) { |
- const SpdyHeaderInfo kSynStartHeader = { |
- SYN_REPLY, // Kind = SynReply |
- 1, // Stream ID |
- 0, // Associated stream ID |
- ConvertRequestPriorityToSpdyPriority( |
- LOWEST, spdy_util_.spdy_version()), |
- kSpdyCredentialSlotUnused, |
- CONTROL_FLAG_NONE, // Control Flags |
- false, // Compressed |
- RST_STREAM_INVALID, // Status |
- NULL, // Data |
- 0, // Length |
- DATA_FLAG_NONE // Data Flags |
- }; |
- |
struct InvalidSynReplyTests { |
int num_headers; |
const char* headers[10]; |
@@ -3589,12 +3512,11 @@ TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) { |
CreateMockWrite(*rst), |
}; |
- scoped_ptr<SpdyFrame> resp( |
- spdy_util_.ConstructSpdyFrame(kSynStartHeader, |
- NULL, 0, |
- test_cases[i].headers, |
- test_cases[i].num_headers)); |
- scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
+ // Construct the reply. |
+ SpdyHeaderBlock reply_headers; |
+ AppendToHeaderBlock( |
+ test_cases[i].headers, test_cases[i].num_headers, &reply_headers); |
+ scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyReply(1, reply_headers)); |
MockRead reads[] = { |
CreateMockRead(*resp), |
MockRead(ASYNC, 0, 0) // EOF |
@@ -4131,22 +4053,13 @@ TEST_P(SpdyNetworkTransactionTest, BufferedAll) { |
MockWrite writes[] = { CreateMockWrite(*req) }; |
// 5 data frames in a single read. |
- SpdySynReplyIR reply_ir(1); |
- reply_ir.SetHeader(spdy_util_.GetStatusKey(), "200"); |
- reply_ir.SetHeader(spdy_util_.GetVersionKey(), "HTTP/1.1"); |
- |
- scoped_ptr<SpdyFrame> syn_reply(framer.SerializeFrame(reply_ir)); |
+ scoped_ptr<SpdyFrame> reply(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
scoped_ptr<SpdyFrame> data_frame( |
framer.CreateDataFrame(1, "message", 7, DATA_FLAG_NONE)); |
scoped_ptr<SpdyFrame> data_frame_fin( |
framer.CreateDataFrame(1, "message", 7, DATA_FLAG_FIN)); |
- const SpdyFrame* frames[5] = { |
- syn_reply.get(), |
- data_frame.get(), |
- data_frame.get(), |
- data_frame.get(), |
- data_frame_fin.get() |
- }; |
+ const SpdyFrame* frames[5] = {reply.get(), data_frame.get(), data_frame.get(), |
+ data_frame.get(), data_frame_fin.get()}; |
char combined_frames[200]; |
int combined_frames_len = |
CombineFrames(frames, arraysize(frames), |
@@ -4379,8 +4292,7 @@ TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) { |
// the settings in the HttpServerProperties. |
TEST_P(SpdyNetworkTransactionTest, SettingsSaved) { |
if (spdy_util_.spdy_version() >= SPDY4) { |
- // SPDY4 doesn't support flags on individual settings, and |
- // has no concept of settings persistence. |
+ // SPDY4 doesn't support settings persistence. |
return; |
} |
static const SpdyHeaderInfo kSynReplyInfo = { |
@@ -4487,7 +4399,10 @@ TEST_P(SpdyNetworkTransactionTest, SettingsSaved) { |
// Test that when there are settings saved that they are sent back to the |
// server upon session establishment. |
TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { |
- // TODO(jgraettinger): Remove settings persistence mechanisms altogether. |
+ if (spdy_util_.spdy_version() >= SPDY4) { |
+ // SPDY4 doesn't support settings persistence. |
+ return; |
+ } |
static const SpdyHeaderInfo kSynReplyInfo = { |
SYN_REPLY, // Syn Reply |
1, // Stream ID |
@@ -5615,21 +5530,11 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { |
scoped_ptr<SpdyFrame> rst( |
spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
MockWrite writes[] = { |
- CreateMockWrite(*req), |
- CreateMockWrite(*rst), |
- }; |
+ CreateMockWrite(*req), CreateMockWrite(*rst), |
+ }; |
- scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); |
- (*initial_headers)[spdy_util_.GetStatusKey()] = "200 OK"; |
- (*initial_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; |
scoped_ptr<SpdyFrame> stream1_reply( |
- spdy_util_.ConstructSpdyControlFrame(initial_headers.Pass(), |
- false, |
- 1, |
- LOWEST, |
- SYN_REPLY, |
- CONTROL_FLAG_NONE, |
- 0)); |
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
scoped_ptr<SpdyHeaderBlock> late_headers(new SpdyHeaderBlock()); |
(*late_headers)["hello"] = "bye"; |
@@ -5669,17 +5574,8 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyWithLateHeaders) { |
CreateMockWrite(*rst), |
}; |
- scoped_ptr<SpdyHeaderBlock> initial_headers(new SpdyHeaderBlock()); |
- (*initial_headers)[spdy_util_.GetStatusKey()] = "200 OK"; |
- (*initial_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; |
scoped_ptr<SpdyFrame> stream1_reply( |
- spdy_util_.ConstructSpdyControlFrame(initial_headers.Pass(), |
- false, |
- 1, |
- LOWEST, |
- SYN_REPLY, |
- CONTROL_FLAG_NONE, |
- 0)); |
+ spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
scoped_ptr<SpdyHeaderBlock> late_headers(new SpdyHeaderBlock()); |
(*late_headers)["hello"] = "bye"; |