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

Unified Diff: net/spdy/spdy_framer_test.cc

Issue 9689078: SPDY - unforked spdy_framer and spdy_protocol tests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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/spdy_framer_test.cc
===================================================================
--- net/spdy/spdy_framer_test.cc (working copy)
+++ net/spdy/spdy_framer_test.cc (working copy)
@@ -14,7 +14,7 @@
namespace {
// Default SPDY version for unit tests.
-const int SPDY_VERSION_FOR_TESTS = 3;
+int SPDY_VERSION_FOR_TESTS = 2;
Ryan Hamilton 2012/03/13 19:59:12 I think I would make these member variables instea
ramant (doing other things) 2012/03/13 21:43:02 Done.
// The current default spdy version as a byte to be included in const
// byte arrays below. Name choice is unfortunate, but better to fit to four
@@ -31,7 +31,7 @@
namespace spdy {
-namespace test_spdy3 {
+namespace test {
static const size_t kMaxDecompressedSize = 1024;
@@ -449,7 +449,7 @@
SpdyCredential credential_;
};
-} // namespace test_spdy3
+} // namespace test
} // namespace spdy
@@ -467,13 +467,13 @@
using spdy::DATA_FLAG_COMPRESSED;
using spdy::DATA_FLAG_FIN;
using spdy::SYN_STREAM;
-using spdy::test_spdy3::CompareCharArraysWithHexError;
-using spdy::test_spdy3::SpdyFramerTestUtil;
-using spdy::test_spdy3::TestSpdyVisitor;
+using spdy::test::CompareCharArraysWithHexError;
+using spdy::test::SpdyFramerTestUtil;
+using spdy::test::TestSpdyVisitor;
namespace spdy {
-TEST(SpdyFrameBuilderSpdy3Test, WriteLimits) {
+TEST(SpdyFrameBuilderTest, WriteLimits) {
SpdyFrameBuilder builder(kLengthMask + 4);
// length field should fail.
EXPECT_FALSE(builder.WriteBytes(reinterpret_cast<const void*>(0x1),
@@ -488,11 +488,26 @@
EXPECT_EQ(4 + kLengthMask, static_cast<unsigned>(builder.length()));
}
-class SpdyFramerSpdy3Test : public PlatformTest {
- public:
+enum SpdyFramerTestTypes {
+ SPDY2,
+ SPDY3,
+};
+
+class SpdyFramerTest
+ : public ::testing::TestWithParam<SpdyFramerTestTypes> {
+ protected:
+ virtual void SetUp() {
+ if (GetParam() == SPDY2) {
+ kVer = 2;
+ SPDY_VERSION_FOR_TESTS = 2;
+ } else {
+ kVer = 3;
+ SPDY_VERSION_FOR_TESTS = 3;
+ }
+ }
+
virtual void TearDown() {}
- protected:
void CompareFrame(const std::string& description,
const SpdyFrame& actual_frame,
const unsigned char* expected,
@@ -534,8 +549,14 @@
};
+//-----------------------------------------------------------------------------
+// All tests are run with two different SPDY versions: SPDY/2 and SPDY/3.
+INSTANTIATE_TEST_CASE_P(SpdyFramerTests,
+ SpdyFramerTest,
+ ::testing::Values(SPDY2, SPDY3));
+
// Test that we can encode and decode a SpdyHeaderBlock in serialized form.
-TEST_F(SpdyFramerSpdy3Test, HeaderBlockInBuffer) {
+TEST_P(SpdyFramerTest, HeaderBlockInBuffer) {
SpdyHeaderBlock headers;
headers["alpha"] = "beta";
headers["gamma"] = "charlie";
@@ -558,7 +579,7 @@
}
// Test that if there's not a full frame, we fail to parse it.
-TEST_F(SpdyFramerSpdy3Test, UndersizedHeaderBlockInBuffer) {
+TEST_P(SpdyFramerTest, UndersizedHeaderBlockInBuffer) {
SpdyHeaderBlock headers;
headers["alpha"] = "beta";
headers["gamma"] = "charlie";
@@ -577,7 +598,7 @@
&new_headers));
}
-TEST_F(SpdyFramerSpdy3Test, OutOfOrderHeaders) {
+TEST_P(SpdyFramerTest, OutOfOrderHeaders) {
// Frame builder with plentiful buffer size.
SpdyFrameBuilder frame(1024);
@@ -616,7 +637,7 @@
&new_headers));
}
-TEST_F(SpdyFramerSpdy3Test, CreateCredential) {
+TEST_P(SpdyFramerTest, CreateCredential) {
SpdyFramer framer(kVer);
{
@@ -649,7 +670,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, ParseCredentialFrameData) {
+TEST_P(SpdyFramerTest, ParseCredentialFrameData) {
SpdyFramer framer(kVer);
{
@@ -687,7 +708,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, DuplicateHeader) {
+TEST_P(SpdyFramerTest, DuplicateHeader) {
// Frame builder with plentiful buffer size.
SpdyFrameBuilder frame(1024);
@@ -727,7 +748,7 @@
&new_headers));
}
-TEST_F(SpdyFramerSpdy3Test, MultiValueHeader) {
+TEST_P(SpdyFramerTest, MultiValueHeader) {
// Frame builder with plentiful buffer size.
SpdyFrameBuilder frame(1024);
@@ -765,7 +786,7 @@
EXPECT_EQ(value, new_headers.find("name")->second);
}
-TEST_F(SpdyFramerSpdy3Test, BasicCompression) {
+TEST_P(SpdyFramerTest, BasicCompression) {
SpdyHeaderBlock headers;
headers["server"] = "SpdyServer 1.0";
headers["date"] = "Mon 12 Jan 2009 12:12:12 PST";
@@ -811,7 +832,7 @@
SpdyFrame::kHeaderSize + uncompressed_frame->length()));
}
-TEST_F(SpdyFramerSpdy3Test, Basic) {
+TEST_P(SpdyFramerTest, Basic) {
const unsigned char kV2Input[] = {
0x80, kVer, 0x00, 0x01, // SYN Stream #1
0x00, 0x00, 0x00, 0x14,
@@ -943,7 +964,7 @@
}
// Test that the FIN flag on a data frame signifies EOF.
-TEST_F(SpdyFramerSpdy3Test, FinOnDataFrame) {
+TEST_P(SpdyFramerTest, FinOnDataFrame) {
const unsigned char kV2Input[] = {
0x80, kVer, 0x00, 0x01, // SYN Stream #1
0x00, 0x00, 0x00, 0x14,
@@ -1020,7 +1041,7 @@
}
// Test that the FIN flag on a SYN reply frame signifies EOF.
-TEST_F(SpdyFramerSpdy3Test, FinOnSynReplyFrame) {
+TEST_P(SpdyFramerTest, FinOnSynReplyFrame) {
const unsigned char kV2Input[] = {
0x80, kVer, 0x00, 0x01, // SYN Stream #1
0x00, 0x00, 0x00, 0x14,
@@ -1078,7 +1099,7 @@
EXPECT_EQ(0, visitor.data_frame_count_);
}
-TEST_F(SpdyFramerSpdy3Test, HeaderCompression) {
+TEST_P(SpdyFramerTest, HeaderCompression) {
SpdyFramer send_framer(kVer);
SpdyFramer recv_framer(kVer);
@@ -1157,7 +1178,7 @@
}
// Verify we don't leak when we leave streams unclosed
-TEST_F(SpdyFramerSpdy3Test, UnclosedStreamDataCompressors) {
+TEST_P(SpdyFramerTest, UnclosedStreamDataCompressors) {
SpdyFramer send_framer(kVer);
send_framer.set_enable_compression(true);
@@ -1210,7 +1231,7 @@
// Verify we can decompress the stream even if handed over to the
// framer 1 byte at a time.
-TEST_F(SpdyFramerSpdy3Test, UnclosedStreamDataCompressorsOneByteAtATime) {
+TEST_P(SpdyFramerTest, UnclosedStreamDataCompressorsOneByteAtATime) {
SpdyFramer send_framer(kVer);
send_framer.set_enable_compression(true);
@@ -1271,7 +1292,7 @@
EXPECT_EQ(0, send_framer.num_stream_decompressors());
}
-TEST_F(SpdyFramerSpdy3Test, WindowUpdateFrame) {
+TEST_P(SpdyFramerTest, WindowUpdateFrame) {
SpdyFramer framer(kVer);
scoped_ptr<SpdyWindowUpdateControlFrame> window_update_frame(
framer.CreateWindowUpdate(1, 0x12345678));
@@ -1288,7 +1309,7 @@
memcmp(window_update_frame->data(), expected_data_frame, 16));
}
-TEST_F(SpdyFramerSpdy3Test, CreateDataFrame) {
+TEST_P(SpdyFramerTest, CreateDataFrame) {
SpdyFramer framer(kVer);
{
@@ -1374,7 +1395,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, CreateSynStreamUncompressed) {
+TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) {
SpdyFramer framer(kVer);
framer.set_enable_compression(false);
@@ -1516,7 +1537,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, CreateSynStreamCompressed) {
+TEST_P(SpdyFramerTest, CreateSynStreamCompressed) {
SpdyFramer framer(kVer);
framer.set_enable_compression(true);
@@ -1568,7 +1589,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, CreateSynReplyUncompressed) {
+TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) {
SpdyFramer framer(kVer);
framer.set_enable_compression(false);
@@ -1695,7 +1716,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, CreateSynReplyCompressed) {
+TEST_P(SpdyFramerTest, CreateSynReplyCompressed) {
SpdyFramer framer(kVer);
framer.set_enable_compression(true);
@@ -1742,7 +1763,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, CreateRstStream) {
+TEST_P(SpdyFramerTest, CreateRstStream) {
SpdyFramer framer(kVer);
{
@@ -1786,7 +1807,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, CreateSettings) {
+TEST_P(SpdyFramerTest, CreateSettings) {
SpdyFramer framer(kVer);
{
@@ -1905,7 +1926,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, CreatePingFrame) {
+TEST_P(SpdyFramerTest, CreatePingFrame) {
SpdyFramer framer(kVer);
{
@@ -1922,7 +1943,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, CreateGoAway) {
+TEST_P(SpdyFramerTest, CreateGoAway) {
SpdyFramer framer(kVer);
{
@@ -1950,7 +1971,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, CreateHeadersUncompressed) {
+TEST_P(SpdyFramerTest, CreateHeadersUncompressed) {
SpdyFramer framer(kVer);
framer.set_enable_compression(false);
@@ -2077,7 +2098,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, CreateHeadersCompressed) {
+TEST_P(SpdyFramerTest, CreateHeadersCompressed) {
SpdyFramer framer(kVer);
framer.set_enable_compression(true);
@@ -2124,7 +2145,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, CreateWindowUpdate) {
+TEST_P(SpdyFramerTest, CreateWindowUpdate) {
SpdyFramer framer(kVer);
{
@@ -2166,7 +2187,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, DuplicateFrame) {
+TEST_P(SpdyFramerTest, DuplicateFrame) {
SpdyFramer framer(kVer);
{
@@ -2189,7 +2210,7 @@
// the framer to overrun the buffer, and smash other heap contents. This test
// relies on the debug version of the heap manager, which checks for buffer
// overrun errors during delete processing. Regression test for b/2974814.
-TEST_F(SpdyFramerSpdy3Test, ExpandBuffer_HeapSmash) {
+TEST_P(SpdyFramerTest, ExpandBuffer_HeapSmash) {
// Sweep through the area of problematic values, to make sure we always cover
// the danger zone, even if it moves around at bit due to SPDY changes.
for (uint16 val2_len = SpdyFramer::kControlFrameBufferInitialSize - 50;
@@ -2217,7 +2238,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, ControlFrameSizesAreValidated) {
+TEST_P(SpdyFramerTest, ControlFrameSizesAreValidated) {
// Create a GoAway frame that has a few extra bytes at the end.
// We create enough overhead to require the framer to expand its frame buffer.
size_t overhead = SpdyFramer::kUncompressedControlFrameBufferInitialSize;
@@ -2250,7 +2271,7 @@
EXPECT_EQ(1, visitor.goaway_count_); // Unchanged from before.
}
-TEST_F(SpdyFramerSpdy3Test, ReadZeroLenSettingsFrame) {
+TEST_P(SpdyFramerTest, ReadZeroLenSettingsFrame) {
SpdyFramer framer(kVer);
SpdySettings settings;
scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings));
@@ -2265,7 +2286,7 @@
}
// Tests handling of SETTINGS frames with invalid length.
-TEST_F(SpdyFramerSpdy3Test, ReadBogusLenSettingsFrame) {
+TEST_P(SpdyFramerTest, ReadBogusLenSettingsFrame) {
SpdyFramer framer(kVer);
SpdySettings settings;
// Add a setting to pad the frame so that we don't get a buffer overflow when
@@ -2283,7 +2304,7 @@
}
// Tests handling of SETTINGS frames larger than the frame buffer size.
-TEST_F(SpdyFramerSpdy3Test, ReadLargeSettingsFrame) {
+TEST_P(SpdyFramerTest, ReadLargeSettingsFrame) {
SpdyFramer framer(kVer);
SpdySettings settings;
settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002));
@@ -2322,7 +2343,7 @@
}
// Tests handling of SETTINGS frame with duplicate entries.
-TEST_F(SpdyFramerSpdy3Test, ReadDuplicateSettings) {
+TEST_P(SpdyFramerTest, ReadDuplicateSettings) {
SpdyFramer framer(kVer);
SpdySettings settings;
settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002));
@@ -2342,7 +2363,7 @@
}
// Tests handling of SETTINGS frame with entries out of order.
-TEST_F(SpdyFramerSpdy3Test, ReadOutOfOrderSettings) {
+TEST_P(SpdyFramerTest, ReadOutOfOrderSettings) {
SpdyFramer framer(kVer);
SpdySettings settings;
settings.push_back(SpdySetting(SettingsFlagsAndId(0, 2), 0x00000002));
@@ -2361,7 +2382,7 @@
EXPECT_EQ(1, visitor.settings_frame_count_);
}
-TEST_F(SpdyFramerSpdy3Test, ReadCredentialFrame) {
+TEST_P(SpdyFramerTest, ReadCredentialFrame) {
SpdyCredential credential;
credential.slot = 3;
credential.proof = "proof";
@@ -2388,7 +2409,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, ReadCredentialFrameWithCorruptProof) {
+TEST_P(SpdyFramerTest, ReadCredentialFrameWithCorruptProof) {
SpdyCredential credential;
credential.slot = 3;
credential.proof = "proof";
@@ -2410,7 +2431,7 @@
EXPECT_EQ(1, visitor.error_count_);
}
-TEST_F(SpdyFramerSpdy3Test, ReadCredentialFrameWithCorruptCertificate) {
+TEST_P(SpdyFramerTest, ReadCredentialFrameWithCorruptCertificate) {
SpdyCredential credential;
credential.slot = 3;
credential.proof = "proof";
@@ -2432,7 +2453,7 @@
EXPECT_EQ(1, visitor.error_count_);
}
-TEST_F(SpdyFramerSpdy3Test, ReadGarbage) {
+TEST_P(SpdyFramerTest, ReadGarbage) {
SpdyFramer framer(kVer);
unsigned char garbage_frame[256];
memset(garbage_frame, ~0, sizeof(garbage_frame));
@@ -2442,7 +2463,7 @@
EXPECT_EQ(1, visitor.error_count_);
}
-TEST_F(SpdyFramerSpdy3Test, ReadGarbageWithValidVersion) {
+TEST_P(SpdyFramerTest, ReadGarbageWithValidVersion) {
SpdyFramer framer(kVer);
char garbage_frame[256];
memset(garbage_frame, ~0, sizeof(garbage_frame));
@@ -2456,7 +2477,7 @@
EXPECT_EQ(1, visitor.error_count_);
}
-TEST_F(SpdyFramerSpdy3Test, StateToStringTest) {
+TEST_P(SpdyFramerTest, StateToStringTest) {
EXPECT_STREQ("ERROR",
SpdyFramer::StateToString(SpdyFramer::SPDY_ERROR));
EXPECT_STREQ("DONE",
@@ -2494,7 +2515,7 @@
SpdyFramer::SPDY_SETTINGS_FRAME_PAYLOAD + 1));
}
-TEST_F(SpdyFramerSpdy3Test, ErrorCodeToStringTest) {
+TEST_P(SpdyFramerTest, ErrorCodeToStringTest) {
EXPECT_STREQ("NO_ERROR",
SpdyFramer::ErrorCodeToString(SpdyFramer::SPDY_NO_ERROR));
EXPECT_STREQ("INVALID_CONTROL_FRAME",
@@ -2519,7 +2540,7 @@
SpdyFramer::ErrorCodeToString(SpdyFramer::LAST_ERROR));
}
-TEST_F(SpdyFramerSpdy3Test, StatusCodeToStringTest) {
+TEST_P(SpdyFramerTest, StatusCodeToStringTest) {
EXPECT_STREQ("INVALID",
SpdyFramer::StatusCodeToString(INVALID));
EXPECT_STREQ("PROTOCOL_ERROR",
@@ -2540,7 +2561,7 @@
SpdyFramer::StatusCodeToString(NUM_STATUS_CODES));
}
-TEST_F(SpdyFramerSpdy3Test, ControlTypeToStringTest) {
+TEST_P(SpdyFramerTest, ControlTypeToStringTest) {
EXPECT_STREQ("SYN_STREAM",
SpdyFramer::ControlTypeToString(SYN_STREAM));
EXPECT_STREQ("SYN_REPLY",
@@ -2565,7 +2586,7 @@
SpdyFramer::ControlTypeToString(NUM_CONTROL_FRAME_TYPES));
}
-TEST_F(SpdyFramerSpdy3Test, GetMinimumControlFrameSizeTest) {
+TEST_P(SpdyFramerTest, GetMinimumControlFrameSizeTest) {
EXPECT_EQ(SpdySynStreamControlFrame::size(),
SpdyFramer::GetMinimumControlFrameSize(SYN_STREAM));
EXPECT_EQ(SpdySynReplyControlFrame::size(),
@@ -2590,7 +2611,7 @@
SpdyFramer::GetMinimumControlFrameSize(NUM_CONTROL_FRAME_TYPES));
}
-TEST_F(SpdyFramerSpdy3Test, CatchProbableHttpResponse) {
+TEST_P(SpdyFramerTest, CatchProbableHttpResponse) {
SpdyFramerTestUtil::DecompressionVisitor visitor;
visitor.set_allow_data_frames(true);
{
@@ -2607,7 +2628,7 @@
}
}
-TEST_F(SpdyFramerSpdy3Test, SettingsFlagsAndId) {
+TEST_P(SpdyFramerTest, SettingsFlagsAndId) {
const uint32 kId = 0x020304;
const uint32 kFlags = 0x01;
const uint32 kWireFormat =

Powered by Google App Engine
This is Rietveld 408576698