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

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

Issue 1918953003: Landing Recent QUIC changes until 4/22/2016 14:55 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Deleted SpdyFramerTests missed while mergeing 120451808 Created 4 years, 7 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/quic/quic_framer_test.cc ('k') | net/quic/quic_packet_creator.h » ('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/quic_headers_stream.h" 5 #include "net/quic/quic_headers_stream.h"
6 6
7 #include "net/quic/quic_utils.h" 7 #include "net/quic/quic_utils.h"
8 #include "net/quic/spdy_utils.h" 8 #include "net/quic/spdy_utils.h"
9 #include "net/quic/test_tools/quic_connection_peer.h" 9 #include "net/quic/test_tools/quic_connection_peer.h"
10 #include "net/quic/test_tools/quic_spdy_session_peer.h" 10 #include "net/quic/test_tools/quic_spdy_session_peer.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 void(SpdyStreamId stream_id, 89 void(SpdyStreamId stream_id,
90 StringPiece origin, 90 StringPiece origin,
91 const SpdyAltSvcWireFormat::AlternativeServiceVector& 91 const SpdyAltSvcWireFormat::AlternativeServiceVector&
92 altsvc_vector)); 92 altsvc_vector));
93 MOCK_METHOD2(OnUnknownFrame, bool(SpdyStreamId stream_id, int frame_type)); 93 MOCK_METHOD2(OnUnknownFrame, bool(SpdyStreamId stream_id, int frame_type));
94 }; 94 };
95 95
96 // Run all tests with each version, perspective (client or server), 96 // Run all tests with each version, perspective (client or server),
97 // and relevant flag options (false or true) 97 // and relevant flag options (false or true)
98 struct TestParams { 98 struct TestParams {
99 TestParams(QuicVersion version, 99 TestParams(QuicVersion version, Perspective perspective)
100 Perspective perspective, 100 : version(version), perspective(perspective) {}
101 bool spdy_on_stream_end)
102 : version(version),
103 perspective(perspective),
104 spdy_on_stream_end(spdy_on_stream_end) {}
105 101
106 friend ostream& operator<<(ostream& os, const TestParams& p) { 102 friend ostream& operator<<(ostream& os, const TestParams& p) {
107 os << "{ version: " << QuicVersionToString(p.version); 103 os << "{ version: " << QuicVersionToString(p.version);
108 os << ", perspective: " << p.perspective; 104 os << ", perspective: " << p.perspective << " }";
109 os << ", spdy_on_stream_end: " << p.spdy_on_stream_end << " }";
110 return os; 105 return os;
111 } 106 }
112 107
113 QuicVersion version; 108 QuicVersion version;
114 Perspective perspective; 109 Perspective perspective;
115 bool spdy_on_stream_end;
116 }; 110 };
117 111
118 // Constructs various test permutations. 112 // Constructs various test permutations.
119 vector<TestParams> GetTestParams() { 113 vector<TestParams> GetTestParams() {
120 vector<TestParams> params; 114 vector<TestParams> params;
121 QuicVersionVector all_supported_versions = QuicSupportedVersions(); 115 QuicVersionVector all_supported_versions = QuicSupportedVersions();
122 for (const QuicVersion version : all_supported_versions) { 116 for (const QuicVersion version : all_supported_versions) {
123 params.push_back(TestParams(version, Perspective::IS_CLIENT, true)); 117 params.push_back(TestParams(version, Perspective::IS_CLIENT));
124 params.push_back(TestParams(version, Perspective::IS_SERVER, true)); 118 params.push_back(TestParams(version, Perspective::IS_SERVER));
125 params.push_back(TestParams(version, Perspective::IS_CLIENT, false));
126 params.push_back(TestParams(version, Perspective::IS_SERVER, false));
127 } 119 }
128 FLAGS_quic_supports_push_promise = true; 120 FLAGS_quic_supports_push_promise = true;
129 return params; 121 return params;
130 } 122 }
131 123
132 class QuicHeadersStreamTest : public ::testing::TestWithParam<TestParams> { 124 class QuicHeadersStreamTest : public ::testing::TestWithParam<TestParams> {
133 public: 125 public:
134 QuicHeadersStreamTest() 126 QuicHeadersStreamTest()
135 : connection_(new StrictMock<MockConnection>(&helper_, 127 : connection_(new StrictMock<MockConnection>(&helper_,
136 &alarm_factory_, 128 &alarm_factory_,
137 perspective(), 129 perspective(),
138 GetVersion())), 130 GetVersion())),
139 session_(connection_), 131 session_(connection_),
140 headers_stream_(QuicSpdySessionPeer::GetHeadersStream(&session_)), 132 headers_stream_(QuicSpdySessionPeer::GetHeadersStream(&session_)),
141 body_("hello world"), 133 body_("hello world"),
142 stream_frame_(kHeadersStreamId, /*fin=*/false, /*offset=*/0, ""), 134 stream_frame_(kHeadersStreamId, /*fin=*/false, /*offset=*/0, ""),
143 next_promised_stream_id_(2) { 135 next_promised_stream_id_(2) {
144 FLAGS_quic_always_log_bugs_for_tests = true; 136 FLAGS_quic_always_log_bugs_for_tests = true;
145 headers_[":version"] = "HTTP/1.1"; 137 headers_[":version"] = "HTTP/1.1";
146 headers_[":status"] = "200 Ok"; 138 headers_[":status"] = "200 Ok";
147 headers_["content-length"] = "11"; 139 headers_["content-length"] = "11";
148 FLAGS_spdy_on_stream_end = GetParam().spdy_on_stream_end;
149 framer_ = std::unique_ptr<SpdyFramer>(new SpdyFramer(HTTP2)); 140 framer_ = std::unique_ptr<SpdyFramer>(new SpdyFramer(HTTP2));
150 framer_->set_visitor(&visitor_); 141 framer_->set_visitor(&visitor_);
151 EXPECT_EQ(version(), session_.connection()->version()); 142 EXPECT_EQ(version(), session_.connection()->version());
152 EXPECT_TRUE(headers_stream_ != nullptr); 143 EXPECT_TRUE(headers_stream_ != nullptr);
153 VLOG(1) << GetParam(); 144 VLOG(1) << GetParam();
154 connection_->AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); 145 connection_->AdvanceTime(QuicTime::Delta::FromMilliseconds(1));
155 } 146 }
156 147
157 QuicConsumedData SaveIov(const QuicIOVector& data) { 148 QuicConsumedData SaveIov(const QuicIOVector& data) {
158 const iovec* iov = data.iov; 149 const iovec* iov = data.iov;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 EXPECT_CALL(visitor_, 192 EXPECT_CALL(visitor_,
202 OnHeaders(stream_id, !kHasPriority, 193 OnHeaders(stream_id, !kHasPriority,
203 /*priority=*/0, 194 /*priority=*/0,
204 /*parent_stream_id=*/0, 195 /*parent_stream_id=*/0,
205 /*exclusive=*/false, fin, kFrameComplete)); 196 /*exclusive=*/false, fin, kFrameComplete));
206 } 197 }
207 EXPECT_CALL(visitor_, OnControlFrameHeaderData(stream_id, _, _)) 198 EXPECT_CALL(visitor_, OnControlFrameHeaderData(stream_id, _, _))
208 .WillRepeatedly(WithArgs<1, 2>( 199 .WillRepeatedly(WithArgs<1, 2>(
209 Invoke(this, &QuicHeadersStreamTest::SaveHeaderData))); 200 Invoke(this, &QuicHeadersStreamTest::SaveHeaderData)));
210 if (fin) { 201 if (fin) {
211 if (FLAGS_spdy_on_stream_end) { 202 EXPECT_CALL(visitor_, OnStreamEnd(stream_id));
212 EXPECT_CALL(visitor_, OnStreamEnd(stream_id));
213 } else {
214 EXPECT_CALL(visitor_, OnStreamFrameData(stream_id, nullptr, 0, true));
215 }
216 } 203 }
217 framer_->ProcessInput(saved_data_.data(), saved_data_.length()); 204 framer_->ProcessInput(saved_data_.data(), saved_data_.length());
218 EXPECT_FALSE(framer_->HasError()) 205 EXPECT_FALSE(framer_->HasError())
219 << SpdyFramer::ErrorCodeToString(framer_->error_code()); 206 << SpdyFramer::ErrorCodeToString(framer_->error_code());
220 207
221 CheckHeaders(); 208 CheckHeaders();
222 saved_data_.clear(); 209 saved_data_.clear();
223 } 210 }
224 211
225 void CheckHeaders() { 212 void CheckHeaders() {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 } 578 }
592 579
593 TEST_P(QuicHeadersStreamTest, NoConnectionLevelFlowControl) { 580 TEST_P(QuicHeadersStreamTest, NoConnectionLevelFlowControl) {
594 EXPECT_FALSE(ReliableQuicStreamPeer::StreamContributesToConnectionFlowControl( 581 EXPECT_FALSE(ReliableQuicStreamPeer::StreamContributesToConnectionFlowControl(
595 headers_stream_)); 582 headers_stream_));
596 } 583 }
597 584
598 } // namespace 585 } // namespace
599 } // namespace test 586 } // namespace test
600 } // namespace net 587 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer_test.cc ('k') | net/quic/quic_packet_creator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698