Introduced IDR_SIGNIN_INTERNALS_INDEX_* strings to grit_whitelist.txt
[chromium-blink-merge.git] / remoting / protocol / protocol_mock_objects.h
blob16bb8663d7fdf60868cc25b83d4aaa92eee1865c
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 #ifndef REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_
6 #define REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_
8 #include <map>
9 #include <string>
11 #include "base/location.h"
12 #include "base/single_thread_task_runner.h"
13 #include "base/values.h"
14 #include "net/base/ip_endpoint.h"
15 #include "remoting/proto/internal.pb.h"
16 #include "remoting/proto/video.pb.h"
17 #include "remoting/protocol/authenticator.h"
18 #include "remoting/protocol/client_stub.h"
19 #include "remoting/protocol/clipboard_stub.h"
20 #include "remoting/protocol/connection_to_client.h"
21 #include "remoting/protocol/host_stub.h"
22 #include "remoting/protocol/input_stub.h"
23 #include "remoting/protocol/pairing_registry.h"
24 #include "remoting/protocol/session.h"
25 #include "remoting/protocol/session_manager.h"
26 #include "remoting/protocol/transport.h"
27 #include "remoting/protocol/video_stub.h"
28 #include "testing/gmock/include/gmock/gmock.h"
30 namespace remoting {
31 namespace protocol {
33 class MockConnectionToClient : public ConnectionToClient {
34 public:
35 MockConnectionToClient(Session* session,
36 HostStub* host_stub);
37 virtual ~MockConnectionToClient();
39 MOCK_METHOD1(Init, void(Session* session));
40 MOCK_METHOD0(video_stub, VideoStub*());
41 MOCK_METHOD0(client_stub, ClientStub*());
42 MOCK_METHOD0(session, Session*());
43 MOCK_METHOD0(Disconnect, void());
45 private:
46 DISALLOW_COPY_AND_ASSIGN(MockConnectionToClient);
49 class MockConnectionToClientEventHandler :
50 public ConnectionToClient::EventHandler {
51 public:
52 MockConnectionToClientEventHandler();
53 virtual ~MockConnectionToClientEventHandler();
55 MOCK_METHOD1(OnConnectionAuthenticated, void(ConnectionToClient* connection));
56 MOCK_METHOD1(OnConnectionChannelsConnected,
57 void(ConnectionToClient* connection));
58 MOCK_METHOD2(OnConnectionClosed, void(ConnectionToClient* connection,
59 ErrorCode error));
60 MOCK_METHOD2(OnSequenceNumberUpdated, void(ConnectionToClient* connection,
61 int64 sequence_number));
62 MOCK_METHOD3(OnRouteChange, void(ConnectionToClient* connection,
63 const std::string& channel_name,
64 const TransportRoute& route));
66 private:
67 DISALLOW_COPY_AND_ASSIGN(MockConnectionToClientEventHandler);
70 class MockClipboardStub : public ClipboardStub {
71 public:
72 MockClipboardStub();
73 virtual ~MockClipboardStub();
75 MOCK_METHOD1(InjectClipboardEvent, void(const ClipboardEvent& event));
77 private:
78 DISALLOW_COPY_AND_ASSIGN(MockClipboardStub);
81 class MockCursorShapeChangeCallback {
82 public:
83 MockCursorShapeChangeCallback();
84 virtual ~MockCursorShapeChangeCallback();
86 MOCK_METHOD1(CursorShapeChangedPtr, void(CursorShapeInfo* info));
87 void CursorShapeChanged(scoped_ptr<CursorShapeInfo> info);
89 private:
90 DISALLOW_COPY_AND_ASSIGN(MockCursorShapeChangeCallback);
93 class MockInputStub : public InputStub {
94 public:
95 MockInputStub();
96 virtual ~MockInputStub();
98 MOCK_METHOD1(InjectKeyEvent, void(const KeyEvent& event));
99 MOCK_METHOD1(InjectMouseEvent, void(const MouseEvent& event));
101 private:
102 DISALLOW_COPY_AND_ASSIGN(MockInputStub);
105 class MockHostStub : public HostStub {
106 public:
107 MockHostStub();
108 virtual ~MockHostStub();
110 MOCK_METHOD1(NotifyClientResolution,
111 void(const ClientResolution& resolution));
112 MOCK_METHOD1(ControlVideo, void(const VideoControl& video_control));
113 MOCK_METHOD1(ControlAudio, void(const AudioControl& audio_control));
114 MOCK_METHOD1(SetCapabilities, void(const Capabilities& capabilities));
115 MOCK_METHOD1(RequestPairing,
116 void(const PairingRequest& pairing_request));
117 MOCK_METHOD1(DeliverClientMessage, void(const ExtensionMessage& message));
119 private:
120 DISALLOW_COPY_AND_ASSIGN(MockHostStub);
123 class MockClientStub : public ClientStub {
124 public:
125 MockClientStub();
126 virtual ~MockClientStub();
128 // ClientStub mock implementation.
129 MOCK_METHOD1(SetCapabilities, void(const Capabilities& capabilities));
130 MOCK_METHOD1(SetPairingResponse,
131 void(const PairingResponse& pairing_response));
132 MOCK_METHOD1(DeliverHostMessage, void(const ExtensionMessage& message));
134 // ClipboardStub mock implementation.
135 MOCK_METHOD1(InjectClipboardEvent, void(const ClipboardEvent& event));
137 // CursorShapeStub mock implementation.
138 MOCK_METHOD1(SetCursorShape, void(const CursorShapeInfo& cursor_shape));
140 private:
141 DISALLOW_COPY_AND_ASSIGN(MockClientStub);
144 class MockVideoStub : public VideoStub {
145 public:
146 MockVideoStub();
147 virtual ~MockVideoStub();
149 MOCK_METHOD2(ProcessVideoPacketPtr, void(const VideoPacket* video_packet,
150 const base::Closure& done));
151 virtual void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet,
152 const base::Closure& done) {
153 ProcessVideoPacketPtr(video_packet.get(), done);
156 private:
157 DISALLOW_COPY_AND_ASSIGN(MockVideoStub);
160 class MockSession : public Session {
161 public:
162 MockSession();
163 virtual ~MockSession();
165 MOCK_METHOD1(SetEventHandler, void(Session::EventHandler* event_handler));
166 MOCK_METHOD0(error, ErrorCode());
167 MOCK_METHOD0(GetTransportChannelFactory, ChannelFactory*());
168 MOCK_METHOD0(GetMultiplexedChannelFactory, ChannelFactory*());
169 MOCK_METHOD0(jid, const std::string&());
170 MOCK_METHOD0(candidate_config, const CandidateSessionConfig*());
171 MOCK_METHOD0(config, const SessionConfig&());
172 MOCK_METHOD1(set_config, void(const SessionConfig& config));
173 MOCK_METHOD0(initiator_token, const std::string&());
174 MOCK_METHOD1(set_initiator_token, void(const std::string& initiator_token));
175 MOCK_METHOD0(receiver_token, const std::string&());
176 MOCK_METHOD1(set_receiver_token, void(const std::string& receiver_token));
177 MOCK_METHOD1(set_shared_secret, void(const std::string& secret));
178 MOCK_METHOD0(shared_secret, const std::string&());
179 MOCK_METHOD0(Close, void());
181 private:
182 DISALLOW_COPY_AND_ASSIGN(MockSession);
185 class MockSessionManager : public SessionManager {
186 public:
187 MockSessionManager();
188 virtual ~MockSessionManager();
190 MOCK_METHOD2(Init, void(SignalStrategy*, Listener*));
191 MOCK_METHOD3(ConnectPtr, Session*(
192 const std::string& host_jid,
193 Authenticator* authenticator,
194 CandidateSessionConfig* config));
195 MOCK_METHOD0(Close, void());
196 MOCK_METHOD1(set_authenticator_factory_ptr,
197 void(AuthenticatorFactory* factory));
198 virtual scoped_ptr<Session> Connect(
199 const std::string& host_jid,
200 scoped_ptr<Authenticator> authenticator,
201 scoped_ptr<CandidateSessionConfig> config) {
202 return scoped_ptr<Session>(ConnectPtr(
203 host_jid, authenticator.get(), config.get()));
205 virtual void set_authenticator_factory(
206 scoped_ptr<AuthenticatorFactory> authenticator_factory) {
207 set_authenticator_factory_ptr(authenticator_factory.release());
210 private:
211 DISALLOW_COPY_AND_ASSIGN(MockSessionManager);
214 // Simple delegate that caches information on paired clients in memory.
215 class MockPairingRegistryDelegate : public PairingRegistry::Delegate {
216 public:
217 MockPairingRegistryDelegate();
218 virtual ~MockPairingRegistryDelegate();
220 // PairingRegistry::Delegate implementation.
221 virtual scoped_ptr<base::ListValue> LoadAll() OVERRIDE;
222 virtual bool DeleteAll() OVERRIDE;
223 virtual protocol::PairingRegistry::Pairing Load(
224 const std::string& client_id) OVERRIDE;
225 virtual bool Save(const protocol::PairingRegistry::Pairing& pairing) OVERRIDE;
226 virtual bool Delete(const std::string& client_id) OVERRIDE;
228 private:
229 typedef std::map<std::string, protocol::PairingRegistry::Pairing> Pairings;
230 Pairings pairings_;
233 class SynchronousPairingRegistry : public PairingRegistry {
234 public:
235 explicit SynchronousPairingRegistry(scoped_ptr<Delegate> delegate);
237 protected:
238 virtual ~SynchronousPairingRegistry();
240 // Runs tasks synchronously instead of posting them to |task_runner|.
241 virtual void PostTask(
242 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
243 const tracked_objects::Location& from_here,
244 const base::Closure& task) OVERRIDE;
247 } // namespace protocol
248 } // namespace remoting
250 #endif // REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_