2 #include <privilege_information.h>
10 static int fail_cnt=0;
11 static int success_cnt=0;
13 static void __change_color_to_red(){
14 printf("%c[%d;%dm", 0x1B, BRIGHTNESS, RED);
17 static void __change_color_to_green(){
18 printf("%c[%d;%dm", 0x1B, BRIGHTNESS, GREEN);
21 static void __change_color_to_yellow(){
22 printf("%c[%d;%dm", 0x1B, BRIGHTNESS, YELLOW);
25 static void __change_color_to_origin(){
26 printf("%c[%dm", 0x1B, 0);
29 static const char* __get_result_string(privilege_info_error_e ret){
30 if(ret == PRVINFO_ERROR_NONE){
31 return "PRVINFO_ERROR_NONE";
33 else if(ret == PRVINFO_ERROR_INVALID_PARAMETER){
34 return "PRVINFO_ERROR_INVALID_PARAMETER";
36 else if(ret == PRVINFO_ERROR_OUT_OF_MEMORY)
38 return "PRVINFO_ERROR_OUT_OF_MEMORY";
40 else if(ret == PRVINFO_ERROR_INTERNAL_ERROR){
41 return "PRVINFO_ERROR_INTERNAL_ERROR";
45 static void __check_get_privilege_display_name_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* display_name)
47 printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result));
49 if(expected_result != result)
51 printf("not matched\n");
52 __change_color_to_red();
53 printf("test fail\n");
57 if(result == PRVINFO_ERROR_NONE)
59 if(display_name == NULL)
61 printf("display_name must not be NULL\n");
62 __change_color_to_red();
63 printf("test fail\n");
65 __change_color_to_origin();
68 printf("display_name = %s\n", display_name);
71 if(display_name != NULL)
73 printf("display_name = %s\n", display_name);
74 printf("display_name must be NULL\n");
75 __change_color_to_red();
76 printf("test fail\n");
78 __change_color_to_origin();
82 __change_color_to_green();
83 printf("test success\n");
86 __change_color_to_origin();
90 static void __check_get_privilege_description_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* description)
92 printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result));
94 if(expected_result != result)
96 printf("not matched\n");
97 __change_color_to_red();
98 printf("test fail\n");
102 if(result == PRVINFO_ERROR_NONE)
104 if(description == NULL)
106 printf("description must not be NULL\n");
107 __change_color_to_red();
108 printf("test fail\n");
110 __change_color_to_origin();
113 printf("description = %s\n", description);
116 if(description != NULL)
118 printf("description = %s\n", description);
119 printf("description must be NULL\n");
120 __change_color_to_red();
121 printf("test fail\n");
123 __change_color_to_origin();
128 __change_color_to_green();
129 printf("test success\n");
132 __change_color_to_origin();
135 static void __test_privilege_info_get_display_name()
138 char* display_name = NULL;
140 printf("-----------------------------------------------------------\n");
141 printf("api_version : 2.3\n");
142 printf("privilege : http://tizen.org/privilege/window.priority.set\n");
143 printf("expected result : PRVINFO_ERROR_NONE\n");
144 ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/window.priority.set", &display_name);
145 __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
147 printf("-----------------------------------------------------------\n");
148 printf("api_version : 2.3\n");
149 printf("privilege : http://tizen.org/privilege/mediacapture\n");
150 printf("expected result : PRVINFO_ERROR_NONE\n");
151 if(display_name != NULL)
156 ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/mediacapture", &display_name);
157 __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
159 printf("-----------------------------------------------------------\n");
160 printf("Not existing privilege\n");
161 printf("api_version : 2.3\n");
162 printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
163 printf("expected result : PRVINFO_ERROR_NONE\n");
164 if(display_name != NULL)
169 ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name);
170 __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
172 printf("-----------------------------------------------------------\n");
173 printf("Invalid parameter\n");
174 printf("api_version : NULL\n");
175 printf("privilege : http://tizen.org/privilege/window.priority.set\n");
176 printf("expected result : PRVINFO_ERROR_NONE\n");
177 if(display_name != NULL)
182 ret = privilege_info_get_display_name(NULL, "http://tizen.org/privilege/window,priority.set", &display_name);
183 __check_get_privilege_display_name_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, display_name);
187 static void __test_privilege_info_get_display_name_by_pkgtype()
190 char* display_name = NULL;
192 printf("-----------------------------------------------------------\n");
193 printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
194 printf("api_version : 2.3\n");
195 printf("privilege : http://tizen.org/privilege/window.priority.set\n");
196 printf("expected result : PRVINFO_ERROR_NONE\n");
197 ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &display_name);
198 __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
200 printf("-----------------------------------------------------------\n");
201 printf("pkgtype : PRVINFO_PACKAGE_TYPE_WEB\n");
202 printf("api_version : 2.3\n");
203 printf("privilege : http://tizen.org/privilege/mediacapture\n");
204 printf("expected result : PRVINFO_ERROR_NONE\n");
205 if(display_name != NULL)
210 ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
211 __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
213 printf("-----------------------------------------------------------\n");
214 printf("Mismatched package type: write WEB as NATIVE\n");
215 printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
216 printf("api_version : 2.3\n");
217 printf("privilege : http://tizen.org/privilege/mediacapture\n");
218 printf("expected result : PRVINFO_ERROR_NONE\n");
219 if(display_name != NULL)
224 ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
225 __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
228 printf("-----------------------------------------------------------\n");
229 printf("Not existing privilege\n");
230 printf("api_version : 2.3\n");
231 printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
232 printf("expected result : PRVINFO_ERROR_NONE\n");
233 if(display_name != NULL)
238 ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name);
239 __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
241 printf("-----------------------------------------------------------\n");
242 printf("Invalid parameter\n");
243 printf("api_version : 2.3\n");
244 printf("privilege : http://tizen.org/privilege/mediacapture\n");
245 printf("expected result : PRVINFO_ERROR_NONE\n");
246 if(display_name != NULL)
251 ret = privilege_info_get_display_name_by_pkgtype(NULL, "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
252 __check_get_privilege_display_name_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, display_name);
257 static void __test_privilege_info_get_description()
260 char* description = NULL;
262 printf("-----------------------------------------------------------\n");
263 printf("api_version : 2.3\n");
264 printf("privilege : http://tizen.org/privilege/window.priority.set\n");
265 printf("expected result : PRVINFO_ERROR_NONE\n");
266 ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/window.priority.set", &description);
267 __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
269 printf("-----------------------------------------------------------\n");
270 printf("api_version : 2.3\n");
271 printf("privilege : http://tizen.org/privilege/mediacapture\n");
272 printf("expected result : PRVINFO_ERROR_NONE\n");
273 if(description != NULL)
278 ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/mediacapture", &description);
279 __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
281 printf("-----------------------------------------------------------\n");
282 printf("Not existing privilege\n");
283 printf("api_version : 2.3\n");
284 printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
285 printf("expected result : PRVINFO_ERROR_NONE\n");
286 if(description != NULL)
291 ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description);
292 __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
294 printf("-----------------------------------------------------------\n");
295 printf("Invalid parameter\n");
296 printf("api_version : 2.3\n");
297 printf("privilege : http://tizen.org/privilege/mediacapture\n");
298 printf("expected result : PRVINFO_ERROR_NONE\n");
299 if(description != NULL)
304 ret = privilege_info_get_description(NULL, "http://tizen.org/privilege/mediacapture", &description);
305 __check_get_privilege_description_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, description);
310 static void __test_privilege_info_get_description_by_pkgtype()
313 char* description = NULL;
315 printf("-----------------------------------------------------------\n");
316 printf("api_version : 2.3\n");
317 printf("privilege : http://tizen.org/privilege/window.priority.set\n");
318 printf("expected result : PRVINFO_ERROR_NONE\n");
319 ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &description);
320 __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
322 printf("-----------------------------------------------------------\n");
323 printf("api_version : 2.3\n");
324 printf("privilege : http://tizen.org/privilege/mediacapture\n");
325 printf("expected result : PRVINFO_ERROR_NONE\n");
326 if(description != NULL)
331 ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/mediacapture", &description);
332 __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
334 printf("-----------------------------------------------------------\n");
335 printf("Mismatched package type: write WEB as NATIVE\n");
336 printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
337 printf("api_version : 2.3\n");
338 printf("privilege : http://tizen.org/privilege/mediacapture\n");
339 printf("expected result : PRVINFO_ERROR_NONE\n");
340 if(description != NULL)
345 ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &description);
346 __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
348 printf("-----------------------------------------------------------\n");
349 printf("Not existing privilege\n");
350 printf("api_version : 2.3\n");
351 printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
352 printf("expected result : PRVINFO_ERROR_NONE\n");
353 if(description != NULL)
358 ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description);
359 __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
361 printf("-----------------------------------------------------------\n");
362 printf("Invalid parameter\n");
363 printf("api_version : 2.3\n");
364 printf("privilege : NULL\n");
365 printf("expected result : PRVINFO_ERROR_INVALID_PARAMETER\n");
366 if(description != NULL)
371 ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE","2.3", NULL, &description);
372 __check_get_privilege_description_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, description);
379 __change_color_to_yellow();
380 printf("Test function : privilege_info_get_display_name\n");
381 __change_color_to_origin();
382 __test_privilege_info_get_display_name();
384 __change_color_to_yellow();
385 printf("Test function : privilege_info_get_display_name_by_pkgtype\n");
386 __change_color_to_origin();
387 __test_privilege_info_get_display_name_by_pkgtype();
389 __change_color_to_yellow();
390 printf("Test function : privilege_info_get_description\n");
391 __change_color_to_origin();
392 __test_privilege_info_get_description();
394 __change_color_to_yellow();
395 printf("Test function : privilege_info_get_description_by_pkgtype\n");
396 __change_color_to_origin();
397 __test_privilege_info_get_description_by_pkgtype();
399 __change_color_to_green();
400 printf("Test Complete\n");
401 printf("success : %d, ", success_cnt);
402 __change_color_to_red();
403 printf("fail : %d\n", fail_cnt);
404 __change_color_to_origin();