Index: net/spdy/spdy_framer_test.cc |
diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc |
index 9852daf82c89ab7c9e9ed8e776bc010c80edd2f9..c09e86174fdc32d6220405ee7925e30cb548b2d7 100644 |
--- a/net/spdy/spdy_framer_test.cc |
+++ b/net/spdy/spdy_framer_test.cc |
@@ -1614,7 +1614,8 @@ TEST_P(SpdyFramerTest, CreateDataFrame) { |
SpdyDataIR data_header_ir(1); |
data_header_ir.SetDataShallow(base::StringPiece(bytes, strlen(bytes))); |
- frame.reset(framer.SerializeDataFrameHeader(data_header_ir)); |
+ frame.reset(framer.SerializeDataFrameHeaderWithPaddingLengthField( |
+ data_header_ir)); |
CompareCharArraysWithHexError( |
kDescription, |
reinterpret_cast<const unsigned char*>(frame->data()), |
@@ -1624,7 +1625,68 @@ TEST_P(SpdyFramerTest, CreateDataFrame) { |
} |
{ |
- const char kDescription[] = "'hello' data frame with padding, no FIN"; |
+ const char kDescription[] = "'hello' data frame with more padding, no FIN"; |
+ const unsigned char kV3FrameData[] = { // Also applies for V2. |
+ 0x00, 0x00, 0x00, 0x01, |
+ 0x00, 0x00, 0x00, 0x05, |
+ 'h', 'e', 'l', 'l', |
+ 'o' |
+ }; |
+ |
+ const unsigned char kV4FrameData[] = { |
+ 0x01, 0x0b, 0x00, 0x30, // Length = 267. PAD_HIGH and PAD_LOW set. |
+ 0x00, 0x00, 0x00, 0x01, |
+ 0x01, 0x04, // Pad Low and Pad High fields. |
+ 'h', 'e', 'l', 'l', // Data |
+ 'o', |
+ // Padding of 260 zeros (so both PAD_HIGH and PAD_LOW fields are used). |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', |
+ }; |
+ const char bytes[] = "hello"; |
+ |
+ SpdyDataIR data_ir(1, StringPiece(bytes, strlen(bytes))); |
+ // 260 zeros and the pad low/high fields make the overall padding to be 262 |
+ // bytes. |
+ data_ir.set_padding_len(262); |
+ scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
+ if (IsSpdy4()) { |
+ CompareFrame( |
+ kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
+ } else { |
+ CompareFrame( |
+ kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
+ } |
+ |
+ frame.reset(framer.SerializeDataFrameHeaderWithPaddingLengthField(data_ir)); |
+ CompareCharArraysWithHexError( |
+ kDescription, |
+ reinterpret_cast<const unsigned char*>(frame->data()), |
+ framer.GetDataFrameMinimumSize(), |
+ IsSpdy4() ? kV4FrameData : kV3FrameData, |
+ framer.GetDataFrameMinimumSize()); |
+ } |
+ |
+ { |
+ const char kDescription[] = "'hello' data frame with few padding, no FIN"; |
const unsigned char kV3FrameData[] = { // Also applies for V2. |
0x00, 0x00, 0x00, 0x01, |
0x00, 0x00, 0x00, 0x05, |
@@ -1644,7 +1706,7 @@ TEST_P(SpdyFramerTest, CreateDataFrame) { |
const char bytes[] = "hello"; |
SpdyDataIR data_ir(1, StringPiece(bytes, strlen(bytes))); |
- // 7 zeros and the pad low field make the overal padding to be 8 bytes. |
+ // 7 zeros and the pad low field make the overall padding to be 8 bytes. |
data_ir.set_padding_len(8); |
scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
if (IsSpdy4()) { |
@@ -1654,6 +1716,14 @@ TEST_P(SpdyFramerTest, CreateDataFrame) { |
CompareFrame( |
kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
} |
+ |
+ frame.reset(framer.SerializeDataFrameHeaderWithPaddingLengthField(data_ir)); |
+ CompareCharArraysWithHexError( |
+ kDescription, |
+ reinterpret_cast<const unsigned char*>(frame->data()), |
+ framer.GetDataFrameMinimumSize(), |
+ IsSpdy4() ? kV4FrameData : kV3FrameData, |
+ framer.GetDataFrameMinimumSize()); |
} |
{ |
@@ -4529,7 +4599,7 @@ TEST_P(SpdyFramerTest, PingFrameFlags) { |
scoped_ptr<SpdyFrame> frame(framer.SerializePing(SpdyPingIR(42))); |
SetFrameFlags(frame.get(), flags, spdy_version_); |
- if (spdy_version_ >= SPDY4 && |
+ if (spdy_version_ > SPDY3 && |
flags == PING_FLAG_ACK) { |
EXPECT_CALL(visitor, OnPing(42, true)); |
} else if (flags == 0) { |
@@ -4539,7 +4609,7 @@ TEST_P(SpdyFramerTest, PingFrameFlags) { |
} |
framer.ProcessInput(frame->data(), frame->size()); |
- if ((spdy_version_ >= SPDY4 && flags == PING_FLAG_ACK) || |
+ if ((spdy_version_ > SPDY3 && flags == PING_FLAG_ACK) || |
flags == 0) { |
EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) |