From: Nibha Sharma Date: Fri, 17 Sep 2021 11:28:34 +0000 (+0530) Subject: [ITC][capi-network-ua][ACR-1646][Added new api and new feature for location ua] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cef5b6b2bb57f40b65e351a49dbb6fa799208b84;p=test%2Ftct%2Fnative%2Fapi.git [ITC][capi-network-ua][ACR-1646][Added new api and new feature for location ua] Change-Id: Iba79f34a86f52b2045bb109b5daa7c6d75e3603f Signed-off-by: Nibha Sharma --- diff --git a/src/itc/capi-network-ua/CMakeLists.txt b/src/itc/capi-network-ua/CMakeLists.txt index d58d6ae7c..36ec8f7c1 100755 --- a/src/itc/capi-network-ua/CMakeLists.txt +++ b/src/itc/capi-network-ua/CMakeLists.txt @@ -10,6 +10,7 @@ SET(TC_SOURCES ITs-capi-network-ua-monitor.c ITs-capi-network-ua-device.c ITs-capi-network-ua-user.c + ITs-capi-network-ua-location.c ) PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED diff --git a/src/itc/capi-network-ua/ITs-capi-network-ua-common.h b/src/itc/capi-network-ua/ITs-capi-network-ua-common.h index f0e57f067..3b569311c 100755 --- a/src/itc/capi-network-ua/ITs-capi-network-ua-common.h +++ b/src/itc/capi-network-ua/ITs-capi-network-ua-common.h @@ -46,6 +46,7 @@ static char g_hServiceStr[] = {"ua.service.default"}; #define GMAINTIMEOUT 30000 //30 seconds #define API_NAMESPACE "UA_ITC" #define UA_FEATURE "http://tizen.org/feature/user_awareness" +#define UA_LOCATION_FEATURE "http://tizen.org/feature/user_awareness.location" #define START_TEST {\ FPRINTF("[Line : %d][%s] Starting test : %s\\n", __LINE__, API_NAMESPACE, __FUNCTION__);\ diff --git a/src/itc/capi-network-ua/ITs-capi-network-ua-location.c b/src/itc/capi-network-ua/ITs-capi-network-ua-location.c new file mode 100755 index 000000000..c5db09da6 --- /dev/null +++ b/src/itc/capi-network-ua/ITs-capi-network-ua-location.c @@ -0,0 +1,142 @@ +// +// Copyright (c) 2021 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 "ITs-capi-network-ua-common.h" + +//& set: CapiNetwork-ua + +/** @addtogroup itc-capi-network-ua +* @ingroup itc +* @{ +*/ + +/** + * @function ITs_capi_network_ua_location_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void ITs_capi_network_ua_location_startup(void) +{ + g_bUaInit = false; + g_bIsUaFeatureSupported = false; + g_bFeatureByPass = false; + + struct stat stBuff; + if ( stat(ERR_LOG, &stBuff) == 0 ) + { + remove(ERR_LOG); + } + int nRet = UA_ERROR_NONE; + + g_bIsUaFeatureSupported = TCTCheckSystemInfoFeatureSupported(UA_FEATURE, API_NAMESPACE); + + nRet = ua_initialize(); + if(!g_bIsUaFeatureSupported) + { + if ( nRet != UA_ERROR_NOT_SUPPORTED ) + { + FPRINTF("[%s:%d] ua_initialize failed to return UA_ERROR_NOT_SUPPORTED for unsupported feature, error returned = (%d)\\n", __FILE__, __LINE__,nRet); + return; + } + + FPRINTF("[%s:%d] feature and ua_initialize is unsupported\\n", __FILE__, __LINE__); + g_bFeatureByPass = true; + return; + } + else if (nRet == UA_ERROR_NONE || nRet == UA_ERROR_ALREADY_DONE) + g_bUaInit = true; + else + { + FPRINTF("[%s:%d] ua_initialize failed, error returned =(%d)\\n", __FILE__, __LINE__, nRet); + g_bUaInit = false; + } +} + + +/** + * @function ITs_capi_network_ua_location_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void ITs_capi_network_ua_location_cleanup(void) +{ + int nRet = UA_ERROR_NONE; + + if (g_bIsUaFeatureSupported && g_bUaInit) + { + nRet = ua_deinitialize(); + if ( nRet != UA_ERROR_NONE ) + { + FPRINTF("[%s:%d] ua_deinitialize failed, error returned =(%d)\\n", __FILE__, __LINE__, nRet); + } + } + return; +} + +//& purpose: Set location period +//& type: auto +/** +* @testcase ITc_capi_network_ua_monitor_set_location_period_p +* @since_tizen 6.5 +* @author SRID(nibha.sharma) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Set location period +* @scenario Set location period +* @apicovered ua_monitor_set_location_period +* @passcase If ua_monitor_set_location_period is successfull +* @failcase If ua_monitor_set_location_period or any precondition fails +* @precondition NA +* @postcondition NA +*/ +int ITc_capi_network_ua_monitor_set_location_period_p(void) +{ + START_TEST; + + int nRet = UA_ERROR_NONE; + ua_monitor_h hMonitor = NULL; + // Feature is specific to ua_monitor_set_location_period api + bool bIsUaLocationFeatureSupported = TCTCheckSystemInfoFeatureSupported(UA_LOCATION_FEATURE, API_NAMESPACE); + + nRet = ua_monitor_create(&hMonitor); + PRINT_RESULT(UA_ERROR_NONE, nRet, "ua_monitor_create", UaGetError(nRet)); + CHECK_HANDLE(hMonitor, "ua_monitor_create"); + + //Target API + nRet = ua_monitor_set_location_period(hMonitor, 500); + if (!bIsUaLocationFeatureSupported) + { + if ( nRet != UA_ERROR_NOT_SUPPORTED ) + { + FPRINTF("[%s:%d] ua_monitor_set_location_period failed to return UA_ERROR_NOT_SUPPORTED for unsupported feature, error returned = (%d)\\n", __FILE__, __LINE__,nRet); + ua_monitor_destroy(hMonitor); + return 1; + } + else + { + FPRINTF("[%s:%d] feature is unsupported and ua_monitor_set_location_period also returned not supported\\n", __FILE__, __LINE__); + ua_monitor_destroy(hMonitor); + return 0; + } + } + PRINT_RESULT(UA_ERROR_NONE, nRet, "ua_monitor_set_location_period", UaGetError(nRet)); + + nRet = ua_monitor_destroy(hMonitor); + PRINT_RESULT_NORETURN(UA_ERROR_NONE, nRet, "ua_monitor_destroy", UaGetError(nRet)); + + return 0; +} \ No newline at end of file diff --git a/src/itc/capi-network-ua/tct-capi-network-ua-native_mobile.h b/src/itc/capi-network-ua/tct-capi-network-ua-native_mobile.h index e9327c2d9..31608e304 100755 --- a/src/itc/capi-network-ua/tct-capi-network-ua-native_mobile.h +++ b/src/itc/capi-network-ua/tct-capi-network-ua-native_mobile.h @@ -31,6 +31,9 @@ extern void ITs_capi_network_ua_device_cleanup(void); extern void ITs_capi_network_ua_user_startup(void); extern void ITs_capi_network_ua_user_cleanup(void); +extern void ITs_capi_network_ua_location_startup(void); +extern void ITs_capi_network_ua_location_cleanup(void); + extern int ITc_capi_network_ua_service_add_remove_p(void); extern int ITc_capi_network_ua_service_create_destroy_p(void); extern int ITc_capi_network_ua_get_default_service_p(void); @@ -66,6 +69,7 @@ extern int ITc_capi_network_ua_device_get_by_device_id_p(void); extern int ITc_capi_network_ua_user_create_destroy_p(void); extern int ITc_capi_network_ua_user_add_remove_p(void); extern int ITc_capi_network_ua_user_get_account_p(void); +extern int ITc_capi_network_ua_monitor_set_location_period_p(void); testcase tc_array[] = { {"ITc_capi_network_ua_service_add_remove_p", ITc_capi_network_ua_service_add_remove_p, ITs_capi_network_ua_service_startup, ITs_capi_network_ua_service_cleanup}, @@ -103,6 +107,7 @@ testcase tc_array[] = { {"ITc_capi_network_ua_user_create_destroy_p", ITc_capi_network_ua_user_create_destroy_p, ITs_capi_network_ua_user_startup, ITs_capi_network_ua_user_cleanup}, {"ITc_capi_network_ua_user_add_remove_p", ITc_capi_network_ua_user_add_remove_p, ITs_capi_network_ua_user_startup, ITs_capi_network_ua_user_cleanup}, {"ITc_capi_network_ua_user_get_account_p", ITc_capi_network_ua_user_get_account_p, ITs_capi_network_ua_user_startup, ITs_capi_network_ua_user_cleanup}, + {"ITc_capi_network_ua_monitor_set_location_period_p", ITc_capi_network_ua_monitor_set_location_period_p, ITs_capi_network_ua_location_startup, ITs_capi_network_ua_location_cleanup}, {NULL, NULL} }; diff --git a/src/itc/capi-network-ua/tct-capi-network-ua-native_tizeniot.h b/src/itc/capi-network-ua/tct-capi-network-ua-native_tizeniot.h index aad218647..d2f57341d 100755 --- a/src/itc/capi-network-ua/tct-capi-network-ua-native_tizeniot.h +++ b/src/itc/capi-network-ua/tct-capi-network-ua-native_tizeniot.h @@ -31,6 +31,9 @@ extern void ITs_capi_network_ua_device_cleanup(void); extern void ITs_capi_network_ua_user_startup(void); extern void ITs_capi_network_ua_user_cleanup(void); +extern void ITs_capi_network_ua_location_startup(void); +extern void ITs_capi_network_ua_location_cleanup(void); + extern int ITc_capi_network_ua_service_add_remove_p(void); extern int ITc_capi_network_ua_service_create_destroy_p(void); extern int ITc_capi_network_ua_get_default_service_p(void); @@ -66,6 +69,7 @@ extern int ITc_capi_network_ua_device_get_by_device_id_p(void); extern int ITc_capi_network_ua_user_create_destroy_p(void); extern int ITc_capi_network_ua_user_add_remove_p(void); extern int ITc_capi_network_ua_user_get_account_p(void); +extern int ITc_capi_network_ua_monitor_set_location_period_p(void); testcase tc_array[] = { {"ITc_capi_network_ua_service_add_remove_p", ITc_capi_network_ua_service_add_remove_p, ITs_capi_network_ua_service_startup, ITs_capi_network_ua_service_cleanup}, @@ -103,6 +107,7 @@ testcase tc_array[] = { {"ITc_capi_network_ua_user_create_destroy_p", ITc_capi_network_ua_user_create_destroy_p, ITs_capi_network_ua_user_startup, ITs_capi_network_ua_user_cleanup}, {"ITc_capi_network_ua_user_add_remove_p", ITc_capi_network_ua_user_add_remove_p, ITs_capi_network_ua_user_startup, ITs_capi_network_ua_user_cleanup}, {"ITc_capi_network_ua_user_get_account_p", ITc_capi_network_ua_user_get_account_p, ITs_capi_network_ua_user_startup, ITs_capi_network_ua_user_cleanup}, + {"ITc_capi_network_ua_monitor_set_location_period_p", ITc_capi_network_ua_monitor_set_location_period_p, ITs_capi_network_ua_location_startup, ITs_capi_network_ua_location_cleanup}, {NULL, NULL} }; diff --git a/src/itc/capi-network-ua/tct-capi-network-ua-native_tv.h b/src/itc/capi-network-ua/tct-capi-network-ua-native_tv.h index aad218647..d2f57341d 100755 --- a/src/itc/capi-network-ua/tct-capi-network-ua-native_tv.h +++ b/src/itc/capi-network-ua/tct-capi-network-ua-native_tv.h @@ -31,6 +31,9 @@ extern void ITs_capi_network_ua_device_cleanup(void); extern void ITs_capi_network_ua_user_startup(void); extern void ITs_capi_network_ua_user_cleanup(void); +extern void ITs_capi_network_ua_location_startup(void); +extern void ITs_capi_network_ua_location_cleanup(void); + extern int ITc_capi_network_ua_service_add_remove_p(void); extern int ITc_capi_network_ua_service_create_destroy_p(void); extern int ITc_capi_network_ua_get_default_service_p(void); @@ -66,6 +69,7 @@ extern int ITc_capi_network_ua_device_get_by_device_id_p(void); extern int ITc_capi_network_ua_user_create_destroy_p(void); extern int ITc_capi_network_ua_user_add_remove_p(void); extern int ITc_capi_network_ua_user_get_account_p(void); +extern int ITc_capi_network_ua_monitor_set_location_period_p(void); testcase tc_array[] = { {"ITc_capi_network_ua_service_add_remove_p", ITc_capi_network_ua_service_add_remove_p, ITs_capi_network_ua_service_startup, ITs_capi_network_ua_service_cleanup}, @@ -103,6 +107,7 @@ testcase tc_array[] = { {"ITc_capi_network_ua_user_create_destroy_p", ITc_capi_network_ua_user_create_destroy_p, ITs_capi_network_ua_user_startup, ITs_capi_network_ua_user_cleanup}, {"ITc_capi_network_ua_user_add_remove_p", ITc_capi_network_ua_user_add_remove_p, ITs_capi_network_ua_user_startup, ITs_capi_network_ua_user_cleanup}, {"ITc_capi_network_ua_user_get_account_p", ITc_capi_network_ua_user_get_account_p, ITs_capi_network_ua_user_startup, ITs_capi_network_ua_user_cleanup}, + {"ITc_capi_network_ua_monitor_set_location_period_p", ITc_capi_network_ua_monitor_set_location_period_p, ITs_capi_network_ua_location_startup, ITs_capi_network_ua_location_cleanup}, {NULL, NULL} }; diff --git a/src/itc/capi-network-ua/tct-capi-network-ua-native_wearable.h b/src/itc/capi-network-ua/tct-capi-network-ua-native_wearable.h index e9327c2d9..31608e304 100755 --- a/src/itc/capi-network-ua/tct-capi-network-ua-native_wearable.h +++ b/src/itc/capi-network-ua/tct-capi-network-ua-native_wearable.h @@ -31,6 +31,9 @@ extern void ITs_capi_network_ua_device_cleanup(void); extern void ITs_capi_network_ua_user_startup(void); extern void ITs_capi_network_ua_user_cleanup(void); +extern void ITs_capi_network_ua_location_startup(void); +extern void ITs_capi_network_ua_location_cleanup(void); + extern int ITc_capi_network_ua_service_add_remove_p(void); extern int ITc_capi_network_ua_service_create_destroy_p(void); extern int ITc_capi_network_ua_get_default_service_p(void); @@ -66,6 +69,7 @@ extern int ITc_capi_network_ua_device_get_by_device_id_p(void); extern int ITc_capi_network_ua_user_create_destroy_p(void); extern int ITc_capi_network_ua_user_add_remove_p(void); extern int ITc_capi_network_ua_user_get_account_p(void); +extern int ITc_capi_network_ua_monitor_set_location_period_p(void); testcase tc_array[] = { {"ITc_capi_network_ua_service_add_remove_p", ITc_capi_network_ua_service_add_remove_p, ITs_capi_network_ua_service_startup, ITs_capi_network_ua_service_cleanup}, @@ -103,6 +107,7 @@ testcase tc_array[] = { {"ITc_capi_network_ua_user_create_destroy_p", ITc_capi_network_ua_user_create_destroy_p, ITs_capi_network_ua_user_startup, ITs_capi_network_ua_user_cleanup}, {"ITc_capi_network_ua_user_add_remove_p", ITc_capi_network_ua_user_add_remove_p, ITs_capi_network_ua_user_startup, ITs_capi_network_ua_user_cleanup}, {"ITc_capi_network_ua_user_get_account_p", ITc_capi_network_ua_user_get_account_p, ITs_capi_network_ua_user_startup, ITs_capi_network_ua_user_cleanup}, + {"ITc_capi_network_ua_monitor_set_location_period_p", ITc_capi_network_ua_monitor_set_location_period_p, ITs_capi_network_ua_location_startup, ITs_capi_network_ua_location_cleanup}, {NULL, NULL} };