Don't crash when SimpleCache index is corrupt.
[chromium-blink-merge.git] / dbus / mock_bus.h
blob26113d4730e7bf15fb91f5d2fbc13c43817dde51
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
3 // found in the LICENSE file.
5 #ifndef DBUS_MOCK_BUS_H_
6 #define DBUS_MOCK_BUS_H_
8 #include "dbus/bus.h"
9 #include "dbus/object_path.h"
10 #include "testing/gmock/include/gmock/gmock.h"
12 namespace dbus {
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:
19 MockBus(const Bus::Options& options);
21 MOCK_METHOD2(GetObjectProxy, ObjectProxy*(const std::string& service_name,
22 const ObjectPath& object_path));
23 MOCK_METHOD3(GetObjectProxyWithOptions,
24 ObjectProxy*(const std::string& service_name,
25 const ObjectPath& object_path,
26 int options));
27 MOCK_METHOD1(GetExportedObject, ExportedObject*(
28 const ObjectPath& object_path));
29 MOCK_METHOD2(GetObjectManager, ObjectManager*(const std::string&,
30 const ObjectPath&));
31 MOCK_METHOD0(ShutdownAndBlock, void());
32 MOCK_METHOD0(ShutdownOnDBusThreadAndBlock, void());
33 MOCK_METHOD0(Connect, bool());
34 MOCK_METHOD2(RequestOwnership, void(
35 const std::string& service_name,
36 OnOwnershipCallback on_ownership_callback));
37 MOCK_METHOD1(RequestOwnershipAndBlock, bool(const std::string& service_name));
38 MOCK_METHOD1(ReleaseOwnership, bool(const std::string& service_name));
39 MOCK_METHOD0(SetUpAsyncOperations, bool());
40 MOCK_METHOD3(SendWithReplyAndBlock, DBusMessage*(DBusMessage* request,
41 int timeout_ms,
42 DBusError* error));
43 MOCK_METHOD3(SendWithReply, void(DBusMessage* request,
44 DBusPendingCall** pending_call,
45 int timeout_ms));
46 MOCK_METHOD2(Send, void(DBusMessage* request,
47 uint32* serial));
48 MOCK_METHOD2(AddFilter, void(DBusHandleMessageFunction handle_message,
49 void* user_data));
50 MOCK_METHOD2(RemoveFilter, void(DBusHandleMessageFunction handle_message,
51 void* user_data));
52 MOCK_METHOD2(AddMatch, void(const std::string& match_rule,
53 DBusError* error));
54 MOCK_METHOD2(RemoveMatch, bool(const std::string& match_rule,
55 DBusError* error));
56 MOCK_METHOD4(TryRegisterObjectPath, bool(const ObjectPath& object_path,
57 const DBusObjectPathVTable* vtable,
58 void* user_data,
59 DBusError* error));
60 MOCK_METHOD1(UnregisterObjectPath, void(const ObjectPath& object_path));
61 MOCK_METHOD2(PostTaskToOriginThread, void(
62 const tracked_objects::Location& from_here,
63 const base::Closure& task));
64 MOCK_METHOD2(PostTaskToDBusThread, void(
65 const tracked_objects::Location& from_here,
66 const base::Closure& task));
67 MOCK_METHOD3(PostDelayedTaskToDBusThread, void(
68 const tracked_objects::Location& from_here,
69 const base::Closure& task,
70 base::TimeDelta delay));
71 MOCK_METHOD0(HasDBusThread, bool());
72 MOCK_METHOD0(AssertOnOriginThread, void());
73 MOCK_METHOD0(AssertOnDBusThread, void());
75 protected:
76 virtual ~MockBus();
79 } // namespace dbus
81 #endif // DBUS_MOCK_BUS_H_