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

Unified Diff: net/spdy/hpack_encoder_test.cc

Issue 243153003: HPACK optimal Huffman code instrumentation and UMA collection. (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
Index: net/spdy/hpack_encoder_test.cc
diff --git a/net/spdy/hpack_encoder_test.cc b/net/spdy/hpack_encoder_test.cc
index 316952edd0dcbd4fe4e91f628b5e3b0cb59ffc46..da9bff5a7c4a5444ad4aea29e2e39f2d121ca9de 100644
--- a/net/spdy/hpack_encoder_test.cc
+++ b/net/spdy/hpack_encoder_test.cc
@@ -23,6 +23,9 @@ class HpackEncoderPeer {
explicit HpackEncoderPeer(HpackEncoder* encoder)
: encoder_(encoder) {}
+ void UpdateCharacterCounts(StringPiece str) {
+ encoder_->UpdateCharacterCounts(str);
+ }
void set_max_string_literal_size(uint32 size) {
encoder_->max_string_literal_size_ = size;
}
@@ -112,6 +115,30 @@ TEST(HpackEncoderTest, HeaderTooLarge) {
EXPECT_FALSE(encoder.EncodeHeaderSet(header_set, &encoded_header_set));
}
+TEST(HpackEncoderTest, UpdateCharacterCounts) {
+ HpackEncoder encoder;
+ test::HpackEncoderPeer peer(&encoder);
+
+ std::vector<size_t> counts(256, 0);
+ size_t total_counts = 0;
+ encoder.SetCharCountsStorage(&counts, &total_counts);
+
+ char kTestString[] = "foo\0\1\xff""boo";
+ peer.UpdateCharacterCounts(
+ StringPiece(kTestString, arraysize(kTestString) - 1));
+
+ std::vector<size_t> expect(256, 0);
+ expect[static_cast<uint8>('f')] = 1;
+ expect[static_cast<uint8>('o')] = 4;
+ expect[static_cast<uint8>('\0')] = 1;
+ expect[static_cast<uint8>('\1')] = 1;
+ expect[static_cast<uint8>('\xff')] = 1;
+ expect[static_cast<uint8>('b')] = 1;
+
+ EXPECT_EQ(expect, counts);
+ EXPECT_EQ(9u, total_counts);
+}
+
} // namespace
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698