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

Unified Diff: net/spdy/spdy_framer_test.cc

Issue 12224019: Add SpdyFramerDebugVisitorInterface for later usage in stats collecting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test failures, add OVERRIDE Created 7 years, 10 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 98320f6e9d61be7336b62361eb99468e0e8e4639..27dd87650a49c093b893b4305f7dfaa4f0d5278e 100644
--- a/net/spdy/spdy_framer_test.cc
+++ b/net/spdy/spdy_framer_test.cc
@@ -301,7 +301,8 @@ void CompareCharArraysWithHexError(
<< HexDumpWithMarks(actual, actual_len, marks.get(), max_len);
}
-class TestSpdyVisitor : public SpdyFramerVisitorInterface {
+class TestSpdyVisitor : public SpdyFramerVisitorInterface,
+ public SpdyFramerDebugVisitorInterface {
public:
static const size_t kDefaultHeaderBufferSize = 16 * 1024;
static const size_t kDefaultCredentialBufferSize = 16 * 1024;
@@ -323,6 +324,8 @@ class TestSpdyVisitor : public SpdyFramerVisitorInterface {
control_frame_header_data_count_(0),
zero_length_control_frame_header_data_count_(0),
data_frame_count_(0),
+ last_decompressed_size_(0),
+ last_compressed_size_(0),
header_buffer_(new char[kDefaultHeaderBufferSize]),
header_buffer_length_(0),
header_buffer_size_(kDefaultHeaderBufferSize),
@@ -334,21 +337,21 @@ class TestSpdyVisitor : public SpdyFramerVisitorInterface {
credential_buffer_size_(kDefaultCredentialBufferSize) {
}
- void OnError(SpdyFramer* f) {
+ virtual void OnError(SpdyFramer* f) OVERRIDE {
LOG(INFO) << "SpdyFramer Error: "
<< SpdyFramer::ErrorCodeToString(f->error_code());
error_count_++;
}
- void OnDataFrameHeader(const SpdyDataFrame* frame) {
+ virtual void OnDataFrameHeader(const SpdyDataFrame* frame) OVERRIDE {
data_frame_count_++;
header_stream_id_ = frame->stream_id();
}
- void OnStreamFrameData(SpdyStreamId stream_id,
- const char* data,
- size_t len,
- SpdyDataFlags flags) {
+ virtual void OnStreamFrameData(SpdyStreamId stream_id,
+ const char* data,
+ size_t len,
+ SpdyDataFlags flags) OVERRIDE {
EXPECT_EQ(header_stream_id_, stream_id);
if (len == 0)
++zero_length_data_frame_count_;
@@ -368,7 +371,7 @@ class TestSpdyVisitor : public SpdyFramerVisitorInterface {
SpdyPriority priority,
uint8 credential_slot,
bool fin,
- bool unidirectional) {
+ bool unidirectional) OVERRIDE {
syn_frame_count_++;
InitHeaderStreaming(SYN_STREAM, stream_id);
if (fin) {
@@ -376,7 +379,7 @@ class TestSpdyVisitor : public SpdyFramerVisitorInterface {
}
}
- virtual void OnSynReply(SpdyStreamId stream_id, bool fin) {
+ virtual void OnSynReply(SpdyStreamId stream_id, bool fin) OVERRIDE {
syn_reply_frame_count_++;
InitHeaderStreaming(HEADERS, stream_id);
if (fin) {
@@ -384,7 +387,7 @@ class TestSpdyVisitor : public SpdyFramerVisitorInterface {
}
}
- virtual void OnHeaders(SpdyStreamId stream_id, bool fin) {
+ virtual void OnHeaders(SpdyStreamId stream_id, bool fin) OVERRIDE {
headers_frame_count_++;
InitHeaderStreaming(SYN_REPLY, stream_id);
if (fin) {
@@ -392,36 +395,39 @@ class TestSpdyVisitor : public SpdyFramerVisitorInterface {
}
}
- virtual void OnSetting(SpdySettingsIds id, uint8 flags, uint32 value) {
+ virtual void OnSetting(
+ SpdySettingsIds id, uint8 flags, uint32 value) OVERRIDE {
setting_count_++;
}
virtual void OnControlFrameCompressed(
const SpdyControlFrame& uncompressed_frame,
- const SpdyControlFrame& compressed_frame) {
+ const SpdyControlFrame& compressed_frame) OVERRIDE {
}
- virtual void OnPing(uint32 unique_id) {
+ virtual void OnPing(uint32 unique_id) OVERRIDE {
DLOG(FATAL);
}
- virtual void OnRstStream(SpdyStreamId stream_id, SpdyStatusCodes status) {
+ virtual void OnRstStream(SpdyStreamId stream_id,
+ SpdyStatusCodes status) OVERRIDE {
fin_frame_count_++;
}
virtual void OnGoAway(SpdyStreamId last_accepted_stream_id,
- SpdyGoAwayStatus status) {
+ SpdyGoAwayStatus status) OVERRIDE {
goaway_count_++;
}
- virtual void OnWindowUpdate(SpdyStreamId stream_id, int delta_window_size) {
+ virtual void OnWindowUpdate(SpdyStreamId stream_id,
+ int delta_window_size) OVERRIDE {
last_window_update_stream_ = stream_id;
last_window_update_delta_ = delta_window_size;
}
- bool OnControlFrameHeaderData(SpdyStreamId stream_id,
- const char* header_data,
- size_t len) {
+ virtual bool OnControlFrameHeaderData(SpdyStreamId stream_id,
+ const char* header_data,
+ size_t len) OVERRIDE {
++control_frame_header_data_count_;
CHECK_EQ(header_stream_id_, stream_id);
if (len == 0) {
@@ -443,8 +449,8 @@ class TestSpdyVisitor : public SpdyFramerVisitorInterface {
return true;
}
- bool OnCredentialFrameData(const char* credential_data,
- size_t len) {
+ virtual bool OnCredentialFrameData(const char* credential_data,
+ size_t len) OVERRIDE {
if (len == 0) {
if (!framer_.ParseCredentialData(credential_buffer_.get(),
credential_buffer_length_,
@@ -464,6 +470,12 @@ class TestSpdyVisitor : public SpdyFramerVisitorInterface {
return true;
}
+ virtual void OnCompressedHeaderBlock(size_t decompressed_size,
+ size_t compressed_size) OVERRIDE {
+ last_decompressed_size_ = decompressed_size;
+ last_compressed_size_ = compressed_size;
+ }
+
// Convenience function which runs a framer simulation with particular input.
void SimulateInFramer(const unsigned char* input, size_t size) {
framer_.set_enable_compression(use_compression_);
@@ -531,6 +543,8 @@ class TestSpdyVisitor : public SpdyFramerVisitorInterface {
// The count of zero-length control frame header data chunks received.
int zero_length_control_frame_header_data_count_;
int data_frame_count_;
+ size_t last_decompressed_size_;
+ size_t last_compressed_size_;
// Header block streaming state:
scoped_array<char> header_buffer_;
@@ -892,7 +906,9 @@ TEST_P(SpdyFramerTest, BasicCompression) {
headers["content-type"] = "text/html";
headers["content-length"] = "12";
+ TestSpdyVisitor visitor(spdy_version_);
SpdyFramer framer(spdy_version_);
+ framer.set_debug_visitor(&visitor);
framer.set_enable_compression(true);
scoped_ptr<SpdySynStreamControlFrame> frame1(
framer.CreateSynStream(1, // stream id
@@ -902,6 +918,26 @@ TEST_P(SpdyFramerTest, BasicCompression) {
CONTROL_FLAG_NONE,
true, // compress
&headers));
+ if (IsSpdy2()) {
+ EXPECT_EQ(139u, visitor.last_decompressed_size_);
+ EXPECT_EQ(
+#if defined(USE_SYSTEM_ZLIB)
+ 93u,
akalin 2013/02/06 00:25:07 I do it this way instead of just copying the line
akalin 2013/02/06 00:29:01 Oh. looks like only "decompressed" actually chang
Ryan Hamilton 2013/02/06 00:32:30 Either way is fine with me.
+#else // !defined(USE_SYSTEM_ZLIB)
+ 135u,
+#endif // !defined(USE_SYSTEM_ZLIB)
+ visitor.last_compressed_size_);
+ EXPECT_EQ(135u, visitor.last_compressed_size_);
+ } else {
+ EXPECT_EQ(165u, visitor.last_decompressed_size_);
+ EXPECT_EQ(
+#if defined(USE_SYSTEM_ZLIB)
+ 72u,
+#else // !defined(USE_SYSTEM_ZLIB)
+ 117u,
+#endif // !defined(USE_SYSTEM_ZLIB)
+ visitor.last_compressed_size_);
+ }
scoped_ptr<SpdySynStreamControlFrame> frame2(
framer.CreateSynStream(1, // stream id
0, // associated stream id
« 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