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

Side by Side Diff: net/websockets/websocket_stream_test_util.h

Issue 869073002: Add WebSocket cookie tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_WEBSOCKETS_WEBSOCKET_STREAM_TEST_UTIL_H_
6 #define NET_WEBSOCKETS_WEBSOCKET_STREAM_TEST_UTIL_H_
Ryan Sleevi 2015/02/07 02:32:46 This file needs to be renamed to websocket_stream_
yhirano 2015/02/09 10:50:15 websocket_stream_create_test_base.h
7
8 #include <string>
9 #include <utility>
10 #include <vector>
11
12 #include "base/memory/scoped_ptr.h"
13 #include "base/run_loop.h"
14 #include "net/base/net_export.h"
15 #include "net/http/http_request_headers.h"
Ryan Sleevi 2015/02/02 20:14:42 Forward declare
yhirano 2015/02/09 10:50:15 Done.
16 #include "net/http/http_response_headers.h"
Ryan Sleevi 2015/02/02 20:14:42 Forward declare
yhirano 2015/02/09 10:50:16 Done.
17 #include "net/socket/socket_test_util.h"
Ryan Sleevi 2015/02/02 20:14:43 unnecessary?
yhirano 2015/02/09 10:50:15 For ScopedWebSocketEndpointZeroUnlockDelay
18 #include "net/websockets/websocket_handshake_request_info.h"
Ryan Sleevi 2015/02/02 20:14:42 Forward declare
yhirano 2015/02/09 10:50:15 Done.
19 #include "net/websockets/websocket_handshake_response_info.h"
Ryan Sleevi 2015/02/02 20:14:42 Forward declare
yhirano 2015/02/09 10:50:15 Done.
20 #include "net/websockets/websocket_test_util.h"
21 #include "url/gurl.h"
Ryan Sleevi 2015/02/02 20:14:42 Forward declare
yhirano 2015/02/09 10:50:15 removed
22
23 namespace net {
24
25 NET_EXPORT_PRIVATE class WebSocketStreamCreateTestBase {
Ryan Sleevi 2015/02/02 20:14:42 class NET_EXPORT_PRIVATE WebSocketStreamCreateTest
yhirano 2015/02/09 10:50:15 Done.
26 class TestConnectDelegate;
Ryan Sleevi 2015/02/02 20:14:42 STYLE: Inappropriate forward declaration. See http
yhirano 2015/02/09 10:50:15 Done.
27
28 public:
29 using HeaderKeyValuePair = std::pair<std::string, std::string>;
30
31 WebSocketStreamCreateTestBase();
32 virtual ~WebSocketStreamCreateTestBase();
33
34 // A wrapper for CreateAndConnectStreamForTesting that knows about our default
35 // parameters.
36 void CreateAndConnectStream(const std::string& socket_url,
37 const std::vector<std::string>& sub_protocols,
38 const std::string& origin,
39 scoped_ptr<base::Timer> timer);
Ryan Sleevi 2015/02/02 20:14:43 IWYU: Include timer header
yhirano 2015/02/09 10:50:15 Done. You suggested forward-declaring WebSocketHan
Ryan Sleevi 2015/02/10 01:26:48 Forward declaring should also work here. I was not
40
41 static std::vector<HeaderKeyValuePair> ToVector(
42 const HttpRequestHeaders& headers);
43 static std::vector<HeaderKeyValuePair> ToVector(
44 const HttpResponseHeaders& headers);
45
46 const std::string& failure_message() const { return failure_message_; }
47 bool has_failed() const { return has_failed_; }
48
49 static void RunUntilIdle() { base::RunLoop().RunUntilIdle(); }
Ryan Sleevi 2015/02/02 20:14:42 Don't inline
yhirano 2015/02/09 10:50:15 Done.
50
51 // A simple function to make the tests more readable. Creates an empty vector.
Ryan Sleevi 2015/02/02 20:14:42 Drop second sentance
yhirano 2015/02/09 10:50:15 Done.
52 static std::vector<std::string> NoSubProtocols() {
Ryan Sleevi 2015/02/02 20:14:42 Is static really necessary? Ditto line 49.
yhirano 2015/02/03 01:26:32 I'd like to leave it be because we can see more ea
Ryan Sleevi 2015/02/03 02:16:27 Why is this desirable? It's a unit test. A new ins
Adam Rice 2015/02/03 05:34:35 I agree with yhirano that this method should be st
yhirano 2015/02/09 10:50:15 Done (static). Regarding public / protected, some
53 return std::vector<std::string>();
Ryan Sleevi 2015/02/02 20:14:42 Don't inline
yhirano 2015/02/09 10:50:15 Done.
54 }
55
56 protected:
57 WebSocketTestURLRequestContextHost url_request_context_host_;
58 scoped_ptr<WebSocketStreamRequest> stream_request_;
59 // Only set if the connection succeeded.
60 scoped_ptr<WebSocketStream> stream_;
61 // Only set if the connection failed.
62 std::string failure_message_;
63 bool has_failed_;
64 scoped_ptr<WebSocketHandshakeRequestInfo> request_info_;
65 scoped_ptr<WebSocketHandshakeResponseInfo> response_info_;
66 scoped_ptr<WebSocketEventInterface::SSLErrorCallbacks> ssl_error_callbacks_;
67 SSLInfo ssl_info_;
Ryan Sleevi 2015/02/02 20:14:43 IWYU: Include SSLInfo header
yhirano 2015/02/09 10:50:15 Done.
68 bool ssl_fatal_;
69 ScopedVector<SSLSocketDataProvider> ssl_data_;
Ryan Sleevi 2015/02/02 20:14:42 IWYU: Include base/memory/scoped_vector
yhirano 2015/02/09 10:50:15 Done.
70 ScopedWebSocketEndpointZeroUnlockDelay zero_unlock_delay_;
71 };
Ryan Sleevi 2015/02/02 20:14:42 private: DISALLOW_COPY_AND_ASSIGN
yhirano 2015/02/09 10:50:16 Done.
72
73 } // namespace net
74
75 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_TEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698