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

Side by Side Diff: net/quic/core/quic_headers_stream_test.cc

Issue 2644683002: Add HpackDecoder3, an adapter using HpackDecoder (in net/http2/hpack/decoder). (Closed)
Patch Set: Nits. Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « net/net.gypi ('k') | net/spdy/hpack/hpack_decoder2_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <cstdint> 7 #include <cstdint>
8 #include <ostream> 8 #include <ostream>
9 #include <string> 9 #include <string>
10 #include <tuple> 10 #include <tuple>
(...skipping 22 matching lines...) Expand all
33 using testing::AtLeast; 33 using testing::AtLeast;
34 using testing::HasSubstr; 34 using testing::HasSubstr;
35 using testing::InSequence; 35 using testing::InSequence;
36 using testing::Invoke; 36 using testing::Invoke;
37 using testing::Return; 37 using testing::Return;
38 using testing::StrictMock; 38 using testing::StrictMock;
39 using testing::WithArgs; 39 using testing::WithArgs;
40 40
41 // TODO(bnc): Merge these correctly. 41 // TODO(bnc): Merge these correctly.
42 bool FLAGS_use_http2_frame_decoder_adapter; 42 bool FLAGS_use_http2_frame_decoder_adapter;
43 bool FLAGS_spdy_use_hpack_decoder2;
44 bool FLAGS_spdy_framer_use_new_methods4; 43 bool FLAGS_spdy_framer_use_new_methods4;
45 44
46 namespace net { 45 namespace net {
47 namespace test { 46 namespace test {
48 47
49 class MockQuicHpackDebugVisitor : public QuicHpackDebugVisitor { 48 class MockQuicHpackDebugVisitor : public QuicHpackDebugVisitor {
50 public: 49 public:
51 MockQuicHpackDebugVisitor() : QuicHpackDebugVisitor() {} 50 MockQuicHpackDebugVisitor() : QuicHpackDebugVisitor() {}
52 51
53 MOCK_METHOD1(OnUseEntry, void(QuicTime::Delta elapsed)); 52 MOCK_METHOD1(OnUseEntry, void(QuicTime::Delta elapsed));
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 case HTTP2_DECODER_SPDY: 145 case HTTP2_DECODER_SPDY:
147 return os << "SPDY"; 146 return os << "SPDY";
148 case HTTP2_DECODER_NESTED_SPDY: 147 case HTTP2_DECODER_NESTED_SPDY:
149 return os << "NESTED_SPDY"; 148 return os << "NESTED_SPDY";
150 case HTTP2_DECODER_NEW: 149 case HTTP2_DECODER_NEW:
151 return os << "NEW"; 150 return os << "NEW";
152 } 151 }
153 return os; 152 return os;
154 } 153 }
155 154
156 enum HpackDecoderChoice { HPACK_DECODER_SPDY, HPACK_DECODER_NEW }; 155 enum HpackDecoderChoice { HPACK_DECODER_SPDY, HPACK_DECODER2, HPACK_DECODER3 };
157 std::ostream& operator<<(std::ostream& os, HpackDecoderChoice v) { 156 std::ostream& operator<<(std::ostream& os, HpackDecoderChoice v) {
158 switch (v) { 157 switch (v) {
159 case HPACK_DECODER_SPDY: 158 case HPACK_DECODER_SPDY:
160 return os << "SPDY"; 159 return os << "SPDY";
161 case HPACK_DECODER_NEW: 160 case HPACK_DECODER2:
162 return os << "NEW"; 161 return os << "HPACK_DECODER2";
162 case HPACK_DECODER3:
163 return os << "HPACK_DECODER3";
163 } 164 }
164 return os; 165 return os;
165 } 166 }
166 167
167 typedef testing:: 168 typedef testing::
168 tuple<QuicVersion, Perspective, Http2DecoderChoice, HpackDecoderChoice> 169 tuple<QuicVersion, Perspective, Http2DecoderChoice, HpackDecoderChoice>
169 TestParamsTuple; 170 TestParamsTuple;
170 171
171 struct TestParams { 172 struct TestParams {
172 explicit TestParams(TestParamsTuple params) 173 explicit TestParams(TestParamsTuple params)
(...skipping 13 matching lines...) Expand all
186 case HTTP2_DECODER_NEW: 187 case HTTP2_DECODER_NEW:
187 FLAGS_use_nested_spdy_framer_decoder = false; 188 FLAGS_use_nested_spdy_framer_decoder = false;
188 FLAGS_use_http2_frame_decoder_adapter = true; 189 FLAGS_use_http2_frame_decoder_adapter = true;
189 // Http2FrameDecoderAdapter needs the new header methods, else 190 // Http2FrameDecoderAdapter needs the new header methods, else
190 // --use_http2_frame_decoder_adapter=true will be ignored. 191 // --use_http2_frame_decoder_adapter=true will be ignored.
191 FLAGS_spdy_framer_use_new_methods4 = true; 192 FLAGS_spdy_framer_use_new_methods4 = true;
192 break; 193 break;
193 } 194 }
194 switch (hpack_decoder) { 195 switch (hpack_decoder) {
195 case HPACK_DECODER_SPDY: 196 case HPACK_DECODER_SPDY:
196 FLAGS_spdy_use_hpack_decoder2 = false; 197 FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2 = false;
198 FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = false;
197 break; 199 break;
198 case HPACK_DECODER_NEW: 200 case HPACK_DECODER2:
199 FLAGS_spdy_use_hpack_decoder2 = true; 201 FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2 = true;
200 // Needs new header methods to be used. 202 FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = false;
201 FLAGS_spdy_framer_use_new_methods4 = true; 203 break;
204 case HPACK_DECODER3:
205 FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2 = false;
206 FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3 = true;
202 break; 207 break;
203 } 208 }
204 QUIC_LOG(INFO) << "TestParams: version: " << QuicVersionToString(version) 209 QUIC_LOG(INFO) << "TestParams: version: " << QuicVersionToString(version)
205 << ", perspective: " << perspective 210 << ", perspective: " << perspective
206 << ", http2_decoder: " << http2_decoder 211 << ", http2_decoder: " << http2_decoder
207 << ", hpack_decoder: " << hpack_decoder; 212 << ", hpack_decoder: " << hpack_decoder;
208 } 213 }
209 214
210 QuicVersion version; 215 QuicVersion version;
211 Perspective perspective; 216 Perspective perspective;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // HTTP/2 and HPACK decoder. 413 // HTTP/2 and HPACK decoder.
409 INSTANTIATE_TEST_CASE_P( 414 INSTANTIATE_TEST_CASE_P(
410 Tests, 415 Tests,
411 QuicHeadersStreamTest, 416 QuicHeadersStreamTest,
412 ::testing::Combine( 417 ::testing::Combine(
413 ::testing::ValuesIn(AllSupportedVersions()), 418 ::testing::ValuesIn(AllSupportedVersions()),
414 ::testing::Values(Perspective::IS_CLIENT, Perspective::IS_SERVER), 419 ::testing::Values(Perspective::IS_CLIENT, Perspective::IS_SERVER),
415 ::testing::Values(HTTP2_DECODER_SPDY, 420 ::testing::Values(HTTP2_DECODER_SPDY,
416 HTTP2_DECODER_NESTED_SPDY, 421 HTTP2_DECODER_NESTED_SPDY,
417 HTTP2_DECODER_NEW), 422 HTTP2_DECODER_NEW),
418 ::testing::Values(HPACK_DECODER_SPDY, HPACK_DECODER_NEW))); 423 ::testing::Values(HPACK_DECODER_SPDY, HPACK_DECODER2, HPACK_DECODER3)));
419 424
420 TEST_P(QuicHeadersStreamTest, StreamId) { 425 TEST_P(QuicHeadersStreamTest, StreamId) {
421 EXPECT_EQ(3u, headers_stream_->id()); 426 EXPECT_EQ(3u, headers_stream_->id());
422 } 427 }
423 428
424 TEST_P(QuicHeadersStreamTest, WriteHeaders) { 429 TEST_P(QuicHeadersStreamTest, WriteHeaders) {
425 for (QuicStreamId stream_id = kClientDataStreamId1; 430 for (QuicStreamId stream_id = kClientDataStreamId1;
426 stream_id < kClientDataStreamId3; stream_id += 2) { 431 stream_id < kClientDataStreamId3; stream_id += 2) {
427 for (bool fin : kFins) { 432 for (bool fin : kFins) {
428 if (perspective() == Perspective::IS_SERVER) { 433 if (perspective() == Perspective::IS_SERVER) {
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 stream_frame_.data_length = frame.size(); 847 stream_frame_.data_length = frame.size();
843 headers_stream_->OnStreamFrame(stream_frame_); 848 headers_stream_->OnStreamFrame(stream_frame_);
844 } 849 }
845 850
846 TEST_P(QuicHeadersStreamTest, NoConnectionLevelFlowControl) { 851 TEST_P(QuicHeadersStreamTest, NoConnectionLevelFlowControl) {
847 EXPECT_FALSE(QuicStreamPeer::StreamContributesToConnectionFlowControl( 852 EXPECT_FALSE(QuicStreamPeer::StreamContributesToConnectionFlowControl(
848 headers_stream_)); 853 headers_stream_));
849 } 854 }
850 855
851 TEST_P(QuicHeadersStreamTest, HpackDecoderDebugVisitor) { 856 TEST_P(QuicHeadersStreamTest, HpackDecoderDebugVisitor) {
857 if (test_params_.hpack_decoder == HPACK_DECODER3) {
858 return;
859 }
860
852 StrictMock<MockQuicHpackDebugVisitor>* hpack_decoder_visitor = 861 StrictMock<MockQuicHpackDebugVisitor>* hpack_decoder_visitor =
853 hpack_decoder_visitor_.get(); 862 hpack_decoder_visitor_.get();
854 QuicSpdySessionPeer::SetHpackDecoderDebugVisitor( 863 QuicSpdySessionPeer::SetHpackDecoderDebugVisitor(
855 &session_, std::move(hpack_decoder_visitor_)); 864 &session_, std::move(hpack_decoder_visitor_));
856 865
857 // Create some headers we expect to generate entries in HPACK's 866 // Create some headers we expect to generate entries in HPACK's
858 // dynamic table, in addition to content-length. 867 // dynamic table, in addition to content-length.
859 headers_["key0"] = string(1 << 1, '.'); 868 headers_["key0"] = string(1 << 1, '.');
860 headers_["key1"] = string(1 << 2, '.'); 869 headers_["key1"] = string(1 << 2, '.');
861 headers_["key2"] = string(1 << 3, '.'); 870 headers_["key2"] = string(1 << 3, '.');
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 consumed_data = session_.WritevStreamData(id, MakeIOVector(data, &iov), 1053 consumed_data = session_.WritevStreamData(id, MakeIOVector(data, &iov),
1045 offset, fin, nullptr); 1054 offset, fin, nullptr);
1046 1055
1047 EXPECT_EQ(consumed_data.bytes_consumed, 0u); 1056 EXPECT_EQ(consumed_data.bytes_consumed, 0u);
1048 EXPECT_EQ(consumed_data.fin_consumed, false); 1057 EXPECT_EQ(consumed_data.fin_consumed, false);
1049 } 1058 }
1050 1059
1051 } // namespace 1060 } // namespace
1052 } // namespace test 1061 } // namespace test
1053 } // namespace net 1062 } // namespace net
OLDNEW
« no previous file with comments | « net/net.gypi ('k') | net/spdy/hpack/hpack_decoder2_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698