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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 static const char *const kBaseValue; | 102 static const char *const kBaseValue; |
103 | 103 |
104 // Number of headers and header blocks used in the tests. | 104 // Number of headers and header blocks used in the tests. |
105 static const int kNumHeadersInBlock = 10; | 105 static const int kNumHeadersInBlock = 10; |
106 static const int kNumHeaderBlocks = 10; | 106 static const int kNumHeaderBlocks = 10; |
107 }; | 107 }; |
108 | 108 |
109 const char *const SpdyHeadersBlockParserTest::kBaseKey = "test_key"; | 109 const char *const SpdyHeadersBlockParserTest::kBaseKey = "test_key"; |
110 const char *const SpdyHeadersBlockParserTest::kBaseValue = "test_value"; | 110 const char *const SpdyHeadersBlockParserTest::kBaseValue = "test_value"; |
111 | 111 |
112 // All tests are run with 3 different SPDY versions: SPDY/2, SPDY/3, SPDY/4. | |
113 INSTANTIATE_TEST_CASE_P(SpdyHeadersBlockParserTests, | 112 INSTANTIATE_TEST_CASE_P(SpdyHeadersBlockParserTests, |
114 SpdyHeadersBlockParserTest, | 113 SpdyHeadersBlockParserTest, |
115 ::testing::Values(SPDY2, SPDY3, SPDY4)); | 114 ::testing::Values(SPDY3, SPDY4)); |
116 | 115 |
117 TEST_P(SpdyHeadersBlockParserTest, BasicTest) { | 116 TEST_P(SpdyHeadersBlockParserTest, BasicTest) { |
118 // Sanity test, verify that we parse out correctly a block with | 117 // Sanity test, verify that we parse out correctly a block with |
119 // a single key-value pair and that we notify when we start and finish | 118 // a single key-value pair and that we notify when we start and finish |
120 // handling a headers block. | 119 // handling a headers block. |
121 string headers(CreateHeaders(1, false)); | 120 string headers(CreateHeaders(1, false)); |
122 | 121 |
123 EXPECT_CALL(handler_, OnHeaderBlock(1, 1)).Times(1); | 122 EXPECT_CALL(handler_, OnHeaderBlock(1, 1)).Times(1); |
124 | 123 |
125 std::string expect_key = kBaseKey + IntToString(0); | 124 std::string expect_key = kBaseKey + IntToString(0); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 string expect_value = kBaseValue + IntToString(0); | 247 string expect_value = kBaseValue + IntToString(0); |
249 EXPECT_CALL(handler_, OnHeader(1, StringPiece(expect_key), | 248 EXPECT_CALL(handler_, OnHeader(1, StringPiece(expect_key), |
250 StringPiece(expect_value))).Times(1); | 249 StringPiece(expect_value))).Times(1); |
251 | 250 |
252 EXPECT_FALSE(parser_-> | 251 EXPECT_FALSE(parser_-> |
253 HandleControlFrameHeadersData(1, headers.c_str(), headers.length())); | 252 HandleControlFrameHeadersData(1, headers.c_str(), headers.length())); |
254 EXPECT_EQ(SpdyHeadersBlockParser::TOO_MUCH_DATA, parser_->get_error()); | 253 EXPECT_EQ(SpdyHeadersBlockParser::TOO_MUCH_DATA, parser_->get_error()); |
255 } | 254 } |
256 | 255 |
257 } // namespace net | 256 } // namespace net |
OLD | NEW |