[ITC][capi-network-ua][ACR-1646][Added new api and new feature for location ua] 46/264446/2
authorNibha Sharma <nibha.sharma@samsung.com>
Fri, 17 Sep 2021 11:28:34 +0000 (16:58 +0530)
committershobhit verma <shobhit.v@samsung.com>
Fri, 17 Sep 2021 12:51:19 +0000 (12:51 +0000)
Change-Id: Iba79f34a86f52b2045bb109b5daa7c6d75e3603f
Signed-off-by: Nibha Sharma <nibha.sharma@samsung.com>
src/itc/capi-network-ua/CMakeLists.txt
src/itc/capi-network-ua/ITs-capi-network-ua-common.h
src/itc/capi-network-ua/ITs-capi-network-ua-location.c [new file with mode: 0755]
src/itc/capi-network-ua/tct-capi-network-ua-native_mobile.h
src/itc/capi-network-ua/tct-capi-network-ua-native_tizeniot.h
src/itc/capi-network-ua/tct-capi-network-ua-native_tv.h
src/itc/capi-network-ua/tct-capi-network-ua-native_wearable.h

index d58d6ae7c87e7e9bac027c55488ba38721765b45..36ec8f7c1c08a80452e9f9b8fcc5f6b88e61807d 100755 (executable)
@@ -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
index f0e57f0672569c26ad44e4882de22293d2106595..3b569311cb86e2df6f612f823cd24a123466cef1 100755 (executable)
@@ -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 (executable)
index 0000000..c5db09d
--- /dev/null
@@ -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
index e9327c2d9395cbd7c2e9cd04162e591ff9a0f7bf..31608e304950db089f21a300f3d28b58710e1874 100755 (executable)
@@ -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}
 };
 
index aad218647eb99c4aff03be17c7e9757cb226f961..d2f57341d940014bbc4a97d6ac54f066ce8d85b4 100755 (executable)
@@ -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}
 };
 
index aad218647eb99c4aff03be17c7e9757cb226f961..d2f57341d940014bbc4a97d6ac54f066ce8d85b4 100755 (executable)
@@ -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}
 };
 
index e9327c2d9395cbd7c2e9cd04162e591ff9a0f7bf..31608e304950db089f21a300f3d28b58710e1874 100755 (executable)
@@ -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}
 };