5fba95bae80b34aa07b8d0e79470a9415e645a49
[platform/core/api/system-settings.git] / tests / mocks / system_info.c
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
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 #define _GNU_SOURCE
17 #include <string.h>
18 #include <dlfcn.h>
19 #include <stdbool.h>
20 #include <tizen.h>
21 #include "sst.h"
22 #include "sstt_mock.h"
23
24 static bool sstm_system_info_get_platform_string_enable = true;
25 static bool sstm_system_info_get_platform_bool_enable = true;
26
27 API void sstm_system_info_get_platform_string_setup(bool enable)
28 {
29         sstm_system_info_get_platform_string_enable = enable;
30 }
31
32 API void sstm_system_info_get_platform_bool_setup(bool enable)
33 {
34         sstm_system_info_get_platform_bool_enable = enable;
35 }
36
37 API int system_info_get_platform_bool(const char *key, bool *value)
38 {
39         if (false == sstm_system_info_get_platform_bool_enable)
40                 return TIZEN_ERROR_IO_ERROR;
41
42         if (0 == strcmp(key, "tizen.org/feature/systemsetting.font")) {
43                 *value = true;
44                 return 0;
45         }
46         if (0 == strcmp(key, "tizen.org/feature/systemsetting.incoming_call")) {
47                 *value = true;
48                 return 0;
49         }
50         if (0 == strcmp(key, "tizen.org/feature/systemsetting.home_screen")) {
51                 *value = true;
52                 return 0;
53         }
54         if (0 == strcmp(key, "tizen.org/feature/systemsetting.lock_screen")) {
55                 *value = true;
56                 return 0;
57         }
58         if (0 == strcmp(key, "tizen.org/feature/systemsetting.notification_email")) {
59                 *value = true;
60                 return 0;
61         }
62         if (0 == strcmp(key, "tizen.org/feature/network.wifi")) {
63                 *value = true;
64                 return 0;
65         }
66         if (0 == strcmp(key, "tizen.org/feature/network.telephony")) {
67                 *value = true;
68                 return 0;
69         }
70         if (0 == strcmp(key, "tizen.org/feature/accessibility.grayscale")) {
71                 *value = true;
72                 return 0;
73         }
74         if (0 == strcmp(key, "tizen.org/feature/accessibility.negative")) {
75                 *value = true;
76                 return 0;
77         }
78         if (0 == strcmp(key, "tizen.org/feature/input.rotating_bezel")) {
79                 *value = true;
80                 return 0;
81         }
82
83         int (*fn_org)(const char *, bool *) = NULL;
84         fn_org = dlsym(RTLD_NEXT, "system_info_get_platform_bool");
85         return fn_org(key, value);
86 }
87
88 API int system_info_get_platform_string(const char *key, char **value)
89 {
90         if (false == sstm_system_info_get_platform_string_enable)
91                 return TIZEN_ERROR_IO_ERROR;
92
93         if (0 == strcmp(key, "tizen.org/feature/profile")) {
94                 *value = strdup("wearable");
95                 return 0;
96         }
97
98         int (*fn_org)(const char *, char **) = NULL;
99         fn_org = dlsym(RTLD_NEXT, "system_info_get_platform_string");
100         return fn_org(key, value);
101 }