1 // Copyright (c) 2012 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 #include "net/http/http_pipelined_connection.h" 6 #include "net/http/http_pipelined_host.h" 7 #include "testing/gmock/include/gmock/gmock.h" 8 9 namespace net { 10 11 class MockHostDelegate : public HttpPipelinedHost::Delegate { 12 public: 13 MockHostDelegate(); 14 virtual ~MockHostDelegate(); 15 16 MOCK_METHOD1(OnHostIdle, void(HttpPipelinedHost* host)); 17 MOCK_METHOD1(OnHostHasAdditionalCapacity, void(HttpPipelinedHost* host)); 18 MOCK_METHOD2(OnHostDeterminedCapability, 19 void(HttpPipelinedHost* host, 20 HttpPipelinedHostCapability capability)); 21 }; 22 23 class MockPipelineFactory : public HttpPipelinedConnection::Factory { 24 public: 25 MockPipelineFactory(); 26 virtual ~MockPipelineFactory(); 27 28 MOCK_METHOD8(CreateNewPipeline, HttpPipelinedConnection*( 29 ClientSocketHandle* connection, 30 HttpPipelinedConnection::Delegate* delegate, 31 const HostPortPair& origin, 32 const SSLConfig& used_ssl_config, 33 const ProxyInfo& used_proxy_info, 34 const BoundNetLog& net_log, 35 bool was_npn_negotiated, 36 NextProto protocol_negotiated)); 37 }; 38 39 class MockPipeline : public HttpPipelinedConnection { 40 public: 41 MockPipeline(int depth, bool usable, bool active); 42 virtual ~MockPipeline(); 43 44 void SetState(int depth, bool usable, bool active) { 45 depth_ = depth; 46 usable_ = usable; 47 active_ = active; 48 } 49 50 virtual int depth() const OVERRIDE { return depth_; } 51 virtual bool usable() const OVERRIDE { return usable_; } 52 virtual bool active() const OVERRIDE { return active_; } 53 54 MOCK_METHOD0(CreateNewStream, HttpPipelinedStream*()); 55 MOCK_METHOD1(OnStreamDeleted, void(int pipeline_id)); 56 MOCK_CONST_METHOD0(used_ssl_config, const SSLConfig&()); 57 MOCK_CONST_METHOD0(used_proxy_info, const ProxyInfo&()); 58 MOCK_CONST_METHOD0(net_log, const BoundNetLog&()); 59 MOCK_CONST_METHOD0(was_npn_negotiated, bool()); 60 MOCK_CONST_METHOD0(protocol_negotiated, NextProto()); 61 62 private: 63 int depth_; 64 bool usable_; 65 bool active_; 66 }; 67 68 MATCHER_P(MatchesOrigin, expected, "") { return expected.Equals(arg); } 69 70 } // namespace net 71