blob: 9a87ecf7992f36e5a55a827d4ac1a49bb93ed5a4 [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
8#include "dbus/bus.h"
keybuk@google.combf4649a2012-02-15 06:29:06 +09009#include "dbus/object_path.h"
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090010#include "testing/gmock/include/gmock/gmock.h"
11
12namespace dbus {
13
14// Mock for Bus class. Along with MockObjectProxy and MockExportedObject,
15// the mock classes can be used to write unit tests without issuing real
16// D-Bus calls.
17class MockBus : public Bus {
18 public:
thestig@chromium.org074b1db2013-02-20 10:36:53 +090019 MockBus(const Bus::Options& options);
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090020
21 MOCK_METHOD2(GetObjectProxy, ObjectProxy*(const std::string& service_name,
keybuk@google.combf4649a2012-02-15 06:29:06 +090022 const ObjectPath& object_path));
adamk@chromium.org35c0eef2012-02-11 06:45:23 +090023 MOCK_METHOD3(GetObjectProxyWithOptions,
24 ObjectProxy*(const std::string& service_name,
keybuk@google.combf4649a2012-02-15 06:29:06 +090025 const ObjectPath& object_path,
adamk@chromium.org35c0eef2012-02-11 06:45:23 +090026 int options));
keybuk@chromium.org9cb73f02012-03-10 10:12:52 +090027 MOCK_METHOD1(GetExportedObject, ExportedObject*(
keybuk@google.combf4649a2012-02-15 06:29:06 +090028 const ObjectPath& object_path));
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090029 MOCK_METHOD0(ShutdownAndBlock, void());
satorux@chromium.orgd336d452011-09-02 15:56:23 +090030 MOCK_METHOD0(ShutdownOnDBusThreadAndBlock, void());
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090031 MOCK_METHOD0(Connect, bool());
keybuk@chromium.org9cb73f02012-03-10 10:12:52 +090032 MOCK_METHOD2(RequestOwnership, void(
33 const std::string& service_name,
34 OnOwnershipCallback on_ownership_callback));
35 MOCK_METHOD1(RequestOwnershipAndBlock, bool(const std::string& service_name));
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090036 MOCK_METHOD1(ReleaseOwnership, bool(const std::string& service_name));
37 MOCK_METHOD0(SetUpAsyncOperations, bool());
38 MOCK_METHOD3(SendWithReplyAndBlock, DBusMessage*(DBusMessage* request,
39 int timeout_ms,
40 DBusError* error));
41 MOCK_METHOD3(SendWithReply, void(DBusMessage* request,
42 DBusPendingCall** pending_call,
43 int timeout_ms));
44 MOCK_METHOD2(Send, void(DBusMessage* request,
45 uint32* serial));
46 MOCK_METHOD2(AddFilter, void(DBusHandleMessageFunction handle_message,
47 void* user_data));
48 MOCK_METHOD2(RemoveFilter, void(DBusHandleMessageFunction handle_message,
49 void* user_data));
50 MOCK_METHOD2(AddMatch, void(const std::string& match_rule,
51 DBusError* error));
deymo@chromium.org7894ebf2013-01-31 15:08:02 +090052 MOCK_METHOD2(RemoveMatch, bool(const std::string& match_rule,
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090053 DBusError* error));
keybuk@google.combf4649a2012-02-15 06:29:06 +090054 MOCK_METHOD4(TryRegisterObjectPath, bool(const ObjectPath& object_path,
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090055 const DBusObjectPathVTable* vtable,
56 void* user_data,
57 DBusError* error));
keybuk@google.combf4649a2012-02-15 06:29:06 +090058 MOCK_METHOD1(UnregisterObjectPath, void(const ObjectPath& object_path));
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090059 MOCK_METHOD2(PostTaskToOriginThread, void(
60 const tracked_objects::Location& from_here,
61 const base::Closure& task));
62 MOCK_METHOD2(PostTaskToDBusThread, void(
63 const tracked_objects::Location& from_here,
64 const base::Closure& task));
65 MOCK_METHOD3(PostDelayedTaskToDBusThread, void(
66 const tracked_objects::Location& from_here,
67 const base::Closure& task,
tedvessenes@gmail.com8d7a8762012-03-11 10:12:20 +090068 base::TimeDelta delay));
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090069 MOCK_METHOD0(HasDBusThread, bool());
70 MOCK_METHOD0(AssertOnOriginThread, void());
71 MOCK_METHOD0(AssertOnDBusThread, void());
rsleevi@chromium.orgd2163992012-05-19 03:00:22 +090072
73 protected:
74 virtual ~MockBus();
satorux@chromium.orgf77861f2011-08-25 14:18:29 +090075};
76
77} // namespace dbus
78
79#endif // DBUS_MOCK_BUS_H_