| 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/websockets/websocket_handshake_stream_create_helper.h" | 5 #include "net/websockets/websocket_handshake_stream_create_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 23 | 23 |
| 24 namespace net { | 24 namespace net { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // This class encapsulates the details of creating a mock ClientSocketHandle. | 27 // This class encapsulates the details of creating a mock ClientSocketHandle. |
| 28 class MockClientSocketHandleFactory { | 28 class MockClientSocketHandleFactory { |
| 29 public: | 29 public: |
| 30 MockClientSocketHandleFactory() | 30 MockClientSocketHandleFactory() |
| 31 : histograms_("a"), | 31 : pool_(1, 1, socket_factory_maker_.factory()) {} |
| 32 pool_(1, 1, &histograms_, socket_factory_maker_.factory()) {} | |
| 33 | 32 |
| 34 // The created socket expects |expect_written| to be written to the socket, | 33 // The created socket expects |expect_written| to be written to the socket, |
| 35 // and will respond with |return_to_read|. The test will fail if the expected | 34 // and will respond with |return_to_read|. The test will fail if the expected |
| 36 // text is not written, or if all the bytes are not read. | 35 // text is not written, or if all the bytes are not read. |
| 37 scoped_ptr<ClientSocketHandle> CreateClientSocketHandle( | 36 scoped_ptr<ClientSocketHandle> CreateClientSocketHandle( |
| 38 const std::string& expect_written, | 37 const std::string& expect_written, |
| 39 const std::string& return_to_read) { | 38 const std::string& return_to_read) { |
| 40 socket_factory_maker_.SetExpectations(expect_written, return_to_read); | 39 socket_factory_maker_.SetExpectations(expect_written, return_to_read); |
| 41 scoped_ptr<ClientSocketHandle> socket_handle(new ClientSocketHandle); | 40 scoped_ptr<ClientSocketHandle> socket_handle(new ClientSocketHandle); |
| 42 socket_handle->Init( | 41 socket_handle->Init( |
| 43 "a", | 42 "a", |
| 44 scoped_refptr<MockTransportSocketParams>(), | 43 scoped_refptr<MockTransportSocketParams>(), |
| 45 MEDIUM, | 44 MEDIUM, |
| 46 CompletionCallback(), | 45 CompletionCallback(), |
| 47 &pool_, | 46 &pool_, |
| 48 BoundNetLog()); | 47 BoundNetLog()); |
| 49 return socket_handle.Pass(); | 48 return socket_handle.Pass(); |
| 50 } | 49 } |
| 51 | 50 |
| 52 private: | 51 private: |
| 53 WebSocketDeterministicMockClientSocketFactoryMaker socket_factory_maker_; | 52 WebSocketDeterministicMockClientSocketFactoryMaker socket_factory_maker_; |
| 54 ClientSocketPoolHistograms histograms_; | |
| 55 MockTransportClientSocketPool pool_; | 53 MockTransportClientSocketPool pool_; |
| 56 | 54 |
| 57 DISALLOW_COPY_AND_ASSIGN(MockClientSocketHandleFactory); | 55 DISALLOW_COPY_AND_ASSIGN(MockClientSocketHandleFactory); |
| 58 }; | 56 }; |
| 59 | 57 |
| 60 class TestConnectDelegate : public WebSocketStream::ConnectDelegate { | 58 class TestConnectDelegate : public WebSocketStream::ConnectDelegate { |
| 61 public: | 59 public: |
| 62 ~TestConnectDelegate() override {} | 60 ~TestConnectDelegate() override {} |
| 63 | 61 |
| 64 void OnSuccess(scoped_ptr<WebSocketStream> stream) override {} | 62 void OnSuccess(scoped_ptr<WebSocketStream> stream) override {} |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 184 |
| 187 EXPECT_EQ( | 185 EXPECT_EQ( |
| 188 "permessage-deflate;" | 186 "permessage-deflate;" |
| 189 " client_max_window_bits=14; server_max_window_bits=14;" | 187 " client_max_window_bits=14; server_max_window_bits=14;" |
| 190 " server_no_context_takeover; client_no_context_takeover", | 188 " server_no_context_takeover; client_no_context_takeover", |
| 191 stream->GetExtensions()); | 189 stream->GetExtensions()); |
| 192 } | 190 } |
| 193 | 191 |
| 194 } // namespace | 192 } // namespace |
| 195 } // namespace net | 193 } // namespace net |
| OLD | NEW |