| 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 "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
| 8 #include <stdarg.h> | 8 #include <stdarg.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 12078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12089 TEST_P(HttpNetworkTransactionTest, CreateWebSocketHandshakeStream) { | 12089 TEST_P(HttpNetworkTransactionTest, CreateWebSocketHandshakeStream) { |
| 12090 // The same logic needs to be tested for both ws: and wss: schemes, but this | 12090 // The same logic needs to be tested for both ws: and wss: schemes, but this |
| 12091 // test is already parameterised on NextProto, so it uses a loop to verify | 12091 // test is already parameterised on NextProto, so it uses a loop to verify |
| 12092 // that the different schemes work. | 12092 // that the different schemes work. |
| 12093 std::string test_cases[] = {"ws://www.google.com/", "wss://www.google.com/"}; | 12093 std::string test_cases[] = {"ws://www.google.com/", "wss://www.google.com/"}; |
| 12094 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 12094 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
| 12095 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 12095 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 12096 HttpNetworkSessionPeer peer(session); | 12096 HttpNetworkSessionPeer peer(session); |
| 12097 FakeStreamFactory* fake_factory = new FakeStreamFactory(); | 12097 FakeStreamFactory* fake_factory = new FakeStreamFactory(); |
| 12098 FakeWebSocketStreamCreateHelper websocket_stream_create_helper; | 12098 FakeWebSocketStreamCreateHelper websocket_stream_create_helper; |
| 12099 peer.SetWebSocketHandshakeStreamFactory( | 12099 peer.SetHttpStreamFactoryForWebSocket( |
| 12100 scoped_ptr<HttpStreamFactory>(fake_factory)); | 12100 scoped_ptr<HttpStreamFactory>(fake_factory)); |
| 12101 | 12101 |
| 12102 HttpNetworkTransaction trans(LOW, session); | 12102 HttpNetworkTransaction trans(LOW, session); |
| 12103 trans.SetWebSocketHandshakeStreamCreateHelper( | 12103 trans.SetWebSocketHandshakeStreamCreateHelper( |
| 12104 &websocket_stream_create_helper); | 12104 &websocket_stream_create_helper); |
| 12105 | 12105 |
| 12106 HttpRequestInfo request; | 12106 HttpRequestInfo request; |
| 12107 TestCompletionCallback callback; | 12107 TestCompletionCallback callback; |
| 12108 request.method = "GET"; | 12108 request.method = "GET"; |
| 12109 request.url = GURL(test_cases[i]); | 12109 request.url = GURL(test_cases[i]); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12277 // established, to let the HTTP request start. | 12277 // established, to let the HTTP request start. |
| 12278 ASSERT_EQ(OK, http_callback.WaitForResult()); | 12278 ASSERT_EQ(OK, http_callback.WaitForResult()); |
| 12279 std::string response_data; | 12279 std::string response_data; |
| 12280 ASSERT_EQ(OK, ReadTransaction(http_trans.get(), &response_data)); | 12280 ASSERT_EQ(OK, ReadTransaction(http_trans.get(), &response_data)); |
| 12281 EXPECT_EQ("falafel", response_data); | 12281 EXPECT_EQ("falafel", response_data); |
| 12282 | 12282 |
| 12283 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session)); | 12283 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session)); |
| 12284 } | 12284 } |
| 12285 | 12285 |
| 12286 } // namespace net | 12286 } // namespace net |
| OLD | NEW |