Index: net/http/http_pipelined_host_test_util.h |
diff --git a/net/http/http_pipelined_host_test_util.h b/net/http/http_pipelined_host_test_util.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..51b2c8db5b94018b43b6280cdfa6c6758a79f42a |
--- /dev/null |
+++ b/net/http/http_pipelined_host_test_util.h |
@@ -0,0 +1,69 @@ |
+// Copyright 2012 Google Inc. All Rights Reserved. |
+// Author: simonjam@google.com (James Simonsen) |
+ |
+#include "net/http/http_pipelined_connection.h" |
+#include "net/http/http_pipelined_host.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
+ |
+namespace net { |
+ |
+class MockHostDelegate : public HttpPipelinedHost::Delegate { |
+ public: |
+ MockHostDelegate(); |
+ virtual ~MockHostDelegate(); |
+ |
+ MOCK_METHOD1(OnHostIdle, void(HttpPipelinedHost* host)); |
+ MOCK_METHOD1(OnHostHasAdditionalCapacity, void(HttpPipelinedHost* host)); |
+ MOCK_METHOD2(OnHostDeterminedCapability, |
+ void(HttpPipelinedHost* host, |
+ HttpPipelinedHostCapability capability)); |
+}; |
+ |
+class MockPipelineFactory : public HttpPipelinedConnection::Factory { |
+ public: |
+ MockPipelineFactory(); |
+ virtual ~MockPipelineFactory(); |
+ |
+ MOCK_METHOD8(CreateNewPipeline, HttpPipelinedConnection*( |
+ ClientSocketHandle* connection, |
+ HttpPipelinedConnection::Delegate* delegate, |
+ const HostPortPair& origin, |
+ const SSLConfig& used_ssl_config, |
+ const ProxyInfo& used_proxy_info, |
+ const BoundNetLog& net_log, |
+ bool was_npn_negotiated, |
+ SSLClientSocket::NextProto protocol_negotiated)); |
+}; |
+ |
+class MockPipeline : public HttpPipelinedConnection { |
+ public: |
+ MockPipeline(int depth, bool usable, bool active); |
+ virtual ~MockPipeline(); |
+ |
+ void SetState(int depth, bool usable, bool active) { |
+ depth_ = depth; |
+ usable_ = usable; |
+ active_ = active; |
+ } |
+ |
+ virtual int depth() const OVERRIDE { return depth_; } |
+ virtual bool usable() const OVERRIDE { return usable_; } |
+ virtual bool active() const OVERRIDE { return active_; } |
+ |
+ MOCK_METHOD0(CreateNewStream, HttpPipelinedStream*()); |
+ MOCK_METHOD1(OnStreamDeleted, void(int pipeline_id)); |
+ MOCK_CONST_METHOD0(used_ssl_config, const SSLConfig&()); |
+ MOCK_CONST_METHOD0(used_proxy_info, const ProxyInfo&()); |
+ MOCK_CONST_METHOD0(net_log, const BoundNetLog&()); |
+ MOCK_CONST_METHOD0(was_npn_negotiated, bool()); |
+ MOCK_CONST_METHOD0(protocol_negotiated, SSLClientSocket::NextProto()); |
+ |
+ private: |
+ int depth_; |
+ bool usable_; |
+ bool active_; |
+}; |
+ |
+MATCHER_P(MatchesOrigin, expected, "") { return expected.Equals(arg); } |
+ |
+} // namespace net |