| 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/websockets/websocket_job.h" | 5 #include "net/websockets/websocket_job.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "testing/platform_test.h" | 37 #include "testing/platform_test.h" |
| 38 | 38 |
| 39 using namespace net::test_spdy2; | 39 using namespace net::test_spdy2; |
| 40 | 40 |
| 41 namespace { | 41 namespace { |
| 42 | 42 |
| 43 class MockSocketStream : public net::SocketStream { | 43 class MockSocketStream : public net::SocketStream { |
| 44 public: | 44 public: |
| 45 MockSocketStream(const GURL& url, net::SocketStream::Delegate* delegate) | 45 MockSocketStream(const GURL& url, net::SocketStream::Delegate* delegate) |
| 46 : SocketStream(url, delegate) {} | 46 : SocketStream(url, delegate) {} |
| 47 virtual ~MockSocketStream() {} | |
| 48 | 47 |
| 49 virtual void Connect() OVERRIDE {} | 48 virtual void Connect() OVERRIDE {} |
| 50 virtual bool SendData(const char* data, int len) OVERRIDE { | 49 virtual bool SendData(const char* data, int len) OVERRIDE { |
| 51 sent_data_ += std::string(data, len); | 50 sent_data_ += std::string(data, len); |
| 52 return true; | 51 return true; |
| 53 } | 52 } |
| 54 | 53 |
| 55 virtual void Close() OVERRIDE {} | 54 virtual void Close() OVERRIDE {} |
| 56 virtual void RestartWithAuth( | 55 virtual void RestartWithAuth( |
| 57 const net::AuthCredentials& credentials) OVERRIDE { | 56 const net::AuthCredentials& credentials) OVERRIDE { |
| 58 } | 57 } |
| 59 | 58 |
| 60 virtual void DetachDelegate() OVERRIDE { | 59 virtual void DetachDelegate() OVERRIDE { |
| 61 delegate_ = NULL; | 60 delegate_ = NULL; |
| 62 } | 61 } |
| 63 | 62 |
| 64 const std::string& sent_data() const { | 63 const std::string& sent_data() const { |
| 65 return sent_data_; | 64 return sent_data_; |
| 66 } | 65 } |
| 67 | 66 |
| 68 private: | 67 private: |
| 68 virtual ~MockSocketStream() {} |
| 69 |
| 69 std::string sent_data_; | 70 std::string sent_data_; |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 class MockSocketStreamDelegate : public net::SocketStream::Delegate { | 73 class MockSocketStreamDelegate : public net::SocketStream::Delegate { |
| 73 public: | 74 public: |
| 74 MockSocketStreamDelegate() | 75 MockSocketStreamDelegate() |
| 75 : amount_sent_(0), allow_all_cookies_(true) {} | 76 : amount_sent_(0), allow_all_cookies_(true) {} |
| 76 void set_allow_all_cookies(bool allow_all_cookies) { | 77 void set_allow_all_cookies(bool allow_all_cookies) { |
| 77 allow_all_cookies_ = allow_all_cookies; | 78 allow_all_cookies_ = allow_all_cookies; |
| 78 } | 79 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 229 |
| 229 private: | 230 private: |
| 230 friend class base::RefCountedThreadSafe<MockCookieStore>; | 231 friend class base::RefCountedThreadSafe<MockCookieStore>; |
| 231 virtual ~MockCookieStore() {} | 232 virtual ~MockCookieStore() {} |
| 232 | 233 |
| 233 std::vector<Entry> entries_; | 234 std::vector<Entry> entries_; |
| 234 }; | 235 }; |
| 235 | 236 |
| 236 class MockSSLConfigService : public net::SSLConfigService { | 237 class MockSSLConfigService : public net::SSLConfigService { |
| 237 public: | 238 public: |
| 238 virtual void GetSSLConfig(net::SSLConfig* config) {}; | 239 virtual void GetSSLConfig(net::SSLConfig* config) OVERRIDE {} |
| 240 |
| 241 private: |
| 242 virtual ~MockSSLConfigService() {} |
| 239 }; | 243 }; |
| 240 | 244 |
| 241 class MockURLRequestContext : public net::URLRequestContext { | 245 class MockURLRequestContext : public net::URLRequestContext { |
| 242 public: | 246 public: |
| 243 explicit MockURLRequestContext(net::CookieStore* cookie_store) | 247 explicit MockURLRequestContext(net::CookieStore* cookie_store) |
| 244 : transport_security_state_(std::string()) { | 248 : transport_security_state_(std::string()) { |
| 245 set_cookie_store(cookie_store); | 249 set_cookie_store(cookie_store); |
| 246 set_transport_security_state(&transport_security_state_); | 250 set_transport_security_state(&transport_security_state_); |
| 247 net::TransportSecurityState::DomainState state; | 251 net::TransportSecurityState::DomainState state; |
| 248 state.expiry = base::Time::Now() + base::TimeDelta::FromSeconds(1000); | 252 state.expiry = base::Time::Now() + base::TimeDelta::FromSeconds(1000); |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 | 1098 |
| 1095 TEST_F(WebSocketJobSpdy2Test, ThrottlingSpdySpdyEnabled) { | 1099 TEST_F(WebSocketJobSpdy2Test, ThrottlingSpdySpdyEnabled) { |
| 1096 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1100 WebSocketJob::set_websocket_over_spdy_enabled(true); |
| 1097 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); | 1101 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); |
| 1098 } | 1102 } |
| 1099 | 1103 |
| 1100 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. | 1104 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. |
| 1101 // TODO(toyoshim,yutak): Add tests to verify closing handshake. | 1105 // TODO(toyoshim,yutak): Add tests to verify closing handshake. |
| 1102 | 1106 |
| 1103 } // namespace net | 1107 } // namespace net |
| OLD | NEW |