Andrew de los Reyes | d57d147 | 2010-10-21 13:34:08 -0700 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium OS 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. |
| 4 | |
| 5 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_DBUS_INTERFACE_H__ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_DBUS_INTERFACE_H__ |
| 7 | |
| 8 | #include <gmock/gmock.h> |
| 9 | |
| 10 | #include "update_engine/dbus_interface.h" |
| 11 | |
| 12 | namespace chromeos_update_engine { |
| 13 | |
| 14 | class MockDbusGlib : public DbusGlibInterface { |
| 15 | public: |
| 16 | MOCK_METHOD5(ProxyNewForNameOwner, DBusGProxy*(DBusGConnection *connection, |
| 17 | const char *name, |
| 18 | const char *path, |
| 19 | const char *interface, |
| 20 | GError **error)); |
| 21 | |
| 22 | MOCK_METHOD1(ProxyUnref, void(DBusGProxy* proxy)); |
| 23 | |
| 24 | MOCK_METHOD2(BusGet, DBusGConnection*(DBusBusType type, GError **error)); |
| 25 | |
| 26 | MOCK_METHOD7(ProxyCall, gboolean(DBusGProxy *proxy, |
| 27 | const char *method, |
| 28 | GError **error, |
| 29 | GType first_arg_type, |
| 30 | GType var_arg1, |
| 31 | GHashTable** var_arg2, |
| 32 | GType var_arg3)); |
Andrew de los Reyes | 9cd120d | 2010-11-18 17:50:03 -0800 | [diff] [blame^] | 33 | MOCK_METHOD10(ProxyCall, gboolean(DBusGProxy* proxy, |
| 34 | const char* method, |
| 35 | GError** error, |
| 36 | GType var_arg1, const char* var_arg2, |
| 37 | GType var_arg3, |
| 38 | GType var_arg4, gchar** var_arg5, |
| 39 | GType var_arg6, GArray** var_arg7)); |
| 40 | |
| 41 | // Since gmock only supports mocking functions up to 10 args, we |
| 42 | // take the 11-arg function we'd like to mock, drop the last arg |
| 43 | // and call the 10-arg version. Dropping the last arg isn't ideal, |
| 44 | // but this is a lot better than nothing. |
| 45 | gboolean ProxyCall(DBusGProxy* proxy, |
| 46 | const char* method, |
| 47 | GError** error, |
| 48 | GType var_arg1, const char* var_arg2, |
| 49 | GType var_arg3, |
| 50 | GType var_arg4, gchar** var_arg5, |
| 51 | GType var_arg6, GArray** var_arg7, |
| 52 | GType var_arg8) { |
| 53 | return ProxyCall(proxy, |
| 54 | method, |
| 55 | error, |
| 56 | var_arg1, var_arg2, |
| 57 | var_arg3, |
| 58 | var_arg4, var_arg5, |
| 59 | var_arg6, var_arg7); |
| 60 | } |
Andrew de los Reyes | d57d147 | 2010-10-21 13:34:08 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | } // namespace chromeos_update_engine |
| 64 | |
| 65 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_DBUS_INTERFACE_H__ |