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.
5 #include "net/http/http_pipelined_connection.h"
6 #include "net/http/http_pipelined_host.h"
7 #include "testing/gmock/include/gmock/gmock.h"
11 class MockHostDelegate
: public HttpPipelinedHost::Delegate
{
14 virtual ~MockHostDelegate();
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
));
23 class MockPipelineFactory
: public HttpPipelinedConnection::Factory
{
25 MockPipelineFactory();
26 virtual ~MockPipelineFactory();
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
));
39 class MockPipeline
: public HttpPipelinedConnection
{
41 MockPipeline(int depth
, bool usable
, bool active
);
42 virtual ~MockPipeline();
44 void SetState(int depth
, bool usable
, bool active
) {
50 virtual int depth() const OVERRIDE
{ return depth_
; }
51 virtual bool usable() const OVERRIDE
{ return usable_
; }
52 virtual bool active() const OVERRIDE
{ return active_
; }
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());
68 MATCHER_P(MatchesOrigin
, expected
, "") { return expected
.Equals(arg
); }