diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-25 05:18:29 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-25 05:18:29 +0000 |
commit | b8ae051ea8edaefb9f787bdca704e2df1adfb89f (patch) | |
tree | f26c2509c5f31de44d9446d17be64666558bdfcc /dbus/mock_bus.h | |
parent | 2517cfa5066e63e6ed2642779ea57616ae49eb42 (diff) | |
download | chromium_src-b8ae051ea8edaefb9f787bdca704e2df1adfb89f.zip chromium_src-b8ae051ea8edaefb9f787bdca704e2df1adfb89f.tar.gz chromium_src-b8ae051ea8edaefb9f787bdca704e2df1adfb89f.tar.bz2 |
Add mock classes for Bus, ObjectProxy, and ExportedObject.
Also add mock_unittest.cc that demonstrates how to mock synchronos and
asynchronos D-Bus method calls.
BUG=90036
TEST=dbus_unittests
Review URL: http://codereview.chromium.org/7714030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98188 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/mock_bus.h')
-rw-r--r-- | dbus/mock_bus.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/dbus/mock_bus.h b/dbus/mock_bus.h new file mode 100644 index 0000000..f1c5b4e --- /dev/null +++ b/dbus/mock_bus.h @@ -0,0 +1,71 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef DBUS_MOCK_BUS_H_ +#define DBUS_MOCK_BUS_H_ +#pragma once + +#include "dbus/bus.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace dbus { + +// Mock for Bus class. Along with MockObjectProxy and MockExportedObject, +// the mock classes can be used to write unit tests without issuing real +// D-Bus calls. +class MockBus : public Bus { + public: + MockBus(Bus::Options& options); + virtual ~MockBus(); + + MOCK_METHOD2(GetObjectProxy, ObjectProxy*(const std::string& service_name, + const std::string& object_path)); + MOCK_METHOD2(GetExportedObject, ExportedObject*( + const std::string& service_name, + const std::string& object_path)); + MOCK_METHOD0(ShutdownAndBlock, void()); + MOCK_METHOD1(Shutdown, void(OnShutdownCallback callback)); + MOCK_METHOD0(Connect, bool()); + MOCK_METHOD1(RequestOwnership, bool(const std::string& service_name)); + MOCK_METHOD1(ReleaseOwnership, bool(const std::string& service_name)); + MOCK_METHOD0(SetUpAsyncOperations, bool()); + MOCK_METHOD3(SendWithReplyAndBlock, DBusMessage*(DBusMessage* request, + int timeout_ms, + DBusError* error)); + MOCK_METHOD3(SendWithReply, void(DBusMessage* request, + DBusPendingCall** pending_call, + int timeout_ms)); + MOCK_METHOD2(Send, void(DBusMessage* request, + uint32* serial)); + MOCK_METHOD2(AddFilter, void(DBusHandleMessageFunction handle_message, + void* user_data)); + MOCK_METHOD2(RemoveFilter, void(DBusHandleMessageFunction handle_message, + void* user_data)); + MOCK_METHOD2(AddMatch, void(const std::string& match_rule, + DBusError* error)); + MOCK_METHOD2(RemoveMatch, void(const std::string& match_rule, + DBusError* error)); + MOCK_METHOD4(TryRegisterObjectPath, bool(const std::string& object_path, + const DBusObjectPathVTable* vtable, + void* user_data, + DBusError* error)); + MOCK_METHOD1(UnregisterObjectPath, void(const std::string& object_path)); + MOCK_METHOD2(PostTaskToOriginThread, void( + const tracked_objects::Location& from_here, + const base::Closure& task)); + MOCK_METHOD2(PostTaskToDBusThread, void( + const tracked_objects::Location& from_here, + const base::Closure& task)); + MOCK_METHOD3(PostDelayedTaskToDBusThread, void( + const tracked_objects::Location& from_here, + const base::Closure& task, + int delay_ms)); + MOCK_METHOD0(HasDBusThread, bool()); + MOCK_METHOD0(AssertOnOriginThread, void()); + MOCK_METHOD0(AssertOnDBusThread, void()); +}; + +} // namespace dbus + +#endif // DBUS_MOCK_BUS_H_ |