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 #ifndef NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ |
6 #define NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "net/url_request/url_request_test_util.h" | 12 #include "net/url_request/url_request_test_util.h" |
13 #include "net/websockets/websocket_stream.h" | 13 #include "net/websockets/websocket_stream.h" |
14 | 14 |
15 class GURL; | 15 class GURL; |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class Timer; | 18 class Timer; |
19 } // namespace base | 19 } // namespace base |
20 | 20 |
21 namespace url { | 21 namespace url { |
22 class Origin; | 22 class Origin; |
23 } // namespace url | 23 } // namespace url |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 | 26 |
27 class BoundNetLog; | 27 class BoundNetLog; |
28 class DeterministicMockClientSocketFactory; | 28 class DeterministicMockClientSocketFactory; |
29 class DeterministicSocketData; | 29 class DeterministicSocketData; |
| 30 class ProxyService; |
30 class URLRequestContext; | 31 class URLRequestContext; |
31 class WebSocketHandshakeStreamCreateHelper; | 32 class WebSocketHandshakeStreamCreateHelper; |
32 struct SSLSocketDataProvider; | 33 struct SSLSocketDataProvider; |
33 | 34 |
34 class LinearCongruentialGenerator { | 35 class LinearCongruentialGenerator { |
35 public: | 36 public: |
36 explicit LinearCongruentialGenerator(uint32 seed); | 37 explicit LinearCongruentialGenerator(uint32 seed); |
37 uint32 Generate(); | 38 uint32 Generate(); |
38 | 39 |
39 private: | 40 private: |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 const std::string& return_to_read) { | 117 const std::string& return_to_read) { |
117 maker_.SetExpectations(expect_written, return_to_read); | 118 maker_.SetExpectations(expect_written, return_to_read); |
118 } | 119 } |
119 | 120 |
120 void AddRawExpectations(scoped_ptr<DeterministicSocketData> socket_data); | 121 void AddRawExpectations(scoped_ptr<DeterministicSocketData> socket_data); |
121 | 122 |
122 // Allow an SSL socket data provider to be added. | 123 // Allow an SSL socket data provider to be added. |
123 void AddSSLSocketDataProvider( | 124 void AddSSLSocketDataProvider( |
124 scoped_ptr<SSLSocketDataProvider> ssl_socket_data); | 125 scoped_ptr<SSLSocketDataProvider> ssl_socket_data); |
125 | 126 |
| 127 // Allow a proxy to be set. Usage: |
| 128 // SetProxyConfig("proxy1:8000"); |
| 129 // Any syntax accepted by net::ProxyConfig::ParseFromString() will work. |
| 130 // Do not call after GetURLRequestContext() has been called. |
| 131 void SetProxyConfig(const std::string& proxy_rules); |
| 132 |
126 // Call after calling one of SetExpections() or AddRawExpectations(). The | 133 // Call after calling one of SetExpections() or AddRawExpectations(). The |
127 // returned pointer remains owned by this object. | 134 // returned pointer remains owned by this object. |
128 TestURLRequestContext* GetURLRequestContext(); | 135 TestURLRequestContext* GetURLRequestContext(); |
129 | 136 |
130 private: | 137 private: |
131 WebSocketDeterministicMockClientSocketFactoryMaker maker_; | 138 WebSocketDeterministicMockClientSocketFactoryMaker maker_; |
132 TestURLRequestContext url_request_context_; | 139 TestURLRequestContext url_request_context_; |
133 TestNetworkDelegate network_delegate_; | 140 TestNetworkDelegate network_delegate_; |
| 141 scoped_ptr<ProxyService> proxy_service_; |
134 bool url_request_context_initialized_; | 142 bool url_request_context_initialized_; |
135 | 143 |
136 DISALLOW_COPY_AND_ASSIGN(WebSocketTestURLRequestContextHost); | 144 DISALLOW_COPY_AND_ASSIGN(WebSocketTestURLRequestContextHost); |
137 }; | 145 }; |
138 | 146 |
139 } // namespace net | 147 } // namespace net |
140 | 148 |
141 #endif // NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ | 149 #endif // NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ |
OLD | NEW |