Revise UnitTest of system-settings with GTEST
[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 "sst.h"
21
22 API int system_info_get_platform_bool(const char *key, bool *value)
23 {
24         if (0 == strcmp(key, "tizen.org/feature/systemsetting.font")) {
25                 *value = true;
26                 return 0;
27         }
28         if (0 == strcmp(key, "tizen.org/feature/systemsetting.incoming_call")) {
29                 *value = true;
30                 return 0;
31         }
32         if (0 == strcmp(key, "tizen.org/feature/systemsetting.home_screen")) {
33                 *value = true;
34                 return 0;
35         }
36         if (0 == strcmp(key, "tizen.org/feature/systemsetting.lock_screen")) {
37                 *value = true;
38                 return 0;
39         }
40         if (0 == strcmp(key, "tizen.org/feature/systemsetting.notification_email")) {
41                 *value = true;
42                 return 0;
43         }
44         if (0 == strcmp(key, "tizen.org/feature/network.wifi")) {
45                 *value = true;
46                 return 0;
47         }
48         if (0 == strcmp(key, "tizen.org/feature/network.telephony")) {
49                 *value = true;
50                 return 0;
51         }
52         if (0 == strcmp(key, "tizen.org/feature/accessibility.grayscale")) {
53                 *value = true;
54                 return 0;
55         }
56         if (0 == strcmp(key, "tizen.org/feature/accessibility.negative")) {
57                 *value = true;
58                 return 0;
59         }
60         if (0 == strcmp(key, "tizen.org/feature/input.rotating_bezel")) {
61                 *value = true;
62                 return 0;
63         }
64
65         int (*fn_org)(const char *, bool *) = NULL;
66         fn_org = dlsym(RTLD_NEXT, "system_info_get_platform_bool");
67         return fn_org(key, value);
68 }
69
70 API int system_info_get_platform_string(const char *key, char **value)
71 {
72         if (0 == strcmp(key, "tizen.org/feature/profile")) {
73                 *value = strdup("wearable");
74                 return 0;
75         }
76
77         int (*fn_org)(const char *, char **) = NULL;
78         fn_org = dlsym(RTLD_NEXT, "system_info_get_platform_string");
79         return fn_org(key, value);
80 }