| 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/spdy/spdy_http_stream.h" | 5 #include "net/spdy/spdy_http_stream.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 callback.callback())); | 747 callback.callback())); |
| 748 EXPECT_TRUE(HasSpdySession(http_session_->spdy_session_pool(), key)); | 748 EXPECT_TRUE(HasSpdySession(http_session_->spdy_session_pool(), key)); |
| 749 | 749 |
| 750 // Complete the initial request write and first chunk. | 750 // Complete the initial request write and first chunk. |
| 751 deterministic_data_->RunFor(2); | 751 deterministic_data_->RunFor(2); |
| 752 ASSERT_TRUE(callback.have_result()); | 752 ASSERT_TRUE(callback.have_result()); |
| 753 EXPECT_EQ(OK, callback.WaitForResult()); | 753 EXPECT_EQ(OK, callback.WaitForResult()); |
| 754 | 754 |
| 755 // Verify that the window size has decreased. | 755 // Verify that the window size has decreased. |
| 756 ASSERT_TRUE(http_stream->stream() != NULL); | 756 ASSERT_TRUE(http_stream->stream() != NULL); |
| 757 EXPECT_NE(static_cast<int>(kSpdyStreamInitialWindowSize), | 757 EXPECT_NE( |
| 758 http_stream->stream()->send_window_size()); | 758 static_cast<int>(SpdySession::GetInitialWindowSize(session_->protocol())), |
| 759 http_stream->stream()->send_window_size()); |
| 759 | 760 |
| 760 // Read window update. | 761 // Read window update. |
| 761 deterministic_data_->RunFor(1); | 762 deterministic_data_->RunFor(1); |
| 762 | 763 |
| 763 // Verify the window update. | 764 // Verify the window update. |
| 764 ASSERT_TRUE(http_stream->stream() != NULL); | 765 ASSERT_TRUE(http_stream->stream() != NULL); |
| 765 EXPECT_EQ(static_cast<int>(kSpdyStreamInitialWindowSize), | 766 EXPECT_EQ( |
| 766 http_stream->stream()->send_window_size()); | 767 static_cast<int>(SpdySession::GetInitialWindowSize(session_->protocol())), |
| 768 http_stream->stream()->send_window_size()); |
| 767 | 769 |
| 768 // Read response headers. | 770 // Read response headers. |
| 769 deterministic_data_->RunFor(1); | 771 deterministic_data_->RunFor(1); |
| 770 ASSERT_EQ(OK, http_stream->ReadResponseHeaders(callback.callback())); | 772 ASSERT_EQ(OK, http_stream->ReadResponseHeaders(callback.callback())); |
| 771 | 773 |
| 772 // Read and check |chunk1| response. | 774 // Read and check |chunk1| response. |
| 773 deterministic_data_->RunFor(1); | 775 deterministic_data_->RunFor(1); |
| 774 scoped_refptr<IOBuffer> buf1(new IOBuffer(kUploadDataSize)); | 776 scoped_refptr<IOBuffer> buf1(new IOBuffer(kUploadDataSize)); |
| 775 ASSERT_EQ(kUploadDataSize, | 777 ASSERT_EQ(kUploadDataSize, |
| 776 http_stream->ReadResponseBody( | 778 http_stream->ReadResponseBody( |
| 777 buf1.get(), kUploadDataSize, callback.callback())); | 779 buf1.get(), kUploadDataSize, callback.callback())); |
| 778 EXPECT_EQ(kUploadData, std::string(buf1->data(), kUploadDataSize)); | 780 EXPECT_EQ(kUploadData, std::string(buf1->data(), kUploadDataSize)); |
| 779 | 781 |
| 780 // Finish reading the |EOF|. | 782 // Finish reading the |EOF|. |
| 781 deterministic_data_->RunFor(1); | 783 deterministic_data_->RunFor(1); |
| 782 ASSERT_TRUE(response.headers.get()); | 784 ASSERT_TRUE(response.headers.get()); |
| 783 ASSERT_EQ(200, response.headers->response_code()); | 785 ASSERT_EQ(200, response.headers->response_code()); |
| 784 EXPECT_TRUE(deterministic_data_->at_read_eof()); | 786 EXPECT_TRUE(deterministic_data_->at_read_eof()); |
| 785 EXPECT_TRUE(deterministic_data_->at_write_eof()); | 787 EXPECT_TRUE(deterministic_data_->at_write_eof()); |
| 786 } | 788 } |
| 787 | 789 |
| 788 // TODO(willchan): Write a longer test for SpdyStream that exercises all | 790 // TODO(willchan): Write a longer test for SpdyStream that exercises all |
| 789 // methods. | 791 // methods. |
| 790 | 792 |
| 791 } // namespace net | 793 } // namespace net |
| OLD | NEW |