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

Unified Diff: net/spdy/spdy_framer_test.cc

Issue 353443005: SpdyFramer hooks for parsing and handling PRIORITY frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Additional override => OVERRIDE. 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_protocol.h » ('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 390bc6e1379d03d2774670d9b89aa01508e95dad..933eabc38c53cc6fa0dd12abe13e9da79f230154 100644
--- a/net/spdy/spdy_framer_test.cc
+++ b/net/spdy/spdy_framer_test.cc
@@ -191,6 +191,13 @@ class SpdyFramerTestUtil {
LOG(FATAL);
}
+ virtual void OnPriority(SpdyStreamId stream_id,
+ SpdyStreamId parent_stream_id,
+ uint8 weight,
+ bool exclusive) OVERRIDE {
+ // Do nothing.
+ }
+
char* ReleaseBuffer() {
CHECK(finished_);
return buffer_.release();
@@ -227,41 +234,41 @@ class TestSpdyVisitor : public SpdyFramerVisitorInterface,
static const size_t kDefaultHeaderBufferSize = 16 * 1024 * 1024;
explicit TestSpdyVisitor(SpdyMajorVersion version)
- : framer_(version),
- use_compression_(false),
- error_count_(0),
- syn_frame_count_(0),
- syn_reply_frame_count_(0),
- headers_frame_count_(0),
- push_promise_frame_count_(0),
- goaway_count_(0),
- setting_count_(0),
- settings_ack_sent_(0),
- settings_ack_received_(0),
- continuation_count_(0),
- altsvc_count_(0),
- test_altsvc_ir_(0),
- last_window_update_stream_(0),
- last_window_update_delta_(0),
- last_push_promise_stream_(0),
- last_push_promise_promised_stream_(0),
- data_bytes_(0),
- fin_frame_count_(0),
- fin_opaque_data_(),
- fin_flag_count_(0),
- zero_length_data_frame_count_(0),
- control_frame_header_data_count_(0),
- zero_length_control_frame_header_data_count_(0),
- data_frame_count_(0),
- last_payload_len_(0),
- last_frame_len_(0),
- header_buffer_(new char[kDefaultHeaderBufferSize]),
- header_buffer_length_(0),
- header_buffer_size_(kDefaultHeaderBufferSize),
- header_stream_id_(-1),
- header_control_type_(DATA),
- header_buffer_valid_(false) {
- }
+ : framer_(version),
+ use_compression_(false),
+ error_count_(0),
+ syn_frame_count_(0),
+ syn_reply_frame_count_(0),
+ headers_frame_count_(0),
+ push_promise_frame_count_(0),
+ goaway_count_(0),
+ setting_count_(0),
+ settings_ack_sent_(0),
+ settings_ack_received_(0),
+ continuation_count_(0),
+ altsvc_count_(0),
+ priority_count_(0),
+ test_altsvc_ir_(0),
+ last_window_update_stream_(0),
+ last_window_update_delta_(0),
+ last_push_promise_stream_(0),
+ last_push_promise_promised_stream_(0),
+ data_bytes_(0),
+ fin_frame_count_(0),
+ fin_opaque_data_(),
+ fin_flag_count_(0),
+ zero_length_data_frame_count_(0),
+ control_frame_header_data_count_(0),
+ zero_length_control_frame_header_data_count_(0),
+ data_frame_count_(0),
+ last_payload_len_(0),
+ last_frame_len_(0),
+ header_buffer_(new char[kDefaultHeaderBufferSize]),
+ header_buffer_length_(0),
+ header_buffer_size_(kDefaultHeaderBufferSize),
+ header_stream_id_(-1),
+ header_control_type_(DATA),
+ header_buffer_valid_(false) {}
virtual void OnError(SpdyFramer* f) OVERRIDE {
LOG(INFO) << "SpdyFramer Error: "
@@ -439,6 +446,13 @@ class TestSpdyVisitor : public SpdyFramerVisitorInterface,
last_frame_len_ = frame_len;
}
+ virtual void OnPriority(SpdyStreamId stream_id,
+ SpdyStreamId parent_stream_id,
+ uint8 weight,
+ bool exclusive) OVERRIDE {
+ ++priority_count_;
+ }
+
virtual void OnReceiveCompressedFrame(SpdyStreamId stream_id,
SpdyFrameType type,
size_t frame_len) OVERRIDE {
@@ -507,6 +521,7 @@ class TestSpdyVisitor : public SpdyFramerVisitorInterface,
int settings_ack_received_;
int continuation_count_;
int altsvc_count_;
+ int priority_count_;
SpdyAltSvcIR test_altsvc_ir_;
SpdyStreamId last_window_update_stream_;
uint32 last_window_update_delta_;
@@ -3023,6 +3038,27 @@ TEST_P(SpdyFramerTest, CreateAltSvc) {
CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData));
}
+TEST_P(SpdyFramerTest, CreatePriority) {
+ if (spdy_version_ <= SPDY3) {
+ return;
+ }
+
+ SpdyFramer framer(spdy_version_);
+
+ const char kDescription[] = "PRIORITY frame";
+ const char kType = static_cast<unsigned char>(
+ SpdyConstants::SerializeFrameType(spdy_version_, PRIORITY));
+ const unsigned char kFrameData[] = {
+ 0x00, 0x05, kType, 0x00,
+ 0x00, 0x00, 0x00, 0x02, // Stream ID = 2
+ 0x80, 0x00, 0x00, 0x01, // Exclusive dependency, parent stream ID = 1
+ 0x10, // Weight = 16
+ };
+ SpdyPriorityIR priority_ir(2, 1, 16, true);
+ scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(priority_ir));
+ CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData));
+}
+
TEST_P(SpdyFramerTest, ReadCompressedSynStreamHeaderBlock) {
SpdyFramer framer(spdy_version_);
SpdySynStreamIR syn_stream(1);
@@ -5382,20 +5418,19 @@ TEST_P(SpdyFramerTest, ReadPriority) {
if (spdy_version_ <= SPDY3) {
return;
}
+ SpdyFramer framer(spdy_version_);
+ SpdyPriorityIR priority(3, 1, 99, false);
+ scoped_ptr<SpdySerializedFrame> frame(framer.SerializePriority(priority));
+ testing::StrictMock<test::MockSpdyFramerVisitor> visitor;
+ framer.set_visitor(&visitor);
+ EXPECT_CALL(visitor, OnPriority(3, 1, 99, false));
+ framer.ProcessInput(frame->data(), frame->size());
- const unsigned char kFrameData[] = {
- 0x00, 0x05, 0x02, 0x00, // PRIORITY frame
- 0x00, 0x00, 0x00, 0x03, // stream ID 3
- 0x00, 0x00, 0x00, 0x01, // dependent on stream id 1
- 0x00 // weight 0
- };
-
- TestSpdyVisitor visitor(spdy_version_);
- visitor.SimulateInFramer(kFrameData, sizeof(kFrameData));
-
- EXPECT_EQ(SpdyFramer::SPDY_RESET, visitor.framer_.state());
- EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, visitor.framer_.error_code())
- << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code());
+ EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state());
+ EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code())
+ << SpdyFramer::ErrorCodeToString(framer.error_code());
+ // TODO(mlavan): once we actually maintain a priority tree,
+ // check that state is adjusted correctly.
}
// Tests handling of PRIORITY frame with incorrect size.
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698