From 40e0437e34512aa45d4d7405cf1b7b5c6808cc10 Mon Sep 17 00:00:00 2001 From: Hyunwoo Kim Date: Wed, 27 Mar 2013 00:46:40 +0900 Subject: [PATCH] Modify version Change-Id: I5d49f7aa20e50951cf593182b10c95135fa41954 Signed-off-by: Hyunwoo Kim --- packaging/privacy-manager.spec | 4 +- test/CMakeLists.txt | 61 ++++++++ test/TestMain.cpp | 335 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 397 insertions(+), 3 deletions(-) create mode 100644 test/CMakeLists.txt create mode 100644 test/TestMain.cpp diff --git a/packaging/privacy-manager.spec b/packaging/privacy-manager.spec index 87e72b5..33cb60e 100644 --- a/packaging/privacy-manager.spec +++ b/packaging/privacy-manager.spec @@ -1,7 +1,7 @@ Name: privacy-manager-server Summary: Privacy Management Version: 0.0.2 -Release: 1 +Release: 2 Group: System/Libraries License: SAMSUNG Source0: %{name}-%{version}.tar.gz @@ -50,8 +50,6 @@ Privacy Management(development files) %package -n capi-security-privacy-manager Summary: Privacy Manager API -Version: 0.0.1 -Release: 0 Group: TO_BE/FILLED_IN License: TO BE FILLED IN BuildRequires: cmake diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..839c94c --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,61 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +#PROJECT(privacy-manager-test) + +SET(CMAKE_INSTALL_PREFIX /usr) +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "\${prefix}") +SET(LIBDIR "\${prefix}/lib") +SET(INCLUDEDIR "\${prefix}/include") +SET(VERSION 0.0) + +SET(VERSION_MAJOR 0) +SET(VERSION "${VERSION_MAJOR}.0.1") + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED dlog) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS_PROFILING " -g -pg") +SET(CMAKE_CXX_FLAGS_PROFILING " -std=c++0x -g -pg") +SET(CMAKE_C_FLAGS_DEBUG " -g") +SET(CMAKE_CXX_FLAGS_DEBUG " -std=c++0x -g") +SET(CMAKE_C_FLAGS_RELEASE " -g") +SET(CMAKE_CXX_FLAGS_RELEASE " -std=c++0x -g") +SET(CMAKE_C_FLAGS_CCOV " -g --coverage") +SET(CMAKE_CXX_FLAGS_CCOV " -std=c++0x -g --coverage") + +SET(test_src_dir "${CMAKE_SOURCE_DIR}/test/") +SET(test_include_dir "${CMAKE_SOURCE_DIR}/test/") +SET(client_include_dir "${CMAKE_SOURCE_DIR}/client/inc/") +SET(common_include_dir "${CMAKE_SOURCE_DIR}/common/inc/") + +## Additional flag +ADD_DEFINITIONS("-fvisibility=hidden") +ADD_DEFINITIONS("-Wall -Werror") +ADD_DEFINITIONS("-DDLOG_ERROR_ENABLED") + +################################################################################################### +## for privacy-manager-test (executable) +INCLUDE_DIRECTORIES(${pkgs_INCLUDE_DIRS} ${test_include_dir} ${client_include_dir} ${common_include_dir}) +SET(PRIVACY_MANAGER_TEST_SOURCES + ${test_src_dir}/TestMain.cpp + ) + +SET(PRIVACY_MANAGER_TEST_LDFLAGS " -module -avoid-version -L../client") +SET(PRIVACY_MANAGER_TEST_CFLAGS " ${CFLAGS} -fPIC ") +#SET(PRIVACY_MANAGER_TEST_LIBADD " ") + +ADD_EXECUTABLE(privacy-manager-test ${PRIVACY_MANAGER_TEST_SOURCES}) +ADD_DEPENDENCIES(privacy-manager-test privacy-manager-client) + +TARGET_LINK_LIBRARIES(privacy-manager-test ${pkgs_LDFLAGS} ${pkgs_LIBRARIES} privacy-manager-client) +SET_TARGET_PROPERTIES(privacy-manager-test PROPERTIES COMPILE_FLAGS "${PRIVACY_MANAGER_TEST_CFLAGS}") +#SET_TARGET_PROPERTIES(privacy-manager-test PROPERTIES SOVERSION ${VERSION_MAJOR}) +#SET_TARGET_PROPERTIES(privacy-manager-test PROPERTIES VERSION ${VERSION}) +################################################################################################### + +INSTALL(TARGETS privacy-manager-test DESTINATION ../bin COMPONENT RuntimeLibraries) +#INSTALL(FILES ${PRIVACY_MANAGER_TEST_HEADERS} DESTINATION ../include) \ No newline at end of file diff --git a/test/TestMain.cpp b/test/TestMain.cpp new file mode 100644 index 0000000..012338d --- /dev/null +++ b/test/TestMain.cpp @@ -0,0 +1,335 @@ + + +#include +#include +#include +#include +#include +#include + +bool __privacy_manager_client_privacy_info_cb(privacy_info_client_s* privacy_info, void* user_data) +{ + std::cout << "-----result : " << *(int*) user_data << std::endl; + + char* name, *id, *desc; + bool enabled; + int res; + res = privacy_info_client_get_privacy_id(privacy_info, &id); + std::cout << " id: " << id << " result:" << res << std::endl; + + res = privacy_info_client_get_privacy_display_name(privacy_info, &name); + std::cout << " name: " << name << " result:" << res << std::endl; + + res = privacy_info_client_get_privacy_description(privacy_info, &desc); + std::cout << " desc: " << desc << " result:" << res << std::endl; + + res = privacy_info_client_is_enabled(privacy_info, &enabled); + std::cout << " enabled: " << enabled << " result:" << res << std::endl; + + return true; +} + +bool __privacy_manager_client_privacy_packages_cb(const char *package_id, void* user_data) +{ + int i = *(int*)user_data; + std::cout << "__privacy_manager_client_privacy_packages_cb: userdata: " << i++ << " : " << package_id <removeAppPackagePrivacyInfo("appid2"); + if (res != 0) + { + std::cout << "-- precondition - removeAppPackagePrivacyInfo: FAILED : " << res << " --" << std::endl; + //return -1; + } + + std::cout << "-- addAppPackagePrivacyInfo --" << std::endl; + std::list < std::string> list3; + list3.push_back (std::string("http://tizen.org/privilege/contextmanager.privacy11")); + list3.push_back (std::string("http://tizen.org/privilege/contextmanager.privacydd")); + list3.push_back (std::string("http://tizen.org/privilege/messaging.writ1e")); + res = pInst->addAppPackagePrivacyInfo("appid2", list3 ); + if (res != 0) + { + std::cout << "-- addAppPackagePrivacyInfo: FAILED : " << res << " --" << std::endl; + return -1; + } + return 0; +} + +int tc_capi(void) +{ + //int i = 111; + int res; + + //const char *abc[3] = {"abc","def", NULL}; + + char** abc = (char**)calloc(10,sizeof (char*)); + abc[0] = (char*) calloc(128,sizeof(char)); + abc[1] = (char*) calloc(128,sizeof(char)); + abc[2] = (char*) calloc(128,sizeof(char)); + abc[3] = (char*) calloc(128,sizeof(char)); + abc[4] = (char*) calloc(128,sizeof(char)); + abc[5] = (char*) calloc(128,sizeof(char));; + + std::cout<<"111"< +int tc_check(void) +{ + int res; + PrivacyManagerClient* pInst = PrivacyManagerClient::getInstance(); + + std::cout << "-- precondition - removeAppPackagePrivacyInfo --" << std::endl; + res = pInst->removeAppPackagePrivacyInfo("appid2"); + if (res != 0) + { + std::cout << "-- precondition - removeAppPackagePrivacyInfo: FAILED : " << res << " --" << std::endl; + //return -1; + } + + std::cout << "-- addAppPackagePrivacyInfo --" << std::endl; + std::list < std::string> list3; + list3.push_back (std::string("http://tizen.org/privilege/bluetooth.admin")); + list3.push_back (std::string("http://tizen.org/privilege/contact.read")); + list3.push_back (std::string("http://tizen.org/privilege/messaging.read")); + res = pInst->addAppPackagePrivacyInfo("appid2", list3 ); + if (res != 0) + { + std::cout << "-- addAppPackagePrivacyInfo: FAILED : " << res << " --" << std::endl; + return -1; + } + + res = PrivacyChecker::checkWithPrivilege ("appid2", "http://tizen.org/privilege/bluetooth.admin"); + std::cout << "result : " << res << std::endl; + + sleep(1); + pInst->setPrivacySetting("appid2", "http://tizen.org/privacy/bluetooth", true ); + sleep(1); + + res = PrivacyChecker::checkWithPrivilege ("appid2", "http://tizen.org/privilege/bluetooth.admin"); + std::cout << "result : " << res << std::endl; + + std::cout << "-- postcondition - removeAppPackagePrivacyInfo --" << std::endl; + res = pInst->removeAppPackagePrivacyInfo("appid2"); + if (res != 0) + { + std::cout << "-- postcondition - removeAppPackagePrivacyInfo: FAILED : " << res << " --" << std::endl; + //return -1; + } + return 0; +} + +int main (int argc, char* argv[]) +{ + + + int res; + +// res = check_addAppPackagePrivacyInfo(); + +// std::cout << res << std::endl; + + //res = tc_capi(); + //std::cout << res << std::endl; + + res = tc_check(); + std::cout << res < list; + res = pInst->getPrivacyAppPackages(list); + if (res != 0) + { + std::cout << "-- getPrivacyAppPackages: FAILED : " << res << " --" << std::endl; + return -1; + } + std::list < std::string > ::iterator iter = list.begin(); + std::cout <<"list" <<"\n"; + for (; iter != list.end(); ++iter) + { + std::cout << (*iter) <<"\n"; + } + + std::cout << "-- setPrivacySetting --" << std::endl; + res = pInst->setPrivacySetting("appid1", "privacy1", true); + if (res != 0) + { + std::cout << "-- setPrivacySetting: FAILED : " << res << " --" << std::endl; + return -1; + } + + std::cout << "-- getAppPackagePrivacyInfo --" << std::endl; + std::list < std::pair > list2; + res = pInst->getAppPackagePrivacyInfo("appid1",list2 ); + if (res != 0) + { + std::cout << "-- getAppPackagePrivacyInfo: FAILED : " << res << " --" << std::endl; + return -1; + } + + for (std::list < std::pair >::const_iterator iter = list2.begin(); iter != list2.end(); ++iter) + { + std::cout << iter->first << " : " << iter->second << std::endl; + } + + std::cout << "-- removeAppPackagePrivacyInfo --" << std::endl; + res = pInst->removeAppPackagePrivacyInfo("appid2"); + if (res != 0) + { + std::cout << "-- removeAppPackagePrivacyInfo: FAILED : " << res << " --" << std::endl; + //return -1; + } + + std::cout << "-- addAppPackagePrivacyInfo --" << std::endl; + std::list < std::string> list3; + list3.push_back (std::string("privacy1")); + list3.push_back (std::string("privacy4")); + list3.push_back (std::string("privacy5")); + res = pInst->addAppPackagePrivacyInfo("appid2", list3 ); + if (res != 0) + { + std::cout << "-- addAppPackagePrivacyInfo: FAILED : " << res << " --" << std::endl; + return -1; + } + + std::cout << "-- removeAppPackagePrivacyInfo --" << std::endl; + pInst->removeAppPackagePrivacyInfo("appid2"); + if (res != 0) + { + std::cout << "-- removeAppPackagePrivacyInfo: FAILED : " << res << " --" << std::endl; + return -1; + } + + + std::cout <<"result of : " << PrivacyChecker::check("privacy1") << std::endl; + std::cout <<"result of : " << PrivacyChecker::check("privacy2") << std::endl; + std::cout <<"result of : " << PrivacyChecker::check("privacy10") << std::endl; + + + + std::cout << "-- setUserPrompted -- " << false <setUserPrompted("appid1", false); + if (res != 0) + { + std::cout << "-- setUserPrompted: FAILED : " << res << " --" << std::endl; +// return -1; + } + bool isPrompted; + res = pInst->isUserPrompted("appid1", isPrompted); + if (res != 0) + { + std::cout << "-- isUserPrompted: FAILED : " << res << " --" << std::endl; + return -1; + } + std::cout <<"prompted? appid1 : " << isPrompted << std::endl; + + std::cout << "-- setUserPrompted -- " << !isPrompted <setUserPrompted("appid1", !isPrompted); + if (res != 0) + { + std::cout << "-- setUserPrompted: FAILED : " << res << " --" << std::endl; +// return -1; + } + + res = pInst->isUserPrompted("appid1", isPrompted); + std::cout <<"prompted? appid1 : " << isPrompted << std::endl; + if (res != 0) + { + std::cout << "-- setUserPrompted: FAILED : " << res << " --" << std::endl; +// return -1; + } + + std::cout << "-- addAppPackagePrivacyInfo --" << std::endl; + std::list < std::string> list5; + list5.push_back (std::string("privacy1")); + list5.push_back (std::string("privacy4")); + list5.push_back (std::string("privacy5")); + res = pInst->addAppPackagePrivacyInfo("appid11", list5 ); + if (res != 0) + { + std::cout << "-- addAppPackagePrivacyInfo: FAILED : " << res << " --" << std::endl; + return -1; + } + std::cout << "-- removeAppPackagePrivacyInfo --" << std::endl; + pInst->removeAppPackagePrivacyInfo("appid11"); + if (res != 0) + { + std::cout << "-- removeAppPackagePrivacyInfo: FAILED : " << res << " --" << std::endl; + return -1; + }*/ + return 0; +} \ No newline at end of file -- 2.7.4