2 * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <gtest/gtest.h>
23 #include "system_settings.h"
24 #include "mocks/sstt_mock.h"
29 #include "sst_vconf.h"
30 #include "sst_interface.h"
32 typedef struct __font_size_info {
42 static void* _utils_load_lib()
44 const char* const path = SETTING_UTILS_SO_FILE_PATH;
45 void *handle = dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
47 ERR("dlopen(%s) Fail", path);
52 TEST(SstFontTest,loadFontSizeInfoPathERR)
54 static font_size_info info;
55 void *handle = _utils_load_lib();
56 EXPECT_NE((void*)NULL, handle);
58 typedef int (*fn_impl)(font_size_info *info, const char *path);
59 fn_impl load_font_size_info = NULL;
61 load_font_size_info = (fn_impl)dlsym(handle, "load_font_size_info");
62 char *error = dlerror();
65 int ret = load_font_size_info(&info, "/error/asdlfajsdf.json");
69 EXPECT_EQ(-90, info.small);
70 EXPECT_EQ(-110, info.large);
72 EXPECT_EQ(-80, info.small);
73 EXPECT_EQ(-150, info.large);
75 EXPECT_EQ(-100, info.normal);
76 EXPECT_EQ(-190, info.huge);
77 EXPECT_EQ(-250, info.giant);
83 TEST(SstFontTest,loadFontSizeInfoInputERR)
85 void *handle = _utils_load_lib();
86 EXPECT_NE((void*)NULL, handle);
88 typedef int (*fn_impl)(font_size_info *info, const char *path);
89 fn_impl load_font_size_info = NULL;
91 load_font_size_info = (fn_impl)dlsym(handle, "load_font_size_info");
92 char *error = dlerror();
95 int ret = load_font_size_info(NULL, "/error/asdlfajsdf.json");
102 TEST(SstFontTest,loadFontSizeInfoSmallERR)
105 void *handle = _utils_load_lib();
106 EXPECT_NE((void*)NULL, handle);
108 typedef int (*fn_impl)(font_size_info *info, const char *path);
109 fn_impl load_font_size_info = NULL;
111 load_font_size_info = (fn_impl)dlsym(handle, "load_font_size_info");
112 char *error = dlerror();
115 int ret = load_font_size_info(&info, "tests/res/font_scale_small_error.json");
118 #ifdef TIZEN_WEARABLE
119 EXPECT_EQ(-90, info.small);
120 EXPECT_EQ(-110, info.large);
122 EXPECT_EQ(-80, info.small);
123 EXPECT_EQ(-150, info.large);
125 EXPECT_EQ(-100, info.normal);
126 EXPECT_EQ(-190, info.huge);
127 EXPECT_EQ(-250, info.giant);
133 TEST(SstFontTest,loadFontSizeInfoNormalERR)
136 void *handle = _utils_load_lib();
137 EXPECT_NE((void*)NULL, handle);
139 typedef int (*fn_impl)(font_size_info *info, const char *path);
140 fn_impl load_font_size_info = NULL;
142 load_font_size_info = (fn_impl)dlsym(handle, "load_font_size_info");
143 char *error = dlerror();
146 int ret = load_font_size_info(&info, "tests/res/font_scale_normal_error.json");
149 #ifdef TIZEN_WEARABLE
150 EXPECT_EQ(-90, info.small);
151 EXPECT_EQ(-110, info.large);
153 EXPECT_EQ(-80, info.small);
154 EXPECT_EQ(-150, info.large);
156 EXPECT_EQ(-100, info.normal);
157 EXPECT_EQ(-190, info.huge);
158 EXPECT_EQ(-250, info.giant);
164 TEST(SstFontTest,loadFontSizeInfoLargeERR)
167 void *handle = _utils_load_lib();
168 EXPECT_NE((void*)NULL, handle);
170 typedef int (*fn_impl)(font_size_info *info, const char *path);
171 fn_impl load_font_size_info = NULL;
173 load_font_size_info = (fn_impl)dlsym(handle, "load_font_size_info");
174 char *error = dlerror();
177 int ret = load_font_size_info(&info, "tests/res/font_scale_large_error.json");
180 #ifdef TIZEN_WEARABLE
181 EXPECT_EQ(-90, info.small);
182 EXPECT_EQ(-110, info.large);
184 EXPECT_EQ(-80, info.small);
185 EXPECT_EQ(-150, info.large);
187 EXPECT_EQ(-100, info.normal);
188 EXPECT_EQ(-190, info.huge);
189 EXPECT_EQ(-250, info.giant);
195 TEST(SstFontTest,loadFontSizeInfoHugeERR)
198 void *handle = _utils_load_lib();
199 EXPECT_NE((void*)NULL, handle);
201 typedef int (*fn_impl)(font_size_info *info, const char *path);
202 fn_impl load_font_size_info = NULL;
204 load_font_size_info = (fn_impl)dlsym(handle, "load_font_size_info");
205 char *error = dlerror();
208 int ret = load_font_size_info(&info, "tests/res/font_scale_huge_error.json");
211 #ifdef TIZEN_WEARABLE
212 EXPECT_EQ(-90, info.small);
213 EXPECT_EQ(-110, info.large);
215 EXPECT_EQ(-80, info.small);
216 EXPECT_EQ(-150, info.large);
218 EXPECT_EQ(-100, info.normal);
219 EXPECT_EQ(-190, info.huge);
220 EXPECT_EQ(-250, info.giant);
226 TEST(SstFontTest,loadFontSizeInfoGiantERR)
229 void *handle = _utils_load_lib();
230 EXPECT_NE((void*)NULL, handle);
232 typedef int (*fn_impl)(font_size_info *info, const char *path);
233 fn_impl load_font_size_info = NULL;
235 load_font_size_info = (fn_impl)dlsym(handle, "load_font_size_info");
236 char *error = dlerror();
239 int ret = load_font_size_info(&info, "tests/res/font_scale_giant_error.json");
242 #ifdef TIZEN_WEARABLE
243 EXPECT_EQ(-90, info.small);
244 EXPECT_EQ(-110, info.large);
246 EXPECT_EQ(-80, info.small);
247 EXPECT_EQ(-150, info.large);
249 EXPECT_EQ(-100, info.normal);
250 EXPECT_EQ(-190, info.huge);
251 EXPECT_EQ(-250, info.giant);