+/*
+ * Copyright (c) 2014-2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <stdio.h>
+#include <stdlib.h>
#include <privilege_information.h>
#define BRIGHTNESS 0
#define YELLOW 33
#define BG_BLACK 40
-static int fail_cnt=0;
-static int success_cnt=0;
-
-static void __change_color_to_red(){
- printf("%c[%d;%dm", 0x1B, BRIGHTNESS, RED);
-}
+static int fail_cnt = 0;
+static int success_cnt = 0;
-static void __change_color_to_green(){
- printf("%c[%d;%dm", 0x1B, BRIGHTNESS, GREEN);
+static void __change_color_to_red()
+{
+ printf("%c[%d;%dm", 0x1B, BRIGHTNESS, RED);
}
-static void __change_color_to_yellow(){
- printf("%c[%d;%dm", 0x1B, BRIGHTNESS, YELLOW);
+static void __change_color_to_green()
+{
+ printf("%c[%d;%dm", 0x1B, BRIGHTNESS, GREEN);
}
-static void __change_color_to_origin(){
- printf("%c[%dm", 0x1B, 0);
+static void __change_color_to_origin()
+{
+ printf("%c[%dm", 0x1B, 0);
}
-static const char* __get_result_string(privilege_info_error_e ret){
- if(ret == PRVINFO_ERROR_NONE){
- return "PRVINFO_ERROR_NONE";
- }
- else if(ret == PRVINFO_ERROR_INVALID_PARAMETER){
- return "PRVINFO_ERROR_INVALID_PARAMETER";
- }
- else if(ret == PRVINFO_ERROR_OUT_OF_MEMORY)
- {
- return "PRVINFO_ERROR_OUT_OF_MEMORY";
- }
- else if(ret == PRVINFO_ERROR_INTERNAL_ERROR){
- return "PRVINFO_ERROR_INTERNAL_ERROR";
- }
+static const char* __get_result_string(privilege_info_error_e ret)
+{
+ if (ret == PRVINFO_ERROR_NONE)
+ return "PRVINFO_ERROR_NONE";
+ else if (ret == PRVINFO_ERROR_INVALID_PARAMETER)
+ return "PRVINFO_ERROR_INVALID_PARAMETER";
+ else if (ret == PRVINFO_ERROR_OUT_OF_MEMORY)
+ return "PRVINFO_ERROR_OUT_OF_MEMORY";
+ else if (ret == PRVINFO_ERROR_INTERNAL_ERROR)
+ return "PRVINFO_ERROR_INTERNAL_ERROR";
+ else if (ret == PRVINFO_ERROR_NOT_SUPPORTED)
+ return "PRVINFO_ERROR_NOT_SUPPORTED";
+ else if (ret == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE)
+ return "PRVINFO_ERROR_NO_MATCHING_PRIVILEGE";
+
+ return "PRVINFO_ERROR_NO_MATCHED_ERROR_MESSAGE";
}
static void __check_get_privilege_display_name_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* display_name)
{
- printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result));
-
- if(expected_result != result)
- {
- printf("not matched\n");
- __change_color_to_red();
- printf("test fail\n");
- fail_cnt++;
- }else{
- printf("matched\n");
- if(result == PRVINFO_ERROR_NONE)
- {
- if(display_name == NULL)
- {
- printf("display_name must not be NULL\n");
- __change_color_to_red();
- printf("test fail\n");
- fail_cnt++;
- __change_color_to_origin();
- return;
- }else{
- printf("display_name = %s\n", display_name);
- }
- }else{
- if(display_name != NULL)
- {
- printf("display_name = %s\n", display_name);
- printf("display_name must be NULL\n");
- __change_color_to_red();
- printf("test fail\n");
- fail_cnt++;
- __change_color_to_origin();
- return;
- }
- }
- __change_color_to_green();
- printf("test success\n");
- success_cnt++;
- }
- __change_color_to_origin();
+ printf("--- expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result));
+
+ if (expected_result != result) {
+ __change_color_to_red();
+ printf("TEST RESULT: FAILED\n");
+ fail_cnt++;
+ } else {
+ if (result == PRVINFO_ERROR_NONE) {
+ if (display_name == NULL) {
+ printf("--- display_name must not be NULL\n");
+ __change_color_to_red();
+ printf("TEST RESULT: FAILED\n");
+ fail_cnt++;
+ __change_color_to_origin();
+ return;
+ } else {
+ printf("--- display_name = %s\n", display_name);
+ }
+ } else if (result == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) {
+ if (display_name != NULL) {
+ printf("--- display_name = %s\n", display_name);
+ printf("--- display_name must be NULL\n");
+ __change_color_to_red();
+ printf("TEST RESULT: FAILED\n");
+ fail_cnt++;
+ __change_color_to_origin();
+ return;
+ }
+ }
+ __change_color_to_green();
+ printf("TEST RESULT: SUCCESS\n");
+ success_cnt++;
+ }
+ __change_color_to_origin();
}
static void __check_get_privilege_description_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* description)
{
- printf("expected result = %s, result = %s\n", __get_result_string(expected_result), __get_result_string(result));
-
- if(expected_result != result)
- {
- printf("not matched\n");
- __change_color_to_red();
- printf("test fail\n");
- fail_cnt++;
- }else{
- printf("matched\n");
- if(result == PRVINFO_ERROR_NONE)
- {
- if(description == NULL)
- {
- printf("description must not be NULL\n");
- __change_color_to_red();
- printf("test fail\n");
- fail_cnt++;
- __change_color_to_origin();
- return;
- }else{
- printf("description = %s\n", description);
- }
- }else{
- if(description != NULL)
- {
- printf("description = %s\n", description);
- printf("description must be NULL\n");
- __change_color_to_red();
- printf("test fail\n");
- fail_cnt++;
- __change_color_to_origin();
- return;
- }
- }
-
- __change_color_to_green();
- printf("test success\n");
- success_cnt++;
- }
- __change_color_to_origin();
+ printf("--- expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result));
+
+ if (expected_result != result) {
+ __change_color_to_red();
+ printf("TEST RESULT: FAILED\n");
+ fail_cnt++;
+ } else {
+ if (result == PRVINFO_ERROR_NONE) {
+ if (description == NULL) {
+ printf("--- description must not be NULL\n");
+ __change_color_to_red();
+ printf("TEST RESULT: FAILED\n");
+ fail_cnt++;
+ __change_color_to_origin();
+ return;
+ } else {
+ printf("--- description = %s\n", description);
+ }
+ } else if (result == PRVINFO_ERROR_NO_MATCHING_PRIVILEGE) {
+ if (description != NULL) {
+ printf("--- description = %s\n", description);
+ printf("--- description must be NULL\n");
+ __change_color_to_red();
+ printf("TEST RESULT: FAILED\n");
+ fail_cnt++;
+ __change_color_to_origin();
+ return;
+ }
+ }
+
+ __change_color_to_green();
+ printf("TEST RESULT: SUCCESS\n");
+ success_cnt++;
+ }
+ __change_color_to_origin();
}
-static void __test_privilege_info_get_display_name()
+static void __check_get_privacy_display_name_result(privilege_info_error_e expected_result, privilege_info_error_e result, const char* privacy_display)
{
- int ret;
- char* display_name = NULL;
-
- printf("-----------------------------------------------------------\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/window.priority.set\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/window.priority.set", &display_name);
- __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
-
- printf("-----------------------------------------------------------\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/mediacapture\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- if(display_name != NULL)
- {
- free(display_name);
- display_name = NULL;
- }
- ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/mediacapture", &display_name);
- __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
-
- printf("-----------------------------------------------------------\n");
- printf("Not existing privilege\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- if(display_name != NULL)
- {
- free(display_name);
- display_name = NULL;
- }
- ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name);
- __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
-
- printf("-----------------------------------------------------------\n");
- printf("Invalid parameter\n");
- printf("api_version : NULL\n");
- printf("privilege : http://tizen.org/privilege/window.priority.set\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- if(display_name != NULL)
- {
- free(display_name);
- display_name = NULL;
- }
- ret = privilege_info_get_display_name(NULL, "http://tizen.org/privilege/window,priority.set", &display_name);
- __check_get_privilege_display_name_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, display_name);
-
- free(display_name);
+ printf("--- expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result));
+
+ if (expected_result != result) {
+ __change_color_to_red();
+ printf("TEST RESULT: FAILED\n");
+ fail_cnt++;
+ } else {
+ if (privacy_display != NULL)
+ printf("--- privacy_display_name = %s\n", privacy_display);
+ else
+ printf("--- privacy_display_name is NULL.\n");
+ __change_color_to_green();
+ printf("TEST RESULT: SUCCESS\n");
+ success_cnt++;
+ }
+ __change_color_to_origin();
}
-static void __test_privilege_info_get_display_name_by_pkgtype()
+
+static void __test_positive_privilege_info_get_display_name()
{
- int ret;
- char* display_name = NULL;
-
- printf("-----------------------------------------------------------\n");
- printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/window.priority.set\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &display_name);
- __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
-
- printf("-----------------------------------------------------------\n");
- printf("pkgtype : PRVINFO_PACKAGE_TYPE_WEB\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/mediacapture\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- if(display_name != NULL)
- {
- free(display_name);
- display_name = NULL;
- }
- ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
- __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
-
- printf("-----------------------------------------------------------\n");
- printf("Mismatched package type: write WEB as NATIVE\n");
- printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/mediacapture\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- if(display_name != NULL)
- {
- free(display_name);
- display_name = NULL;
- }
- ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
- __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
-
-
- printf("-----------------------------------------------------------\n");
- printf("Not existing privilege\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- if(display_name != NULL)
- {
- free(display_name);
- display_name = NULL;
- }
- ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name);
- __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
-
- printf("-----------------------------------------------------------\n");
- printf("Invalid parameter\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/mediacapture\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- if(display_name != NULL)
- {
- free(display_name);
- display_name = NULL;
- }
- ret = privilege_info_get_display_name_by_pkgtype(NULL, "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
- __check_get_privilege_display_name_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, display_name);
-
- free(display_name);
+ int ret;
+ char* display_name = NULL;
+
+ printf("TEST NAME: %s #1\n",__func__);
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/window.priority.set\n");
+ ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/window.priority.set", &display_name);
+ __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
+
+ printf("-----------------------------------------------------------\n");
+ printf("TEST NAME: %s #2\n",__func__);
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/mediacapture\n");
+ if (display_name != NULL) {
+ free(display_name);
+ display_name = NULL;
+ }
+ ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/mediacapture", &display_name);
+ __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
+
+ free(display_name);
}
-static void __test_privilege_info_get_description()
+static void __test_negative_privilege_info_get_display_name()
{
- int ret;
- char* description = NULL;
-
- printf("-----------------------------------------------------------\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/window.priority.set\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/window.priority.set", &description);
- __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
-
- printf("-----------------------------------------------------------\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/mediacapture\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- if(description != NULL)
- {
- free(description);
- description = NULL;
- }
- ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/mediacapture", &description);
- __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
-
- printf("-----------------------------------------------------------\n");
- printf("Not existing privilege\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- if(description != NULL)
- {
- free(description);
- description = NULL;
- }
- ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description);
- __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
-
- printf("-----------------------------------------------------------\n");
- printf("Invalid parameter\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/mediacapture\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- if(description != NULL)
- {
- free(description);
- description = NULL;
- }
- ret = privilege_info_get_description(NULL, "http://tizen.org/privilege/mediacapture", &description);
- __check_get_privilege_description_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, description);
-
- free(description);
+ int ret;
+ char * display_name = NULL;
+
+ printf("TEST NAME: %s #1\n",__func__);
+ printf("--- Not existing privilege\n");
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
+ if (display_name != NULL) {
+ free(display_name);
+ display_name = NULL;
+ }
+ ret = privilege_info_get_display_name("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name);
+ __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name);
+
+ printf("TEST NAME: %s #2\n",__func__);
+ printf("--- Invalid parameter\n");
+ printf("--- api_version : NULL\n");
+ printf("--- privilege : http://tizen.org/privilege/window.priority.set\n");
+ if (display_name != NULL) {
+ free(display_name);
+ display_name = NULL;
+ }
+ ret = privilege_info_get_display_name(NULL, "http://tizen.org/privilege/window, priority.set", &display_name);
+ __check_get_privilege_display_name_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, display_name);
+
+ free(display_name);
}
-static void __test_privilege_info_get_description_by_pkgtype()
+static void __test_positive_privilege_info_get_display_name_by_pkgtype()
{
- int ret;
- char* description = NULL;
-
- printf("-----------------------------------------------------------\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/window.priority.set\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &description);
- __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
-
- printf("-----------------------------------------------------------\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/mediacapture\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- if(description != NULL)
- {
- free(description);
- description = NULL;
- }
- ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/mediacapture", &description);
- __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
-
- printf("-----------------------------------------------------------\n");
- printf("Mismatched package type: write WEB as NATIVE\n");
- printf("pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/mediacapture\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- if(description != NULL)
- {
- free(description);
- description = NULL;
- }
- ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &description);
- __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
-
- printf("-----------------------------------------------------------\n");
- printf("Not existing privilege\n");
- printf("api_version : 2.3\n");
- printf("privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
- printf("expected result : PRVINFO_ERROR_NONE\n");
- if(description != NULL)
- {
- free(description);
- description = NULL;
- }
- ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description);
- __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
-
- printf("-----------------------------------------------------------\n");
- printf("Invalid parameter\n");
- printf("api_version : 2.3\n");
- printf("privilege : NULL\n");
- printf("expected result : PRVINFO_ERROR_INVALID_PARAMETER\n");
- if(description != NULL)
- {
- free(description);
- description = NULL;
- }
- ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE","2.3", NULL, &description);
- __check_get_privilege_description_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, description);
-
- free(description);
+ int ret;
+ char* display_name = NULL;
+
+ printf("TEST NAME: %s #1\n",__func__);
+ printf("--- pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/window.priority.set\n");
+ ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &display_name);
+ __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
+
+ printf("TEST NAME: %s #2\n",__func__);
+ printf("--- pkgtype : PRVINFO_PACKAGE_TYPE_WEB\n");
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/mediacapture\n");
+ if (display_name != NULL) {
+ free(display_name);
+ display_name = NULL;
+ }
+ ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
+ __check_get_privilege_display_name_result(PRVINFO_ERROR_NONE, ret, display_name);
+
+ free(display_name);
}
-int main()
+static void __test_negative_privilege_info_get_display_name_by_pkgtype()
+{
+ int ret;
+ char* display_name = NULL;
+
+ printf("TEST NAME: %s #1\n",__func__);
+ printf("--- Mismatched package type: write WEB as NATIVE\n");
+ printf("--- pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/mediacapture\n");
+ if (display_name != NULL) {
+ free(display_name);
+ display_name = NULL;
+ }
+ ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
+ __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name);
+
+ printf("TEST NAME: %s #2\n",__func__);
+ printf("--- Not existing privilege\n");
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
+ if (display_name != NULL) {
+ free(display_name);
+ display_name = NULL;
+ }
+ ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &display_name);
+ __check_get_privilege_display_name_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, display_name);
+
+ printf("TEST NAME: %s #3\n",__func__);
+ printf("--- Invalid parameter\n");
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/mediacapture\n");
+ if (display_name != NULL) {
+ free(display_name);
+ display_name = NULL;
+ }
+ ret = privilege_info_get_display_name_by_pkgtype(NULL, "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
+ __check_get_privilege_display_name_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, display_name);
+
+ printf("TEST NAME: %s #4\n",__func__);
+ printf("--- Invalid parameter\n");
+ printf("--- pkgtype : PRVINFO_PACKAGE_TYPE_NONE\n");
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/mediacapture\n");
+ if (display_name != NULL) {
+ free(display_name);
+ display_name = NULL;
+ }
+ ret = privilege_info_get_display_name_by_pkgtype("PRVINFO_PACKAGE_TYPE_NONE", "2.3", "http://tizen.org/privilege/mediacapture", &display_name);
+ __check_get_privilege_display_name_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, display_name);
+
+ free(display_name);
+}
+
+
+static void __test_positive_privilege_info_get_description()
+{
+ int ret;
+ char* description = NULL;
+
+ printf("TEST NAME: %s #1\n",__func__);
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/window.priority.set\n");
+ ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/window.priority.set", &description);
+ __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
+
+ printf("TEST NAME: %s #2\n",__func__);
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/mediacapture\n");
+ if (description != NULL) {
+ free(description);
+ description = NULL;
+ }
+ ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/mediacapture", &description);
+ __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
+
+ free(description);
+}
+
+static void __test_negative_privilege_info_get_description()
+{
+ int ret;
+ char* description = NULL;
+
+ printf("TEST NAME: %s #1\n",__func__);
+ printf("--- Not existing privilege\n");
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
+ if (description != NULL) {
+ free(description);
+ description = NULL;
+ }
+ ret = privilege_info_get_description("2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description);
+ __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description);
+
+ printf("TEST NAME: %s #2\n",__func__);
+ printf("--- Invalid parameter\n");
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/mediacapture\n");
+ if (description != NULL) {
+ free(description);
+ description = NULL;
+ }
+ ret = privilege_info_get_description(NULL, "http://tizen.org/privilege/mediacapture", &description);
+ __check_get_privilege_description_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, description);
+
+ free(description);
+}
+
+static void __test_positive_privilege_info_get_description_by_pkgtype()
+{
+ int ret;
+ char* description = NULL;
+
+ printf("TEST NAME: %s #1\n",__func__);
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/window.priority.set\n");
+ ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/window.priority.set", &description);
+ __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
+
+ printf("TEST NAME: %s #2\n",__func__);
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/mediacapture\n");
+ if (description != NULL) {
+ free(description);
+ description = NULL;
+ }
+ ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_WEB", "2.3", "http://tizen.org/privilege/mediacapture", &description);
+ __check_get_privilege_description_result(PRVINFO_ERROR_NONE, ret, description);
+
+ free(description);
+}
+
+static void __test_negative_privilege_info_get_description_by_pkgtype()
+{
+ int ret;
+ char* description = NULL;
+
+ printf("TEST NAME: %s #1\n",__func__);
+ printf("--- Mismatched package type: write WEB as NATIVE\n");
+ printf("--- pkgtype : PRVINFO_PACKAGE_TYPE_NATIVE\n");
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/mediacapture\n");
+ if (description != NULL) {
+ free(description);
+ description = NULL;
+ }
+ ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/mediacapture", &description);
+ __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description);
+
+ printf("TEST NAME: %s #2\n",__func__);
+ printf("--- Not existing privilege\n");
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : http://tizen.org/privilege/RRRRRRRRRR\n");
+ if (description != NULL) {
+ free(description);
+ description = NULL;
+ }
+ ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", "http://tizen.org/privilege/RRRRRRRRRR", &description);
+ __check_get_privilege_description_result(PRVINFO_ERROR_NO_MATCHING_PRIVILEGE, ret, description);
+
+ printf("TEST NAME: %s #3\n",__func__);
+ printf("--- Invalid parameter\n");
+ printf("--- api_version : 2.3\n");
+ printf("--- privilege : NULL\n");
+ if (description != NULL) {
+ free(description);
+ description = NULL;
+ }
+ ret = privilege_info_get_description_by_pkgtype("PRVINFO_PACKAGE_TYPE_NATIVE", "2.3", NULL, &description);
+ __check_get_privilege_description_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, description);
+
+ free(description);
+}
+
+static void __test_positive_privilege_info_get_privacy_display_name()
{
- __change_color_to_yellow();
- printf("Test function : privilege_info_get_display_name\n");
- __change_color_to_origin();
- __test_privilege_info_get_display_name();
-
- __change_color_to_yellow();
- printf("Test function : privilege_info_get_display_name_by_pkgtype\n");
- __change_color_to_origin();
- __test_privilege_info_get_display_name_by_pkgtype();
-
- __change_color_to_yellow();
- printf("Test function : privilege_info_get_description\n");
- __change_color_to_origin();
- __test_privilege_info_get_description();
-
- __change_color_to_yellow();
- printf("Test function : privilege_info_get_description_by_pkgtype\n");
- __change_color_to_origin();
- __test_privilege_info_get_description_by_pkgtype();
-
- __change_color_to_green();
- printf("Test Complete\n");
- printf("success : %d, ", success_cnt);
- __change_color_to_red();
- printf("fail : %d\n", fail_cnt);
- __change_color_to_origin();
+ int ret;
+ char* privacy_display_name = NULL;
+
+ printf("TEST NAME: %s #1\n",__func__);
+ printf("--- Privacy related privilege\n");
+ printf("--- privilege: http://tizen.org/privilege/account.read\n");
+ ret = privilege_info_get_privacy_display_name("http://tizen.org/privilege/account.read", &privacy_display_name);
+ __check_get_privacy_display_name_result(PRVINFO_ERROR_NOT_SUPPORTED, ret, privacy_display_name);
+ free(privacy_display_name);
+}
+
+static void __test_negative_privilege_info_get_privacy_display_name()
+{
+ int ret;
+ char* privacy_display_name = NULL;
+
+ printf("TEST NAME: %s #1\n",__func__);
+ printf("--- Invalid parameter\n");
+ printf("--- no input privilege\n");
+ ret = privilege_info_get_privacy_display_name(NULL, &privacy_display_name);
+ __check_get_privacy_display_name_result(PRVINFO_ERROR_NOT_SUPPORTED, ret, privacy_display_name);
+
+ if (privacy_display_name != NULL) {
+ free(privacy_display_name);
+ privacy_display_name = NULL;
+ }
+
+ printf("TEST NAME: %s #2\n",__func__);
+ printf("--- Not a privacy related privilege\n");
+ printf("--- privilege: http://tizen.org/privilege/internet\n");
+ ret = privilege_info_get_privacy_display_name("http://tizen.org/privilege/internet", &privacy_display_name);
+ __check_get_privacy_display_name_result(PRVINFO_ERROR_NOT_SUPPORTED, ret, privacy_display_name);
+
+ if (privacy_display_name != NULL) {
+ free(privacy_display_name);
+ privacy_display_name = NULL;
+ }
+
+ printf("TEST NAME: %s #3\n",__func__);
+ printf("--- Not existing privilege\n");
+ printf("--- privilege: http://tizen.org/privilege/wrong.privilege.name\n");
+ ret = privilege_info_get_privacy_display_name("http://tizen.org/privilege/wrong.privilege.name", &privacy_display_name);
+ __check_get_privacy_display_name_result(PRVINFO_ERROR_NOT_SUPPORTED, ret, privacy_display_name);
+
+ if (privacy_display_name != NULL) {
+ free(privacy_display_name);
+ privacy_display_name = NULL;
+ }
+
+ free(privacy_display_name);
+}
+
+static void __check_privilege_info_get_privilege_info(privilege_info_error_e expected_result, privilege_info_error_e result, GList* privilege_info_list, int return_result)
+{
+ printf("--- expected : %s\n result : %s\n", __get_result_string(expected_result), __get_result_string(result));
+
+ if (expected_result != result) {
+ __change_color_to_red();
+ printf("TEST RESULT: FAILED\n");
+ fail_cnt++;
+ __change_color_to_origin();
+ } else {
+ __change_color_to_green();
+ printf("TEST RESULT: SUCCESS\n");
+ success_cnt++;
+ __change_color_to_origin();
+ }
+
+ printf("--- return_result = %d\n", return_result);
+ GList* l;
+ if (result == PRVINFO_ERROR_NONE) {
+ for (l = privilege_info_list; l != NULL; l = l->next) {
+ privilege_info_s* privilege_info = (privilege_info_s*)l->data;
+
+ printf("--- privilege_info->privilege_name = %s\n", privilege_info->privilege_name);
+ printf("--- privilege_info->display_name = %s\n", privilege_info->display_name);
+ printf("--- privilege_info->description = %s\n", privilege_info->description);
+ printf("\n");
+ }
+ }
+
+ printf("\n");
+}
+
+static void __test_positive_privilege_info_get_privilege_info_list()
+{
+ GList* privilege_name_list = NULL;
+ GList* privilege_info_list = NULL;
+ privilege_consumer_return_code_e return_result;
+ int ret;
+
+ printf("TEST NAME: %s #1\n",__func__);
+ printf("--- locale : ko_KR.UTF8\n");
+ printf("--- privilege name : http://tizen.org/privilege/call\n");
+ printf("--- privilege name : http://tizen.org/privilege/content.read\n");
+ printf("--- privilege name : http://tizen.org/privilege/filesystem.read\n");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/content.read");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/filesystem.read");
+
+ ret = privilege_info_get_privilege_info_list("ko_KR.UTF8", privilege_name_list, &privilege_info_list, &return_result);
+ __check_privilege_info_get_privilege_info(PRVINFO_ERROR_NONE, ret, privilege_info_list, return_result);
+ g_list_free(privilege_name_list);
+ privilege_name_list = NULL;
+ privilege_info_free_privilege_info_list(privilege_info_list);
+ privilege_info_list = NULL;
+ printf("-----------------------------------------------------------\n");
+
+ printf("TEST NAME: %s #2\n",__func__);
+ printf("--- locale : ko_KR.UTF8\n");
+ printf("--- privilege name : http://tizen.org/privilege/call\n");
+ printf("--- privilege name : http://tizen.org/privilege/systemsettings.admin\n");
+ printf("--- privilege name : http://tizen.org/privilege/bookmark.admin\n");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/systemsettings.admin");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/bookmark.admin");
+
+ ret = privilege_info_get_privilege_info_list("ko_KR.UTF8", privilege_name_list, &privilege_info_list, &return_result);
+ __check_privilege_info_get_privilege_info(PRVINFO_ERROR_NONE, ret, privilege_info_list, return_result);
+ g_list_free(privilege_name_list);
+ privilege_name_list = NULL;
+ privilege_info_free_privilege_info_list(privilege_info_list);
+ privilege_info_list = NULL;
+ printf("-----------------------------------------------------------\n");
+
+ printf("TEST NAME: %s #3\n",__func__);
+ printf("--- locale : ko_KR.UTF8\n");
+ printf("--- privilege name : http://tizen.org/privilege/call\n");
+ printf("--- privilege name : http://tizen.org/privilege/alarm.xxxx\n");
+ printf("--- privilege name : http://tizen.org/privilege/account.xxx\n");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/alarm.xxxx");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/account.xxx");
+
+ ret = privilege_info_get_privilege_info_list("ko_KR.UTF8", privilege_name_list, &privilege_info_list, &return_result);
+ __check_privilege_info_get_privilege_info(PRVINFO_ERROR_NONE, ret, privilege_info_list, return_result);
+ g_list_free(privilege_name_list);
+ privilege_name_list = NULL;
+ privilege_info_free_privilege_info_list(privilege_info_list);
+ privilege_info_list = NULL;
+ printf("-----------------------------------------------------------\n");
+}
+
+static void __test_negative_privilege_info_get_privilege_info_list()
+{
+ GList* privilege_name_list = NULL;
+ GList* privilege_info_list = NULL;
+ privilege_consumer_return_code_e return_result;
+ int ret;
+
+ printf("TEST NAME: %s #1\n",__func__);
+ printf("--- UNKNOWN_LOCAL_CODE\n");
+ printf("--- locale : xx_XX.UTF8\n");
+ printf("--- privilege name : http://tizen.org/privilege/call\n");
+ printf("--- privilege name : http://tizen.org/privilege/content.read\n");
+ printf("--- privilege name : http://tizen.org/privilege/filesystem.read\n");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/call");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/content.read");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/filesystem.read");
+
+ ret = privilege_info_get_privilege_info_list("xx_XX.UTF8", privilege_name_list, &privilege_info_list, &return_result);
+ __check_privilege_info_get_privilege_info(PRVINFO_ERROR_NONE, ret, privilege_info_list, return_result);
+ g_list_free(privilege_name_list);
+ privilege_name_list = NULL;
+ privilege_info_free_privilege_info_list(privilege_info_list);
+ privilege_info_list = NULL;
+
+ printf("TEST NAME: %s #2\n",__func__);
+ printf("--- INVAILD_PARAMETER\n");
+ printf("--- locale : ko_KR.UTF8\n");
+ printf("--- privilege name : http://tizen.org/privilege/xxxx\n");
+ printf("--- privilege name : http://tizen.org/privilege/alarm.xxxx\n");
+ printf("--- privilege name : http://tizen.org/privilege/account.xxx\n");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/xxxx");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/alarm.xxxx");
+ privilege_name_list = g_list_append(privilege_name_list, "http://tizen.org/privilege/account.xxx");
+
+ ret = privilege_info_get_privilege_info_list("ko_KR.UTF8", privilege_name_list, &privilege_info_list, &return_result);
+ __check_privilege_info_get_privilege_info(PRVINFO_ERROR_NONE, ret, privilege_info_list, return_result);
+ g_list_free(privilege_name_list);
+ privilege_name_list = NULL;
+ privilege_info_free_privilege_info_list(privilege_info_list);
+ privilege_info_list = NULL;
+ printf("-----------------------------------------------------------\n");
+}
+
+int main()
+{
+ __change_color_to_origin();
+ __test_positive_privilege_info_get_display_name();
+ __test_negative_privilege_info_get_display_name();
+
+ __change_color_to_origin();
+ __test_positive_privilege_info_get_display_name_by_pkgtype();
+ __test_negative_privilege_info_get_display_name_by_pkgtype();
+
+ __change_color_to_origin();
+ __test_positive_privilege_info_get_description();
+ __test_negative_privilege_info_get_description();
+
+ __change_color_to_origin();
+ __test_positive_privilege_info_get_description_by_pkgtype();
+ __test_negative_privilege_info_get_description_by_pkgtype();
+
+ __change_color_to_origin();
+ __test_positive_privilege_info_get_privacy_display_name();
+ __test_negative_privilege_info_get_privacy_display_name();
+
+ __change_color_to_origin();
+ __test_positive_privilege_info_get_privilege_info_list();
+ __test_negative_privilege_info_get_privilege_info_list();
+
+ __change_color_to_green();
+ printf("Test Complete\n");
+ printf("success : %d, ", success_cnt);
+ __change_color_to_red();
+ printf("fail : %d\n", fail_cnt);
+ __change_color_to_origin();
+
+ return 0;
}