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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 EXPECT_EQ(OK, connection->Init(host_port_pair.ToString(), transport_params, | 271 EXPECT_EQ(OK, connection->Init(host_port_pair.ToString(), transport_params, |
272 LOWEST, CompletionCallback(), | 272 LOWEST, CompletionCallback(), |
273 session_->GetTransportSocketPool( | 273 session_->GetTransportSocketPool( |
274 HttpNetworkSession::NORMAL_SOCKET_POOL), | 274 HttpNetworkSession::NORMAL_SOCKET_POOL), |
275 BoundNetLog())); | 275 BoundNetLog())); |
276 spdy_session->InitializeWithSocket(connection.release(), false, OK); | 276 spdy_session->InitializeWithSocket(connection.release(), false, OK); |
277 BoundNetLog net_log; | 277 BoundNetLog net_log; |
278 | 278 |
279 // Conjure up a stream. | 279 // Conjure up a stream. |
280 scoped_refptr<SpdyStream> stream = new SpdyStream(spdy_session, | 280 scoped_refptr<SpdyStream> stream = new SpdyStream(spdy_session, |
281 2, | |
282 true, | 281 true, |
283 net_log); | 282 net_log); |
| 283 stream->set_stream_id(2); |
284 EXPECT_FALSE(stream->response_received()); | 284 EXPECT_FALSE(stream->response_received()); |
285 EXPECT_FALSE(stream->HasUrl()); | 285 EXPECT_FALSE(stream->HasUrl()); |
286 | 286 |
287 // Set a couple of headers. | 287 // Set a couple of headers. |
288 SpdyHeaderBlock response; | 288 SpdyHeaderBlock response; |
289 GURL url(kStreamUrl); | 289 GURL url(kStreamUrl); |
290 response[":host"] = url.host(); | 290 response[":host"] = url.host(); |
291 response[":scheme"] = url.scheme(); | 291 response[":scheme"] = url.scheme(); |
292 response[":path"] = url.path(); | 292 response[":path"] = url.path(); |
293 stream->OnResponseReceived(response); | 293 stream->OnResponseReceived(response); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 (*headers)[":scheme"] = url.scheme(); | 406 (*headers)[":scheme"] = url.scheme(); |
407 (*headers)[":host"] = url.host(); | 407 (*headers)[":host"] = url.host(); |
408 (*headers)[":path"] = url.path(); | 408 (*headers)[":path"] = url.path(); |
409 (*headers)[":version"] = "HTTP/1.1"; | 409 (*headers)[":version"] = "HTTP/1.1"; |
410 stream->set_spdy_headers(headers); | 410 stream->set_spdy_headers(headers); |
411 EXPECT_TRUE(stream->HasUrl()); | 411 EXPECT_TRUE(stream->HasUrl()); |
412 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec()); | 412 EXPECT_EQ(kStreamUrl, stream->GetUrl().spec()); |
413 | 413 |
414 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true)); | 414 EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(true)); |
415 | 415 |
| 416 EXPECT_EQ(OK, callback.WaitForResult()); |
| 417 |
416 const SpdyStreamId stream_id = stream->stream_id(); | 418 const SpdyStreamId stream_id = stream->stream_id(); |
417 | 419 |
418 EXPECT_EQ(OK, callback.WaitForResult()); | |
419 | |
420 EXPECT_TRUE(delegate->send_headers_completed()); | 420 EXPECT_TRUE(delegate->send_headers_completed()); |
421 EXPECT_EQ("200", (*delegate->response())[":status"]); | 421 EXPECT_EQ("200", (*delegate->response())[":status"]); |
422 EXPECT_EQ("HTTP/1.1", (*delegate->response())[":version"]); | 422 EXPECT_EQ("HTTP/1.1", (*delegate->response())[":version"]); |
423 EXPECT_EQ(std::string("\0hello!\xff", 8), delegate->received_data()); | 423 EXPECT_EQ(std::string("\0hello!\xff", 8), delegate->received_data()); |
424 EXPECT_EQ(8, delegate->data_sent()); | 424 EXPECT_EQ(8, delegate->data_sent()); |
425 EXPECT_TRUE(delegate->closed()); | 425 EXPECT_TRUE(delegate->closed()); |
426 | 426 |
427 // Check that the NetLog was filled reasonably. | 427 // Check that the NetLog was filled reasonably. |
428 net::CapturingNetLog::CapturedEntryList entries; | 428 net::CapturingNetLog::CapturedEntryList entries; |
429 log.GetEntries(&entries); | 429 log.GetEntries(&entries); |
430 EXPECT_LT(0u, entries.size()); | 430 EXPECT_LT(0u, entries.size()); |
431 | 431 |
432 // Check that we logged SPDY_STREAM_ERROR correctly. | 432 // Check that we logged SPDY_STREAM_ERROR correctly. |
433 int pos = net::ExpectLogContainsSomewhere( | 433 int pos = net::ExpectLogContainsSomewhere( |
434 entries, 0, | 434 entries, 0, |
435 net::NetLog::TYPE_SPDY_STREAM_ERROR, | 435 net::NetLog::TYPE_SPDY_STREAM_ERROR, |
436 net::NetLog::PHASE_NONE); | 436 net::NetLog::PHASE_NONE); |
437 | 437 |
438 int stream_id2; | 438 int stream_id2; |
439 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &stream_id2)); | 439 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &stream_id2)); |
440 EXPECT_EQ(static_cast<int>(stream_id), stream_id2); | 440 EXPECT_EQ(static_cast<int>(stream_id), stream_id2); |
441 } | 441 } |
442 | 442 |
443 } // namespace net | 443 } // namespace net |
OLD | NEW |