[UTC][capi-privacy-privilege-manager][ACR-1015][Add new TCs for new APIs]
authorPiotr Sawicki <p.sawicki2@partner.samsung.com>
Tue, 8 Aug 2017 10:38:30 +0000 (12:38 +0200)
committerPiotr Sawicki <p.sawicki2@partner.samsung.com>
Tue, 8 Aug 2017 10:42:15 +0000 (12:42 +0200)
Change-Id: Icbaf57a236327eff1b577328d821a383a92e7c18

packaging/utc/core-privacy-privilege-manager-tests.xml [new file with mode: 0644]
src/utc/privacy-privilege-manager/CMakeLists.txt [new file with mode: 0644]
src/utc/privacy-privilege-manager/tct-privacy-privilege-manager-core.c [new file with mode: 0644]
src/utc/privacy-privilege-manager/tct-privacy-privilege-manager-core_mobile.h [new file with mode: 0644]
src/utc/privacy-privilege-manager/tct-privacy-privilege-manager-core_wearable.h [new file with mode: 0644]
src/utc/privacy-privilege-manager/utc-privacy-privilege-manager.c [new file with mode: 0644]

diff --git a/packaging/utc/core-privacy-privilege-manager-tests.xml b/packaging/utc/core-privacy-privilege-manager-tests.xml
new file mode 100644 (file)
index 0000000..1b39568
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="core-privacy-privilege-manager-tests" version="0.1.0" api-version="3.0">
+    <label>CorePrivacyPrivilegeManagerTest</label>
+    <author email="test@tizen.org" href="www.tizen.org">test</author>
+    <description>Core API test Application</description>
+    <ui-application appid="core.privacy-privilege-manager-tests" exec="/usr/apps/core-privacy-privilege-manager-tests/bin/tct-privacy-privilege-manager-core" nodisplay="false" multiple="false" type="capp" taskmanage="true">
+        <background-category value="background-network"/>
+        <background-category value="download"/>
+        <background-category value="iot-communication"/>
+        <background-category value="location"/>
+        <background-category value="media"/>
+        <background-category value="sensor"/>
+    </ui-application>
+    <privileges>
+        <privilege>http://tizen.org/privilege/location</privilege>
+    </privileges>
+</manifest>
diff --git a/src/utc/privacy-privilege-manager/CMakeLists.txt b/src/utc/privacy-privilege-manager/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f4aa4de
--- /dev/null
@@ -0,0 +1,41 @@
+SET(PKG_NAME "privacy-privilege-manager")
+
+SET(EXEC_NAME "tct-${PKG_NAME}-core")
+SET(RPM_NAME "core-${PKG_NAME}-tests")
+
+SET(CAPI_LIB "capi-privacy-privilege-manager")
+SET(TC_SOURCES
+       utc-privacy-privilege-manager.c
+)
+
+PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
+       ${CAPI_LIB}
+       capi-appfw-application
+       capi-system-info
+       glib-2.0
+       bundle
+       dlog 
+       elementary
+)
+
+INCLUDE_DIRECTORIES(
+       ${${CAPI_LIB}_INCLUDE_DIRS}
+)
+
+ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.c ${TC_SOURCES} ${COMMON_FILE})
+TARGET_LINK_LIBRARIES(${EXEC_NAME}
+       ${${CAPI_LIB}_LIBRARIES}
+       bundle
+)
+
+INSTALL(PROGRAMS ${EXEC_NAME}
+       DESTINATION ${BIN_DIR}/${RPM_NAME}/bin
+)
+
+IF( DEFINED ASAN )
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -pie -g -fsanitize=address -fsanitize-recover=address -U_FORTIFY_SOURCE -fno-omit-frame-pointer")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib -Wl,-fsanitize=address")
+ELSE()
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fPIE -Wall")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib -pie")
+ENDIF()
diff --git a/src/utc/privacy-privilege-manager/tct-privacy-privilege-manager-core.c b/src/utc/privacy-privilege-manager/tct-privacy-privilege-manager-core.c
new file mode 100644 (file)
index 0000000..e152c66
--- /dev/null
@@ -0,0 +1,140 @@
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// 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 "tct_common.h"
+
+#ifdef MOBILE  //Starts MOBILE
+#include "tct-privacy-privilege-manager-core_mobile.h"
+#endif  //MOBILE       //End MOBILE
+
+#ifdef WEARABLE        //Starts WEARABLE
+#include "tct-privacy-privilege-manager-core_wearable.h"
+#endif  //WEARABLE     //End WEARABLE
+
+#ifdef TV      //Starts TV
+#include "tct-privacy-privilege-manager-core_tv.h"
+#endif  //TV   //End TV
+
+#ifdef COMMON_IOT      //Starts COMMON_IOT
+#include "tct-privacy-privilege-manager-core_common_iot.h"
+#endif  //COMMON_IOT   //End COMMON_IOT
+
+#include <stdio.h>
+#include <string.h>
+#include <malloc.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <glib.h>
+#include <stdbool.h>
+#include <app.h>
+#include <dlog.h>
+
+#include <Elementary.h>
+
+typedef struct appdata {
+       Evas_Object *win;
+       Evas_Object *conform;
+       Evas_Object *label;
+} appdata_s;
+
+static bool app_create(void *data)
+{
+       return true;
+}
+
+static void app_control(app_control_h app_control, void *data)
+{
+       char* pszGetTCName = NULL;
+       int i=0, result=0, nRet=0;
+       nRet = app_control_get_extra_data(app_control, "testcase_name", &pszGetTCName);
+       if(nRet != APP_CONTROL_ERROR_NONE)
+       {
+               dlog_print(DLOG_ERROR, "NativeTCT", "[%s:%d] app_control_get_extra_data returns error = %d", __FUNCTION__, __LINE__, nRet);
+               PRINT_UTC_LOG("\\n[%s][Line : %d]Unable to fetch test case name: app_control_get_extra_data API call fails\\n", __FILE__, __LINE__);
+               PRINT_TC_RESULT("%d",1);
+               FREE_MEMORY_TC(pszGetTCName);
+               return;
+       }
+
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Executing TC Name = %s", __FUNCTION__, __LINE__, pszGetTCName);
+       for ( i = 0; tc_array[i].name; i++ )
+       {
+               if ( 0 == strncmp(pszGetTCName, tc_array[i].name, strlen(pszGetTCName)) )
+               {
+                       DUMP_UTC_ERRLOG();
+                       if ( tc_array[i].startup )
+                       {
+                               dlog_print(DLOG_INFO, "NativeTCT", "%s : Start up", pszGetTCName);
+                               tc_array[i].startup();
+                       }
+
+                       dlog_print(DLOG_INFO, "NativeTCT", "%s : Body", pszGetTCName);
+                       result = tc_array[i].function();
+                       dlog_print(DLOG_INFO, "NativeTCT", "%s returns value = %d", pszGetTCName, result);
+
+                       if ( tc_array[i].cleanup )
+                       {
+                               dlog_print(DLOG_INFO, "NativeTCT", "%s : Clean up", pszGetTCName);
+                               tc_array[i].cleanup();
+                       }
+
+                       CLOSE_UTC_ERRLOG();
+                       PRINT_TC_RESULT("%d",result);
+                       FREE_MEMORY_TC(pszGetTCName);
+                       return;
+               }
+       }
+
+       dlog_print(DLOG_ERROR, "NativeTCT", "[%s:%d] Unable to execute %s : Unknown Test Case Name", __FUNCTION__, __LINE__, pszGetTCName);
+       PRINT_UTC_LOG("\\n[%s][Line : %d]Unable to execute %s : Unknown Test Case Name\\n", __FILE__, __LINE__, pszGetTCName);
+       PRINT_TC_RESULT("%d",1);
+       FREE_MEMORY_TC(pszGetTCName);
+       return;
+}
+
+static void app_terminate(void *data)
+{
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Package is now Terminating", __FUNCTION__, __LINE__);
+}
+
+int main(int argc, char *argv[])
+{
+       int ret = 0;
+       appdata_s ad = {0,};
+
+       ui_app_lifecycle_callback_s event_callback = {0,};
+       event_callback.create = app_create;
+       event_callback.terminate = app_terminate;
+       event_callback.app_control = app_control;
+
+       //setting gcda file location for coverage
+       setenv("GCOV_PREFIX","/tmp",1);
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Coverage *.gcda File location set to /tmp/home/abuild/rpmbuild/BUILD/ ", __FUNCTION__, __LINE__);
+
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Main Function is Invoked", __FUNCTION__, __LINE__);
+       ret = ui_app_main(argc, argv, &event_callback, &ad);
+       if (ret != APP_ERROR_NONE)
+       {
+               dlog_print(DLOG_ERROR, "NativeTCT", "Application ui_app_main call gets failed. err = %d", ret);
+               PRINT_UTC_LOG("\\n[%s][Line : %d]Application ui_app_main call gets failed. err = %d\\n", __FILE__, __LINE__, ret);
+               PRINT_TC_RESULT("%d",1);
+               return ret;
+       }
+
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Package is Terminated", __FUNCTION__, __LINE__);
+       return ret;
+}
diff --git a/src/utc/privacy-privilege-manager/tct-privacy-privilege-manager-core_mobile.h b/src/utc/privacy-privilege-manager/tct-privacy-privilege-manager-core_mobile.h
new file mode 100644 (file)
index 0000000..1ce718d
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+#ifndef __TCT_PRIVACY_PRIVILEGE_MANAGER_NATIVE_H__
+#define __TCT_PRIVACY_PRIVILEGE_MANAGER_NATIVE_H__
+
+#include "testcase.h"
+#include "tct_common.h"
+
+extern int utc_ppm_check_permission_n1(void);
+extern int utc_ppm_check_permission_n2(void);
+extern int utc_ppm_check_permission_n3(void);
+extern int utc_ppm_request_permission_n1(void);
+extern int utc_ppm_request_permission_n2(void);
+extern int utc_ppm_request_permission_n3(void);
+
+testcase tc_array[] = {
+    {"utc_ppm_check_permission_n1", utc_ppm_check_permission_n1, NULL, NULL},
+    {"utc_ppm_check_permission_n2", utc_ppm_check_permission_n2, NULL, NULL},
+    {"utc_ppm_check_permission_n3", utc_ppm_check_permission_n3, NULL, NULL},
+    {"utc_ppm_request_permission_n1", utc_ppm_request_permission_n1, NULL, NULL},
+    {"utc_ppm_request_permission_n2", utc_ppm_request_permission_n2, NULL, NULL},
+    {"utc_ppm_request_permission_n3", utc_ppm_request_permission_n3, NULL, NULL},
+    {NULL, NULL}
+};
+
+#endif // __TCT_PRIVACY_PRIVILEGE_MANAGER_NATIVE_H__
diff --git a/src/utc/privacy-privilege-manager/tct-privacy-privilege-manager-core_wearable.h b/src/utc/privacy-privilege-manager/tct-privacy-privilege-manager-core_wearable.h
new file mode 100644 (file)
index 0000000..1ce718d
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+#ifndef __TCT_PRIVACY_PRIVILEGE_MANAGER_NATIVE_H__
+#define __TCT_PRIVACY_PRIVILEGE_MANAGER_NATIVE_H__
+
+#include "testcase.h"
+#include "tct_common.h"
+
+extern int utc_ppm_check_permission_n1(void);
+extern int utc_ppm_check_permission_n2(void);
+extern int utc_ppm_check_permission_n3(void);
+extern int utc_ppm_request_permission_n1(void);
+extern int utc_ppm_request_permission_n2(void);
+extern int utc_ppm_request_permission_n3(void);
+
+testcase tc_array[] = {
+    {"utc_ppm_check_permission_n1", utc_ppm_check_permission_n1, NULL, NULL},
+    {"utc_ppm_check_permission_n2", utc_ppm_check_permission_n2, NULL, NULL},
+    {"utc_ppm_check_permission_n3", utc_ppm_check_permission_n3, NULL, NULL},
+    {"utc_ppm_request_permission_n1", utc_ppm_request_permission_n1, NULL, NULL},
+    {"utc_ppm_request_permission_n2", utc_ppm_request_permission_n2, NULL, NULL},
+    {"utc_ppm_request_permission_n3", utc_ppm_request_permission_n3, NULL, NULL},
+    {NULL, NULL}
+};
+
+#endif // __TCT_PRIVACY_PRIVILEGE_MANAGER_NATIVE_H__
diff --git a/src/utc/privacy-privilege-manager/utc-privacy-privilege-manager.c b/src/utc/privacy-privilege-manager/utc-privacy-privilege-manager.c
new file mode 100644 (file)
index 0000000..b9bf0c0
--- /dev/null
@@ -0,0 +1,135 @@
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// 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 "assert.h"
+
+#include <privacy_privilege_manager.h>
+
+static const char *location_privilege = "http://tizen.org/privilege/location";
+
+/**
+ * @testcase           utc_ppm_check_permission_n1
+ * @since_tizen                4.0
+ * @description                Check permission for a given privilege
+ *                                     - check status of privilege when the privilege parameter is NULL
+ */
+int utc_ppm_check_permission_n1(void)
+{
+       int ret;
+       ppm_check_result_e result = PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ALLOW;
+       ret = ppm_check_permission(NULL, &result);
+
+       assert_eq(ret, PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER);
+       assert_eq(result, PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ALLOW);
+
+       return 0;
+}
+
+/**
+ * @testcase           utc_ppm_check_permission_n2
+ * @since_tizen                4.0
+ * @description                Check permission for a given privilege
+ *                                     - check status of privilege when the privilege parameter is
+ *                                       an empty string
+ */
+int utc_ppm_check_permission_n2(void)
+{
+       int ret;
+       ppm_check_result_e result = PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ALLOW;
+
+       ret = ppm_check_permission("", &result);
+
+       assert_eq(ret, PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER);
+       assert_eq(result, PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ALLOW);
+
+       return 0;
+}
+
+/**
+ * @testcase           utc_ppm_check_permission_n3
+ * @since_tizen                4.0
+ * @description                Check permission for a given privilege
+ *                                     - check status of privilege when the result parameter is NULL
+ */
+int utc_ppm_check_permission_n3(void)
+{
+       int ret;
+
+       ret = ppm_check_permission(location_privilege, NULL);
+
+       assert_eq(ret, PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER);
+
+       return 0;
+}
+
+void ppm_request_response_test_cb(ppm_call_cause_e cause,
+                                                                 ppm_request_result_e result,
+                                                                 const char *privilege,
+                                                                 void *user_data)
+{
+}
+
+/**
+ * @testcase           utc_ppm_request_permission_n1
+ * @since_tizen                4.0
+ * @description                Request user permission
+ *                                     - request permission when the privilege parameter is NULL
+ */
+int utc_ppm_request_permission_n1(void)
+{
+       int ret;
+
+       ret = ppm_request_permission(NULL, ppm_request_response_test_cb, NULL);
+
+       assert_eq(ret, PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER);
+
+       return 0;
+}
+
+/**
+ * @testcase           utc_ppm_request_permission_n2
+ * @since_tizen                4.0
+ * @description                Request user permission
+ *                                     - request permission when the privilege parameter is an empty
+ *                                       string
+ */
+int utc_ppm_request_permission_n2(void)
+{
+       int ret;
+
+       ret = ppm_request_permission("", ppm_request_response_test_cb, NULL);
+
+       assert_eq(ret, PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER);
+
+       return 0;
+}
+
+/**
+ * @testcase           utc_ppm_request_permission_n3
+ * @since_tizen                4.0
+ * @description                Request user permission
+ *                                     - request permission when the callback parameter is NULL
+ */
+int utc_ppm_request_permission_n3(void)
+{
+       int ret;
+
+       ret = ppm_request_permission(location_privilege, NULL, NULL);
+
+       assert_eq(ret, PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER);
+
+       return 0;
+}
+