adamk@chromium.org | 35c0eef | 2012-02-11 06:45:23 +0900 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 2 | // 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.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 7 | |
| 8 | #include "dbus/bus.h" |
keybuk@google.com | bf4649a | 2012-02-15 06:29:06 +0900 | [diff] [blame] | 9 | #include "dbus/object_path.h" |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 10 | #include "testing/gmock/include/gmock/gmock.h" |
| 11 | |
| 12 | namespace 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. |
| 17 | class MockBus : public Bus { |
| 18 | public: |
thestig@chromium.org | 074b1db | 2013-02-20 10:36:53 +0900 | [diff] [blame] | 19 | MockBus(const Bus::Options& options); |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 20 | |
| 21 | MOCK_METHOD2(GetObjectProxy, ObjectProxy*(const std::string& service_name, |
keybuk@google.com | bf4649a | 2012-02-15 06:29:06 +0900 | [diff] [blame] | 22 | const ObjectPath& object_path)); |
adamk@chromium.org | 35c0eef | 2012-02-11 06:45:23 +0900 | [diff] [blame] | 23 | MOCK_METHOD3(GetObjectProxyWithOptions, |
| 24 | ObjectProxy*(const std::string& service_name, |
keybuk@google.com | bf4649a | 2012-02-15 06:29:06 +0900 | [diff] [blame] | 25 | const ObjectPath& object_path, |
adamk@chromium.org | 35c0eef | 2012-02-11 06:45:23 +0900 | [diff] [blame] | 26 | int options)); |
keybuk@chromium.org | 9cb73f0 | 2012-03-10 10:12:52 +0900 | [diff] [blame] | 27 | MOCK_METHOD1(GetExportedObject, ExportedObject*( |
keybuk@google.com | bf4649a | 2012-02-15 06:29:06 +0900 | [diff] [blame] | 28 | const ObjectPath& object_path)); |
keybuk@chromium.org | 0971501 | 2013-03-26 03:20:08 +0900 | [diff] [blame] | 29 | MOCK_METHOD2(GetObjectManager, ObjectManager*(const std::string&, |
| 30 | const ObjectPath&)); |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 31 | MOCK_METHOD0(ShutdownAndBlock, void()); |
satorux@chromium.org | d336d45 | 2011-09-02 15:56:23 +0900 | [diff] [blame] | 32 | MOCK_METHOD0(ShutdownOnDBusThreadAndBlock, void()); |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 33 | MOCK_METHOD0(Connect, bool()); |
cmasone@chromium.org | 989857e | 2013-07-31 15:34:59 +0900 | [diff] [blame] | 34 | MOCK_METHOD3(RequestOwnership, void( |
keybuk@chromium.org | 9cb73f0 | 2012-03-10 10:12:52 +0900 | [diff] [blame] | 35 | const std::string& service_name, |
cmasone@chromium.org | 989857e | 2013-07-31 15:34:59 +0900 | [diff] [blame] | 36 | ServiceOwnershipOptions options, |
keybuk@chromium.org | 9cb73f0 | 2012-03-10 10:12:52 +0900 | [diff] [blame] | 37 | OnOwnershipCallback on_ownership_callback)); |
cmasone@chromium.org | 989857e | 2013-07-31 15:34:59 +0900 | [diff] [blame] | 38 | MOCK_METHOD2(RequestOwnershipAndBlock, bool(const std::string& service_name, |
| 39 | ServiceOwnershipOptions options)); |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 40 | MOCK_METHOD1(ReleaseOwnership, bool(const std::string& service_name)); |
| 41 | MOCK_METHOD0(SetUpAsyncOperations, bool()); |
| 42 | MOCK_METHOD3(SendWithReplyAndBlock, DBusMessage*(DBusMessage* request, |
| 43 | int timeout_ms, |
| 44 | DBusError* error)); |
| 45 | MOCK_METHOD3(SendWithReply, void(DBusMessage* request, |
| 46 | DBusPendingCall** pending_call, |
| 47 | int timeout_ms)); |
| 48 | MOCK_METHOD2(Send, void(DBusMessage* request, |
| 49 | uint32* serial)); |
| 50 | MOCK_METHOD2(AddFilter, void(DBusHandleMessageFunction handle_message, |
| 51 | void* user_data)); |
| 52 | MOCK_METHOD2(RemoveFilter, void(DBusHandleMessageFunction handle_message, |
| 53 | void* user_data)); |
| 54 | MOCK_METHOD2(AddMatch, void(const std::string& match_rule, |
| 55 | DBusError* error)); |
deymo@chromium.org | 7894ebf | 2013-01-31 15:08:02 +0900 | [diff] [blame] | 56 | MOCK_METHOD2(RemoveMatch, bool(const std::string& match_rule, |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 57 | DBusError* error)); |
keybuk@google.com | bf4649a | 2012-02-15 06:29:06 +0900 | [diff] [blame] | 58 | MOCK_METHOD4(TryRegisterObjectPath, bool(const ObjectPath& object_path, |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 59 | const DBusObjectPathVTable* vtable, |
| 60 | void* user_data, |
| 61 | DBusError* error)); |
keybuk@google.com | bf4649a | 2012-02-15 06:29:06 +0900 | [diff] [blame] | 62 | MOCK_METHOD1(UnregisterObjectPath, void(const ObjectPath& object_path)); |
hashimoto@chromium.org | 955f648 | 2013-09-26 13:32:29 +0900 | [diff] [blame^] | 63 | MOCK_METHOD0(GetDBusTaskRunner, base::TaskRunner*()); |
| 64 | MOCK_METHOD0(GetOriginTaskRunner, base::TaskRunner*()); |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 65 | MOCK_METHOD0(HasDBusThread, bool()); |
| 66 | MOCK_METHOD0(AssertOnOriginThread, void()); |
| 67 | MOCK_METHOD0(AssertOnDBusThread, void()); |
rsleevi@chromium.org | d216399 | 2012-05-19 03:00:22 +0900 | [diff] [blame] | 68 | |
| 69 | protected: |
| 70 | virtual ~MockBus(); |
satorux@chromium.org | f77861f | 2011-08-25 14:18:29 +0900 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | } // namespace dbus |
| 74 | |
| 75 | #endif // DBUS_MOCK_BUS_H_ |