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

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: Disable experiment by default; raise publish threshold to 50K characters. 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 6c8d40988168721867be522f4caa327f118d51bd..33c001c8168fa053c6bfa59331540dbc1e4abeea 100644
--- a/net/spdy/hpack_encoder_test.cc
+++ b/net/spdy/hpack_encoder_test.cc
@@ -57,6 +57,9 @@ class HpackEncoderPeer {
void TakeString(string* out) {
encoder_->output_stream_.TakeString(out);
}
+ void UpdateCharacterCounts(StringPiece str) {
+ encoder_->UpdateCharacterCounts(str);
+ }
static void CookieToCrumbs(StringPiece cookie,
std::vector<StringPiece>* out) {
Representations tmp;
@@ -420,6 +423,27 @@ TEST_F(HpackEncoderTest, CookieToCrumbs) {
EXPECT_THAT(out, ElementsAre("foo", "bar", "baz", "bing", ""));
}
+TEST_F(HpackEncoderTest, UpdateCharacterCounts) {
+ 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