| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DBUS_MOCK_BUS_H_ | 5 #ifndef DBUS_MOCK_BUS_H_ |
| 6 #define DBUS_MOCK_BUS_H_ | 6 #define DBUS_MOCK_BUS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "dbus/bus.h" | 9 #include "dbus/bus.h" |
| 10 #include "dbus/object_path.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 11 | 12 |
| 12 namespace dbus { | 13 namespace dbus { |
| 13 | 14 |
| 14 // Mock for Bus class. Along with MockObjectProxy and MockExportedObject, | 15 // Mock for Bus class. Along with MockObjectProxy and MockExportedObject, |
| 15 // the mock classes can be used to write unit tests without issuing real | 16 // the mock classes can be used to write unit tests without issuing real |
| 16 // D-Bus calls. | 17 // D-Bus calls. |
| 17 class MockBus : public Bus { | 18 class MockBus : public Bus { |
| 18 public: | 19 public: |
| 19 MockBus(Bus::Options& options); | 20 MockBus(Bus::Options& options); |
| 20 virtual ~MockBus(); | 21 virtual ~MockBus(); |
| 21 | 22 |
| 22 MOCK_METHOD2(GetObjectProxy, ObjectProxy*(const std::string& service_name, | 23 MOCK_METHOD2(GetObjectProxy, ObjectProxy*(const std::string& service_name, |
| 23 const std::string& object_path)); | 24 const ObjectPath& object_path)); |
| 24 MOCK_METHOD3(GetObjectProxyWithOptions, | 25 MOCK_METHOD3(GetObjectProxyWithOptions, |
| 25 ObjectProxy*(const std::string& service_name, | 26 ObjectProxy*(const std::string& service_name, |
| 26 const std::string& object_path, | 27 const ObjectPath& object_path, |
| 27 int options)); | 28 int options)); |
| 28 MOCK_METHOD2(GetExportedObject, ExportedObject*( | 29 MOCK_METHOD2(GetExportedObject, ExportedObject*( |
| 29 const std::string& service_name, | 30 const std::string& service_name, |
| 30 const std::string& object_path)); | 31 const ObjectPath& object_path)); |
| 31 MOCK_METHOD0(ShutdownAndBlock, void()); | 32 MOCK_METHOD0(ShutdownAndBlock, void()); |
| 32 MOCK_METHOD0(ShutdownOnDBusThreadAndBlock, void()); | 33 MOCK_METHOD0(ShutdownOnDBusThreadAndBlock, void()); |
| 33 MOCK_METHOD0(Connect, bool()); | 34 MOCK_METHOD0(Connect, bool()); |
| 34 MOCK_METHOD1(RequestOwnership, bool(const std::string& service_name)); | 35 MOCK_METHOD1(RequestOwnership, bool(const std::string& service_name)); |
| 35 MOCK_METHOD1(ReleaseOwnership, bool(const std::string& service_name)); | 36 MOCK_METHOD1(ReleaseOwnership, bool(const std::string& service_name)); |
| 36 MOCK_METHOD0(SetUpAsyncOperations, bool()); | 37 MOCK_METHOD0(SetUpAsyncOperations, bool()); |
| 37 MOCK_METHOD3(SendWithReplyAndBlock, DBusMessage*(DBusMessage* request, | 38 MOCK_METHOD3(SendWithReplyAndBlock, DBusMessage*(DBusMessage* request, |
| 38 int timeout_ms, | 39 int timeout_ms, |
| 39 DBusError* error)); | 40 DBusError* error)); |
| 40 MOCK_METHOD3(SendWithReply, void(DBusMessage* request, | 41 MOCK_METHOD3(SendWithReply, void(DBusMessage* request, |
| 41 DBusPendingCall** pending_call, | 42 DBusPendingCall** pending_call, |
| 42 int timeout_ms)); | 43 int timeout_ms)); |
| 43 MOCK_METHOD2(Send, void(DBusMessage* request, | 44 MOCK_METHOD2(Send, void(DBusMessage* request, |
| 44 uint32* serial)); | 45 uint32* serial)); |
| 45 MOCK_METHOD2(AddFilter, void(DBusHandleMessageFunction handle_message, | 46 MOCK_METHOD2(AddFilter, void(DBusHandleMessageFunction handle_message, |
| 46 void* user_data)); | 47 void* user_data)); |
| 47 MOCK_METHOD2(RemoveFilter, void(DBusHandleMessageFunction handle_message, | 48 MOCK_METHOD2(RemoveFilter, void(DBusHandleMessageFunction handle_message, |
| 48 void* user_data)); | 49 void* user_data)); |
| 49 MOCK_METHOD2(AddMatch, void(const std::string& match_rule, | 50 MOCK_METHOD2(AddMatch, void(const std::string& match_rule, |
| 50 DBusError* error)); | 51 DBusError* error)); |
| 51 MOCK_METHOD2(RemoveMatch, void(const std::string& match_rule, | 52 MOCK_METHOD2(RemoveMatch, void(const std::string& match_rule, |
| 52 DBusError* error)); | 53 DBusError* error)); |
| 53 MOCK_METHOD4(TryRegisterObjectPath, bool(const std::string& object_path, | 54 MOCK_METHOD4(TryRegisterObjectPath, bool(const ObjectPath& object_path, |
| 54 const DBusObjectPathVTable* vtable, | 55 const DBusObjectPathVTable* vtable, |
| 55 void* user_data, | 56 void* user_data, |
| 56 DBusError* error)); | 57 DBusError* error)); |
| 57 MOCK_METHOD1(UnregisterObjectPath, void(const std::string& object_path)); | 58 MOCK_METHOD1(UnregisterObjectPath, void(const ObjectPath& object_path)); |
| 58 MOCK_METHOD2(PostTaskToOriginThread, void( | 59 MOCK_METHOD2(PostTaskToOriginThread, void( |
| 59 const tracked_objects::Location& from_here, | 60 const tracked_objects::Location& from_here, |
| 60 const base::Closure& task)); | 61 const base::Closure& task)); |
| 61 MOCK_METHOD2(PostTaskToDBusThread, void( | 62 MOCK_METHOD2(PostTaskToDBusThread, void( |
| 62 const tracked_objects::Location& from_here, | 63 const tracked_objects::Location& from_here, |
| 63 const base::Closure& task)); | 64 const base::Closure& task)); |
| 64 MOCK_METHOD3(PostDelayedTaskToDBusThread, void( | 65 MOCK_METHOD3(PostDelayedTaskToDBusThread, void( |
| 65 const tracked_objects::Location& from_here, | 66 const tracked_objects::Location& from_here, |
| 66 const base::Closure& task, | 67 const base::Closure& task, |
| 67 int delay_ms)); | 68 int delay_ms)); |
| 68 MOCK_METHOD0(HasDBusThread, bool()); | 69 MOCK_METHOD0(HasDBusThread, bool()); |
| 69 MOCK_METHOD0(AssertOnOriginThread, void()); | 70 MOCK_METHOD0(AssertOnOriginThread, void()); |
| 70 MOCK_METHOD0(AssertOnDBusThread, void()); | 71 MOCK_METHOD0(AssertOnDBusThread, void()); |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 } // namespace dbus | 74 } // namespace dbus |
| 74 | 75 |
| 75 #endif // DBUS_MOCK_BUS_H_ | 76 #endif // DBUS_MOCK_BUS_H_ |
| OLD | NEW |