Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(720)

Side by Side Diff: net/websockets/websocket_stream_test.cc

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/websockets/websocket_handshake_constants.cc ('k') | sandbox/linux/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_stream.h" 5 #include "net/websockets/websocket_stream.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 requested_subprotocols) {} 100 requested_subprotocols) {}
101 101
102 void OnStreamCreated(WebSocketBasicHandshakeStream* stream) override { 102 void OnStreamCreated(WebSocketBasicHandshakeStream* stream) override {
103 stream->SetWebSocketKeyForTesting("dGhlIHNhbXBsZSBub25jZQ=="); 103 stream->SetWebSocketKeyForTesting("dGhlIHNhbXBsZSBub25jZQ==");
104 } 104 }
105 }; 105 };
106 106
107 class WebSocketStreamCreateTest : public ::testing::Test { 107 class WebSocketStreamCreateTest : public ::testing::Test {
108 public: 108 public:
109 WebSocketStreamCreateTest() : has_failed_(false), ssl_fatal_(false) {} 109 WebSocketStreamCreateTest() : has_failed_(false), ssl_fatal_(false) {}
110 ~WebSocketStreamCreateTest() override {
111 // Permit any endpoint locks to be released.
112 stream_request_.reset();
113 stream_.reset();
114 RunUntilIdle();
115 }
110 116
111 void CreateAndConnectCustomResponse( 117 void CreateAndConnectCustomResponse(
112 const std::string& socket_url, 118 const std::string& socket_url,
113 const std::string& socket_host, 119 const std::string& socket_host,
114 const std::string& socket_path, 120 const std::string& socket_path,
115 const std::vector<std::string>& sub_protocols, 121 const std::vector<std::string>& sub_protocols,
116 const std::string& origin, 122 const std::string& origin,
117 const std::string& extra_request_headers, 123 const std::string& extra_request_headers,
118 const std::string& response_body, 124 const std::string& response_body,
119 scoped_ptr<base::Timer> timer = scoped_ptr<base::Timer>()) { 125 scoped_ptr<base::Timer> timer = scoped_ptr<base::Timer>()) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 scoped_ptr<WebSocketStream> stream_; 247 scoped_ptr<WebSocketStream> stream_;
242 // Only set if the connection failed. 248 // Only set if the connection failed.
243 std::string failure_message_; 249 std::string failure_message_;
244 bool has_failed_; 250 bool has_failed_;
245 scoped_ptr<WebSocketHandshakeRequestInfo> request_info_; 251 scoped_ptr<WebSocketHandshakeRequestInfo> request_info_;
246 scoped_ptr<WebSocketHandshakeResponseInfo> response_info_; 252 scoped_ptr<WebSocketHandshakeResponseInfo> response_info_;
247 scoped_ptr<WebSocketEventInterface::SSLErrorCallbacks> ssl_error_callbacks_; 253 scoped_ptr<WebSocketEventInterface::SSLErrorCallbacks> ssl_error_callbacks_;
248 SSLInfo ssl_info_; 254 SSLInfo ssl_info_;
249 bool ssl_fatal_; 255 bool ssl_fatal_;
250 ScopedVector<SSLSocketDataProvider> ssl_data_; 256 ScopedVector<SSLSocketDataProvider> ssl_data_;
257 ScopedWebSocketEndpointZeroUnlockDelay zero_unlock_delay_;
251 }; 258 };
252 259
253 // There are enough tests of the Sec-WebSocket-Extensions header that they 260 // There are enough tests of the Sec-WebSocket-Extensions header that they
254 // deserve their own test fixture. 261 // deserve their own test fixture.
255 class WebSocketStreamCreateExtensionTest : public WebSocketStreamCreateTest { 262 class WebSocketStreamCreateExtensionTest : public WebSocketStreamCreateTest {
256 public: 263 public:
257 // Performs a standard connect, with the value of the Sec-WebSocket-Extensions 264 // Performs a standard connect, with the value of the Sec-WebSocket-Extensions
258 // header in the response set to |extensions_header_value|. Runs the event 265 // header in the response set to |extensions_header_value|. Runs the event
259 // loop to allow the connect to complete. 266 // loop to allow the connect to complete.
260 void CreateAndConnectWithExtensions( 267 void CreateAndConnectWithExtensions(
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 if (original) { 1383 if (original) {
1377 samples->Subtract(*original); // Cancel the original values. 1384 samples->Subtract(*original); // Cancel the original values.
1378 } 1385 }
1379 EXPECT_EQ(1, samples->GetCount(INCOMPLETE)); 1386 EXPECT_EQ(1, samples->GetCount(INCOMPLETE));
1380 EXPECT_EQ(0, samples->GetCount(CONNECTED)); 1387 EXPECT_EQ(0, samples->GetCount(CONNECTED));
1381 EXPECT_EQ(0, samples->GetCount(FAILED)); 1388 EXPECT_EQ(0, samples->GetCount(FAILED));
1382 } 1389 }
1383 1390
1384 } // namespace 1391 } // namespace
1385 } // namespace net 1392 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_handshake_constants.cc ('k') | sandbox/linux/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698