OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/quic/core/quic_headers_stream.h" | 5 #include "net/quic/core/quic_headers_stream.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "net/quic/core/quic_bug_tracker.h" | 10 #include "net/quic/core/quic_bug_tracker.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 using testing::InSequence; | 33 using testing::InSequence; |
34 using testing::Invoke; | 34 using testing::Invoke; |
35 using testing::Return; | 35 using testing::Return; |
36 using testing::StrictMock; | 36 using testing::StrictMock; |
37 using testing::WithArgs; | 37 using testing::WithArgs; |
38 using testing::_; | 38 using testing::_; |
39 | 39 |
40 // TODO(bnc): Merge these correctly. | 40 // TODO(bnc): Merge these correctly. |
41 bool FLAGS_use_http2_frame_decoder_adapter; | 41 bool FLAGS_use_http2_frame_decoder_adapter; |
42 bool FLAGS_spdy_use_hpack_decoder2; | 42 bool FLAGS_spdy_use_hpack_decoder2; |
43 bool FLAGS_spdy_framer_use_new_methods2; | 43 bool FLAGS_spdy_framer_use_new_methods3; |
44 | 44 |
45 namespace net { | 45 namespace net { |
46 namespace test { | 46 namespace test { |
47 | 47 |
48 class MockHpackDebugVisitor : public QuicHeadersStream::HpackDebugVisitor { | 48 class MockHpackDebugVisitor : public QuicHeadersStream::HpackDebugVisitor { |
49 public: | 49 public: |
50 explicit MockHpackDebugVisitor() : HpackDebugVisitor() {} | 50 explicit MockHpackDebugVisitor() : HpackDebugVisitor() {} |
51 | 51 |
52 MOCK_METHOD1(OnUseEntry, void(QuicTime::Delta elapsed)); | 52 MOCK_METHOD1(OnUseEntry, void(QuicTime::Delta elapsed)); |
53 | 53 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 ostream& operator<<(ostream& os, HpackDecoderChoice v) { | 164 ostream& operator<<(ostream& os, HpackDecoderChoice v) { |
165 switch (v) { | 165 switch (v) { |
166 case HPACK_DECODER_SPDY: | 166 case HPACK_DECODER_SPDY: |
167 return os << "SPDY"; | 167 return os << "SPDY"; |
168 case HPACK_DECODER_NEW: | 168 case HPACK_DECODER_NEW: |
169 return os << "NEW"; | 169 return os << "NEW"; |
170 } | 170 } |
171 return os; | 171 return os; |
172 } | 172 } |
173 | 173 |
174 typedef std:: | 174 typedef testing:: |
175 tuple<QuicVersion, Perspective, Http2DecoderChoice, HpackDecoderChoice> | 175 tuple<QuicVersion, Perspective, Http2DecoderChoice, HpackDecoderChoice> |
176 TestParamsTuple; | 176 TestParamsTuple; |
177 | 177 |
178 struct TestParams { | 178 struct TestParams { |
179 explicit TestParams(TestParamsTuple params) | 179 explicit TestParams(TestParamsTuple params) |
180 : version(std::get<0>(params)), | 180 : version(testing::get<0>(params)), |
181 perspective(std::get<1>(params)), | 181 perspective(testing::get<1>(params)), |
182 http2_decoder(std::get<2>(params)), | 182 http2_decoder(testing::get<2>(params)), |
183 hpack_decoder(std::get<3>(params)) { | 183 hpack_decoder(testing::get<3>(params)) { |
184 switch (http2_decoder) { | 184 switch (http2_decoder) { |
185 case HTTP2_DECODER_SPDY: | 185 case HTTP2_DECODER_SPDY: |
186 FLAGS_use_nested_spdy_framer_decoder = false; | 186 FLAGS_use_nested_spdy_framer_decoder = false; |
187 FLAGS_use_http2_frame_decoder_adapter = false; | 187 FLAGS_use_http2_frame_decoder_adapter = false; |
188 break; | 188 break; |
189 case HTTP2_DECODER_NESTED_SPDY: | 189 case HTTP2_DECODER_NESTED_SPDY: |
190 FLAGS_use_nested_spdy_framer_decoder = true; | 190 FLAGS_use_nested_spdy_framer_decoder = true; |
191 FLAGS_use_http2_frame_decoder_adapter = false; | 191 FLAGS_use_http2_frame_decoder_adapter = false; |
192 break; | 192 break; |
193 case HTTP2_DECODER_NEW: | 193 case HTTP2_DECODER_NEW: |
194 FLAGS_use_nested_spdy_framer_decoder = false; | 194 FLAGS_use_nested_spdy_framer_decoder = false; |
195 FLAGS_use_http2_frame_decoder_adapter = true; | 195 FLAGS_use_http2_frame_decoder_adapter = true; |
196 // Http2FrameDecoderAdapter needs the new header methods, else | 196 // Http2FrameDecoderAdapter needs the new header methods, else |
197 // --use_http2_frame_decoder_adapter=true will be ignored. | 197 // --use_http2_frame_decoder_adapter=true will be ignored. |
198 FLAGS_spdy_framer_use_new_methods2 = true; | 198 FLAGS_spdy_framer_use_new_methods3 = true; |
199 break; | 199 break; |
200 } | 200 } |
201 switch (hpack_decoder) { | 201 switch (hpack_decoder) { |
202 case HPACK_DECODER_SPDY: | 202 case HPACK_DECODER_SPDY: |
203 FLAGS_spdy_use_hpack_decoder2 = false; | 203 FLAGS_spdy_use_hpack_decoder2 = false; |
204 break; | 204 break; |
205 case HPACK_DECODER_NEW: | 205 case HPACK_DECODER_NEW: |
206 FLAGS_spdy_use_hpack_decoder2 = true; | 206 FLAGS_spdy_use_hpack_decoder2 = true; |
207 // Needs new header methods to be used. | 207 // Needs new header methods to be used. |
208 FLAGS_spdy_framer_use_new_methods2 = true; | 208 FLAGS_spdy_framer_use_new_methods3 = true; |
209 break; | 209 break; |
210 } | 210 } |
211 FLAGS_quic_always_log_bugs_for_tests = true; | 211 FLAGS_quic_always_log_bugs_for_tests = true; |
212 VLOG(1) << "TestParams: version: " << QuicVersionToString(version) | 212 VLOG(1) << "TestParams: version: " << QuicVersionToString(version) |
213 << ", perspective: " << perspective | 213 << ", perspective: " << perspective |
214 << ", http2_decoder: " << http2_decoder | 214 << ", http2_decoder: " << http2_decoder |
215 << ", hpack_decoder: " << hpack_decoder; | 215 << ", hpack_decoder: " << hpack_decoder; |
216 } | 216 } |
217 | 217 |
218 QuicVersion version; | 218 QuicVersion version; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 QuicStreamFrame stream_frame_; | 401 QuicStreamFrame stream_frame_; |
402 QuicStreamId next_promised_stream_id_; | 402 QuicStreamId next_promised_stream_id_; |
403 }; | 403 }; |
404 | 404 |
405 // Run all tests with each version, perspective (client or server), | 405 // Run all tests with each version, perspective (client or server), |
406 // HTTP/2 and HPACK decoder. | 406 // HTTP/2 and HPACK decoder. |
407 INSTANTIATE_TEST_CASE_P( | 407 INSTANTIATE_TEST_CASE_P( |
408 Tests, | 408 Tests, |
409 QuicHeadersStreamTest, | 409 QuicHeadersStreamTest, |
410 ::testing::Combine( | 410 ::testing::Combine( |
411 ::testing::ValuesIn(QuicSupportedVersions()), | 411 ::testing::ValuesIn(AllSupportedVersions()), |
412 ::testing::Values(Perspective::IS_CLIENT, Perspective::IS_SERVER), | 412 ::testing::Values(Perspective::IS_CLIENT, Perspective::IS_SERVER), |
413 ::testing::Values(HTTP2_DECODER_SPDY, | 413 ::testing::Values(HTTP2_DECODER_SPDY, |
414 HTTP2_DECODER_NESTED_SPDY, | 414 HTTP2_DECODER_NESTED_SPDY, |
415 HTTP2_DECODER_NEW), | 415 HTTP2_DECODER_NEW), |
416 ::testing::Values(HPACK_DECODER_SPDY, HPACK_DECODER_NEW))); | 416 ::testing::Values(HPACK_DECODER_SPDY, HPACK_DECODER_NEW))); |
417 | 417 |
418 TEST_P(QuicHeadersStreamTest, StreamId) { | 418 TEST_P(QuicHeadersStreamTest, StreamId) { |
419 EXPECT_EQ(3u, headers_stream_->id()); | 419 EXPECT_EQ(3u, headers_stream_->id()); |
420 } | 420 } |
421 | 421 |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 } | 964 } |
965 saved_data_.clear(); | 965 saved_data_.clear(); |
966 saved_payloads_.clear(); | 966 saved_payloads_.clear(); |
967 } | 967 } |
968 } | 968 } |
969 } | 969 } |
970 | 970 |
971 } // namespace | 971 } // namespace |
972 } // namespace test | 972 } // namespace test |
973 } // namespace net | 973 } // namespace net |
OLD | NEW |