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 DBUS_MOCK_OBJECT_PROXY_H_ | 5 #ifndef DBUS_MOCK_OBJECT_PROXY_H_ |
6 #define DBUS_MOCK_OBJECT_PROXY_H_ | 6 #define DBUS_MOCK_OBJECT_PROXY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "dbus/message.h" | 10 #include "dbus/message.h" |
11 #include "dbus/object_path.h" | 11 #include "dbus/object_path.h" |
12 #include "dbus/object_proxy.h" | 12 #include "dbus/object_proxy.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
14 | 14 |
15 namespace dbus { | 15 namespace dbus { |
16 | 16 |
17 // Mock for ObjectProxy. | 17 // Mock for ObjectProxy. |
18 class MockObjectProxy : public ObjectProxy { | 18 class MockObjectProxy : public ObjectProxy { |
19 public: | 19 public: |
20 MockObjectProxy(Bus* bus, | 20 MockObjectProxy(Bus* bus, |
21 const std::string& service_name, | 21 const std::string& service_name, |
22 const ObjectPath& object_path); | 22 const ObjectPath& object_path); |
23 | 23 |
24 // GMock doesn't support the return type of scoped_ptr<> because scoped_ptr is | 24 // GMock doesn't support the return type of scoped_ptr<> because scoped_ptr is |
25 // uncopyable. This is a workaround which defines |MockCallMethodAndBlock| as | 25 // uncopyable. This is a workaround which defines |MockCallMethodAndBlock| as |
26 // a mock method and makes |CallMethodAndBlock| call the mocked method. | 26 // a mock method and makes |CallMethodAndBlock| call the mocked method. |
27 // Use |MockCallMethodAndBlock| for setting/testing expectations. | 27 // Use |MockCallMethodAndBlock| for setting/testing expectations. |
| 28 MOCK_METHOD3(MockCallMethodAndBlockWithErrorDetails, |
| 29 Response*(MethodCall* method_call, |
| 30 int timeout_ms, |
| 31 ScopedDBusError* error)); |
| 32 virtual scoped_ptr<Response> CallMethodAndBlockWithErrorDetails( |
| 33 MethodCall* method_call, |
| 34 int timeout_ms, |
| 35 ScopedDBusError* error) OVERRIDE { |
| 36 return scoped_ptr<Response>( |
| 37 MockCallMethodAndBlockWithErrorDetails(method_call, timeout_ms, error)); |
| 38 } |
28 MOCK_METHOD2(MockCallMethodAndBlock, Response*(MethodCall* method_call, | 39 MOCK_METHOD2(MockCallMethodAndBlock, Response*(MethodCall* method_call, |
29 int timeout_ms)); | 40 int timeout_ms)); |
30 virtual scoped_ptr<Response> CallMethodAndBlock(MethodCall* method_call, | 41 virtual scoped_ptr<Response> CallMethodAndBlock(MethodCall* method_call, |
31 int timeout_ms) OVERRIDE { | 42 int timeout_ms) OVERRIDE { |
32 return scoped_ptr<Response>(MockCallMethodAndBlock(method_call, | 43 return scoped_ptr<Response>(MockCallMethodAndBlock(method_call, |
33 timeout_ms)); | 44 timeout_ms)); |
34 } | 45 } |
35 MOCK_METHOD3(CallMethod, void(MethodCall* method_call, | 46 MOCK_METHOD3(CallMethod, void(MethodCall* method_call, |
36 int timeout_ms, | 47 int timeout_ms, |
37 ResponseCallback callback)); | 48 ResponseCallback callback)); |
38 MOCK_METHOD4(CallMethodWithErrorCallback, void(MethodCall* method_call, | 49 MOCK_METHOD4(CallMethodWithErrorCallback, void(MethodCall* method_call, |
39 int timeout_ms, | 50 int timeout_ms, |
40 ResponseCallback callback, | 51 ResponseCallback callback, |
41 ErrorCallback error_callback)); | 52 ErrorCallback error_callback)); |
42 MOCK_METHOD4(ConnectToSignal, | 53 MOCK_METHOD4(ConnectToSignal, |
43 void(const std::string& interface_name, | 54 void(const std::string& interface_name, |
44 const std::string& signal_name, | 55 const std::string& signal_name, |
45 SignalCallback signal_callback, | 56 SignalCallback signal_callback, |
46 OnConnectedCallback on_connected_callback)); | 57 OnConnectedCallback on_connected_callback)); |
47 MOCK_METHOD0(Detach, void()); | 58 MOCK_METHOD0(Detach, void()); |
48 | 59 |
49 protected: | 60 protected: |
50 virtual ~MockObjectProxy(); | 61 virtual ~MockObjectProxy(); |
51 }; | 62 }; |
52 | 63 |
53 } // namespace dbus | 64 } // namespace dbus |
54 | 65 |
55 #endif // DBUS_MOCK_OBJECT_PROXY_H_ | 66 #endif // DBUS_MOCK_OBJECT_PROXY_H_ |
OLD | NEW |