OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_ | 5 #ifndef REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_ |
6 #define REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_ | 6 #define REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" |
15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "net/base/ip_endpoint.h" | 18 #include "net/base/ip_endpoint.h" |
18 #include "remoting/proto/internal.pb.h" | 19 #include "remoting/proto/internal.pb.h" |
19 #include "remoting/proto/video.pb.h" | 20 #include "remoting/proto/video.pb.h" |
20 #include "remoting/protocol/authenticator.h" | 21 #include "remoting/protocol/authenticator.h" |
21 #include "remoting/protocol/client_stub.h" | 22 #include "remoting/protocol/client_stub.h" |
22 #include "remoting/protocol/clipboard_stub.h" | 23 #include "remoting/protocol/clipboard_stub.h" |
23 #include "remoting/protocol/connection_to_client.h" | 24 #include "remoting/protocol/connection_to_client.h" |
24 #include "remoting/protocol/host_stub.h" | 25 #include "remoting/protocol/host_stub.h" |
(...skipping 14 matching lines...) Expand all Loading... |
39 MockConnectionToClientEventHandler(); | 40 MockConnectionToClientEventHandler(); |
40 ~MockConnectionToClientEventHandler() override; | 41 ~MockConnectionToClientEventHandler() override; |
41 | 42 |
42 MOCK_METHOD1(OnConnectionAuthenticating, | 43 MOCK_METHOD1(OnConnectionAuthenticating, |
43 void(ConnectionToClient* connection)); | 44 void(ConnectionToClient* connection)); |
44 MOCK_METHOD1(OnConnectionAuthenticated, void(ConnectionToClient* connection)); | 45 MOCK_METHOD1(OnConnectionAuthenticated, void(ConnectionToClient* connection)); |
45 MOCK_METHOD1(OnConnectionChannelsConnected, | 46 MOCK_METHOD1(OnConnectionChannelsConnected, |
46 void(ConnectionToClient* connection)); | 47 void(ConnectionToClient* connection)); |
47 MOCK_METHOD2(OnConnectionClosed, | 48 MOCK_METHOD2(OnConnectionClosed, |
48 void(ConnectionToClient* connection, ErrorCode error)); | 49 void(ConnectionToClient* connection, ErrorCode error)); |
49 MOCK_METHOD1(OnCreateVideoEncoder, void(scoped_ptr<VideoEncoder>* encoder)); | 50 MOCK_METHOD1(OnCreateVideoEncoder, |
| 51 void(std::unique_ptr<VideoEncoder>* encoder)); |
50 MOCK_METHOD2(OnInputEventReceived, | 52 MOCK_METHOD2(OnInputEventReceived, |
51 void(ConnectionToClient* connection, int64_t timestamp)); | 53 void(ConnectionToClient* connection, int64_t timestamp)); |
52 MOCK_METHOD3(OnRouteChange, | 54 MOCK_METHOD3(OnRouteChange, |
53 void(ConnectionToClient* connection, | 55 void(ConnectionToClient* connection, |
54 const std::string& channel_name, | 56 const std::string& channel_name, |
55 const TransportRoute& route)); | 57 const TransportRoute& route)); |
56 | 58 |
57 private: | 59 private: |
58 DISALLOW_COPY_AND_ASSIGN(MockConnectionToClientEventHandler); | 60 DISALLOW_COPY_AND_ASSIGN(MockConnectionToClientEventHandler); |
59 }; | 61 }; |
60 | 62 |
61 class MockClipboardStub : public ClipboardStub { | 63 class MockClipboardStub : public ClipboardStub { |
62 public: | 64 public: |
63 MockClipboardStub(); | 65 MockClipboardStub(); |
64 ~MockClipboardStub() override; | 66 ~MockClipboardStub() override; |
65 | 67 |
66 MOCK_METHOD1(InjectClipboardEvent, void(const ClipboardEvent& event)); | 68 MOCK_METHOD1(InjectClipboardEvent, void(const ClipboardEvent& event)); |
67 | 69 |
68 private: | 70 private: |
69 DISALLOW_COPY_AND_ASSIGN(MockClipboardStub); | 71 DISALLOW_COPY_AND_ASSIGN(MockClipboardStub); |
70 }; | 72 }; |
71 | 73 |
72 class MockCursorShapeChangeCallback { | 74 class MockCursorShapeChangeCallback { |
73 public: | 75 public: |
74 MockCursorShapeChangeCallback(); | 76 MockCursorShapeChangeCallback(); |
75 virtual ~MockCursorShapeChangeCallback(); | 77 virtual ~MockCursorShapeChangeCallback(); |
76 | 78 |
77 MOCK_METHOD1(CursorShapeChangedPtr, void(CursorShapeInfo* info)); | 79 MOCK_METHOD1(CursorShapeChangedPtr, void(CursorShapeInfo* info)); |
78 void CursorShapeChanged(scoped_ptr<CursorShapeInfo> info); | 80 void CursorShapeChanged(std::unique_ptr<CursorShapeInfo> info); |
79 | 81 |
80 private: | 82 private: |
81 DISALLOW_COPY_AND_ASSIGN(MockCursorShapeChangeCallback); | 83 DISALLOW_COPY_AND_ASSIGN(MockCursorShapeChangeCallback); |
82 }; | 84 }; |
83 | 85 |
84 class MockInputStub : public InputStub { | 86 class MockInputStub : public InputStub { |
85 public: | 87 public: |
86 MockInputStub(); | 88 MockInputStub(); |
87 ~MockInputStub() override; | 89 ~MockInputStub() override; |
88 | 90 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 }; | 148 }; |
147 | 149 |
148 class MockVideoStub : public VideoStub { | 150 class MockVideoStub : public VideoStub { |
149 public: | 151 public: |
150 MockVideoStub(); | 152 MockVideoStub(); |
151 ~MockVideoStub() override; | 153 ~MockVideoStub() override; |
152 | 154 |
153 MOCK_METHOD2(ProcessVideoPacketPtr, | 155 MOCK_METHOD2(ProcessVideoPacketPtr, |
154 void(const VideoPacket* video_packet, | 156 void(const VideoPacket* video_packet, |
155 const base::Closure& done)); | 157 const base::Closure& done)); |
156 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, | 158 void ProcessVideoPacket(std::unique_ptr<VideoPacket> video_packet, |
157 const base::Closure& done) override { | 159 const base::Closure& done) override { |
158 ProcessVideoPacketPtr(video_packet.get(), done); | 160 ProcessVideoPacketPtr(video_packet.get(), done); |
159 } | 161 } |
160 | 162 |
161 private: | 163 private: |
162 DISALLOW_COPY_AND_ASSIGN(MockVideoStub); | 164 DISALLOW_COPY_AND_ASSIGN(MockVideoStub); |
163 }; | 165 }; |
164 | 166 |
165 class MockSession : public Session { | 167 class MockSession : public Session { |
166 public: | 168 public: |
(...skipping 10 matching lines...) Expand all Loading... |
177 private: | 179 private: |
178 DISALLOW_COPY_AND_ASSIGN(MockSession); | 180 DISALLOW_COPY_AND_ASSIGN(MockSession); |
179 }; | 181 }; |
180 | 182 |
181 class MockSessionManager : public SessionManager { | 183 class MockSessionManager : public SessionManager { |
182 public: | 184 public: |
183 MockSessionManager(); | 185 MockSessionManager(); |
184 ~MockSessionManager() override; | 186 ~MockSessionManager() override; |
185 | 187 |
186 MOCK_METHOD1(AcceptIncoming, void(const IncomingSessionCallback&)); | 188 MOCK_METHOD1(AcceptIncoming, void(const IncomingSessionCallback&)); |
187 void set_protocol_config(scoped_ptr<CandidateSessionConfig> config) override { | 189 void set_protocol_config( |
188 } | 190 std::unique_ptr<CandidateSessionConfig> config) override {} |
189 MOCK_METHOD2(ConnectPtr, | 191 MOCK_METHOD2(ConnectPtr, |
190 Session*(const std::string& host_jid, | 192 Session*(const std::string& host_jid, |
191 Authenticator* authenticator)); | 193 Authenticator* authenticator)); |
192 MOCK_METHOD0(Close, void()); | 194 MOCK_METHOD0(Close, void()); |
193 MOCK_METHOD1(set_authenticator_factory_ptr, | 195 MOCK_METHOD1(set_authenticator_factory_ptr, |
194 void(AuthenticatorFactory* factory)); | 196 void(AuthenticatorFactory* factory)); |
195 scoped_ptr<Session> Connect( | 197 std::unique_ptr<Session> Connect( |
196 const std::string& host_jid, | 198 const std::string& host_jid, |
197 scoped_ptr<Authenticator> authenticator) override { | 199 std::unique_ptr<Authenticator> authenticator) override { |
198 return make_scoped_ptr(ConnectPtr(host_jid, authenticator.get())); | 200 return base::WrapUnique(ConnectPtr(host_jid, authenticator.get())); |
199 } | 201 } |
200 void set_authenticator_factory( | 202 void set_authenticator_factory( |
201 scoped_ptr<AuthenticatorFactory> authenticator_factory) override { | 203 std::unique_ptr<AuthenticatorFactory> authenticator_factory) override { |
202 set_authenticator_factory_ptr(authenticator_factory.release()); | 204 set_authenticator_factory_ptr(authenticator_factory.release()); |
203 } | 205 } |
204 | 206 |
205 private: | 207 private: |
206 DISALLOW_COPY_AND_ASSIGN(MockSessionManager); | 208 DISALLOW_COPY_AND_ASSIGN(MockSessionManager); |
207 }; | 209 }; |
208 | 210 |
209 // Simple delegate that caches information on paired clients in memory. | 211 // Simple delegate that caches information on paired clients in memory. |
210 class MockPairingRegistryDelegate : public PairingRegistry::Delegate { | 212 class MockPairingRegistryDelegate : public PairingRegistry::Delegate { |
211 public: | 213 public: |
212 MockPairingRegistryDelegate(); | 214 MockPairingRegistryDelegate(); |
213 ~MockPairingRegistryDelegate() override; | 215 ~MockPairingRegistryDelegate() override; |
214 | 216 |
215 // PairingRegistry::Delegate implementation. | 217 // PairingRegistry::Delegate implementation. |
216 scoped_ptr<base::ListValue> LoadAll() override; | 218 std::unique_ptr<base::ListValue> LoadAll() override; |
217 bool DeleteAll() override; | 219 bool DeleteAll() override; |
218 protocol::PairingRegistry::Pairing Load( | 220 protocol::PairingRegistry::Pairing Load( |
219 const std::string& client_id) override; | 221 const std::string& client_id) override; |
220 bool Save(const protocol::PairingRegistry::Pairing& pairing) override; | 222 bool Save(const protocol::PairingRegistry::Pairing& pairing) override; |
221 bool Delete(const std::string& client_id) override; | 223 bool Delete(const std::string& client_id) override; |
222 | 224 |
223 private: | 225 private: |
224 typedef std::map<std::string, protocol::PairingRegistry::Pairing> Pairings; | 226 typedef std::map<std::string, protocol::PairingRegistry::Pairing> Pairings; |
225 Pairings pairings_; | 227 Pairings pairings_; |
226 }; | 228 }; |
227 | 229 |
228 class SynchronousPairingRegistry : public PairingRegistry { | 230 class SynchronousPairingRegistry : public PairingRegistry { |
229 public: | 231 public: |
230 explicit SynchronousPairingRegistry(scoped_ptr<Delegate> delegate); | 232 explicit SynchronousPairingRegistry(std::unique_ptr<Delegate> delegate); |
231 | 233 |
232 protected: | 234 protected: |
233 ~SynchronousPairingRegistry() override; | 235 ~SynchronousPairingRegistry() override; |
234 | 236 |
235 // Runs tasks synchronously instead of posting them to |task_runner|. | 237 // Runs tasks synchronously instead of posting them to |task_runner|. |
236 void PostTask(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 238 void PostTask(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
237 const tracked_objects::Location& from_here, | 239 const tracked_objects::Location& from_here, |
238 const base::Closure& task) override; | 240 const base::Closure& task) override; |
239 }; | 241 }; |
240 | 242 |
241 } // namespace protocol | 243 } // namespace protocol |
242 } // namespace remoting | 244 } // namespace remoting |
243 | 245 |
244 #endif // REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_ | 246 #endif // REMOTING_PROTOCOL_PROTOCOL_MOCK_OBJECTS_H_ |
OLD | NEW |