OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/spdy/spdy_headers_block_parser.h" | 5 #include "net/spdy/spdy_headers_block_parser.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 static const char *const kBaseValue; | 104 static const char *const kBaseValue; |
105 | 105 |
106 // Number of headers and header blocks used in the tests. | 106 // Number of headers and header blocks used in the tests. |
107 static const int kNumHeadersInBlock = 10; | 107 static const int kNumHeadersInBlock = 10; |
108 static const int kNumHeaderBlocks = 10; | 108 static const int kNumHeaderBlocks = 10; |
109 }; | 109 }; |
110 | 110 |
111 const char *const SpdyHeadersBlockParserTest::kBaseKey = "test_key"; | 111 const char *const SpdyHeadersBlockParserTest::kBaseKey = "test_key"; |
112 const char *const SpdyHeadersBlockParserTest::kBaseValue = "test_value"; | 112 const char *const SpdyHeadersBlockParserTest::kBaseValue = "test_value"; |
113 | 113 |
114 // All tests are run with 3 different SPDY versions: SPDY/2, SPDY/3, SPDY/4. | |
115 INSTANTIATE_TEST_CASE_P(SpdyHeadersBlockParserTests, | 114 INSTANTIATE_TEST_CASE_P(SpdyHeadersBlockParserTests, |
116 SpdyHeadersBlockParserTest, | 115 SpdyHeadersBlockParserTest, |
117 ::testing::Values(SPDY2, SPDY3, SPDY4)); | 116 ::testing::Values(SPDY3, SPDY4)); |
118 | 117 |
119 TEST_P(SpdyHeadersBlockParserTest, BasicTest) { | 118 TEST_P(SpdyHeadersBlockParserTest, BasicTest) { |
120 // Sanity test, verify that we parse out correctly a block with | 119 // Sanity test, verify that we parse out correctly a block with |
121 // a single key-value pair and that we notify when we start and finish | 120 // a single key-value pair and that we notify when we start and finish |
122 // handling a headers block. | 121 // handling a headers block. |
123 string headers(CreateHeaders(1, false)); | 122 string headers(CreateHeaders(1, false)); |
124 | 123 |
125 EXPECT_CALL(handler_, OnHeaderBlock(1, 1)).Times(1); | 124 EXPECT_CALL(handler_, OnHeaderBlock(1, 1)).Times(1); |
126 | 125 |
127 std::string expect_key = kBaseKey + IntToString(0); | 126 std::string expect_key = kBaseKey + IntToString(0); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 string expect_value = kBaseValue + IntToString(0); | 249 string expect_value = kBaseValue + IntToString(0); |
251 EXPECT_CALL(handler_, OnHeader(1, StringPiece(expect_key), | 250 EXPECT_CALL(handler_, OnHeader(1, StringPiece(expect_key), |
252 StringPiece(expect_value))).Times(1); | 251 StringPiece(expect_value))).Times(1); |
253 | 252 |
254 EXPECT_FALSE(parser_-> | 253 EXPECT_FALSE(parser_-> |
255 HandleControlFrameHeadersData(1, headers.c_str(), headers.length())); | 254 HandleControlFrameHeadersData(1, headers.c_str(), headers.length())); |
256 EXPECT_EQ(SpdyHeadersBlockParser::TOO_MUCH_DATA, parser_->get_error()); | 255 EXPECT_EQ(SpdyHeadersBlockParser::TOO_MUCH_DATA, parser_->get_error()); |
257 } | 256 } |
258 | 257 |
259 } // namespace net | 258 } // namespace net |
OLD | NEW |