1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright (c) 2012 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.
#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,
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, NextProto());
private:
int depth_;
bool usable_;
bool active_;
};
MATCHER_P(MatchesOrigin, expected, "") { return expected.Equals(arg); }
} // namespace net
|