OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // End-to-end tests for WebSocket. | 5 // End-to-end tests for WebSocket. |
6 // | 6 // |
7 // A python server is (re)started for each test, which is moderately | 7 // A python server is (re)started for each test, which is moderately |
8 // inefficient. However, it makes these tests a good fit for scenarios which | 8 // inefficient. However, it makes these tests a good fit for scenarios which |
9 // require special server configurations. | 9 // require special server configurations. |
10 | 10 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // Send the connect request to |socket_url| and wait for a response. Returns | 264 // Send the connect request to |socket_url| and wait for a response. Returns |
265 // true if the handshake succeeded. | 265 // true if the handshake succeeded. |
266 bool ConnectAndWait(const GURL& socket_url) { | 266 bool ConnectAndWait(const GURL& socket_url) { |
267 if (!initialised_context_) { | 267 if (!initialised_context_) { |
268 InitialiseContext(); | 268 InitialiseContext(); |
269 } | 269 } |
270 url::Origin origin(GURL("http://localhost")); | 270 url::Origin origin(GURL("http://localhost")); |
271 event_interface_ = new ConnectTestingEventInterface; | 271 event_interface_ = new ConnectTestingEventInterface; |
272 channel_.reset( | 272 channel_.reset( |
273 new WebSocketChannel(base::WrapUnique(event_interface_), &context_)); | 273 new WebSocketChannel(base::WrapUnique(event_interface_), &context_)); |
274 channel_->SendAddChannelRequest(GURL(socket_url), sub_protocols_, origin); | 274 channel_->SendAddChannelRequest(GURL(socket_url), sub_protocols_, origin, |
| 275 ""); |
275 event_interface_->WaitForResponse(); | 276 event_interface_->WaitForResponse(); |
276 return !event_interface_->failed(); | 277 return !event_interface_->failed(); |
277 } | 278 } |
278 | 279 |
279 ConnectTestingEventInterface* event_interface_; // owned by channel_ | 280 ConnectTestingEventInterface* event_interface_; // owned by channel_ |
280 std::unique_ptr<TestProxyDelegateWithProxyInfo> proxy_delegate_; | 281 std::unique_ptr<TestProxyDelegateWithProxyInfo> proxy_delegate_; |
281 TestURLRequestContext context_; | 282 TestURLRequestContext context_; |
282 std::unique_ptr<WebSocketChannel> channel_; | 283 std::unique_ptr<WebSocketChannel> channel_; |
283 std::vector<std::string> sub_protocols_; | 284 std::vector<std::string> sub_protocols_; |
284 bool initialised_context_; | 285 bool initialised_context_; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 GURL ws_url = ws_server.GetURL("header-continuation"); | 514 GURL ws_url = ws_server.GetURL("header-continuation"); |
514 | 515 |
515 EXPECT_TRUE(ConnectAndWait(ws_url)); | 516 EXPECT_TRUE(ConnectAndWait(ws_url)); |
516 EXPECT_EQ("permessage-deflate; server_max_window_bits=10", | 517 EXPECT_EQ("permessage-deflate; server_max_window_bits=10", |
517 event_interface_->extensions()); | 518 event_interface_->extensions()); |
518 } | 519 } |
519 | 520 |
520 } // namespace | 521 } // namespace |
521 | 522 |
522 } // namespace net | 523 } // namespace net |
OLD | NEW |