Chromium Code Reviews| Index: net/websockets/websocket_stream_create_test_base.h |
| diff --git a/net/websockets/websocket_stream_create_test_base.h b/net/websockets/websocket_stream_create_test_base.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c6742e357a6b136c7b5d38d45978d316852c1971 |
| --- /dev/null |
| +++ b/net/websockets/websocket_stream_create_test_base.h |
| @@ -0,0 +1,80 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef NET_WEBSOCKETS_WEBSOCKET_STREAM_CREATE_TEST_BASE_H_ |
| +#define NET_WEBSOCKETS_WEBSOCKET_STREAM_CREATE_TEST_BASE_H_ |
| + |
| +#include <string> |
| +#include <utility> |
| +#include <vector> |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/scoped_vector.h" |
| +#include "base/timer/timer.h" |
| +#include "net/base/net_export.h" |
| +#include "net/socket/socket_test_util.h" |
| +#include "net/ssl/ssl_info.h" |
| +#include "net/websockets/websocket_event_interface.h" |
| +#include "net/websockets/websocket_test_util.h" |
| + |
| +namespace net { |
| + |
| +class HttpRequestHeaders; |
| +class HttpResponseHeaders; |
| +class WebSocketStream; |
| +class WebSocketStreamRequest; |
| +struct WebSocketHandshakeRequestInfo; |
| +struct WebSocketHandshakeResponseInfo; |
| + |
| +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.
|
| + public: |
| + using HeaderKeyValuePair = std::pair<std::string, std::string>; |
| + |
| + WebSocketStreamCreateTestBase(); |
| + virtual ~WebSocketStreamCreateTestBase(); |
| + |
| + // A wrapper for CreateAndConnectStreamForTesting that knows about our default |
| + // parameters. |
| + void CreateAndConnectStream(const std::string& socket_url, |
| + const std::vector<std::string>& sub_protocols, |
| + const std::string& origin, |
| + scoped_ptr<base::Timer> timer); |
| + |
| + static std::vector<HeaderKeyValuePair> ToVector( |
| + const HttpRequestHeaders& headers); |
| + static std::vector<HeaderKeyValuePair> ToVector( |
| + 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.
|
| + |
| + const std::string& failure_message() const { return failure_message_; } |
| + bool has_failed() const { return has_failed_; } |
| + |
| + 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
|
| + |
| + // A simple function to make the tests more readable. |
| + std::vector<std::string> NoSubProtocols(); |
| + |
| + protected: |
| + WebSocketTestURLRequestContextHost url_request_context_host_; |
| + scoped_ptr<WebSocketStreamRequest> stream_request_; |
| + // Only set if the connection succeeded. |
| + scoped_ptr<WebSocketStream> stream_; |
| + // Only set if the connection failed. |
| + std::string failure_message_; |
| + bool has_failed_; |
| + scoped_ptr<WebSocketHandshakeRequestInfo> request_info_; |
| + scoped_ptr<WebSocketHandshakeResponseInfo> response_info_; |
| + scoped_ptr<WebSocketEventInterface::SSLErrorCallbacks> ssl_error_callbacks_; |
| + SSLInfo ssl_info_; |
| + bool ssl_fatal_; |
| + ScopedVector<SSLSocketDataProvider> ssl_data_; |
| + 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.
|
| + |
| + private: |
| + class TestConnectDelegate; |
| + DISALLOW_COPY_AND_ASSIGN(WebSocketStreamCreateTestBase); |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_CREATE_TEST_BASE_H_ |