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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 UpdateSpdySessionDependencies(test_params, session_deps); | 110 UpdateSpdySessionDependencies(test_params, session_deps); |
111 return session_deps; | 111 return session_deps; |
112 } | 112 } |
113 | 113 |
114 } // namespace | 114 } // namespace |
115 | 115 |
116 class SpdyNetworkTransactionTest | 116 class SpdyNetworkTransactionTest |
117 : public ::testing::TestWithParam<SpdyNetworkTransactionTestParams> { | 117 : public ::testing::TestWithParam<SpdyNetworkTransactionTestParams> { |
118 protected: | 118 protected: |
119 SpdyNetworkTransactionTest() : spdy_util_(GetParam().protocol) { | 119 SpdyNetworkTransactionTest() : spdy_util_(GetParam().protocol) { |
120 LOG(INFO) << __FUNCTION__; | |
121 } | 120 } |
122 | 121 |
123 virtual ~SpdyNetworkTransactionTest() { | 122 virtual ~SpdyNetworkTransactionTest() { |
124 LOG(INFO) << __FUNCTION__; | |
125 // UploadDataStream posts deletion tasks back to the message loop on | 123 // UploadDataStream posts deletion tasks back to the message loop on |
126 // destruction. | 124 // destruction. |
127 upload_data_stream_.reset(); | 125 upload_data_stream_.reset(); |
128 base::RunLoop().RunUntilIdle(); | 126 base::RunLoop().RunUntilIdle(); |
129 LOG(INFO) << __FUNCTION__; | |
130 } | 127 } |
131 | 128 |
132 virtual void SetUp() { | 129 virtual void SetUp() { |
133 LOG(INFO) << __FUNCTION__; | |
134 google_get_request_initialized_ = false; | 130 google_get_request_initialized_ = false; |
135 google_post_request_initialized_ = false; | 131 google_post_request_initialized_ = false; |
136 google_chunked_post_request_initialized_ = false; | 132 google_chunked_post_request_initialized_ = false; |
137 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 133 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
138 LOG(INFO) << __FUNCTION__; | |
139 } | 134 } |
140 | 135 |
141 struct TransactionHelperResult { | 136 struct TransactionHelperResult { |
142 int rv; | 137 int rv; |
143 std::string status_line; | 138 std::string status_line; |
144 std::string response_data; | 139 std::string response_data; |
145 HttpResponseInfo response_info; | 140 HttpResponseInfo response_info; |
146 }; | 141 }; |
147 | 142 |
148 // A helper class that handles all the initial npn/ssl setup. | 143 // A helper class that handles all the initial npn/ssl setup. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 session_deps_.get()); | 189 session_deps_.get()); |
195 deterministic_ = true; | 190 deterministic_ = true; |
196 } | 191 } |
197 | 192 |
198 void SetSpdyDisabled() { | 193 void SetSpdyDisabled() { |
199 spdy_enabled_ = false; | 194 spdy_enabled_ = false; |
200 port_ = 80; | 195 port_ = 80; |
201 } | 196 } |
202 | 197 |
203 void RunPreTestSetup() { | 198 void RunPreTestSetup() { |
204 LOG(INFO) << __FUNCTION__; | |
205 if (!session_deps_.get()) | 199 if (!session_deps_.get()) |
206 session_deps_.reset(CreateSpdySessionDependencies(test_params_)); | 200 session_deps_.reset(CreateSpdySessionDependencies(test_params_)); |
207 if (!session_.get()) { | 201 if (!session_.get()) { |
208 session_ = SpdySessionDependencies::SpdyCreateSession( | 202 session_ = SpdySessionDependencies::SpdyCreateSession( |
209 session_deps_.get()); | 203 session_deps_.get()); |
210 } | 204 } |
211 | 205 |
212 // We're now ready to use SSL-npn SPDY. | 206 // We're now ready to use SSL-npn SPDY. |
213 trans_.reset(new HttpNetworkTransaction(priority_, session_.get())); | 207 trans_.reset(new HttpNetworkTransaction(priority_, session_.get())); |
214 LOG(INFO) << __FUNCTION__; | |
215 } | 208 } |
216 | 209 |
217 // Start the transaction, read some data, finish. | 210 // Start the transaction, read some data, finish. |
218 void RunDefaultTest() { | 211 void RunDefaultTest() { |
219 LOG(INFO) << __FUNCTION__; | |
220 if (!StartDefaultTest()) | 212 if (!StartDefaultTest()) |
221 return; | 213 return; |
222 FinishDefaultTest(); | 214 FinishDefaultTest(); |
223 LOG(INFO) << __FUNCTION__; | |
224 } | 215 } |
225 | 216 |
226 bool StartDefaultTest() { | 217 bool StartDefaultTest() { |
227 output_.rv = trans_->Start(&request_, callback_.callback(), log_); | 218 output_.rv = trans_->Start(&request_, callback_.callback(), log_); |
228 | 219 |
229 // We expect an IO Pending or some sort of error. | 220 // We expect an IO Pending or some sort of error. |
230 EXPECT_LT(output_.rv, 0); | 221 EXPECT_LT(output_.rv, 0); |
231 return output_.rv == ERR_IO_PENDING; | 222 return output_.rv == ERR_IO_PENDING; |
232 } | 223 } |
233 | 224 |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 SpdyNetworkTransactionTestParams(kProtoSPDY3, SPDYNPN), | 720 SpdyNetworkTransactionTestParams(kProtoSPDY3, SPDYNPN), |
730 SpdyNetworkTransactionTestParams(kProtoSPDY31, SPDYNOSSL), | 721 SpdyNetworkTransactionTestParams(kProtoSPDY31, SPDYNOSSL), |
731 SpdyNetworkTransactionTestParams(kProtoSPDY31, SPDYSSL), | 722 SpdyNetworkTransactionTestParams(kProtoSPDY31, SPDYSSL), |
732 SpdyNetworkTransactionTestParams(kProtoSPDY31, SPDYNPN), | 723 SpdyNetworkTransactionTestParams(kProtoSPDY31, SPDYNPN), |
733 SpdyNetworkTransactionTestParams(kProtoSPDY4, SPDYNOSSL), | 724 SpdyNetworkTransactionTestParams(kProtoSPDY4, SPDYNOSSL), |
734 SpdyNetworkTransactionTestParams(kProtoSPDY4, SPDYSSL), | 725 SpdyNetworkTransactionTestParams(kProtoSPDY4, SPDYSSL), |
735 SpdyNetworkTransactionTestParams(kProtoSPDY4, SPDYNPN))); | 726 SpdyNetworkTransactionTestParams(kProtoSPDY4, SPDYNPN))); |
736 | 727 |
737 // Verify HttpNetworkTransaction constructor. | 728 // Verify HttpNetworkTransaction constructor. |
738 TEST_P(SpdyNetworkTransactionTest, Constructor) { | 729 TEST_P(SpdyNetworkTransactionTest, Constructor) { |
739 LOG(INFO) << __FUNCTION__; | |
740 scoped_ptr<SpdySessionDependencies> session_deps( | 730 scoped_ptr<SpdySessionDependencies> session_deps( |
741 CreateSpdySessionDependencies(GetParam())); | 731 CreateSpdySessionDependencies(GetParam())); |
742 LOG(INFO) << __FUNCTION__; | |
743 scoped_refptr<HttpNetworkSession> session( | 732 scoped_refptr<HttpNetworkSession> session( |
744 SpdySessionDependencies::SpdyCreateSession(session_deps.get())); | 733 SpdySessionDependencies::SpdyCreateSession(session_deps.get())); |
745 LOG(INFO) << __FUNCTION__; | |
746 scoped_ptr<HttpTransaction> trans( | 734 scoped_ptr<HttpTransaction> trans( |
747 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 735 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
748 LOG(INFO) << __FUNCTION__; | |
749 } | 736 } |
750 | 737 |
751 TEST_P(SpdyNetworkTransactionTest, Get) { | 738 TEST_P(SpdyNetworkTransactionTest, Get) { |
752 LOG(INFO) << __FUNCTION__; | |
753 // Construct the request. | 739 // Construct the request. |
754 scoped_ptr<SpdyFrame> req( | 740 scoped_ptr<SpdyFrame> req( |
755 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); | 741 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); |
756 MockWrite writes[] = { CreateMockWrite(*req) }; | 742 MockWrite writes[] = { CreateMockWrite(*req) }; |
757 | 743 |
758 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 744 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
759 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 745 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
760 MockRead reads[] = { | 746 MockRead reads[] = { |
761 CreateMockRead(*resp), | 747 CreateMockRead(*resp), |
762 CreateMockRead(*body), | 748 CreateMockRead(*body), |
(...skipping 5799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6562 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 6548 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
6563 scoped_ptr<SSLSocketDataProvider> ssl_provider( | 6549 scoped_ptr<SSLSocketDataProvider> ssl_provider( |
6564 new SSLSocketDataProvider(ASYNC, OK)); | 6550 new SSLSocketDataProvider(ASYNC, OK)); |
6565 // Set to TLS_RSA_WITH_NULL_MD5 | 6551 // Set to TLS_RSA_WITH_NULL_MD5 |
6566 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 6552 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
6567 | 6553 |
6568 RunTLSUsageCheckTest(ssl_provider.Pass()); | 6554 RunTLSUsageCheckTest(ssl_provider.Pass()); |
6569 } | 6555 } |
6570 | 6556 |
6571 } // namespace net | 6557 } // namespace net |
OLD | NEW |