Add new unittest TCs
[platform/core/appfw/widget-service.git] / unittest / mock / mock.cc
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <sys/types.h>
18
19 #include "mock.h"
20 #include "system_info_mock.h"
21 #include "aul_mock.h"
22 #include "cynara_mock.h"
23 #include "fcntl_mock.h"
24 #include "tzplatform_config_mock.h"
25 #include "pkgmgr_info_mock.h"
26
27 DEFINE_FFF_GLOBALS;
28
29 /* system */
30 DEFINE_FAKE_VALUE_FUNC(int, system_info_get_platform_bool,
31     const char*, bool*);
32 DEFINE_FAKE_VALUE_FUNC(uid_t, getuid);
33
34 /* aul */
35 DEFINE_FAKE_VALUE_FUNC(int, aul_widget_service_set_disable,
36     const char*, bool);
37 DEFINE_FAKE_VALUE_FUNC(int, aul_app_com_create, const char *, aul_app_com_permission_h,
38     app_com_cb, void *, aul_app_com_connection_h *);
39 DEFINE_FAKE_VALUE_FUNC(int, aul_app_com_leave, aul_app_com_connection_h);
40 DEFINE_FAKE_VALUE_FUNC(int, aul_widget_instance_update, const char *,
41     const char *, bundle *);
42 DEFINE_FAKE_VALUE_FUNC(int, aul_widget_instance_foreach, const char *,
43     aul_widget_instance_foreach_cb, void *);
44 DEFINE_FAKE_VALUE_FUNC(int, aul_widget_instance_get_content, const char *,
45     const char *, char **);
46 DEFINE_FAKE_VALUE_FUNC(int, aul_widget_instance_count, const char *);
47 DEFINE_FAKE_VALUE_FUNC(int, aul_launch_app_async, const char *, bundle *);
48 DEFINE_FAKE_VALUE_FUNC(int, aul_debug_info_init);
49 DEFINE_FAKE_VALUE_FUNC(int, aul_debug_info_set, bundle *, bundle *);
50
51 /* cynara */
52 DEFINE_FAKE_VALUE_FUNC(int, cynara_initialize, cynara**,
53     const cynara_configuration*);
54 DEFINE_FAKE_VALUE_FUNC(int, cynara_finish, cynara*);
55 DEFINE_FAKE_VALUE_FUNC(int, cynara_check, cynara*,
56     const char*, const char*, const char*, const char*);
57
58 /* fcntl */
59 DEFINE_FAKE_VALUE_FUNC(int, open, const char *, int);
60 DEFINE_FAKE_VALUE_FUNC(ssize_t, read, int, void *, size_t);
61 DEFINE_FAKE_VALUE_FUNC(int, chown, const char *, uid_t, gid_t);
62 DEFINE_FAKE_VALUE_FUNC(int, chmod, const char *, mode_t);
63
64 /* tzplatform_config */
65 DEFINE_FAKE_VALUE_FUNC(const char *, tzplatform_mkpath,
66     enum tzplatform_variable, const char *);
67
68 /* pkgmgr_info */
69 DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_get_usr_pkginfo,
70     const char *, uid_t, pkgmgrinfo_pkginfo_h *);
71 DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_get_mainappid,
72     pkgmgrinfo_pkginfo_h, char **);
73