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

Unified Diff: net/spdy/spdy_framer_test.cc

Issue 357513003: Stop using SpdySynStreamIR for SPDY 4. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: WebSocket test fix. Created 6 years, 6 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') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | 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 888fcd7c8124242674cb597b96e2158924492460..a131f62037feee8a1a9dea3ef5324bc7cf71b888 100644
--- a/net/spdy/spdy_framer_test.cc
+++ b/net/spdy/spdy_framer_test.cc
@@ -673,13 +673,13 @@ TEST_P(SpdyFramerTest, HeaderBlockInBuffer) {
SpdyFramer framer(spdy_version_);
framer.set_enable_compression(false);
- // Encode the header block into a SynStream frame.
- SpdySynStreamIR syn_stream(1);
- syn_stream.set_priority(1);
- syn_stream.SetHeader("alpha", "beta");
- syn_stream.SetHeader("gamma", "charlie");
- syn_stream.SetHeader("cookie", "key1=value1; key2=value2");
- scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream));
+ // Encode the header block into a Headers frame.
+ SpdyHeadersIR headers(1);
+ headers.set_priority(1);
+ headers.SetHeader("alpha", "beta");
+ headers.SetHeader("gamma", "charlie");
+ headers.SetHeader("cookie", "key1=value1; key2=value2");
+ scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers));
EXPECT_TRUE(frame.get() != NULL);
TestSpdyVisitor visitor(spdy_version_);
@@ -689,7 +689,7 @@ TEST_P(SpdyFramerTest, HeaderBlockInBuffer) {
frame->size());
EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_);
- EXPECT_TRUE(CompareHeaderBlocks(&syn_stream.name_value_block(),
+ EXPECT_TRUE(CompareHeaderBlocks(&headers.name_value_block(),
&visitor.headers_));
}
@@ -698,12 +698,12 @@ TEST_P(SpdyFramerTest, UndersizedHeaderBlockInBuffer) {
SpdyFramer framer(spdy_version_);
framer.set_enable_compression(false);
- // Encode the header block into a SynStream frame.
- SpdySynStreamIR syn_stream(1);
- syn_stream.set_priority(1);
- syn_stream.SetHeader("alpha", "beta");
- syn_stream.SetHeader("gamma", "charlie");
- scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream));
+ // Encode the header block into a Headers frame.
+ SpdyHeadersIR headers(1);
+ headers.set_priority(1);
+ headers.SetHeader("alpha", "beta");
+ headers.SetHeader("gamma", "charlie");
+ scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers));
EXPECT_TRUE(frame.get() != NULL);
TestSpdyVisitor visitor(spdy_version_);
@@ -997,18 +997,18 @@ TEST_P(SpdyFramerTest, BasicCompression) {
TEST_P(SpdyFramerTest, CompressEmptyHeaders) {
// See crbug.com/172383
- SpdySynStreamIR syn_stream(1);
- syn_stream.SetHeader("server", "SpdyServer 1.0");
- syn_stream.SetHeader("date", "Mon 12 Jan 2009 12:12:12 PST");
- syn_stream.SetHeader("status", "200");
- syn_stream.SetHeader("version", "HTTP/1.1");
- syn_stream.SetHeader("content-type", "text/html");
- syn_stream.SetHeader("content-length", "12");
- syn_stream.SetHeader("x-empty-header", "");
+ SpdyHeadersIR headers(1);
+ headers.SetHeader("server", "SpdyServer 1.0");
+ headers.SetHeader("date", "Mon 12 Jan 2009 12:12:12 PST");
+ headers.SetHeader("status", "200");
+ headers.SetHeader("version", "HTTP/1.1");
+ headers.SetHeader("content-type", "text/html");
+ headers.SetHeader("content-length", "12");
+ headers.SetHeader("x-empty-header", "");
SpdyFramer framer(spdy_version_);
framer.set_enable_compression(true);
- scoped_ptr<SpdyFrame> frame1(framer.SerializeSynStream(syn_stream));
+ scoped_ptr<SpdyFrame> frame1(framer.SerializeHeaders(headers));
}
TEST_P(SpdyFramerTest, Basic) {
@@ -1450,49 +1450,6 @@ TEST_P(SpdyFramerTest, HeaderCompression) {
EXPECT_EQ(kValue3, decompressed_headers[kHeader3]);
}
-// Verify we don't leak when we leave streams unclosed
-TEST_P(SpdyFramerTest, UnclosedStreamDataCompressors) {
- SpdyFramer send_framer(spdy_version_);
-
- send_framer.set_enable_compression(true);
-
- const char kHeader1[] = "header1";
- const char kHeader2[] = "header2";
- const char kValue1[] = "value1";
- const char kValue2[] = "value2";
-
- SpdySynStreamIR syn_stream(1);
- syn_stream.SetHeader(kHeader1, kValue1);
- syn_stream.SetHeader(kHeader2, kValue2);
- scoped_ptr<SpdyFrame> syn_frame(send_framer.SerializeSynStream(syn_stream));
- EXPECT_TRUE(syn_frame.get() != NULL);
-
- StringPiece bytes = "this is a test test test test test!";
- SpdyDataIR data_ir(1, bytes);
- data_ir.set_fin(true);
- scoped_ptr<SpdyFrame> send_frame(send_framer.SerializeData(data_ir));
- EXPECT_TRUE(send_frame.get() != NULL);
-
- // Run the inputs through the framer.
- TestSpdyVisitor visitor(spdy_version_);
- visitor.use_compression_ = true;
- const unsigned char* data;
- data = reinterpret_cast<const unsigned char*>(syn_frame->data());
- visitor.SimulateInFramer(data, syn_frame->size());
- data = reinterpret_cast<const unsigned char*>(send_frame->data());
- visitor.SimulateInFramer(data, send_frame->size());
-
- EXPECT_EQ(0, visitor.error_count_);
- EXPECT_EQ(1, visitor.syn_frame_count_);
- EXPECT_EQ(0, visitor.syn_reply_frame_count_);
- EXPECT_EQ(0, visitor.headers_frame_count_);
- EXPECT_EQ(bytes.size(), static_cast<unsigned>(visitor.data_bytes_));
- EXPECT_EQ(0, visitor.fin_frame_count_);
- EXPECT_EQ(0, visitor.fin_flag_count_);
- EXPECT_EQ(1, visitor.zero_length_data_frame_count_);
- EXPECT_EQ(1, visitor.data_frame_count_);
-}
-
// Verify we can decompress the stream even if handed over to the
// framer 1 byte at a time.
TEST_P(SpdyFramerTest, UnclosedStreamDataCompressorsOneByteAtATime) {
@@ -1505,11 +1462,11 @@ TEST_P(SpdyFramerTest, UnclosedStreamDataCompressorsOneByteAtATime) {
const char kValue1[] = "value1";
const char kValue2[] = "value2";
- SpdySynStreamIR syn_stream(1);
- syn_stream.SetHeader(kHeader1, kValue1);
- syn_stream.SetHeader(kHeader2, kValue2);
- scoped_ptr<SpdyFrame> syn_frame(send_framer.SerializeSynStream(syn_stream));
- EXPECT_TRUE(syn_frame.get() != NULL);
+ SpdyHeadersIR headers(1);
+ headers.SetHeader(kHeader1, kValue1);
+ headers.SetHeader(kHeader2, kValue2);
+ scoped_ptr<SpdyFrame> headers_frame(send_framer.SerializeHeaders(headers));
+ EXPECT_TRUE(headers_frame.get() != NULL);
const char bytes[] = "this is a test test test test test!";
SpdyDataIR data_ir(1, StringPiece(bytes, arraysize(bytes)));
@@ -1521,8 +1478,8 @@ TEST_P(SpdyFramerTest, UnclosedStreamDataCompressorsOneByteAtATime) {
TestSpdyVisitor visitor(spdy_version_);
visitor.use_compression_ = true;
const unsigned char* data;
- data = reinterpret_cast<const unsigned char*>(syn_frame->data());
- for (size_t idx = 0; idx < syn_frame->size(); ++idx) {
+ data = reinterpret_cast<const unsigned char*>(headers_frame->data());
+ for (size_t idx = 0; idx < headers_frame->size(); ++idx) {
visitor.SimulateInFramer(data + idx, 1);
ASSERT_EQ(0, visitor.error_count_);
}
@@ -1533,9 +1490,9 @@ TEST_P(SpdyFramerTest, UnclosedStreamDataCompressorsOneByteAtATime) {
}
EXPECT_EQ(0, visitor.error_count_);
- EXPECT_EQ(1, visitor.syn_frame_count_);
+ EXPECT_EQ(0, visitor.syn_frame_count_);
EXPECT_EQ(0, visitor.syn_reply_frame_count_);
- EXPECT_EQ(0, visitor.headers_frame_count_);
+ EXPECT_EQ(1, visitor.headers_frame_count_);
EXPECT_EQ(arraysize(bytes), static_cast<unsigned>(visitor.data_bytes_));
EXPECT_EQ(0, visitor.fin_frame_count_);
EXPECT_EQ(0, visitor.fin_flag_count_);
@@ -1873,6 +1830,10 @@ TEST_P(SpdyFramerTest, CreateDataFrame) {
}
TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) {
+ if (!IsSpdy2() && !IsSpdy3()) {
+ // SYN_STREAM unsupported in SPDY>3
+ return;
+ }
SpdyFramer framer(spdy_version_);
framer.set_enable_compression(false);
@@ -1907,16 +1868,6 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) {
0x00, 0x00, 0x03, 'b',
'a', 'r'
};
- const unsigned char kV4FrameData[] = {
- 0x00, 0x17, 0x01, 0x24, // HEADERS: PRIORITY | END_HEADERS
- 0x00, 0x00, 0x00, 0x01, // Stream 1
- 0x00, 0x00, 0x00, 0x00, // Non-exclusive dependency 0. Weight 0.
- 0x00, 0x00, 0x03, 0x62,
- 0x61, 0x72, 0x03, 0x66,
- 0x6f, 0x6f, 0x00, 0x03,
- 0x66, 0x6f, 0x6f, 0x03,
- 0x62, 0x61, 0x72,
- };
SpdySynStreamIR syn_stream(1);
syn_stream.set_priority(framer.GetLowestPriority());
syn_stream.SetHeader("bar", "foo");
@@ -1927,7 +1878,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) {
} else if (IsSpdy3()) {
CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
} else {
- CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
+ LOG(FATAL) << "Unsupported version in test.";
}
}
@@ -1962,15 +1913,6 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) {
0x00, 0x00, 0x00, 0x03,
'b', 'a', 'r'
};
- const unsigned char kV4FrameData[] = {
- 0x00, 0x14, 0x01, 0x25, // HEADERS: PRIORITY | FIN | END_HEADERS
- 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
- 0x00, 0x00, 0x00, 0x00, // Non-exclusive dependency 0. Weight 255.
- 0xff, 0x00, 0x00, 0x03,
- 0x66, 0x6f, 0x6f, 0x00,
- 0x03, 0x66, 0x6f, 0x6f,
- 0x03, 0x62, 0x61, 0x72,
- };
SpdySynStreamIR syn_stream(0x7fffffff);
syn_stream.set_associated_to_stream_id(0x7fffffff);
syn_stream.set_priority(framer.GetHighestPriority());
@@ -1983,7 +1925,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) {
} else if (IsSpdy3()) {
CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
} else {
- CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
+ LOG(FATAL) << "Unsupported version in test.";
}
}
@@ -2019,15 +1961,6 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) {
'f', 'o', 'o', 0x00,
0x00, 0x00, 0x00
};
- const unsigned char kV4FrameData[] = {
- 0x00, 0x14, 0x01, 0x25, // HEADERS: PRIORITY | FIN | END_HEADERS
- 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
- 0x00, 0x00, 0x00, 0x00, // Non-exclusive dependency 0. Weight 219.
- 0xdb, 0x00, 0x03, 0x62,
- 0x61, 0x72, 0x03, 0x66,
- 0x6f, 0x6f, 0x00, 0x03,
- 0x66, 0x6f, 0x6f, 0x00,
- };
SpdySynStreamIR syn_stream(0x7fffffff);
syn_stream.set_associated_to_stream_id(0x7fffffff);
syn_stream.set_priority(1);
@@ -2040,7 +1973,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) {
} else if (IsSpdy3()) {
CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
} else {
- CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
+ LOG(FATAL) << "Unsupported version in test.";
}
}
}
@@ -2049,6 +1982,10 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) {
// to workaround http://crbug.com/139744.
#if !defined(USE_SYSTEM_ZLIB)
TEST_P(SpdyFramerTest, CreateSynStreamCompressed) {
+ if (!IsSpdy2() && !IsSpdy3()) {
+ // SYN_STREAM not supported for SPDY>3
+ return;
+ }
SpdyFramer framer(spdy_version_);
framer.set_enable_compression(true);
@@ -2103,7 +2040,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamCompressed) {
} else if (IsSpdy3()) {
CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
} else {
- // Deflate compression doesn't apply to HPACK.
+ LOG(FATAL) << "Unsupported version in test.";
}
}
}
@@ -2111,6 +2048,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamCompressed) {
TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) {
if (spdy_version_ > SPDY3) {
+ // SYN_REPLY unsupported in SPDY>3
return;
}
SpdyFramer framer(spdy_version_);
@@ -2143,15 +2081,6 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) {
'o', 0x00, 0x00, 0x00,
0x03, 'b', 'a', 'r'
};
- const unsigned char kV4FrameData[] = {
- 0x00, 0x12, 0x01, 0x04, // HEADER: END_HEADERS
- 0x00, 0x00, 0x00, 0x01, // Stream 1
- 0x00, 0x03, 0x62, 0x61, // @.ba
- 0x72, 0x03, 0x66, 0x6f, // r.fo
- 0x6f, 0x00, 0x03, 0x66, // o@.f
- 0x6f, 0x6f, 0x03, 0x62, // oo.b
- 0x61, 0x72, // ar
- };
SpdySynReplyIR syn_reply(1);
syn_reply.SetHeader("bar", "foo");
syn_reply.SetHeader("foo", "bar");
@@ -2161,7 +2090,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) {
} else if (IsSpdy3()) {
CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
} else {
- CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
+ LOG(FATAL) << "Unsupported version in test.";
}
}
@@ -2193,14 +2122,6 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) {
0x00, 0x03, 'b', 'a',
'r'
};
- const unsigned char kV4FrameData[] = {
- 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS
- 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
- 0x00, 0x00, 0x03, 0x66, // @..f
- 0x6f, 0x6f, 0x00, 0x03, // oo@.
- 0x66, 0x6f, 0x6f, 0x03, // foo.
- 0x62, 0x61, 0x72, // bar
- };
SpdySynReplyIR syn_reply(0x7fffffff);
syn_reply.set_fin(true);
syn_reply.SetHeader("", "foo");
@@ -2211,7 +2132,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) {
} else if (IsSpdy3()) {
CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
} else {
- CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
+ LOG(FATAL) << "Unsupported version in test.";
}
}
@@ -2243,14 +2164,6 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) {
'o', 0x00, 0x00, 0x00,
0x00
};
- const unsigned char kV4FrameData[] = {
- 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS
- 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
- 0x00, 0x03, 0x62, 0x61, // @.ba
- 0x72, 0x03, 0x66, 0x6f, // r.fo
- 0x6f, 0x00, 0x03, 0x66, // o@.f
- 0x6f, 0x6f, 0x00, // oo.
- };
SpdySynReplyIR syn_reply(0x7fffffff);
syn_reply.set_fin(true);
syn_reply.SetHeader("bar", "foo");
@@ -2261,7 +2174,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) {
} else if (IsSpdy3()) {
CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
} else {
- CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
+ LOG(FATAL) << "Unsupported version in test.";
}
}
}
@@ -2271,6 +2184,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) {
#if !defined(USE_SYSTEM_ZLIB)
TEST_P(SpdyFramerTest, CreateSynReplyCompressed) {
if (spdy_version_ > SPDY3) {
+ // SYN_REPLY unsupported in SPDY>3
return;
}
SpdyFramer framer(spdy_version_);
@@ -2322,7 +2236,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyCompressed) {
} else if (IsSpdy3()) {
CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData));
} else {
- // Deflate compression doesn't apply to HPACK.
+ LOG(FATAL) << "Unsupported version in test.";
}
}
}
@@ -2811,6 +2725,34 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) {
CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
}
}
+
+ {
+ const char kDescription[] =
+ "HEADERS frame with a 0-length header val, FIN, max stream ID, pri";
+
+ const unsigned char kV4FrameData[] = {
+ 0x00, 0x14, 0x01, 0x25, // Headers: FIN | END_HEADERS | PRIORITY
+ 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
+ 0x00, 0x00, 0x00, 0x00, // parent stream
+ 0xdb, // weight
+ 0x00, 0x03, 0x62, 0x61, // @.ba
+ 0x72, 0x03, 0x66, 0x6f, // r.fo
+ 0x6f, 0x00, 0x03, 0x66, // o@.f
+ 0x6f, 0x6f, 0x00, // oo.
+ };
+ SpdyHeadersIR headers_ir(0x7fffffff);
+ headers_ir.set_fin(true);
+ headers_ir.set_priority(1);
+ headers_ir.set_has_priority(true);
+ headers_ir.SetHeader("bar", "foo");
+ headers_ir.SetHeader("foo", "");
+ scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir));
+ if (IsSpdy2() || IsSpdy3()) {
+ // HEADERS with priority not supported.
+ } else {
+ CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData));
+ }
+ }
}
// TODO(phajdan.jr): Clean up after we no longer need
@@ -3060,6 +3002,10 @@ TEST_P(SpdyFramerTest, CreatePriority) {
}
TEST_P(SpdyFramerTest, ReadCompressedSynStreamHeaderBlock) {
+ if (spdy_version_ > SPDY3) {
+ // SYN_STREAM not supported in SPDY>3
+ return;
+ }
SpdyFramer framer(spdy_version_);
SpdySynStreamIR syn_stream(1);
syn_stream.set_priority(1);
@@ -3295,11 +3241,11 @@ TEST_P(SpdyFramerTest, ControlFrameMuchTooLarge) {
const size_t kBigValueSize = kHeaderBufferSize * 2;
string big_value(kBigValueSize, 'x');
SpdyFramer framer(spdy_version_);
- SpdySynStreamIR syn_stream(1);
- syn_stream.set_priority(1);
- syn_stream.set_fin(true);
- syn_stream.SetHeader("aa", big_value);
- scoped_ptr<SpdyFrame> control_frame(framer.SerializeSynStream(syn_stream));
+ SpdyHeadersIR headers(1);
+ headers.set_priority(1);
+ headers.set_fin(true);
+ headers.SetHeader("aa", big_value);
+ scoped_ptr<SpdyFrame> control_frame(framer.SerializeHeaders(headers));
EXPECT_TRUE(control_frame.get() != NULL);
TestSpdyVisitor visitor(spdy_version_);
visitor.set_header_buffer_size(kHeaderBufferSize);
@@ -4503,6 +4449,10 @@ TEST_P(SpdyFramerTest, DataFrameFlagsV4) {
}
TEST_P(SpdyFramerTest, SynStreamFrameFlags) {
+ if (!IsSpdy2() && !IsSpdy3()) {
+ // SYN_STREAM not supported in SPDY>3
+ return;
+ }
for (int flags = 0; flags < 256; ++flags) {
SCOPED_TRACE(testing::Message() << "Flags " << flags);
@@ -4520,40 +4470,17 @@ TEST_P(SpdyFramerTest, SynStreamFrameFlags) {
syn_stream.SetHeader("foo", "bar");
scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream));
int set_flags = flags;
- if (IsSpdy4()) {
- // PRIORITY required for SYN_STREAM simulation.
- set_flags |= HEADERS_FLAG_PRIORITY;
-
- // TODO(jgraettinger): Add padding to SynStreamIR, and implement framing.
- set_flags &= ~HEADERS_FLAG_PAD_LOW;
- set_flags &= ~HEADERS_FLAG_PAD_HIGH;
- }
SetFrameFlags(frame.get(), set_flags, spdy_version_);
- if (!IsSpdy4() &&
- flags & ~(CONTROL_FLAG_FIN | CONTROL_FLAG_UNIDIRECTIONAL)) {
- EXPECT_CALL(visitor, OnError(_));
- } else if (IsSpdy4() &&
- flags & ~(CONTROL_FLAG_FIN |
- HEADERS_FLAG_PRIORITY |
- HEADERS_FLAG_END_HEADERS |
- HEADERS_FLAG_END_SEGMENT |
- HEADERS_FLAG_PAD_LOW |
- HEADERS_FLAG_PAD_HIGH)) {
+ if (flags & ~(CONTROL_FLAG_FIN | CONTROL_FLAG_UNIDIRECTIONAL)) {
EXPECT_CALL(visitor, OnError(_));
} else {
EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(8, SYN_STREAM, _));
- if (IsSpdy4()) {
- EXPECT_CALL(visitor, OnSynStream(8, 0, 1, flags & CONTROL_FLAG_FIN,
- false));
- } else {
- EXPECT_CALL(visitor, OnSynStream(8, 3, 1, flags & CONTROL_FLAG_FIN,
- flags & CONTROL_FLAG_UNIDIRECTIONAL));
- }
+ EXPECT_CALL(visitor, OnSynStream(8, 3, 1, flags & CONTROL_FLAG_FIN,
+ flags & CONTROL_FLAG_UNIDIRECTIONAL));
EXPECT_CALL(visitor, OnControlFrameHeaderData(8, _, _))
.WillRepeatedly(testing::Return(true));
- if (flags & DATA_FLAG_FIN && (!IsSpdy4() ||
- flags & HEADERS_FLAG_END_HEADERS)) {
+ if (flags & DATA_FLAG_FIN) {
EXPECT_CALL(visitor, OnStreamFrameData(_, _, 0, true));
} else {
// Do not close the stream if we are expecting a CONTINUATION frame.
@@ -4562,19 +4489,7 @@ TEST_P(SpdyFramerTest, SynStreamFrameFlags) {
}
framer.ProcessInput(frame->data(), frame->size());
- if (!IsSpdy4() &&
- flags & ~(CONTROL_FLAG_FIN | CONTROL_FLAG_UNIDIRECTIONAL)) {
- EXPECT_EQ(SpdyFramer::SPDY_ERROR, framer.state());
- EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME_FLAGS,
- framer.error_code())
- << SpdyFramer::ErrorCodeToString(framer.error_code());
- } else if (IsSpdy4() &&
- flags & ~(CONTROL_FLAG_FIN |
- HEADERS_FLAG_PRIORITY |
- HEADERS_FLAG_END_HEADERS |
- HEADERS_FLAG_END_SEGMENT |
- HEADERS_FLAG_PAD_LOW |
- HEADERS_FLAG_PAD_HIGH)) {
+ if (flags & ~(CONTROL_FLAG_FIN | CONTROL_FLAG_UNIDIRECTIONAL)) {
EXPECT_EQ(SpdyFramer::SPDY_ERROR, framer.state());
EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME_FLAGS,
framer.error_code())
@@ -4588,8 +4503,8 @@ TEST_P(SpdyFramerTest, SynStreamFrameFlags) {
}
TEST_P(SpdyFramerTest, SynReplyFrameFlags) {
- if (IsSpdy4()) {
- // Covered by HEADERS case.
+ if (!IsSpdy2() && !IsSpdy3()) {
+ // SYN_REPLY not supported in SPDY>3
return;
}
for (int flags = 0; flags < 256; ++flags) {
@@ -4778,10 +4693,6 @@ TEST_P(SpdyFramerTest, GoawayFrameFlags) {
TEST_P(SpdyFramerTest, HeadersFrameFlags) {
for (int flags = 0; flags < 256; ++flags) {
- if (IsSpdy4() && flags & HEADERS_FLAG_PRIORITY) {
- // Covered by SYN_STREAM case.
- continue;
- }
SCOPED_TRACE(testing::Message() << "Flags " << flags);
testing::StrictMock<test::MockSpdyFramerVisitor> visitor;
@@ -4789,6 +4700,10 @@ TEST_P(SpdyFramerTest, HeadersFrameFlags) {
framer.set_visitor(&visitor);
SpdyHeadersIR headers_ir(57);
+ if (IsSpdy4() && (flags & HEADERS_FLAG_PRIORITY)) {
+ headers_ir.set_priority(3);
+ headers_ir.set_has_priority(true);
+ }
headers_ir.SetHeader("foo", "bar");
scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir));
int set_flags = flags;
@@ -4806,13 +4721,22 @@ TEST_P(SpdyFramerTest, HeadersFrameFlags) {
HEADERS_FLAG_END_HEADERS |
HEADERS_FLAG_END_SEGMENT |
HEADERS_FLAG_PAD_LOW |
- HEADERS_FLAG_PAD_HIGH)) {
+ HEADERS_FLAG_PAD_HIGH |
+ HEADERS_FLAG_PRIORITY)) {
EXPECT_CALL(visitor, OnError(_));
} else {
- EXPECT_CALL(visitor, OnHeaders(57,
- flags & CONTROL_FLAG_FIN,
- (flags & HEADERS_FLAG_END_HEADERS) ||
- !IsSpdy4()));
+ if (spdy_version_ > SPDY3 && flags & HEADERS_FLAG_PRIORITY) {
+ EXPECT_CALL(visitor, OnSynStream(57, // stream id
+ 0, // associated stream id
+ 3, // priority
+ flags & CONTROL_FLAG_FIN,
+ false)); // unidirectional
+ } else {
+ EXPECT_CALL(visitor, OnHeaders(57,
+ flags & CONTROL_FLAG_FIN,
+ (flags & HEADERS_FLAG_END_HEADERS) ||
+ !IsSpdy4()));
+ }
EXPECT_CALL(visitor, OnControlFrameHeaderData(57, _, _))
.WillRepeatedly(testing::Return(true));
if (flags & DATA_FLAG_FIN && (!IsSpdy4() ||
@@ -4834,7 +4758,8 @@ TEST_P(SpdyFramerTest, HeadersFrameFlags) {
HEADERS_FLAG_END_HEADERS |
HEADERS_FLAG_END_SEGMENT |
HEADERS_FLAG_PAD_LOW |
- HEADERS_FLAG_PAD_HIGH)) {
+ HEADERS_FLAG_PAD_HIGH |
+ HEADERS_FLAG_PRIORITY)) {
EXPECT_EQ(SpdyFramer::SPDY_ERROR, framer.state());
EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME_FLAGS,
framer.error_code())
@@ -5040,6 +4965,10 @@ TEST_P(SpdyFramerTest, ContinuationFrameFlags) {
// TODO(hkhalil): Add TEST_P(SpdyFramerTest, BlockedFrameFlags)
TEST_P(SpdyFramerTest, EmptySynStream) {
+ if (!IsSpdy2() && !IsSpdy3()) {
+ // SYN_STREAM not supported in SPDY>3.
+ return;
+ }
testing::StrictMock<test::MockSpdyFramerVisitor> visitor;
testing::StrictMock<test::MockDebugVisitor> debug_visitor;
SpdyFramer framer(spdy_version_);
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698