summaryrefslogtreecommitdiff
path: root/unittest/mock/mock.cc
blob: 11aa6d15b21b3d2ca8ce4728c2a265a3c3607c7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "aul_fake.h"
#include "gio_fake.h"
#include "glib_fake.h"
#include "mock.h"
#include "notification_fake.h"
#include "pkgmgr_info_fake.h"

DEFINE_FFF_GLOBALS;

/* gio.h */
DEFINE_FAKE_VALUE_FUNC(GDBusConnection*, g_bus_get_sync,
    GBusType, GCancellable*, GError**);
DEFINE_FAKE_VALUE_FUNC(GDBusProxy*, g_dbus_proxy_new_sync,
    GDBusConnection*, GDBusProxyFlags, GDBusInterfaceInfo*,
    const gchar*, const gchar*, const gchar*, GCancellable*, GError**);
DEFINE_FAKE_VALUE_FUNC(GDBusNodeInfo*, g_dbus_node_info_new_for_xml,
    const gchar*, GError**);
DEFINE_FAKE_VALUE_FUNC(guint, g_bus_own_name_on_connection, GDBusConnection*,
    const gchar*, GBusNameOwnerFlags,GBusNameAcquiredCallback,
    GBusNameLostCallback, gpointer, GDestroyNotify);
DEFINE_FAKE_VALUE_FUNC(guint, g_dbus_connection_register_object,
    GDBusConnection*, const gchar*, GDBusInterfaceInfo*,
    const GDBusInterfaceVTable*, gpointer, GDestroyNotify, GError**);
DEFINE_FAKE_VALUE_FUNC(gboolean, g_dbus_connection_unregister_object,
    GDBusConnection*, guint);
DEFINE_FAKE_VOID_FUNC(g_dbus_method_invocation_return_value,
    GDBusMethodInvocation*, GVariant*);
DEFINE_FAKE_VOID_FUNC(g_bus_unown_name, guint);
DEFINE_FAKE_VALUE_FUNC(gboolean, g_dbus_connection_emit_signal,
    GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*,
    GVariant*, GError**);
DEFINE_FAKE_VALUE_FUNC(gboolean, g_dbus_connection_flush_sync,
    GDBusConnection*, GCancellable*, GError**);
DEFINE_FAKE_VOID_FUNC(g_dbus_node_info_unref, GDBusNodeInfo*);
DEFINE_FAKE_VALUE_FUNC(guint, g_dbus_connection_signal_subscribe,
    GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*,
    const gchar*, GDBusSignalFlags, GDBusSignalCallback, gpointer,
    GDestroyNotify);
DEFINE_FAKE_VALUE_FUNC(GVariant*, g_dbus_proxy_call_sync,
    GDBusProxy*, const gchar*, GVariant*, GDBusCallFlags, gint,
    GCancellable*, GError**);
DEFINE_FAKE_VOID_FUNC(g_dbus_proxy_call,
    GDBusProxy*, const gchar*, GVariant*, GDBusCallFlags, gint,
    GCancellable*, GAsyncReadyCallback, gpointer);

/* glib_fake.h */
DEFINE_FAKE_VALUE_FUNC(const gchar*, g_dbus_method_invocation_get_sender, GDBusMethodInvocation*);
DEFINE_FAKE_VALUE_FUNC(gsize, g_variant_get_size, GVariant*);
DEFINE_FAKE_VALUE_FUNC3_VARARG(gboolean, g_variant_iter_loop, GVariantIter*, const gchar*, ...);
DEFINE_FAKE_VOID_FUNC(g_variant_iter_free, GVariantIter*);
DEFINE_FAKE_VOID_FUNC(g_variant_unref, GVariant*);
DEFINE_FAKE_VALUE_FUNC(gpointer, g_hash_table_lookup, GHashTable*, gconstpointer);
DEFINE_FAKE_VALUE_FUNC(guint, g_hash_table_foreach_remove, GHashTable*,
    GHRFunc, gpointer);
DEFINE_FAKE_VALUE_FUNC(gboolean, g_hash_table_insert, GHashTable*,
    gpointer, gpointer);

/* aul.h */
DEFINE_FAKE_VALUE_FUNC(int, aul_app_get_appid_bypid, int, char*, int);
DEFINE_FAKE_VALUE_FUNC(int, aul_app_get_pkgid_bypid_for_uid, int, char*, int, uid_t);

/* notification.h */
DEFINE_FAKE_VALUE_FUNC(notification_h, notification_create, notification_type_e);
DEFINE_FAKE_VALUE_FUNC(GVariant*, notification_ipc_make_gvariant_from_noti, notification_h, bool);

/* pkgmgr_info_fake.h */
DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_get_usr_pkginfo, const char *,
    uid_t, pkgmgrinfo_pkginfo_h*);
DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_get_api_version,
    pkgmgrinfo_pkginfo_h, char **);
DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_is_global,
    pkgmgrinfo_pkginfo_h, bool *);
DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_destroy_pkginfo,
    pkgmgrinfo_pkginfo_h);
DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_appinfo_get_usr_appinfo, const char *,
    uid_t, pkgmgrinfo_appinfo_h*);
DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_appinfo_get_component_type,
    pkgmgrinfo_appinfo_h, char **);
DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_appinfo_destroy_appinfo,
    pkgmgrinfo_appinfo_h);