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

Unified Diff: net/spdy/spdy_framer_test.cc

Issue 244853004: SPDY: Replace SerializeDataFrameHeader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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_framer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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())
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698