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 // Tests for WebSocketBasicStream. Note that we do not attempt to verify that | 5 // Tests for WebSocketBasicStream. Note that we do not attempt to verify that |
6 // frame parsing itself functions correctly, as that is covered by the | 6 // frame parsing itself functions correctly, as that is covered by the |
7 // WebSocketFrameParser tests. | 7 // WebSocketFrameParser tests. |
8 | 8 |
9 #include "net/websockets/websocket_basic_stream.h" | 9 #include "net/websockets/websocket_basic_stream.h" |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 private: | 100 private: |
101 const bool strict_mode_; | 101 const bool strict_mode_; |
102 }; | 102 }; |
103 | 103 |
104 // A fixture for tests which only perform normal socket operations. | 104 // A fixture for tests which only perform normal socket operations. |
105 class WebSocketBasicStreamSocketTest : public WebSocketBasicStreamTest { | 105 class WebSocketBasicStreamSocketTest : public WebSocketBasicStreamTest { |
106 protected: | 106 protected: |
107 WebSocketBasicStreamSocketTest() | 107 WebSocketBasicStreamSocketTest() |
108 : histograms_("a"), | 108 : pool_(1, 1, &factory_), |
109 pool_(1, 1, &histograms_, &factory_), | |
110 generator_(&GenerateNulMaskingKey), | 109 generator_(&GenerateNulMaskingKey), |
111 expect_all_io_to_complete_(true) {} | 110 expect_all_io_to_complete_(true) {} |
112 | 111 |
113 ~WebSocketBasicStreamSocketTest() override { | 112 ~WebSocketBasicStreamSocketTest() override { |
114 // stream_ has a reference to socket_data_ (via MockTCPClientSocket) and so | 113 // stream_ has a reference to socket_data_ (via MockTCPClientSocket) and so |
115 // should be destroyed first. | 114 // should be destroyed first. |
116 stream_.reset(); | 115 stream_.reset(); |
117 } | 116 } |
118 | 117 |
119 scoped_ptr<ClientSocketHandle> MakeTransportSocket(MockRead reads[], | 118 scoped_ptr<ClientSocketHandle> MakeTransportSocket(MockRead reads[], |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 156 |
158 template <size_t N> | 157 template <size_t N> |
159 void CreateReadOnly(MockRead (&reads)[N]) { | 158 void CreateReadOnly(MockRead (&reads)[N]) { |
160 CreateStream(reads, N, NULL, 0); | 159 CreateStream(reads, N, NULL, 0); |
161 } | 160 } |
162 | 161 |
163 void CreateNullStream() { CreateStream(NULL, 0, NULL, 0); } | 162 void CreateNullStream() { CreateStream(NULL, 0, NULL, 0); } |
164 | 163 |
165 scoped_ptr<SocketDataProvider> socket_data_; | 164 scoped_ptr<SocketDataProvider> socket_data_; |
166 MockClientSocketFactory factory_; | 165 MockClientSocketFactory factory_; |
167 ClientSocketPoolHistograms histograms_; | |
168 MockTransportClientSocketPool pool_; | 166 MockTransportClientSocketPool pool_; |
169 CapturingBoundNetLog(bound_net_log_); | 167 CapturingBoundNetLog(bound_net_log_); |
170 ScopedVector<WebSocketFrame> frames_; | 168 ScopedVector<WebSocketFrame> frames_; |
171 TestCompletionCallback cb_; | 169 TestCompletionCallback cb_; |
172 scoped_refptr<GrowableIOBuffer> http_read_buffer_; | 170 scoped_refptr<GrowableIOBuffer> http_read_buffer_; |
173 std::string sub_protocol_; | 171 std::string sub_protocol_; |
174 std::string extensions_; | 172 std::string extensions_; |
175 WebSocketBasicStream::WebSocketMaskingKeyGeneratorFunction generator_; | 173 WebSocketBasicStream::WebSocketMaskingKeyGeneratorFunction generator_; |
176 bool expect_all_io_to_complete_; | 174 bool expect_all_io_to_complete_; |
177 }; | 175 }; |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 | 934 |
937 TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) { | 935 TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) { |
938 sub_protocol_ = "cyberchat"; | 936 sub_protocol_ = "cyberchat"; |
939 CreateNullStream(); | 937 CreateNullStream(); |
940 | 938 |
941 EXPECT_EQ("cyberchat", stream_->GetSubProtocol()); | 939 EXPECT_EQ("cyberchat", stream_->GetSubProtocol()); |
942 } | 940 } |
943 | 941 |
944 } // namespace | 942 } // namespace |
945 } // namespace net | 943 } // namespace net |
OLD | NEW |