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

Unified Diff: net/spdy/spdy_framer_test.cc

Issue 10053029: Factor out the code to write control frame headers into a new constructor of SpdyFrameBuilder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add Data frame constructor Created 8 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 1cfa1014714db3dba6e19332d601654370d4b6fa..0040c0bacb2d1e07a3c974494774bc2630e3067f 100644
--- a/net/spdy/spdy_framer_test.cc
+++ b/net/spdy/spdy_framer_test.cc
@@ -438,18 +438,14 @@ using test::SpdyFramerTestUtil;
using test::TestSpdyVisitor;
TEST(SpdyFrameBuilderTest, WriteLimits) {
- SpdyFrameBuilder builder(kLengthMask + 4);
- // length field should fail.
- EXPECT_FALSE(builder.WriteBytes(reinterpret_cast<const void*>(0x1),
- kLengthMask + 1));
- EXPECT_EQ(0, builder.length());
-
- // Writing a block of the maximum allowed size should succeed.
+ SpdyFrameBuilder builder(1, DATA_FLAG_NONE, kLengthMask + 8);
+ // Data frame header is 8 bytes
+ EXPECT_EQ(8, builder.length());
const std::string kLargeData(kLengthMask, 'A');
builder.WriteUInt32(kLengthMask);
- EXPECT_EQ(4, builder.length());
- EXPECT_TRUE(builder.WriteBytes(kLargeData.data(), kLengthMask));
- EXPECT_EQ(4 + kLengthMask, static_cast<unsigned>(builder.length()));
+ EXPECT_EQ(12, builder.length());
+ EXPECT_TRUE(builder.WriteBytes(kLargeData.data(), kLengthMask - 4));
+ EXPECT_EQ(kLengthMask + 8, static_cast<unsigned>(builder.length()));
}
enum SpdyFramerTestTypes {
@@ -581,11 +577,8 @@ TEST_P(SpdyFramerTest, UndersizedHeaderBlockInBuffer) {
TEST_P(SpdyFramerTest, OutOfOrderHeaders) {
// Frame builder with plentiful buffer size.
- SpdyFrameBuilder frame(1024);
+ SpdyFrameBuilder frame(SYN_STREAM, CONTROL_FLAG_NONE, 1, 1024);
- frame.WriteUInt16(kControlFlagMask | 1);
- frame.WriteUInt16(SYN_STREAM);
- frame.WriteUInt32(0); // Placeholder for the length.
frame.WriteUInt32(3); // stream_id
frame.WriteUInt32(0); // Associated stream id
frame.WriteUInt16(0); // Priority.
@@ -691,11 +684,8 @@ TEST_P(SpdyFramerTest, ParseCredentialFrameData) {
TEST_P(SpdyFramerTest, DuplicateHeader) {
// Frame builder with plentiful buffer size.
- SpdyFrameBuilder frame(1024);
+ SpdyFrameBuilder frame(SYN_STREAM, CONTROL_FLAG_NONE, 1, 1024);
- frame.WriteUInt16(kControlFlagMask | 1);
- frame.WriteUInt16(SYN_STREAM);
- frame.WriteUInt32(0); // Placeholder for the length.
frame.WriteUInt32(3); // stream_id
frame.WriteUInt32(0); // associated stream id
frame.WriteUInt16(0); // Priority.
@@ -731,11 +721,8 @@ TEST_P(SpdyFramerTest, DuplicateHeader) {
TEST_P(SpdyFramerTest, MultiValueHeader) {
// Frame builder with plentiful buffer size.
- SpdyFrameBuilder frame(1024);
+ SpdyFrameBuilder frame(SYN_STREAM, CONTROL_FLAG_NONE, 1, 1024);
- frame.WriteUInt16(kControlFlagMask | 1);
- frame.WriteUInt16(SYN_STREAM);
- frame.WriteUInt32(0); // Placeholder for the length.
frame.WriteUInt32(3); // stream_id
frame.WriteUInt32(0); // associated stream id
frame.WriteUInt16(0); // Priority.
« 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