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

Side by Side Diff: net/spdy/spdy_http_stream_spdy2_unittest.cc

Issue 15829004: Update net/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: license twerk Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_http_stream.cc ('k') | net/spdy/spdy_http_stream_spdy3_unittest.cc » ('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 (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/spdy/spdy_http_stream.h" 5 #include "net/spdy/spdy_http_stream.h"
6 6
7 #include "crypto/ec_private_key.h" 7 #include "crypto/ec_private_key.h"
8 #include "crypto/ec_signature_creator.h" 8 #include "crypto/ec_signature_creator.h"
9 #include "crypto/signature_creator.h" 9 #include "crypto/signature_creator.h"
10 #include "net/base/capturing_net_log.h" 10 #include "net/base/capturing_net_log.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 TestLoadTimingReused(*http_stream2); 289 TestLoadTimingReused(*http_stream2);
290 EXPECT_TRUE(http_stream2->GetLoadTimingInfo(&load_timing_info2)); 290 EXPECT_TRUE(http_stream2->GetLoadTimingInfo(&load_timing_info2));
291 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); 291 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id);
292 292
293 // All the reads. 293 // All the reads.
294 deterministic_data()->RunFor(6); 294 deterministic_data()->RunFor(6);
295 295
296 // Read stream 1 to completion, before making sure we can still read load 296 // Read stream 1 to completion, before making sure we can still read load
297 // timing from both streams. 297 // timing from both streams.
298 scoped_refptr<IOBuffer> buf1(new IOBuffer(1)); 298 scoped_refptr<IOBuffer> buf1(new IOBuffer(1));
299 ASSERT_EQ(0, http_stream1->ReadResponseBody(buf1, 1, callback1.callback())); 299 ASSERT_EQ(
300 0, http_stream1->ReadResponseBody(buf1.get(), 1, callback1.callback()));
300 301
301 // Stream 1 has been read to completion. 302 // Stream 1 has been read to completion.
302 TestLoadTimingNotReused(*http_stream1); 303 TestLoadTimingNotReused(*http_stream1);
303 // Stream 2 still has queued body data. 304 // Stream 2 still has queued body data.
304 TestLoadTimingReused(*http_stream2); 305 TestLoadTimingReused(*http_stream2);
305 } 306 }
306 307
307 TEST_F(SpdyHttpStreamSpdy2Test, SendChunkedPost) { 308 TEST_F(SpdyHttpStreamSpdy2Test, SendChunkedPost) {
308 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); 309 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0));
309 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); 310 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true));
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 deterministic_data()->RunFor(2); 438 deterministic_data()->RunFor(2);
438 439
439 // Read response headers. 440 // Read response headers.
440 deterministic_data()->RunFor(1); 441 deterministic_data()->RunFor(1);
441 ASSERT_EQ(OK, http_stream->ReadResponseHeaders(callback.callback())); 442 ASSERT_EQ(OK, http_stream->ReadResponseHeaders(callback.callback()));
442 443
443 // Read and check |chunk1| response. 444 // Read and check |chunk1| response.
444 deterministic_data()->RunFor(1); 445 deterministic_data()->RunFor(1);
445 scoped_refptr<IOBuffer> buf1(new IOBuffer(kUploadDataSize)); 446 scoped_refptr<IOBuffer> buf1(new IOBuffer(kUploadDataSize));
446 ASSERT_EQ(kUploadDataSize, 447 ASSERT_EQ(kUploadDataSize,
447 http_stream->ReadResponseBody(buf1, 448 http_stream->ReadResponseBody(
448 kUploadDataSize, 449 buf1.get(), kUploadDataSize, callback.callback()));
449 callback.callback()));
450 EXPECT_EQ(kUploadData, std::string(buf1->data(), kUploadDataSize)); 450 EXPECT_EQ(kUploadData, std::string(buf1->data(), kUploadDataSize));
451 451
452 // Read and check |chunk2| response. 452 // Read and check |chunk2| response.
453 deterministic_data()->RunFor(1); 453 deterministic_data()->RunFor(1);
454 scoped_refptr<IOBuffer> buf2(new IOBuffer(kUploadData1Size)); 454 scoped_refptr<IOBuffer> buf2(new IOBuffer(kUploadData1Size));
455 ASSERT_EQ(kUploadData1Size, 455 ASSERT_EQ(kUploadData1Size,
456 http_stream->ReadResponseBody(buf2, 456 http_stream->ReadResponseBody(
457 kUploadData1Size, 457 buf2.get(), kUploadData1Size, callback.callback()));
458 callback.callback()));
459 EXPECT_EQ(kUploadData1, std::string(buf2->data(), kUploadData1Size)); 458 EXPECT_EQ(kUploadData1, std::string(buf2->data(), kUploadData1Size));
460 459
461 // Read and check |chunk3| response. 460 // Read and check |chunk3| response.
462 deterministic_data()->RunFor(1); 461 deterministic_data()->RunFor(1);
463 scoped_refptr<IOBuffer> buf3(new IOBuffer(kUploadDataSize)); 462 scoped_refptr<IOBuffer> buf3(new IOBuffer(kUploadDataSize));
464 ASSERT_EQ(kUploadDataSize, 463 ASSERT_EQ(kUploadDataSize,
465 http_stream->ReadResponseBody(buf3, 464 http_stream->ReadResponseBody(
466 kUploadDataSize, 465 buf3.get(), kUploadDataSize, callback.callback()));
467 callback.callback()));
468 EXPECT_EQ(kUploadData, std::string(buf3->data(), kUploadDataSize)); 466 EXPECT_EQ(kUploadData, std::string(buf3->data(), kUploadDataSize));
469 467
470 // Finish reading the |EOF|. 468 // Finish reading the |EOF|.
471 deterministic_data()->RunFor(1); 469 deterministic_data()->RunFor(1);
472 ASSERT_TRUE(response.headers.get()); 470 ASSERT_TRUE(response.headers.get());
473 ASSERT_EQ(200, response.headers->response_code()); 471 ASSERT_EQ(200, response.headers->response_code());
474 EXPECT_TRUE(deterministic_data()->at_read_eof()); 472 EXPECT_TRUE(deterministic_data()->at_read_eof());
475 EXPECT_TRUE(deterministic_data()->at_write_eof()); 473 EXPECT_TRUE(deterministic_data()->at_write_eof());
476 } 474 }
477 475
(...skipping 18 matching lines...) Expand all
496 EXPECT_EQ(OK, InitSession(reads, arraysize(reads), writes, arraysize(writes), 494 EXPECT_EQ(OK, InitSession(reads, arraysize(reads), writes, arraysize(writes),
497 host_port_pair)); 495 host_port_pair));
498 496
499 HttpRequestInfo request; 497 HttpRequestInfo request;
500 request.method = "GET"; 498 request.method = "GET";
501 request.url = GURL(full_url); 499 request.url = GURL(full_url);
502 TestCompletionCallback callback; 500 TestCompletionCallback callback;
503 HttpResponseInfo response; 501 HttpResponseInfo response;
504 HttpRequestHeaders headers; 502 HttpRequestHeaders headers;
505 BoundNetLog net_log; 503 BoundNetLog net_log;
506 scoped_ptr<SpdyHttpStream> http_stream(new SpdyHttpStream(session_, true)); 504 scoped_ptr<SpdyHttpStream> http_stream(
507 ASSERT_EQ( 505 new SpdyHttpStream(session_.get(), true));
508 OK, 506 ASSERT_EQ(OK,
509 http_stream->InitializeStream(&request, DEFAULT_PRIORITY, 507 http_stream->InitializeStream(
510 net_log, CompletionCallback())); 508 &request, DEFAULT_PRIORITY, net_log, CompletionCallback()));
511 509
512 EXPECT_EQ(ERR_IO_PENDING, http_stream->SendRequest(headers, &response, 510 EXPECT_EQ(ERR_IO_PENDING, http_stream->SendRequest(headers, &response,
513 callback.callback())); 511 callback.callback()));
514 512
515 EXPECT_EQ(base_url, http_stream->stream()->GetUrl().spec()); 513 EXPECT_EQ(base_url, http_stream->stream()->GetUrl().spec());
516 514
517 // This triggers the MockWrite and read 2 515 // This triggers the MockWrite and read 2
518 callback.WaitForResult(); 516 callback.WaitForResult();
519 517
520 // This triggers read 3. The empty read causes the session to shut down. 518 // This triggers read 3. The empty read causes the session to shut down.
521 data()->CompleteRead(); 519 data()->CompleteRead();
522 520
523 // Because we abandoned the stream, we don't expect to find a session in the 521 // Because we abandoned the stream, we don't expect to find a session in the
524 // pool anymore. 522 // pool anymore.
525 EXPECT_FALSE(http_session_->spdy_session_pool()->HasSession(key)); 523 EXPECT_FALSE(http_session_->spdy_session_pool()->HasSession(key));
526 EXPECT_TRUE(data()->at_read_eof()); 524 EXPECT_TRUE(data()->at_read_eof());
527 EXPECT_TRUE(data()->at_write_eof()); 525 EXPECT_TRUE(data()->at_write_eof());
528 } 526 }
529 527
530 // TODO(willchan): Write a longer test for SpdyStream that exercises all 528 // TODO(willchan): Write a longer test for SpdyStream that exercises all
531 // methods. 529 // methods.
532 530
533 } // namespace net 531 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_http_stream.cc ('k') | net/spdy/spdy_http_stream_spdy3_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698