-#include <stdio.h>
-#include <dlog.h>
-#include <stdbool.h>
-#include <privilege_information.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#define LOG_TAG "PRIVILEGE_INFO_TEST_APP"
-#endif
-
-
-static int fail_cnt = 0;
-static int success_cnt = 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_INTERNAL_ERROR)
- return "PRVINFO_ERROR_INTERNAL_ERROR";
- else if (ret == PRVINFO_ERROR_OUT_OF_MEMORY)
- return "PRVINFO_ERROR_UNDECLARED_PRIVILEGE";
- else
- return "FAIL";
-}
-
-static void __check_result(privilege_info_error_e expected_result, privilege_info_error_e result, bool expected_status, bool status)
-{
- LOGD("expected result = %s, result = %s", __get_result_string(expected_result), __get_result_string(result));
- LOGD("expected status = %s, status = %s", expected_status ? "true" : "false", status ? "true" : "false");
-
- if (expected_result != result) {
- LOGD("test fail");
- fail_cnt++;
- } else {
- if (expected_status != status) {
- LOGD("test fail");
- fail_cnt++;
- } else {
- LOGD("test success");
- success_cnt++;
- }
- }
-}
-
-static void __test_privilege_info_get_privacy_privilege_status()
-{
- int ret = PRVINFO_ERROR_NONE;
- bool status;
-
- LOGD("-----------------------------------------------------------");
- LOGD("privilege : http://tizen.org/privilege/account.read");
- LOGD("expected result : PRVINFO_ERROR_NONE");
- ret = privilege_info_get_privacy_privilege_status("http://tizen.org/privilege/account.read", &status);
- __check_result(PRVINFO_ERROR_NONE, ret, true, status);
- LOGD("-----------------------------------------------------------");
-
- LOGD("privilege : http://tizen.org/privilege/contact.read");
- LOGD("expected result : PRVINFO_ERROR_NONE");
- ret = privilege_info_get_privacy_privilege_status("http://tizen.org/privilege/contact.read", &status);
- __check_result(PRVINFO_ERROR_NONE, ret, false, status);
- LOGD("-----------------------------------------------------------");
-
- LOGD("privilege : http://tizen.org/privilege/aaaaa");
- LOGD("expected result : PRVINFO_ERROR_INVALID_PARAMETER");
- ret = privilege_info_get_privacy_privilege_status("http://tizen.org/privilege/aaaaa", &status);
- __check_result(PRVINFO_ERROR_INVALID_PARAMETER, ret, true, status);
- LOGD("-----------------------------------------------------------");
-
-}
-
-int main()
-{
- LOGD("Test function : privilege_info_get_privacy_privilege_status");
- __test_privilege_info_get_privacy_privilege_status();
-
- LOGD("====================================");
- LOGD("Test Complete");
- LOGD("success : %d, ", success_cnt);
- LOGD("fail : %d", fail_cnt);
- LOGD("====================================");
-
- return 0;
-}