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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "net/base/completion_callback.h" | 6 #include "net/base/completion_callback.h" |
7 #include "net/base/net_log_unittest.h" | 7 #include "net/base/net_log_unittest.h" |
8 #include "net/spdy/buffered_spdy_framer.h" | 8 #include "net/spdy/buffered_spdy_framer.h" |
9 #include "net/spdy/spdy_stream.h" | 9 #include "net/spdy/spdy_stream.h" |
10 #include "net/spdy/spdy_http_utils.h" | 10 #include "net/spdy/spdy_http_utils.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 EXPECT_EQ(OK, connection->Init(host_port_pair.ToString(), transport_params, | 200 EXPECT_EQ(OK, connection->Init(host_port_pair.ToString(), transport_params, |
201 LOWEST, CompletionCallback(), | 201 LOWEST, CompletionCallback(), |
202 session_->GetTransportSocketPool( | 202 session_->GetTransportSocketPool( |
203 HttpNetworkSession::NORMAL_SOCKET_POOL), | 203 HttpNetworkSession::NORMAL_SOCKET_POOL), |
204 BoundNetLog())); | 204 BoundNetLog())); |
205 spdy_session->InitializeWithSocket(connection.release(), false, OK); | 205 spdy_session->InitializeWithSocket(connection.release(), false, OK); |
206 BoundNetLog net_log; | 206 BoundNetLog net_log; |
207 | 207 |
208 // Conjure up a stream. | 208 // Conjure up a stream. |
209 scoped_refptr<SpdyStream> stream = new SpdyStream(spdy_session, | 209 scoped_refptr<SpdyStream> stream = new SpdyStream(spdy_session, |
210 2, | |
211 true, | 210 true, |
212 net_log); | 211 net_log); |
| 212 stream->set_stream_id(2); |
213 EXPECT_FALSE(stream->response_received()); | 213 EXPECT_FALSE(stream->response_received()); |
214 EXPECT_FALSE(stream->HasUrl()); | 214 EXPECT_FALSE(stream->HasUrl()); |
215 | 215 |
216 // Set a couple of headers. | 216 // Set a couple of headers. |
217 SpdyHeaderBlock response; | 217 SpdyHeaderBlock response; |
218 GURL url(kStreamUrl); | 218 GURL url(kStreamUrl); |
219 response[":host"] = url.host(); | 219 response[":host"] = url.host(); |
220 response[":scheme"] = url.scheme(); | 220 response[":scheme"] = url.scheme(); |
221 response[":path"] = url.path(); | 221 response[":path"] = url.path(); |
222 stream->OnResponseReceived(response); | 222 stream->OnResponseReceived(response); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 (*headers)[":scheme"] = url.scheme(); | 334 (*headers)[":scheme"] = url.scheme(); |
335 (*headers)[":host"] = url.host(); | 335 (*headers)[":host"] = url.host(); |
336 (*headers)[":path"] = url.path(); | 336 (*headers)[":path"] = url.path(); |
337 (*headers)[":version"] = "HTTP/1.1"; | 337 (*headers)[":version"] = "HTTP/1.1"; |
338 stream->set_spdy_headers(headers.Pass()); | 338 stream->set_spdy_headers(headers.Pass()); |
339 EXPECT_TRUE(stream->HasUrl()); | 339 EXPECT_TRUE(stream->HasUrl()); |
340 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec()); | 340 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec()); |
341 | 341 |
342 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true)); | 342 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true)); |
343 | 343 |
| 344 EXPECT_EQ(OK, callback.WaitForResult()); |
| 345 |
344 const SpdyStreamId stream_id = stream->stream_id(); | 346 const SpdyStreamId stream_id = stream->stream_id(); |
345 | 347 |
346 EXPECT_EQ(OK, callback.WaitForResult()); | |
347 | |
348 EXPECT_TRUE(delegate->send_headers_completed()); | 348 EXPECT_TRUE(delegate->send_headers_completed()); |
349 EXPECT_EQ("200", (*delegate->response())[":status"]); | 349 EXPECT_EQ("200", (*delegate->response())[":status"]); |
350 EXPECT_EQ("HTTP/1.1", (*delegate->response())[":version"]); | 350 EXPECT_EQ("HTTP/1.1", (*delegate->response())[":version"]); |
351 EXPECT_EQ(std::string("\0hello!\xff", 8), delegate->received_data()); | 351 EXPECT_EQ(std::string("\0hello!\xff", 8), delegate->received_data()); |
352 EXPECT_EQ(8, delegate->data_sent()); | 352 EXPECT_EQ(8, delegate->data_sent()); |
353 EXPECT_TRUE(delegate->closed()); | 353 EXPECT_TRUE(delegate->closed()); |
354 | 354 |
355 // Check that the NetLog was filled reasonably. | 355 // Check that the NetLog was filled reasonably. |
356 net::CapturingNetLog::CapturedEntryList entries; | 356 net::CapturingNetLog::CapturedEntryList entries; |
357 log.GetEntries(&entries); | 357 log.GetEntries(&entries); |
358 EXPECT_LT(0u, entries.size()); | 358 EXPECT_LT(0u, entries.size()); |
359 | 359 |
360 // Check that we logged SPDY_STREAM_ERROR correctly. | 360 // Check that we logged SPDY_STREAM_ERROR correctly. |
361 int pos = net::ExpectLogContainsSomewhere( | 361 int pos = net::ExpectLogContainsSomewhere( |
362 entries, 0, | 362 entries, 0, |
363 net::NetLog::TYPE_SPDY_STREAM_ERROR, | 363 net::NetLog::TYPE_SPDY_STREAM_ERROR, |
364 net::NetLog::PHASE_NONE); | 364 net::NetLog::PHASE_NONE); |
365 | 365 |
366 int stream_id2; | 366 int stream_id2; |
367 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &stream_id2)); | 367 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &stream_id2)); |
368 EXPECT_EQ(static_cast<int>(stream_id), stream_id2); | 368 EXPECT_EQ(static_cast<int>(stream_id), stream_id2); |
369 } | 369 } |
370 | 370 |
371 } // namespace test | 371 } // namespace test |
372 | 372 |
373 } // namespace net | 373 } // namespace net |
OLD | NEW |