OLD | NEW |
---|---|
(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_CREATE_TEST_BASE_H_ | |
6 #define NET_WEBSOCKETS_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/memory/scoped_vector.h" | |
14 #include "base/timer/timer.h" | |
15 #include "net/base/net_export.h" | |
16 #include "net/socket/socket_test_util.h" | |
17 #include "net/ssl/ssl_info.h" | |
18 #include "net/websockets/websocket_event_interface.h" | |
19 #include "net/websockets/websocket_test_util.h" | |
20 | |
21 namespace net { | |
22 | |
23 class HttpRequestHeaders; | |
24 class HttpResponseHeaders; | |
25 class WebSocketStream; | |
26 class WebSocketStreamRequest; | |
27 struct WebSocketHandshakeRequestInfo; | |
28 struct WebSocketHandshakeResponseInfo; | |
29 | |
30 class NET_EXPORT_PRIVATE WebSocketStreamCreateTestBase { | |
Ryan Sleevi
2015/02/10 01:26:49
Does this actually need to be NET_EXPORT_PRIVATE?
yhirano
2015/02/10 03:14:03
Done.
| |
31 public: | |
32 using HeaderKeyValuePair = std::pair<std::string, std::string>; | |
33 | |
34 WebSocketStreamCreateTestBase(); | |
35 virtual ~WebSocketStreamCreateTestBase(); | |
36 | |
37 // A wrapper for CreateAndConnectStreamForTesting that knows about our default | |
38 // parameters. | |
39 void CreateAndConnectStream(const std::string& socket_url, | |
40 const std::vector<std::string>& sub_protocols, | |
41 const std::string& origin, | |
42 scoped_ptr<base::Timer> timer); | |
43 | |
44 static std::vector<HeaderKeyValuePair> ToVector( | |
45 const HttpRequestHeaders& headers); | |
46 static std::vector<HeaderKeyValuePair> ToVector( | |
47 const HttpResponseHeaders& headers); | |
Ryan Sleevi
2015/02/10 01:26:49
Per http://google-styleguide.googlecode.com/svn/tr
yhirano
2015/02/10 03:14:03
Done.
| |
48 | |
49 const std::string& failure_message() const { return failure_message_; } | |
50 bool has_failed() const { return has_failed_; } | |
51 | |
52 void RunUntilIdle(); | |
Ryan Sleevi
2015/02/10 01:26:49
I'd love to see this "confusing because it duplica
yhirano
2015/02/10 03:14:03
Replaced with base::RunLoop().RunUntilIdle(), thou
yhirano
2015/02/10 05:51:53
Reverted.
Adam, as we discussed, I created "WaitUn
| |
53 | |
54 // A simple function to make the tests more readable. | |
55 std::vector<std::string> NoSubProtocols(); | |
56 | |
57 protected: | |
58 WebSocketTestURLRequestContextHost url_request_context_host_; | |
59 scoped_ptr<WebSocketStreamRequest> stream_request_; | |
60 // Only set if the connection succeeded. | |
61 scoped_ptr<WebSocketStream> stream_; | |
62 // Only set if the connection failed. | |
63 std::string failure_message_; | |
64 bool has_failed_; | |
65 scoped_ptr<WebSocketHandshakeRequestInfo> request_info_; | |
66 scoped_ptr<WebSocketHandshakeResponseInfo> response_info_; | |
67 scoped_ptr<WebSocketEventInterface::SSLErrorCallbacks> ssl_error_callbacks_; | |
68 SSLInfo ssl_info_; | |
69 bool ssl_fatal_; | |
70 ScopedVector<SSLSocketDataProvider> ssl_data_; | |
71 ScopedWebSocketEndpointZeroUnlockDelay zero_unlock_delay_; | |
Ryan Sleevi
2015/02/10 01:26:49
I'd love to see these documented.
yhirano
2015/02/10 03:14:03
Done.
| |
72 | |
73 private: | |
74 class TestConnectDelegate; | |
75 DISALLOW_COPY_AND_ASSIGN(WebSocketStreamCreateTestBase); | |
76 }; | |
77 | |
78 } // namespace net | |
79 | |
80 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_CREATE_TEST_BASE_H_ | |
OLD | NEW |