keybuk@google.com | bf4649a | 2012-02-15 06:29:06 +0900 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef DBUS_MOCK_OBJECT_PROXY_H_ |
| 6 | #define DBUS_MOCK_OBJECT_PROXY_H_ |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 7 | |
Hidehiko Abe | 8422130 | 2017-06-27 14:45:55 +0900 | [diff] [blame] | 8 | #include <memory> |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 9 | #include <string> |
| 10 | |
yuki@chromium.org | d4eedf8 | 2013-02-07 18:46:24 +0900 | [diff] [blame] | 11 | #include "dbus/message.h" |
keybuk@google.com | bf4649a | 2012-02-15 06:29:06 +0900 | [diff] [blame] | 12 | #include "dbus/object_path.h" |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 13 | #include "dbus/object_proxy.h" |
| 14 | #include "testing/gmock/include/gmock/gmock.h" |
| 15 | |
| 16 | namespace dbus { |
| 17 | |
| 18 | // Mock for ObjectProxy. |
| 19 | class MockObjectProxy : public ObjectProxy { |
| 20 | public: |
| 21 | MockObjectProxy(Bus* bus, |
| 22 | const std::string& service_name, |
keybuk@google.com | bf4649a | 2012-02-15 06:29:06 +0900 | [diff] [blame] | 23 | const ObjectPath& object_path); |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 24 | |
Hidehiko Abe | 8422130 | 2017-06-27 14:45:55 +0900 | [diff] [blame] | 25 | MOCK_METHOD3(CallMethodAndBlockWithErrorDetails, |
| 26 | std::unique_ptr<Response>(MethodCall* method_call, |
| 27 | int timeout_ms, |
| 28 | ScopedDBusError* error)); |
| 29 | MOCK_METHOD2(CallMethodAndBlock, |
| 30 | std::unique_ptr<Response>(MethodCall* method_call, |
| 31 | int timeout_ms)); |
Ryo Hashimoto | 0102c16 | 2017-07-21 17:11:14 +0900 | [diff] [blame] | 32 | |
| 33 | // This method is not mockable because it takes a move-only argument. To work |
| 34 | // around this, CallMethod() implementation here calls DoCallMethod() which is |
| 35 | // mockable. |
| 36 | void CallMethod(MethodCall* method_call, |
| 37 | int timeout_ms, |
| 38 | ResponseCallback callback) override; |
| 39 | MOCK_METHOD3(DoCallMethod, |
| 40 | void(MethodCall* method_call, |
| 41 | int timeout_ms, |
| 42 | ResponseCallback* callback)); |
| 43 | |
| 44 | // This method is not mockable because it takes a move-only argument. To work |
Hidehiko Abe | fb4fdb4 | 2017-10-20 04:54:56 +0900 | [diff] [blame] | 45 | // around this, CallMethodWithErrorResponse() implementation here calls |
| 46 | // DoCallMethodWithErrorResponse() which is mockable. |
| 47 | void CallMethodWithErrorResponse(MethodCall* method_call, |
| 48 | int timeout_ms, |
| 49 | ResponseOrErrorCallback callback) override; |
| 50 | MOCK_METHOD3(DoCallMethodWithErrorResponse, |
| 51 | void(MethodCall* method_call, |
| 52 | int timeout_ms, |
| 53 | ResponseOrErrorCallback* callback)); |
| 54 | |
| 55 | // This method is not mockable because it takes a move-only argument. To work |
Ryo Hashimoto | 0102c16 | 2017-07-21 17:11:14 +0900 | [diff] [blame] | 56 | // around this, CallMethodWithErrorCallback() implementation here calls |
| 57 | // DoCallMethodWithErrorCallback() which is mockable. |
| 58 | void CallMethodWithErrorCallback(MethodCall* method_call, |
| 59 | int timeout_ms, |
| 60 | ResponseCallback callback, |
| 61 | ErrorCallback error_callback) override; |
| 62 | MOCK_METHOD4(DoCallMethodWithErrorCallback, |
| 63 | void(MethodCall* method_call, |
| 64 | int timeout_ms, |
| 65 | ResponseCallback* callback, |
| 66 | ErrorCallback* error_callback)); |
Ryo Hashimoto | baabdc7 | 2017-09-12 13:53:50 +0900 | [diff] [blame] | 67 | |
| 68 | // This method is not mockable because it takes a move-only argument. To work |
| 69 | // around this, ConnectToSignal() implementation here calls |
| 70 | // DoConnectToSignal() which is mockable. |
| 71 | void ConnectToSignal(const std::string& interface_name, |
| 72 | const std::string& signal_name, |
| 73 | SignalCallback signal_callback, |
| 74 | OnConnectedCallback on_connected_callback) override; |
| 75 | MOCK_METHOD4(DoConnectToSignal, |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 76 | void(const std::string& interface_name, |
| 77 | const std::string& signal_name, |
| 78 | SignalCallback signal_callback, |
Ryo Hashimoto | baabdc7 | 2017-09-12 13:53:50 +0900 | [diff] [blame] | 79 | OnConnectedCallback* on_connected_callback)); |
derat | 9f6266c | 2016-09-15 23:32:29 +0900 | [diff] [blame] | 80 | MOCK_METHOD1(SetNameOwnerChangedCallback, |
| 81 | void(NameOwnerChangedCallback callback)); |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 82 | MOCK_METHOD0(Detach, void()); |
rsleevi@chromium.org | d216399 | 2012-05-19 03:00:22 +0900 | [diff] [blame] | 83 | |
| 84 | protected: |
nick | 48b869d | 2015-04-23 13:41:54 +0900 | [diff] [blame] | 85 | ~MockObjectProxy() override; |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | } // namespace dbus |
| 89 | |
| 90 | #endif // DBUS_MOCK_OBJECT_PROXY_H_ |