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

Unified Diff: net/spdy/hpack_input_stream_test.cc

Issue 265763011: Land recent SPDY changes (through 66310528) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/hpack_input_stream.cc ('k') | net/spdy/hpack_output_stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/hpack_input_stream_test.cc
diff --git a/net/spdy/hpack_input_stream_test.cc b/net/spdy/hpack_input_stream_test.cc
index b54174565c6a7b430abfd31057642e44e274293b..215d1c6959d9d319e74acec57675132bc06d9408 100644
--- a/net/spdy/hpack_input_stream_test.cc
+++ b/net/spdy/hpack_input_stream_test.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/strings/string_piece.h"
#include "net/spdy/hpack_constants.h"
+#include "net/spdy/spdy_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
@@ -19,26 +20,28 @@ namespace {
using base::StringPiece;
using std::string;
+using test::a2b_hex;
const size_t kLiteralBound = 1024;
class HpackInputStreamTest : public ::testing::Test {
+ protected:
virtual void SetUp() {
std::vector<HpackHuffmanSymbol> code = HpackHuffmanCode();
EXPECT_TRUE(huffman_table.Initialize(&code[0], code.size()));
}
- protected:
HpackHuffmanTable huffman_table;
};
-const char kEncodedFixture[] = "\x33" // Length prefix.
- "\xc5\xad\xb7\x7f\x87\x6f\xc7\xfb\xf7\xfd\xbf\xbe\xbf\xf3\xf7\xf4"
- "\xfb\x7e\xbb\xbe\x9f\x5f\x87\xe3\x7f\xef\xed\xfa\xee\xfa\x7c\x3f"
- "\x1d\x5d\x1a\x23\xce\x54\x64\x36\xcd\x49\x4b\xd5\xd1\xcc\x5f\x05"
- "\x35\x96\x9b";
+// Hex representation of encoded length and Huffman string.
+const char kEncodedHuffmanFixture[] = "31" // Length prefix.
+ "e0d6cf9f6e8f9fd3e5f6fa76fefd3c7e"
+ "df9eff1f2f0f3cfe9f6fcf7f8f879f61"
+ "ad4f4cc9a973a2200ec3725e18b1b74e"
+ "3f";
-const char kDecodedFixture[] =
+const char kDecodedHuffmanFixture[] =
"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1";
// Utility function to decode an assumed-valid uint32 with an N-bit
@@ -49,7 +52,7 @@ uint32 DecodeValidUint32(uint8 N, StringPiece str) {
HpackInputStream input_stream(kLiteralBound, str);
input_stream.SetBitOffsetForTest(8 - N);
uint32 I;
- EXPECT_TRUE(input_stream.DecodeNextUint32ForTest(&I));
+ EXPECT_TRUE(input_stream.DecodeNextUint32(&I));
return I;
}
@@ -61,7 +64,7 @@ void ExpectDecodeUint32Invalid(uint8 N, StringPiece str) {
HpackInputStream input_stream(kLiteralBound, str);
input_stream.SetBitOffsetForTest(8 - N);
uint32 I;
- EXPECT_FALSE(input_stream.DecodeNextUint32ForTest(&I));
+ EXPECT_FALSE(input_stream.DecodeNextUint32(&I));
}
uint32 bits32(const string& bitstring) {
@@ -514,19 +517,19 @@ TEST_F(HpackInputStreamTest, DecodeNextIdentityStringNotEnoughInput) {
}
TEST_F(HpackInputStreamTest, DecodeNextHuffmanString) {
- string output, input(kEncodedFixture, arraysize(kEncodedFixture)-1);
- HpackInputStream input_stream(arraysize(kDecodedFixture)-1, input);
+ string output, input(a2b_hex(kEncodedHuffmanFixture));
+ HpackInputStream input_stream(arraysize(kDecodedHuffmanFixture)-1, input);
EXPECT_TRUE(input_stream.HasMoreData());
EXPECT_TRUE(input_stream.DecodeNextHuffmanString(huffman_table, &output));
- EXPECT_EQ(kDecodedFixture, output);
+ EXPECT_EQ(kDecodedHuffmanFixture, output);
EXPECT_FALSE(input_stream.HasMoreData());
}
TEST_F(HpackInputStreamTest, DecodeNextHuffmanStringSizeLimit) {
- string output, input(kEncodedFixture, arraysize(kEncodedFixture)-1);
+ string output, input(a2b_hex(kEncodedHuffmanFixture));
// Max string literal is one byte shorter than the decoded fixture.
- HpackInputStream input_stream(arraysize(kDecodedFixture)-2, input);
+ HpackInputStream input_stream(arraysize(kDecodedHuffmanFixture)-2, input);
// Decoded string overflows the max string literal.
EXPECT_TRUE(input_stream.HasMoreData());
@@ -534,9 +537,9 @@ TEST_F(HpackInputStreamTest, DecodeNextHuffmanStringSizeLimit) {
}
TEST_F(HpackInputStreamTest, DecodeNextHuffmanStringNotEnoughInput) {
- string output, input(kEncodedFixture, arraysize(kEncodedFixture)-1);
+ string output, input(a2b_hex(kEncodedHuffmanFixture));
input[0]++; // Input prefix is one byte larger than available input.
- HpackInputStream input_stream(arraysize(kDecodedFixture)-1, input);
+ HpackInputStream input_stream(arraysize(kDecodedHuffmanFixture)-1, input);
// Not enough buffer for declared encoded length.
EXPECT_TRUE(input_stream.HasMoreData());
« no previous file with comments | « net/spdy/hpack_input_stream.cc ('k') | net/spdy/hpack_output_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698