OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/memory/scoped_vector.h" |
12 #include "net/base/auth.h" | 13 #include "net/base/auth.h" |
13 #include "net/base/net_log_unittest.h" | 14 #include "net/base/net_log_unittest.h" |
14 #include "net/http/http_network_session_peer.h" | 15 #include "net/http/http_network_session_peer.h" |
15 #include "net/http/http_transaction_unittest.h" | 16 #include "net/http/http_transaction_unittest.h" |
16 #include "net/socket/client_socket_pool_base.h" | 17 #include "net/socket/client_socket_pool_base.h" |
17 #include "net/spdy/buffered_spdy_framer.h" | 18 #include "net/spdy/buffered_spdy_framer.h" |
18 #include "net/spdy/spdy_http_stream.h" | 19 #include "net/spdy/spdy_http_stream.h" |
19 #include "net/spdy/spdy_http_utils.h" | 20 #include "net/spdy/spdy_http_utils.h" |
20 #include "net/spdy/spdy_session.h" | 21 #include "net/spdy/spdy_session.h" |
21 #include "net/spdy/spdy_session_pool.h" | 22 #include "net/spdy/spdy_session_pool.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 void RunToCompletion(StaticSocketDataProvider* data) { | 223 void RunToCompletion(StaticSocketDataProvider* data) { |
223 RunPreTestSetup(); | 224 RunPreTestSetup(); |
224 AddData(data); | 225 AddData(data); |
225 RunDefaultTest(); | 226 RunDefaultTest(); |
226 VerifyDataConsumed(); | 227 VerifyDataConsumed(); |
227 } | 228 } |
228 | 229 |
229 void AddData(StaticSocketDataProvider* data) { | 230 void AddData(StaticSocketDataProvider* data) { |
230 DCHECK(!deterministic_); | 231 DCHECK(!deterministic_); |
231 data_vector_.push_back(data); | 232 data_vector_.push_back(data); |
232 linked_ptr<SSLSocketDataProvider> ssl_( | 233 SSLSocketDataProvider* ssl_provider = |
233 new SSLSocketDataProvider(ASYNC, OK)); | 234 new SSLSocketDataProvider(ASYNC, OK); |
234 if (test_type_ == SPDYNPN) { | 235 if (test_type_ == SPDYNPN) |
235 ssl_->SetNextProto(kProtoSPDY2); | 236 ssl_provider->SetNextProto(kProtoSPDY2); |
236 } | 237 |
237 ssl_vector_.push_back(ssl_); | 238 ssl_vector_.push_back(ssl_provider); |
238 if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) | 239 if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) |
239 session_deps_->socket_factory->AddSSLSocketDataProvider(ssl_.get()); | 240 session_deps_->socket_factory->AddSSLSocketDataProvider(ssl_provider); |
| 241 |
240 session_deps_->socket_factory->AddSocketDataProvider(data); | 242 session_deps_->socket_factory->AddSocketDataProvider(data); |
241 if (test_type_ == SPDYNPN) { | 243 if (test_type_ == SPDYNPN) { |
242 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 244 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
243 linked_ptr<StaticSocketDataProvider> | 245 StaticSocketDataProvider* hanging_non_alternate_protocol_socket = |
244 hanging_non_alternate_protocol_socket( | 246 new StaticSocketDataProvider(NULL, 0, NULL, 0); |
245 new StaticSocketDataProvider(NULL, 0, NULL, 0)); | |
246 hanging_non_alternate_protocol_socket->set_connect_data( | 247 hanging_non_alternate_protocol_socket->set_connect_data( |
247 never_finishing_connect); | 248 never_finishing_connect); |
248 session_deps_->socket_factory->AddSocketDataProvider( | 249 session_deps_->socket_factory->AddSocketDataProvider( |
249 hanging_non_alternate_protocol_socket.get()); | 250 hanging_non_alternate_protocol_socket); |
250 alternate_vector_.push_back(hanging_non_alternate_protocol_socket); | 251 alternate_vector_.push_back(hanging_non_alternate_protocol_socket); |
251 } | 252 } |
252 } | 253 } |
253 | 254 |
254 void AddDeterministicData(DeterministicSocketData* data) { | 255 void AddDeterministicData(DeterministicSocketData* data) { |
255 DCHECK(deterministic_); | 256 DCHECK(deterministic_); |
256 data_vector_.push_back(data); | 257 data_vector_.push_back(data); |
257 linked_ptr<SSLSocketDataProvider> ssl_( | 258 SSLSocketDataProvider* ssl_provider = |
258 new SSLSocketDataProvider(ASYNC, OK)); | 259 new SSLSocketDataProvider(ASYNC, OK); |
259 if (test_type_ == SPDYNPN) { | 260 if (test_type_ == SPDYNPN) |
260 ssl_->SetNextProto(kProtoSPDY2); | 261 ssl_provider->SetNextProto(kProtoSPDY2); |
261 } | 262 |
262 ssl_vector_.push_back(ssl_); | 263 ssl_vector_.push_back(ssl_provider); |
263 if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) { | 264 if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) { |
264 session_deps_->deterministic_socket_factory-> | 265 session_deps_->deterministic_socket_factory-> |
265 AddSSLSocketDataProvider(ssl_.get()); | 266 AddSSLSocketDataProvider(ssl_provider); |
266 } | 267 } |
267 session_deps_->deterministic_socket_factory->AddSocketDataProvider(data); | 268 session_deps_->deterministic_socket_factory->AddSocketDataProvider(data); |
268 if (test_type_ == SPDYNPN) { | 269 if (test_type_ == SPDYNPN) { |
269 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 270 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
270 scoped_refptr<DeterministicSocketData> | 271 DeterministicSocketData* hanging_non_alternate_protocol_socket = |
271 hanging_non_alternate_protocol_socket( | 272 new DeterministicSocketData(NULL, 0, NULL, 0); |
272 new DeterministicSocketData(NULL, 0, NULL, 0)); | |
273 hanging_non_alternate_protocol_socket->set_connect_data( | 273 hanging_non_alternate_protocol_socket->set_connect_data( |
274 never_finishing_connect); | 274 never_finishing_connect); |
275 session_deps_->deterministic_socket_factory->AddSocketDataProvider( | 275 session_deps_->deterministic_socket_factory->AddSocketDataProvider( |
276 hanging_non_alternate_protocol_socket); | 276 hanging_non_alternate_protocol_socket); |
277 alternate_deterministic_vector_.push_back( | 277 alternate_deterministic_vector_.push_back( |
278 hanging_non_alternate_protocol_socket); | 278 hanging_non_alternate_protocol_socket); |
279 } | 279 } |
280 } | 280 } |
281 | 281 |
282 // This can only be called after RunPreTestSetup. It adds a Data Provider, | |
283 // but not a corresponding SSL data provider | |
284 void AddDataNoSSL(StaticSocketDataProvider* data) { | |
285 DCHECK(!deterministic_); | |
286 session_deps_->socket_factory->AddSocketDataProvider(data); | |
287 } | |
288 void AddDataNoSSL(DeterministicSocketData* data) { | |
289 DCHECK(deterministic_); | |
290 session_deps_->deterministic_socket_factory->AddSocketDataProvider(data); | |
291 } | |
292 | |
293 void SetSession(const scoped_refptr<HttpNetworkSession>& session) { | 282 void SetSession(const scoped_refptr<HttpNetworkSession>& session) { |
294 session_ = session; | 283 session_ = session; |
295 } | 284 } |
296 HttpNetworkTransaction* trans() { return trans_.get(); } | 285 HttpNetworkTransaction* trans() { return trans_.get(); } |
297 void ResetTrans() { trans_.reset(); } | 286 void ResetTrans() { trans_.reset(); } |
298 TransactionHelperResult& output() { return output_; } | 287 TransactionHelperResult& output() { return output_; } |
299 const HttpRequestInfo& request() const { return request_; } | 288 const HttpRequestInfo& request() const { return request_; } |
300 const scoped_refptr<HttpNetworkSession>& session() const { | 289 const scoped_refptr<HttpNetworkSession>& session() const { |
301 return session_; | 290 return session_; |
302 } | 291 } |
303 scoped_ptr<SpdySessionDependencies>& session_deps() { | 292 scoped_ptr<SpdySessionDependencies>& session_deps() { |
304 return session_deps_; | 293 return session_deps_; |
305 } | 294 } |
306 int port() const { return port_; } | 295 int port() const { return port_; } |
307 SpdyNetworkTransactionSpdy2TestTypes test_type() const { | 296 SpdyNetworkTransactionSpdy2TestTypes test_type() const { |
308 return test_type_; | 297 return test_type_; |
309 } | 298 } |
310 | 299 |
311 private: | 300 private: |
312 typedef std::vector<StaticSocketDataProvider*> DataVector; | 301 typedef std::vector<StaticSocketDataProvider*> DataVector; |
313 typedef std::vector<linked_ptr<SSLSocketDataProvider> > SSLVector; | 302 typedef ScopedVector<SSLSocketDataProvider> SSLVector; |
314 typedef std::vector<linked_ptr<StaticSocketDataProvider> > AlternateVector; | 303 typedef ScopedVector<StaticSocketDataProvider> AlternateVector; |
315 typedef std::vector<scoped_refptr<DeterministicSocketData> > | 304 typedef ScopedVector<DeterministicSocketData> AlternateDeterministicVector; |
316 AlternateDeterministicVector; | |
317 HttpRequestInfo request_; | 305 HttpRequestInfo request_; |
318 scoped_ptr<SpdySessionDependencies> session_deps_; | 306 scoped_ptr<SpdySessionDependencies> session_deps_; |
319 scoped_refptr<HttpNetworkSession> session_; | 307 scoped_refptr<HttpNetworkSession> session_; |
320 TransactionHelperResult output_; | 308 TransactionHelperResult output_; |
321 scoped_ptr<StaticSocketDataProvider> first_transaction_; | 309 scoped_ptr<StaticSocketDataProvider> first_transaction_; |
322 SSLVector ssl_vector_; | 310 SSLVector ssl_vector_; |
323 TestCompletionCallback callback; | 311 TestCompletionCallback callback; |
324 scoped_ptr<HttpNetworkTransaction> trans_; | 312 scoped_ptr<HttpNetworkTransaction> trans_; |
325 scoped_ptr<HttpNetworkTransaction> trans_http_; | 313 scoped_ptr<HttpNetworkTransaction> trans_http_; |
326 DataVector data_vector_; | 314 DataVector data_vector_; |
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1766 MockWrite(SYNCHRONOUS, 0, 0, 2), | 1754 MockWrite(SYNCHRONOUS, 0, 0, 2), |
1767 CreateMockWrite(*rst.get(), 3, SYNCHRONOUS), | 1755 CreateMockWrite(*rst.get(), 3, SYNCHRONOUS), |
1768 }; | 1756 }; |
1769 | 1757 |
1770 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 1758 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
1771 MockRead reads[] = { | 1759 MockRead reads[] = { |
1772 CreateMockRead(*resp.get(), 1, ASYNC), | 1760 CreateMockRead(*resp.get(), 1, ASYNC), |
1773 MockRead(ASYNC, 0, 0, 4) // EOF | 1761 MockRead(ASYNC, 0, 0, 4) // EOF |
1774 }; | 1762 }; |
1775 | 1763 |
1776 scoped_refptr<DeterministicSocketData> data( | 1764 scoped_ptr<DeterministicSocketData> data( |
1777 new DeterministicSocketData(reads, arraysize(reads), | 1765 new DeterministicSocketData(reads, arraysize(reads), |
1778 writes, arraysize(writes))); | 1766 writes, arraysize(writes))); |
1779 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 1767 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
1780 BoundNetLog(), GetParam(), NULL); | 1768 BoundNetLog(), GetParam(), NULL); |
1781 helper.SetDeterministic(); | 1769 helper.SetDeterministic(); |
1782 helper.RunPreTestSetup(); | 1770 helper.RunPreTestSetup(); |
1783 helper.AddDeterministicData(data.get()); | 1771 helper.AddDeterministicData(data.get()); |
1784 HttpNetworkTransaction* trans = helper.trans(); | 1772 HttpNetworkTransaction* trans = helper.trans(); |
1785 | 1773 |
1786 TestCompletionCallback callback; | 1774 TestCompletionCallback callback; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1974 CreateMockWrite(*req, 0, SYNCHRONOUS), | 1962 CreateMockWrite(*req, 0, SYNCHRONOUS), |
1975 CreateMockWrite(*rst, 2, SYNCHRONOUS), | 1963 CreateMockWrite(*rst, 2, SYNCHRONOUS), |
1976 }; | 1964 }; |
1977 | 1965 |
1978 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 1966 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
1979 MockRead reads[] = { | 1967 MockRead reads[] = { |
1980 CreateMockRead(*resp, 1, ASYNC), | 1968 CreateMockRead(*resp, 1, ASYNC), |
1981 MockRead(ASYNC, 0, 0, 3) // EOF | 1969 MockRead(ASYNC, 0, 0, 3) // EOF |
1982 }; | 1970 }; |
1983 | 1971 |
1984 scoped_refptr<DeterministicSocketData> data( | 1972 scoped_ptr<DeterministicSocketData> data( |
1985 new DeterministicSocketData(reads, arraysize(reads), | 1973 new DeterministicSocketData(reads, arraysize(reads), |
1986 writes, arraysize(writes))); | 1974 writes, arraysize(writes))); |
1987 | 1975 |
1988 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 1976 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
1989 BoundNetLog(), | 1977 BoundNetLog(), |
1990 GetParam(), NULL); | 1978 GetParam(), NULL); |
1991 helper.SetDeterministic(); | 1979 helper.SetDeterministic(); |
1992 helper.RunPreTestSetup(); | 1980 helper.RunPreTestSetup(); |
1993 helper.AddDeterministicData(data.get()); | 1981 helper.AddDeterministicData(data.get()); |
1994 HttpNetworkTransaction* trans = helper.trans(); | 1982 HttpNetworkTransaction* trans = helper.trans(); |
(...skipping 2984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4979 CreateMockRead(*stream1_body, 3), | 4967 CreateMockRead(*stream1_body, 3), |
4980 CreateMockRead(*stream2_headers, 4), | 4968 CreateMockRead(*stream2_headers, 4), |
4981 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), | 4969 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), |
4982 arraysize(kPushBodyFrame), 5), | 4970 arraysize(kPushBodyFrame), 5), |
4983 MockRead(ASYNC, 0, 5), // EOF | 4971 MockRead(ASYNC, 0, 5), // EOF |
4984 }; | 4972 }; |
4985 | 4973 |
4986 HttpResponseInfo response; | 4974 HttpResponseInfo response; |
4987 HttpResponseInfo response2; | 4975 HttpResponseInfo response2; |
4988 std::string expected_push_result("pushed"); | 4976 std::string expected_push_result("pushed"); |
4989 scoped_refptr<DeterministicSocketData> data(new DeterministicSocketData( | 4977 scoped_ptr<DeterministicSocketData> data( |
4990 reads, | 4978 new DeterministicSocketData(reads, arraysize(reads), |
4991 arraysize(reads), | 4979 writes, arraysize(writes))); |
4992 writes, | |
4993 arraysize(writes))); | |
4994 | 4980 |
4995 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 4981 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
4996 BoundNetLog(), GetParam(), NULL); | 4982 BoundNetLog(), GetParam(), NULL); |
4997 helper.SetDeterministic(); | 4983 helper.SetDeterministic(); |
4998 helper.AddDeterministicData(static_cast<DeterministicSocketData*>(data)); | 4984 helper.AddDeterministicData(data.get()); |
4999 helper.RunPreTestSetup(); | 4985 helper.RunPreTestSetup(); |
5000 | 4986 |
5001 HttpNetworkTransaction* trans = helper.trans(); | 4987 HttpNetworkTransaction* trans = helper.trans(); |
5002 | 4988 |
5003 // Run until we've received the primary SYN_STREAM, the pushed SYN_STREAM, | 4989 // Run until we've received the primary SYN_STREAM, the pushed SYN_STREAM, |
5004 // and the body of the primary stream, but before we've received the HEADERS | 4990 // and the body of the primary stream, but before we've received the HEADERS |
5005 // for the pushed stream. | 4991 // for the pushed stream. |
5006 data->SetStop(3); | 4992 data->SetStop(3); |
5007 | 4993 |
5008 // Start the transaction. | 4994 // Start the transaction. |
(...skipping 13 matching lines...) Expand all Loading... |
5022 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 5008 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); |
5023 EXPECT_EQ(ERR_IO_PENDING, rv); | 5009 EXPECT_EQ(ERR_IO_PENDING, rv); |
5024 data->RunFor(3); | 5010 data->RunFor(3); |
5025 MessageLoop::current()->RunAllPending(); | 5011 MessageLoop::current()->RunAllPending(); |
5026 | 5012 |
5027 // Read the server push body. | 5013 // Read the server push body. |
5028 std::string result2; | 5014 std::string result2; |
5029 ReadResult(trans2.get(), data.get(), &result2); | 5015 ReadResult(trans2.get(), data.get(), &result2); |
5030 // Read the response body. | 5016 // Read the response body. |
5031 std::string result; | 5017 std::string result; |
5032 ReadResult(trans, data, &result); | 5018 ReadResult(trans, data.get(), &result); |
5033 | 5019 |
5034 // Verify that we consumed all test data. | 5020 // Verify that we consumed all test data. |
5035 EXPECT_TRUE(data->at_read_eof()); | 5021 EXPECT_TRUE(data->at_read_eof()); |
5036 EXPECT_TRUE(data->at_write_eof()); | 5022 EXPECT_TRUE(data->at_write_eof()); |
5037 | 5023 |
5038 // Verify that the received push data is same as the expected push data. | 5024 // Verify that the received push data is same as the expected push data. |
5039 EXPECT_EQ(result2.compare(expected_push_result), 0) | 5025 EXPECT_EQ(result2.compare(expected_push_result), 0) |
5040 << "Received data: " | 5026 << "Received data: " |
5041 << result2 | 5027 << result2 |
5042 << "||||| Expected data: " | 5028 << "||||| Expected data: " |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5130 CreateMockRead(*stream2_headers1, 4), | 5116 CreateMockRead(*stream2_headers1, 4), |
5131 CreateMockRead(*stream2_headers2, 5), | 5117 CreateMockRead(*stream2_headers2, 5), |
5132 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), | 5118 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), |
5133 arraysize(kPushBodyFrame), 6), | 5119 arraysize(kPushBodyFrame), 6), |
5134 MockRead(ASYNC, 0, 6), // EOF | 5120 MockRead(ASYNC, 0, 6), // EOF |
5135 }; | 5121 }; |
5136 | 5122 |
5137 HttpResponseInfo response; | 5123 HttpResponseInfo response; |
5138 HttpResponseInfo response2; | 5124 HttpResponseInfo response2; |
5139 std::string expected_push_result("pushed"); | 5125 std::string expected_push_result("pushed"); |
5140 scoped_refptr<DeterministicSocketData> data(new DeterministicSocketData( | 5126 scoped_ptr<DeterministicSocketData> data( |
5141 reads, | 5127 new DeterministicSocketData(reads, arraysize(reads), |
5142 arraysize(reads), | 5128 writes, arraysize(writes))); |
5143 writes, | |
5144 arraysize(writes))); | |
5145 | 5129 |
5146 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 5130 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
5147 BoundNetLog(), GetParam(), NULL); | 5131 BoundNetLog(), GetParam(), NULL); |
5148 helper.SetDeterministic(); | 5132 helper.SetDeterministic(); |
5149 helper.AddDeterministicData(static_cast<DeterministicSocketData*>(data)); | 5133 helper.AddDeterministicData(data.get()); |
5150 helper.RunPreTestSetup(); | 5134 helper.RunPreTestSetup(); |
5151 | 5135 |
5152 HttpNetworkTransaction* trans = helper.trans(); | 5136 HttpNetworkTransaction* trans = helper.trans(); |
5153 | 5137 |
5154 // Run until we've received the primary SYN_STREAM, the pushed SYN_STREAM, | 5138 // Run until we've received the primary SYN_STREAM, the pushed SYN_STREAM, |
5155 // the first HEADERS frame, and the body of the primary stream, but before | 5139 // the first HEADERS frame, and the body of the primary stream, but before |
5156 // we've received the final HEADERS for the pushed stream. | 5140 // we've received the final HEADERS for the pushed stream. |
5157 data->SetStop(4); | 5141 data->SetStop(4); |
5158 | 5142 |
5159 // Start the transaction. | 5143 // Start the transaction. |
(...skipping 10 matching lines...) Expand all Loading... |
5170 scoped_ptr<HttpNetworkTransaction> trans2( | 5154 scoped_ptr<HttpNetworkTransaction> trans2( |
5171 new HttpNetworkTransaction(helper.session())); | 5155 new HttpNetworkTransaction(helper.session())); |
5172 rv = trans2->Start( | 5156 rv = trans2->Start( |
5173 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); | 5157 &CreateGetPushRequest(), callback.callback(), BoundNetLog()); |
5174 EXPECT_EQ(ERR_IO_PENDING, rv); | 5158 EXPECT_EQ(ERR_IO_PENDING, rv); |
5175 data->RunFor(3); | 5159 data->RunFor(3); |
5176 MessageLoop::current()->RunAllPending(); | 5160 MessageLoop::current()->RunAllPending(); |
5177 | 5161 |
5178 // Read the server push body. | 5162 // Read the server push body. |
5179 std::string result2; | 5163 std::string result2; |
5180 ReadResult(trans2.get(), data, &result2); | 5164 ReadResult(trans2.get(), data.get(), &result2); |
5181 // Read the response body. | 5165 // Read the response body. |
5182 std::string result; | 5166 std::string result; |
5183 ReadResult(trans, data, &result); | 5167 ReadResult(trans, data.get(), &result); |
5184 | 5168 |
5185 // Verify that we consumed all test data. | 5169 // Verify that we consumed all test data. |
5186 EXPECT_TRUE(data->at_read_eof()); | 5170 EXPECT_TRUE(data->at_read_eof()); |
5187 EXPECT_TRUE(data->at_write_eof()); | 5171 EXPECT_TRUE(data->at_write_eof()); |
5188 | 5172 |
5189 // Verify that the received push data is same as the expected push data. | 5173 // Verify that the received push data is same as the expected push data. |
5190 EXPECT_EQ(result2.compare(expected_push_result), 0) | 5174 EXPECT_EQ(result2.compare(expected_push_result), 0) |
5191 << "Received data: " | 5175 << "Received data: " |
5192 << result2 | 5176 << result2 |
5193 << "||||| Expected data: " | 5177 << "||||| Expected data: " |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5584 MockRead reads[] = { | 5568 MockRead reads[] = { |
5585 CreateMockRead(*resp1, 1), | 5569 CreateMockRead(*resp1, 1), |
5586 CreateMockRead(*body1, 2), | 5570 CreateMockRead(*body1, 2), |
5587 CreateMockRead(*resp2, 5), | 5571 CreateMockRead(*resp2, 5), |
5588 CreateMockRead(*body2, 6), | 5572 CreateMockRead(*body2, 6), |
5589 CreateMockRead(*resp3, 7), | 5573 CreateMockRead(*resp3, 7), |
5590 CreateMockRead(*body3, 8), | 5574 CreateMockRead(*body3, 8), |
5591 MockRead(ASYNC, 0, 9) // EOF | 5575 MockRead(ASYNC, 0, 9) // EOF |
5592 }; | 5576 }; |
5593 | 5577 |
5594 scoped_refptr<DeterministicSocketData> data( | 5578 scoped_ptr<DeterministicSocketData> data( |
5595 new DeterministicSocketData(reads, arraysize(reads), | 5579 new DeterministicSocketData(reads, arraysize(reads), |
5596 writes, arraysize(writes))); | 5580 writes, arraysize(writes))); |
5597 NormalSpdyTransactionHelper helper(CreateGetRequest(), | 5581 NormalSpdyTransactionHelper helper(CreateGetRequest(), |
5598 BoundNetLog(), GetParam(), NULL); | 5582 BoundNetLog(), GetParam(), NULL); |
5599 helper.SetDeterministic(); | 5583 helper.SetDeterministic(); |
5600 helper.RunPreTestSetup(); | 5584 helper.RunPreTestSetup(); |
5601 helper.AddDeterministicData(data.get()); | 5585 helper.AddDeterministicData(data.get()); |
5602 | 5586 |
5603 // Start the first transaction to set up the SpdySession | 5587 // Start the first transaction to set up the SpdySession |
5604 HttpNetworkTransaction* trans = helper.trans(); | 5588 HttpNetworkTransaction* trans = helper.trans(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5641 // And now we can allow everything else to run to completion. | 5625 // And now we can allow everything else to run to completion. |
5642 data->SetStop(10); | 5626 data->SetStop(10); |
5643 data->Run(); | 5627 data->Run(); |
5644 EXPECT_EQ(OK, callback2.WaitForResult()); | 5628 EXPECT_EQ(OK, callback2.WaitForResult()); |
5645 EXPECT_EQ(OK, callback3.WaitForResult()); | 5629 EXPECT_EQ(OK, callback3.WaitForResult()); |
5646 | 5630 |
5647 helper.VerifyDataConsumed(); | 5631 helper.VerifyDataConsumed(); |
5648 } | 5632 } |
5649 | 5633 |
5650 } // namespace net | 5634 } // namespace net |
OLD | NEW |