| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <cstddef> | 5 #include <cstddef> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 private: | 103 private: |
| 104 // Used by Add{Read,Write}() above. | 104 // Used by Add{Read,Write}() above. |
| 105 std::vector<MockWrite> writes_; | 105 std::vector<MockWrite> writes_; |
| 106 std::vector<MockRead> reads_; | 106 std::vector<MockRead> reads_; |
| 107 int offset_; | 107 int offset_; |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 INSTANTIATE_TEST_CASE_P( | 110 INSTANTIATE_TEST_CASE_P( |
| 111 NextProto, | 111 NextProto, |
| 112 SpdyStreamTest, | 112 SpdyStreamTest, |
| 113 testing::Values(kProtoDeprecatedSPDY2, | 113 testing::Values(kProtoSPDY31, kProtoSPDY4)); |
| 114 kProtoSPDY3, kProtoSPDY31, kProtoSPDY4)); | |
| 115 | 114 |
| 116 TEST_P(SpdyStreamTest, SendDataAfterOpen) { | 115 TEST_P(SpdyStreamTest, SendDataAfterOpen) { |
| 117 GURL url(kStreamUrl); | 116 GURL url(kStreamUrl); |
| 118 | 117 |
| 119 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); | 118 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); |
| 120 | 119 |
| 121 scoped_ptr<SpdyFrame> req( | 120 scoped_ptr<SpdyFrame> req( |
| 122 spdy_util_.ConstructSpdyPost( | 121 spdy_util_.ConstructSpdyPost( |
| 123 kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0)); | 122 kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0)); |
| 124 AddWrite(*req); | 123 AddWrite(*req); |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 | 709 |
| 711 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate.WaitForClose()); | 710 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate.WaitForClose()); |
| 712 } | 711 } |
| 713 | 712 |
| 714 // The tests below are only for SPDY/3 and above. | 713 // The tests below are only for SPDY/3 and above. |
| 715 | 714 |
| 716 // Call IncreaseSendWindowSize on a stream with a large enough delta | 715 // Call IncreaseSendWindowSize on a stream with a large enough delta |
| 717 // to overflow an int32. The SpdyStream should handle that case | 716 // to overflow an int32. The SpdyStream should handle that case |
| 718 // gracefully. | 717 // gracefully. |
| 719 TEST_P(SpdyStreamTest, IncreaseSendWindowSizeOverflow) { | 718 TEST_P(SpdyStreamTest, IncreaseSendWindowSizeOverflow) { |
| 720 if (spdy_util_.protocol() < kProtoSPDY3) | |
| 721 return; | |
| 722 | |
| 723 session_ = | 719 session_ = |
| 724 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_); | 720 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_); |
| 725 | 721 |
| 726 scoped_ptr<SpdyFrame> req( | 722 scoped_ptr<SpdyFrame> req( |
| 727 spdy_util_.ConstructSpdyPost( | 723 spdy_util_.ConstructSpdyPost( |
| 728 kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0)); | 724 kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0)); |
| 729 AddWrite(*req); | 725 AddWrite(*req); |
| 730 | 726 |
| 731 // Triggered by the overflowing call to IncreaseSendWindowSize | 727 // Triggered by the overflowing call to IncreaseSendWindowSize |
| 732 // below. | 728 // below. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 | 866 |
| 871 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate.WaitForClose()); | 867 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate.WaitForClose()); |
| 872 | 868 |
| 873 EXPECT_TRUE(delegate.send_headers_completed()); | 869 EXPECT_TRUE(delegate.send_headers_completed()); |
| 874 EXPECT_EQ("200", delegate.GetResponseHeaderValue(":status")); | 870 EXPECT_EQ("200", delegate.GetResponseHeaderValue(":status")); |
| 875 EXPECT_EQ(std::string(), delegate.TakeReceivedData()); | 871 EXPECT_EQ(std::string(), delegate.TakeReceivedData()); |
| 876 EXPECT_TRUE(data.at_write_eof()); | 872 EXPECT_TRUE(data.at_write_eof()); |
| 877 } | 873 } |
| 878 | 874 |
| 879 TEST_P(SpdyStreamTest, ResumeAfterSendWindowSizeIncreaseRequestResponse) { | 875 TEST_P(SpdyStreamTest, ResumeAfterSendWindowSizeIncreaseRequestResponse) { |
| 880 if (spdy_util_.protocol() < kProtoSPDY3) | |
| 881 return; | |
| 882 | |
| 883 RunResumeAfterUnstallRequestResponseTest( | 876 RunResumeAfterUnstallRequestResponseTest( |
| 884 base::Bind(&IncreaseStreamSendWindowSize)); | 877 base::Bind(&IncreaseStreamSendWindowSize)); |
| 885 } | 878 } |
| 886 | 879 |
| 887 TEST_P(SpdyStreamTest, ResumeAfterSendWindowSizeAdjustRequestResponse) { | 880 TEST_P(SpdyStreamTest, ResumeAfterSendWindowSizeAdjustRequestResponse) { |
| 888 if (spdy_util_.protocol() < kProtoSPDY3) | |
| 889 return; | |
| 890 | |
| 891 RunResumeAfterUnstallRequestResponseTest( | 881 RunResumeAfterUnstallRequestResponseTest( |
| 892 base::Bind(&AdjustStreamSendWindowSize)); | 882 base::Bind(&AdjustStreamSendWindowSize)); |
| 893 } | 883 } |
| 894 | 884 |
| 895 // Given an unstall function, runs a test to make sure that a | 885 // Given an unstall function, runs a test to make sure that a |
| 896 // bidirectional (i.e., non-HTTP-like) stream resumes after a stall | 886 // bidirectional (i.e., non-HTTP-like) stream resumes after a stall |
| 897 // and unstall. | 887 // and unstall. |
| 898 void SpdyStreamTest::RunResumeAfterUnstallBidirectionalTest( | 888 void SpdyStreamTest::RunResumeAfterUnstallBidirectionalTest( |
| 899 const UnstallFunction& unstall_function) { | 889 const UnstallFunction& unstall_function) { |
| 900 GURL url(kStreamUrl); | 890 GURL url(kStreamUrl); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate.WaitForClose()); | 955 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate.WaitForClose()); |
| 966 | 956 |
| 967 EXPECT_TRUE(delegate.send_headers_completed()); | 957 EXPECT_TRUE(delegate.send_headers_completed()); |
| 968 EXPECT_EQ("200", delegate.GetResponseHeaderValue(":status")); | 958 EXPECT_EQ("200", delegate.GetResponseHeaderValue(":status")); |
| 969 EXPECT_EQ(std::string(kPostBody, kPostBodyLength), | 959 EXPECT_EQ(std::string(kPostBody, kPostBodyLength), |
| 970 delegate.TakeReceivedData()); | 960 delegate.TakeReceivedData()); |
| 971 EXPECT_TRUE(data.at_write_eof()); | 961 EXPECT_TRUE(data.at_write_eof()); |
| 972 } | 962 } |
| 973 | 963 |
| 974 TEST_P(SpdyStreamTest, ResumeAfterSendWindowSizeIncreaseBidirectional) { | 964 TEST_P(SpdyStreamTest, ResumeAfterSendWindowSizeIncreaseBidirectional) { |
| 975 if (spdy_util_.protocol() < kProtoSPDY3) | |
| 976 return; | |
| 977 | |
| 978 RunResumeAfterUnstallBidirectionalTest( | 965 RunResumeAfterUnstallBidirectionalTest( |
| 979 base::Bind(&IncreaseStreamSendWindowSize)); | 966 base::Bind(&IncreaseStreamSendWindowSize)); |
| 980 } | 967 } |
| 981 | 968 |
| 982 TEST_P(SpdyStreamTest, ResumeAfterSendWindowSizeAdjustBidirectional) { | 969 TEST_P(SpdyStreamTest, ResumeAfterSendWindowSizeAdjustBidirectional) { |
| 983 if (spdy_util_.protocol() < kProtoSPDY3) | |
| 984 return; | |
| 985 | |
| 986 RunResumeAfterUnstallBidirectionalTest( | 970 RunResumeAfterUnstallBidirectionalTest( |
| 987 base::Bind(&AdjustStreamSendWindowSize)); | 971 base::Bind(&AdjustStreamSendWindowSize)); |
| 988 } | 972 } |
| 989 | 973 |
| 990 // Test calculation of amount of bytes received from network. | 974 // Test calculation of amount of bytes received from network. |
| 991 TEST_P(SpdyStreamTest, ReceivedBytes) { | 975 TEST_P(SpdyStreamTest, ReceivedBytes) { |
| 992 GURL url(kStreamUrl); | 976 GURL url(kStreamUrl); |
| 993 | 977 |
| 994 session_ = | 978 session_ = |
| 995 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_); | 979 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps_); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 data.RunFor(1); // FIN | 1034 data.RunFor(1); // FIN |
| 1051 | 1035 |
| 1052 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate.WaitForClose()); | 1036 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate.WaitForClose()); |
| 1053 } | 1037 } |
| 1054 | 1038 |
| 1055 } // namespace | 1039 } // namespace |
| 1056 | 1040 |
| 1057 } // namespace test | 1041 } // namespace test |
| 1058 | 1042 |
| 1059 } // namespace net | 1043 } // namespace net |
| OLD | NEW |