3 #include <privilege_information.h>
11 static int fail_cnt = 0;
12 static int success_cnt = 0;
14 static void __change_color_to_red()
16 printf("%c[%d;%dm", 0x1B, BRIGHTNESS, RED);
19 static void __change_color_to_green()
21 printf("%c[%d;%dm", 0x1B, BRIGHTNESS, GREEN);
24 static void __change_color_to_yellow()
26 printf("%c[%d;%dm", 0x1B, BRIGHTNESS, YELLOW);
29 static void __change_color_to_origin()
31 printf("%c[%dm", 0x1B, 0);
34 static const char* __get_result_string(privilege_info_error_e ret)
36 if (ret == PRVINFO_ERROR_NONE)
37 return "PRVINFO_ERROR_NONE";
38 else if (ret == PRVINFO_ERROR_INVALID_PARAMETER)
39 return "PRVINFO_ERROR_INVALID_PARAMETER";
40 else if (ret == PRVINFO_ERROR_OUT_OF_MEMORY)
41 return "PRVINFO_ERROR_OUT_OF_MEMORY";
42 else if (ret == PRVINFO_ERROR_INTERNAL_ERROR)
43 return "PRVINFO_ERROR_INTERNAL_ERROR";
45 return "PRVINFO_ERROR_NO_MATCHED_ERROR_MESSAGE";
48 static void __check_get_privilege_display_name_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* display_name)
50 printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result));
52 if (expected_result != result) {
53 printf("not matched\n");
54 __change_color_to_red();
55 printf("test fail\n");
59 if (result == PRVINFO_ERROR_NONE) {
60 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) {
72 printf("display_name = %s\n", display_name);
73 printf("display_name must be NULL\n");
74 __change_color_to_red();
75 printf("test fail\n");
77 __change_color_to_origin();
81 __change_color_to_green();
82 printf("test success\n");
85 __change_color_to_origin();
89 static void __check_get_privilege_description_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* description)
91 printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result));
93 if (expected_result != result) {
94 printf("not matched\n");
95 __change_color_to_red();
96 printf("test fail\n");
100 if (result == PRVINFO_ERROR_NONE) {
101 if (description == NULL) {
102 printf("description must not be NULL\n");
103 __change_color_to_red();
104 printf("test fail\n");
106 __change_color_to_origin();
109 printf("description = %s\n", description);
112 if (description != NULL) {
113 printf("description = %s\n", description);
114 printf("description must be NULL\n");
115 __change_color_to_red();
116 printf("test fail\n");
118 __change_color_to_origin();
123 __change_color_to_green();
124 printf("test success\n");
127 __change_color_to_origin();
130 static void __test_privilege_info_get_display_name()
133 char* display_name = NULL;
135 printf("-----------------------------------------------------------\n");
136 printf("api_version : 2.3\n");
137 printf("privilege : http://tizen.org/privilege/window.priority.set\n");
138 printf("expected result : PRVINFO_ERROR_NONE\n");
139 ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/window.priority.set", &display_name);
140 __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
142 printf("-----------------------------------------------------------\n");
143 printf("api_version : 2.3\n");
144 printf("privilege : http://tizen.org/privilege/mediacapture\n");
145 printf("expected result : PRVINFO_ERROR_NONE\n");
146 if (display_name != NULL) {
150 ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/mediacapture", &display_name);
151 __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
153 printf("-----------------------------------------------------------\n");
154 printf("Not existing privilege\n");
155 printf("api_version : 2.3\n");
156 printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
157 printf("expected result : PRVINFO_ERROR_NONE\n");
158 if (display_name != NULL) {
162 ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name);
163 __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
165 printf("-----------------------------------------------------------\n");
166 printf("Invalid parameter\n");
167 printf("api_version : NULL\n");
168 printf("privilege : http://tizen.org/privilege/window.priority.set\n");
169 printf("expected result : PRVINFO_ERROR_NONE\n");
170 if (display_name != NULL) {
174 ret = privilege_info_get_display_name(NULL, "http://tizen.org/privilege/window, priority.set", &display_name);
175 __check_get_privilege_display_name_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, display_name);
179 static void __test_privilege_info_get_display_name_by_pkgtype()
182 char* display_name = NULL;
184 printf("-----------------------------------------------------------\n");
185 printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
186 printf("api_version : 2.3\n");
187 printf("privilege : http://tizen.org/privilege/window.priority.set\n");
188 printf("expected result : PRVINFO_ERROR_NONE\n");
189 ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &display_name);
190 __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
192 printf("-----------------------------------------------------------\n");
193 printf("pkgtype : PRVINFO_PACKAGE_TYPE_WEB\n");
194 printf("api_version : 2.3\n");
195 printf("privilege : http://tizen.org/privilege/mediacapture\n");
196 printf("expected result : PRVINFO_ERROR_NONE\n");
197 if (display_name != NULL) {
201 ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
202 __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
204 printf("-----------------------------------------------------------\n");
205 printf("Mismatched package type: write WEB as NATIVE\n");
206 printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
207 printf("api_version : 2.3\n");
208 printf("privilege : http://tizen.org/privilege/mediacapture\n");
209 printf("expected result : PRVINFO_ERROR_NONE\n");
210 if (display_name != NULL) {
214 ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
215 __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
218 printf("-----------------------------------------------------------\n");
219 printf("Not existing privilege\n");
220 printf("api_version : 2.3\n");
221 printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
222 printf("expected result : PRVINFO_ERROR_NONE\n");
223 if (display_name != NULL) {
227 ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name);
228 __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
230 printf("-----------------------------------------------------------\n");
231 printf("Invalid parameter\n");
232 printf("api_version : 2.3\n");
233 printf("privilege : http://tizen.org/privilege/mediacapture\n");
234 printf("expected result : PRVINFO_ERROR_NONE\n");
235 if (display_name != NULL) {
239 ret = privilege_info_get_display_name_by_pkgtype(NULL, "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
240 __check_get_privilege_display_name_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, display_name);
245 static void __test_privilege_info_get_description()
248 char* description = NULL;
250 printf("-----------------------------------------------------------\n");
251 printf("api_version : 2.3\n");
252 printf("privilege : http://tizen.org/privilege/window.priority.set\n");
253 printf("expected result : PRVINFO_ERROR_NONE\n");
254 ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/window.priority.set", &description);
255 __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
257 printf("-----------------------------------------------------------\n");
258 printf("api_version : 2.3\n");
259 printf("privilege : http://tizen.org/privilege/mediacapture\n");
260 printf("expected result : PRVINFO_ERROR_NONE\n");
261 if (description != NULL) {
265 ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/mediacapture", &description);
266 __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
268 printf("-----------------------------------------------------------\n");
269 printf("Not existing privilege\n");
270 printf("api_version : 2.3\n");
271 printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
272 printf("expected result : PRVINFO_ERROR_NONE\n");
273 if (description != NULL) {
277 ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description);
278 __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
280 printf("-----------------------------------------------------------\n");
281 printf("Invalid parameter\n");
282 printf("api_version : 2.3\n");
283 printf("privilege : http://tizen.org/privilege/mediacapture\n");
284 printf("expected result : PRVINFO_ERROR_NONE\n");
285 if (description != NULL) {
289 ret = privilege_info_get_description(NULL, "http://tizen.org/privilege/mediacapture", &description);
290 __check_get_privilege_description_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, description);
295 static void __test_privilege_info_get_description_by_pkgtype()
298 char* description = NULL;
300 printf("-----------------------------------------------------------\n");
301 printf("api_version : 2.3\n");
302 printf("privilege : http://tizen.org/privilege/window.priority.set\n");
303 printf("expected result : PRVINFO_ERROR_NONE\n");
304 ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &description);
305 __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
307 printf("-----------------------------------------------------------\n");
308 printf("api_version : 2.3\n");
309 printf("privilege : http://tizen.org/privilege/mediacapture\n");
310 printf("expected result : PRVINFO_ERROR_NONE\n");
311 if (description != NULL) {
315 ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/mediacapture", &description);
316 __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
318 printf("-----------------------------------------------------------\n");
319 printf("Mismatched package type: write WEB as NATIVE\n");
320 printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
321 printf("api_version : 2.3\n");
322 printf("privilege : http://tizen.org/privilege/mediacapture\n");
323 printf("expected result : PRVINFO_ERROR_NONE\n");
324 if (description != NULL) {
328 ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &description);
329 __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
331 printf("-----------------------------------------------------------\n");
332 printf("Not existing privilege\n");
333 printf("api_version : 2.3\n");
334 printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
335 printf("expected result : PRVINFO_ERROR_NONE\n");
336 if (description != NULL) {
340 ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description);
341 __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
343 printf("-----------------------------------------------------------\n");
344 printf("Invalid parameter\n");
345 printf("api_version : 2.3\n");
346 printf("privilege : NULL\n");
347 printf("expected result : PRVINFO_ERROR_INVALID_PARAMETER\n");
348 if (description != NULL) {
352 ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", NULL, &description);
353 __check_get_privilege_description_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, description);
360 __change_color_to_yellow();
361 printf("Test function : privilege_info_get_display_name\n");
362 __change_color_to_origin();
363 __test_privilege_info_get_display_name();
365 __change_color_to_yellow();
366 printf("Test function : privilege_info_get_display_name_by_pkgtype\n");
367 __change_color_to_origin();
368 __test_privilege_info_get_display_name_by_pkgtype();
370 __change_color_to_yellow();
371 printf("Test function : privilege_info_get_description\n");
372 __change_color_to_origin();
373 __test_privilege_info_get_description();
375 __change_color_to_yellow();
376 printf("Test function : privilege_info_get_description_by_pkgtype\n");
377 __change_color_to_origin();
378 __test_privilege_info_get_description_by_pkgtype();
380 __change_color_to_green();
381 printf("Test Complete\n");
382 printf("success : %d, ", success_cnt);
383 __change_color_to_red();
384 printf("fail : %d\n", fail_cnt);
385 __change_color_to_origin();