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