1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef DBUS_MOCK_OBJECT_PROXY_H_
6 #define DBUS_MOCK_OBJECT_PROXY_H_
11 #include "base/types/expected.h"
12 #include "dbus/error.h"
13 #include "dbus/message.h"
14 #include "dbus/object_path.h"
15 #include "dbus/object_proxy.h"
16 #include "testing/gmock/include/gmock/gmock.h"
20 // Mock for ObjectProxy.
21 class MockObjectProxy : public ObjectProxy {
23 MockObjectProxy(Bus* bus,
24 const std::string& service_name,
25 const ObjectPath& object_path);
29 base::expected<std::unique_ptr<Response>, Error>(MethodCall* method_call,
32 // This method is not mockable because it takes a move-only argument. To work
33 // around this, CallMethod() implementation here calls DoCallMethod() which is
35 void CallMethod(MethodCall* method_call,
37 ResponseCallback callback) override;
38 MOCK_METHOD3(DoCallMethod,
39 void(MethodCall* method_call,
41 ResponseCallback* callback));
43 // This method is not mockable because it takes a move-only argument. To work
44 // around this, CallMethodWithErrorResponse() implementation here calls
45 // DoCallMethodWithErrorResponse() which is mockable.
46 void CallMethodWithErrorResponse(MethodCall* method_call,
48 ResponseOrErrorCallback callback) override;
49 MOCK_METHOD3(DoCallMethodWithErrorResponse,
50 void(MethodCall* method_call,
52 ResponseOrErrorCallback* callback));
54 // This method is not mockable because it takes a move-only argument. To work
55 // around this, CallMethodWithErrorCallback() implementation here calls
56 // DoCallMethodWithErrorCallback() which is mockable.
57 void CallMethodWithErrorCallback(MethodCall* method_call,
59 ResponseCallback callback,
60 ErrorCallback error_callback) override;
61 MOCK_METHOD4(DoCallMethodWithErrorCallback,
62 void(MethodCall* method_call,
64 ResponseCallback* callback,
65 ErrorCallback* error_callback));
67 // This method is not mockable because it takes a move-only argument. To work
68 // around this, WaitForServiceToBeAvailable() implementation here calls
69 // DoWaitForServiceToBeAvailable() which is mockable.
70 void WaitForServiceToBeAvailable(
71 WaitForServiceToBeAvailableCallback callback) override;
72 MOCK_METHOD1(DoWaitForServiceToBeAvailable,
73 void(WaitForServiceToBeAvailableCallback* callback));
75 // This method is not mockable because it takes a move-only argument. To work
76 // around this, ConnectToSignal() implementation here calls
77 // DoConnectToSignal() which is mockable.
78 void ConnectToSignal(const std::string& interface_name,
79 const std::string& signal_name,
80 SignalCallback signal_callback,
81 OnConnectedCallback on_connected_callback) override;
82 MOCK_METHOD4(DoConnectToSignal,
83 void(const std::string& interface_name,
84 const std::string& signal_name,
85 SignalCallback signal_callback,
86 OnConnectedCallback* on_connected_callback));
87 MOCK_METHOD1(SetNameOwnerChangedCallback,
88 void(NameOwnerChangedCallback callback));
89 MOCK_METHOD0(Detach, void());
92 ~MockObjectProxy() override;
97 #endif // DBUS_MOCK_OBJECT_PROXY_H_