blob: 40b090b1567f1b5452f2515ffc4f87fcc15b5e9c [file] [log] [blame]
adamk@chromium.org35c0eef2012-02-11 06:45:23 +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_BUS_H_
6#define DBUS_MOCK_BUS_H_
satorux@chromium.orgf77861f2011-08-25 14:18:29 +09007
avi0ad0ce02015-12-23 03:12:45 +09008#include <stdint.h>
9
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090010#include "dbus/bus.h"
keybuk@google.combf4649a2012-02-15 06:29:06 +090011#include "dbus/object_path.h"
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090012#include "testing/gmock/include/gmock/gmock.h"
13
14namespace dbus {
15
16// Mock for Bus class. Along with MockObjectProxy and MockExportedObject,
17// the mock classes can be used to write unit tests without issuing real
18// D-Bus calls.
19class MockBus : public Bus {
20 public:
thestig@chromium.org074b1db2013-02-20 10:36:53 +090021 MockBus(const Bus::Options& options);
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090022
23 MOCK_METHOD2(GetObjectProxy, ObjectProxy*(const std::string& service_name,
keybuk@google.combf4649a2012-02-15 06:29:06 +090024 const ObjectPath& object_path));
adamk@chromium.org35c0eef2012-02-11 06:45:23 +090025 MOCK_METHOD3(GetObjectProxyWithOptions,
26 ObjectProxy*(const std::string& service_name,
keybuk@google.combf4649a2012-02-15 06:29:06 +090027 const ObjectPath& object_path,
adamk@chromium.org35c0eef2012-02-11 06:45:23 +090028 int options));
keybuk@chromium.org9cb73f02012-03-10 10:12:52 +090029 MOCK_METHOD1(GetExportedObject, ExportedObject*(
keybuk@google.combf4649a2012-02-15 06:29:06 +090030 const ObjectPath& object_path));
keybuk@chromium.org09715012013-03-26 03:20:08 +090031 MOCK_METHOD2(GetObjectManager, ObjectManager*(const std::string&,
32 const ObjectPath&));
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090033 MOCK_METHOD0(ShutdownAndBlock, void());
satorux@chromium.orgd336d452011-09-02 15:56:23 +090034 MOCK_METHOD0(ShutdownOnDBusThreadAndBlock, void());
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090035 MOCK_METHOD0(Connect, bool());
cmasone@chromium.org989857e2013-07-31 15:34:59 +090036 MOCK_METHOD3(RequestOwnership, void(
keybuk@chromium.org9cb73f02012-03-10 10:12:52 +090037 const std::string& service_name,
cmasone@chromium.org989857e2013-07-31 15:34:59 +090038 ServiceOwnershipOptions options,
keybuk@chromium.org9cb73f02012-03-10 10:12:52 +090039 OnOwnershipCallback on_ownership_callback));
cmasone@chromium.org989857e2013-07-31 15:34:59 +090040 MOCK_METHOD2(RequestOwnershipAndBlock, bool(const std::string& service_name,
41 ServiceOwnershipOptions options));
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090042 MOCK_METHOD1(ReleaseOwnership, bool(const std::string& service_name));
43 MOCK_METHOD0(SetUpAsyncOperations, bool());
44 MOCK_METHOD3(SendWithReplyAndBlock, DBusMessage*(DBusMessage* request,
45 int timeout_ms,
46 DBusError* error));
47 MOCK_METHOD3(SendWithReply, void(DBusMessage* request,
48 DBusPendingCall** pending_call,
49 int timeout_ms));
avi0ad0ce02015-12-23 03:12:45 +090050 MOCK_METHOD2(Send, void(DBusMessage* request, uint32_t* serial));
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090051 MOCK_METHOD2(AddFilter, void(DBusHandleMessageFunction handle_message,
52 void* user_data));
53 MOCK_METHOD2(RemoveFilter, void(DBusHandleMessageFunction handle_message,
54 void* user_data));
55 MOCK_METHOD2(AddMatch, void(const std::string& match_rule,
56 DBusError* error));
deymo@chromium.org7894ebf2013-01-31 15:08:02 +090057 MOCK_METHOD2(RemoveMatch, bool(const std::string& match_rule,
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090058 DBusError* error));
keybuk@google.combf4649a2012-02-15 06:29:06 +090059 MOCK_METHOD4(TryRegisterObjectPath, bool(const ObjectPath& object_path,
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090060 const DBusObjectPathVTable* vtable,
61 void* user_data,
62 DBusError* error));
keybuk@google.combf4649a2012-02-15 06:29:06 +090063 MOCK_METHOD1(UnregisterObjectPath, void(const ObjectPath& object_path));
hashimoto@chromium.org955f6482013-09-26 13:32:29 +090064 MOCK_METHOD0(GetDBusTaskRunner, base::TaskRunner*());
65 MOCK_METHOD0(GetOriginTaskRunner, base::TaskRunner*());
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090066 MOCK_METHOD0(HasDBusThread, bool());
67 MOCK_METHOD0(AssertOnOriginThread, void());
68 MOCK_METHOD0(AssertOnDBusThread, void());
rsleevi@chromium.orgd2163992012-05-19 03:00:22 +090069
70 protected:
71 virtual ~MockBus();
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090072};
73
74} // namespace dbus
75
76#endif // DBUS_MOCK_BUS_H_