diff options
author | Ryo Hashimoto <hashimoto@chromium.org> | 2017-07-21 17:11:14 +0900 |
---|---|---|
committer | Qijiang Fan <fqj@google.com> | 2020-06-05 06:44:58 +0900 |
commit | 0102c1613a4d3fb7d9f2d2d0633a9189ae7c6ab2 (patch) | |
tree | b92461cd382d738dc5e7a06e9143b85f5ed95530 /dbus/mock_object_proxy.cc | |
parent | 905d9cd064499889a43cde11d4f7c5bb30772f79 (diff) | |
download | libchrome-0102c1613a4d3fb7d9f2d2d0633a9189ae7c6ab2.tar.gz |
dbus: Let ObjectProxy::CallMethod() take OnceCallback
Currently, ObjectProxy::CallMethod is implemented by creating ErrorCallback from ResponseCallback.
This does not work with OnceCallback because it's not allowed to create two callbacks from one OnceCallback.
To solve this, this change introduces CallMethodCallbackInternal to ObjectProxy which takes either Response* or ErrorResponse*, and dispatches the response to the appropriate callback.
Also, Gmock does not allow directly mocking functions which take move-only
arguments.
https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md#mocking-methods-that-use-move-only-types
To workaround this, add DoCallMethod to MockObjetProxy.
BUG=740015
TEST=build
Change-Id: I1a98b5fd1d6d70f69674102a3d66bcec0c13214c
Reviewed-on: https://chromium-review.googlesource.com/578541
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Reviewed-by: Satoru Takabayashi <satorux@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488615}
CrOS-Libchrome-Original-Commit: 2a363a8cb1791cb18a4a64d52afde428e92ba73e
Diffstat (limited to 'dbus/mock_object_proxy.cc')
-rw-r--r-- | dbus/mock_object_proxy.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/dbus/mock_object_proxy.cc b/dbus/mock_object_proxy.cc index 7e26f01ba5..616fb02dc2 100644 --- a/dbus/mock_object_proxy.cc +++ b/dbus/mock_object_proxy.cc @@ -15,4 +15,19 @@ MockObjectProxy::MockObjectProxy(Bus* bus, MockObjectProxy::~MockObjectProxy() { } +void MockObjectProxy::CallMethod(MethodCall* method_call, + int timeout_ms, + ResponseCallback callback) { + DoCallMethod(method_call, timeout_ms, &callback); +} + +void MockObjectProxy::CallMethodWithErrorCallback( + MethodCall* method_call, + int timeout_ms, + ResponseCallback callback, + ErrorCallback error_callback) { + DoCallMethodWithErrorCallback(method_call, timeout_ms, &callback, + &error_callback); +} + } // namespace dbus |