blob: 009d9b77212672b1cfab23f6d32216e52bffda4b [file] [log] [blame]
keybuk@google.combf4649a2012-02-15 06:29:06 +09001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
satorux@chromium.orgf77861f2011-08-25 14:18:29 +09002// 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.orgf77861f2011-08-25 14:18:29 +09007
Hidehiko Abe84221302017-06-27 14:45:55 +09008#include <memory>
satorux@chromium.orgf77861f2011-08-25 14:18:29 +09009#include <string>
10
yuki@chromium.orgd4eedf82013-02-07 18:46:24 +090011#include "dbus/message.h"
keybuk@google.combf4649a2012-02-15 06:29:06 +090012#include "dbus/object_path.h"
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090013#include "dbus/object_proxy.h"
14#include "testing/gmock/include/gmock/gmock.h"
15
16namespace dbus {
17
18// Mock for ObjectProxy.
19class MockObjectProxy : public ObjectProxy {
20 public:
21 MockObjectProxy(Bus* bus,
22 const std::string& service_name,
keybuk@google.combf4649a2012-02-15 06:29:06 +090023 const ObjectPath& object_path);
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090024
Hidehiko Abe84221302017-06-27 14:45:55 +090025 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 Hashimoto0102c162017-07-21 17:11:14 +090032
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 Abefb4fdb42017-10-20 04:54:56 +090045 // 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 Hashimoto0102c162017-07-21 17:11:14 +090056 // 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 Hashimotobaabdc72017-09-12 13:53:50 +090067
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.orgf77861f2011-08-25 14:18:29 +090076 void(const std::string& interface_name,
77 const std::string& signal_name,
78 SignalCallback signal_callback,
Ryo Hashimotobaabdc72017-09-12 13:53:50 +090079 OnConnectedCallback* on_connected_callback));
derat9f6266c2016-09-15 23:32:29 +090080 MOCK_METHOD1(SetNameOwnerChangedCallback,
81 void(NameOwnerChangedCallback callback));
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090082 MOCK_METHOD0(Detach, void());
rsleevi@chromium.orgd2163992012-05-19 03:00:22 +090083
84 protected:
nick48b869d2015-04-23 13:41:54 +090085 ~MockObjectProxy() override;
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090086};
87
88} // namespace dbus
89
90#endif // DBUS_MOCK_OBJECT_PROXY_H_