[ITC][url-download][ACR-1752] Add TCs for new caching APIs 99/291999/2
authorShobhit Verma <shobhit.v@samsung.com>
Wed, 26 Apr 2023 04:12:31 +0000 (09:42 +0530)
committerShobhit Verma <shobhit.v@samsung.com>
Wed, 26 Apr 2023 04:23:01 +0000 (09:53 +0530)
Change-Id: Ifb2cce98e702d5a6c89154bda0eec44150927224
Signed-off-by: Shobhit Verma <shobhit.v@samsung.com>
src/itc/url-download/CMakeLists.txt
src/itc/url-download/ITs-url-download-cache.c [new file with mode: 0755]
src/itc/url-download/tct-url-download-native_mobile.h
src/itc/url-download/tct-url-download-native_tizeniot.h
src/itc/url-download/tct-url-download-native_tv.h
src/itc/url-download/tct-url-download-native_wearable.h

index 06dc807f2096400a40d3544036d98c16201a08de..5a60538386e3b0c7fb7cb3a7a8b285e603d4977c 100755 (executable)
@@ -9,6 +9,7 @@ SET(TC_SOURCES
        ITs-url-download.c
        ITs-url-download-set-get.c
        ITs-url-download-get.c
+       ITs-url-download-cache.c
 )
 
 PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
diff --git a/src/itc/url-download/ITs-url-download-cache.c b/src/itc/url-download/ITs-url-download-cache.c
new file mode 100755 (executable)
index 0000000..4a12107
--- /dev/null
@@ -0,0 +1,169 @@
+//
+// Copyright (c) 2023 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-url-download-common.h"
+
+/** @addtogroup itc-url-download
+*  @ingroup itc
+*  @{
+*/
+
+/**
+* @function            ITs_url_download_cache_startup
+* @description         Called before each test
+* @parameter           NA
+* @return                      NA
+*/
+void ITs_url_download_cache_startup(void)
+{
+       g_bUrlDownloadOpen = false;
+       g_bDownloadNotSupported = false;
+       g_bDownloadMismatch = false;
+       struct stat stBuff;
+       if ( stat(ERR_LOG, &stBuff) == 0 )
+       {
+               remove(ERR_LOG);
+       }
+
+#if DEBUG
+       FPRINTF("[Line : %d][%s] TEST SUIT start-up: ITs_url_download_cache_startup\\n", __LINE__, API_NAMESPACE);
+#endif
+
+       int nRet = download_create(&g_nDownloadRequestID);
+       bool bFeatureDownload  = TCTCheckSystemInfoFeatureSupported(DOWNLOAD_FEATURE, API_NAMESPACE);
+
+       if(!bFeatureDownload)
+       {
+               if(nRet == DOWNLOAD_ERROR_NOT_SUPPORTED)
+               {
+                       FPRINTF("[Line : %d][%s] download_create() returned %s error for unsupported feature :success \\n", __LINE__,
+                               API_NAMESPACE, UrlDownloadGetError(nRet));
+                       g_bDownloadNotSupported = true;
+               }
+               else
+               {
+                       FPRINTF("[Line : %d][%s] download_create() returned %s error for unsupported feature, error mismatch :Failure \\n",
+                        __LINE__, API_NAMESPACE, UrlDownloadGetError(nRet));
+                       g_bDownloadMismatch = true;
+               }
+
+               return;
+       }
+
+       if ( nRet != DOWNLOAD_ERROR_NONE )
+       {
+               FPRINTF("[Line : %d][%s] download_create failed in startup, error returned = %s\\n", __LINE__, API_NAMESPACE, UrlDownloadGetError(nRet));
+       }
+       else
+       {
+               g_bUrlDownloadOpen = true;
+#if DEBUG
+               FPRINTF("[Line : %d][%s] download_create passed in startup\\n", __LINE__, API_NAMESPACE);
+#endif
+       }
+}
+
+/**
+* @function            ITs_url_download_cache_cleanup
+* @description         Called after each test
+* @parameter           NA
+* @return                      NA
+*/
+void ITs_url_download_cache_cleanup(void)
+{
+
+#if DEBUG
+       FPRINTF("[Line : %d][%s] TEST SUIT clean-up: ITs_url_download_cache_cleanup\\n", __LINE__, API_NAMESPACE);
+#endif
+
+       if ( g_bUrlDownloadOpen )
+       {
+               int nRet = download_destroy(g_nDownloadRequestID);
+               if ( nRet != DOWNLOAD_ERROR_NONE )
+               {
+                       FPRINTF("[Line : %d][%s] download_destroy failed in cleanup, error returned = %s\\n", __LINE__, API_NAMESPACE, UrlDownloadGetError(nRet));
+               }
+               else
+               {
+#if DEBUG
+                       FPRINTF("[Line : %d][%s] download_destroy passed in cleanup\\n", __LINE__, API_NAMESPACE);
+#endif
+               }
+       }
+}
+
+//& type: auto
+//& purpose: Scenario to set and get the URL cache
+/**
+* @testcase                    ITc_download_set_get_cache_p
+* @since_tizen                         7.5
+* @author                              SRID(shobhit.v)
+* @reviewer                            SRID(utk.tiwari)
+* @type                                auto
+* @description                 To set and get the URL cache
+* @scenario                            Enable cache and check if it is enabled
+* @apicovered                  download_set_cache and download_get_cache
+* @passcase                            if download_set_cache and download_get_cache returns success
+* @failcase                            if download_set_cache Or download_get_cache fails
+* @precondition                NA
+* @postcondition               NA
+*/
+int ITc_download_set_get_cache_p(void)
+{
+       START_TEST;
+       int nRet = 0;
+       bool bIsEnable = false;
+
+       nRet = download_set_cache(g_nDownloadRequestID, true);
+       PRINT_RESULT(DOWNLOAD_ERROR_NONE, nRet, "download_set_cache", UrlDownloadGetError(nRet));
+
+       nRet = download_get_cache(g_nDownloadRequestID, &bIsEnable);
+       PRINT_RESULT(DOWNLOAD_ERROR_NONE, nRet, "download_get_cache", UrlDownloadGetError(nRet));
+
+       if (bIsEnable == false)
+       {
+               FPRINTF("[Line : %d][%s] Set and Get Cache values mismatch\\n", __LINE__, API_NAMESPACE);
+               return 1;
+       }
+
+       return 0;
+}
+
+//& type: auto
+//& purpose: Scenario to reset the URL cache
+/**
+* @testcase                    ITc_download_reset_cache_p
+* @since_tizen                         7.5
+* @author                              SRID(shobhit.v)
+* @reviewer                            SRID(utk.tiwari)
+* @type                                auto
+* @description                 To reset the URL cache
+* @scenario                            Reset cache
+* @apicovered                  download_reset_cache
+* @passcase                            if download_reset_cache returns success
+* @failcase                            if download_reset_cache fails
+* @precondition                NA
+* @postcondition               NA
+*/
+int ITc_download_reset_cache_p(void)
+{
+       START_TEST;
+       int nRet = 0;
+
+       nRet = download_reset_cache();
+       PRINT_RESULT(DOWNLOAD_ERROR_NONE, nRet, "download_reset_cache", UrlDownloadGetError(nRet));
+
+       return 0;
+}
\ No newline at end of file
index 473856e9a25cc41dfe0f8c1bdf4333abc13dcb44..3cf788c0d31d62129361e4566c6ae5f384f4a0c1 100755 (executable)
@@ -25,6 +25,8 @@ extern void ITs_url_download_set_get_startup(void);
 extern void ITs_url_download_set_get_cleanup(void);
 extern void ITs_url_download_get_startup(void);
 extern void ITs_url_download_get_cleanup(void);
+extern void ITs_url_download_cache_startup(void);
+extern void ITs_url_download_cache_cleanup(void);
 
 extern int ITc_download_create_destroy_p(void);
 extern int ITc_download_add_remove_http_header_field_p(void);
@@ -53,6 +55,8 @@ extern int ITc_download_get_http_status_p(void);
 extern int ITc_download_get_mime_type_p(void);
 extern int ITc_download_get_state_p(void);
 extern int ITc_download_get_error_p(void);
+extern int ITc_download_set_get_cache_p(void);
+extern int ITc_download_reset_cache_p(void);
 
 testcase tc_array[] = {
        {"ITc_download_create_destroy_p",ITc_download_create_destroy_p,ITs_url_download_startup,ITs_url_download_cleanup},
@@ -82,6 +86,8 @@ testcase tc_array[] = {
        {"ITc_download_get_mime_type_p",ITc_download_get_mime_type_p,ITs_url_download_get_startup,ITs_url_download_get_cleanup},
        {"ITc_download_get_state_p",ITc_download_get_state_p,ITs_url_download_get_startup,ITs_url_download_get_cleanup},
        {"ITc_download_get_error_p",ITc_download_get_error_p,ITs_url_download_get_startup,ITs_url_download_get_cleanup},
+       {"ITc_download_set_get_cache_p",ITc_download_set_get_cache_p,ITs_url_download_cache_startup,ITs_url_download_cache_cleanup},
+       {"ITc_download_reset_cache_p",ITc_download_reset_cache_p,ITs_url_download_cache_startup,ITs_url_download_cache_cleanup},
        {NULL, NULL}
 };
 
index 473856e9a25cc41dfe0f8c1bdf4333abc13dcb44..3cf788c0d31d62129361e4566c6ae5f384f4a0c1 100755 (executable)
@@ -25,6 +25,8 @@ extern void ITs_url_download_set_get_startup(void);
 extern void ITs_url_download_set_get_cleanup(void);
 extern void ITs_url_download_get_startup(void);
 extern void ITs_url_download_get_cleanup(void);
+extern void ITs_url_download_cache_startup(void);
+extern void ITs_url_download_cache_cleanup(void);
 
 extern int ITc_download_create_destroy_p(void);
 extern int ITc_download_add_remove_http_header_field_p(void);
@@ -53,6 +55,8 @@ extern int ITc_download_get_http_status_p(void);
 extern int ITc_download_get_mime_type_p(void);
 extern int ITc_download_get_state_p(void);
 extern int ITc_download_get_error_p(void);
+extern int ITc_download_set_get_cache_p(void);
+extern int ITc_download_reset_cache_p(void);
 
 testcase tc_array[] = {
        {"ITc_download_create_destroy_p",ITc_download_create_destroy_p,ITs_url_download_startup,ITs_url_download_cleanup},
@@ -82,6 +86,8 @@ testcase tc_array[] = {
        {"ITc_download_get_mime_type_p",ITc_download_get_mime_type_p,ITs_url_download_get_startup,ITs_url_download_get_cleanup},
        {"ITc_download_get_state_p",ITc_download_get_state_p,ITs_url_download_get_startup,ITs_url_download_get_cleanup},
        {"ITc_download_get_error_p",ITc_download_get_error_p,ITs_url_download_get_startup,ITs_url_download_get_cleanup},
+       {"ITc_download_set_get_cache_p",ITc_download_set_get_cache_p,ITs_url_download_cache_startup,ITs_url_download_cache_cleanup},
+       {"ITc_download_reset_cache_p",ITc_download_reset_cache_p,ITs_url_download_cache_startup,ITs_url_download_cache_cleanup},
        {NULL, NULL}
 };
 
index 473856e9a25cc41dfe0f8c1bdf4333abc13dcb44..3cf788c0d31d62129361e4566c6ae5f384f4a0c1 100755 (executable)
@@ -25,6 +25,8 @@ extern void ITs_url_download_set_get_startup(void);
 extern void ITs_url_download_set_get_cleanup(void);
 extern void ITs_url_download_get_startup(void);
 extern void ITs_url_download_get_cleanup(void);
+extern void ITs_url_download_cache_startup(void);
+extern void ITs_url_download_cache_cleanup(void);
 
 extern int ITc_download_create_destroy_p(void);
 extern int ITc_download_add_remove_http_header_field_p(void);
@@ -53,6 +55,8 @@ extern int ITc_download_get_http_status_p(void);
 extern int ITc_download_get_mime_type_p(void);
 extern int ITc_download_get_state_p(void);
 extern int ITc_download_get_error_p(void);
+extern int ITc_download_set_get_cache_p(void);
+extern int ITc_download_reset_cache_p(void);
 
 testcase tc_array[] = {
        {"ITc_download_create_destroy_p",ITc_download_create_destroy_p,ITs_url_download_startup,ITs_url_download_cleanup},
@@ -82,6 +86,8 @@ testcase tc_array[] = {
        {"ITc_download_get_mime_type_p",ITc_download_get_mime_type_p,ITs_url_download_get_startup,ITs_url_download_get_cleanup},
        {"ITc_download_get_state_p",ITc_download_get_state_p,ITs_url_download_get_startup,ITs_url_download_get_cleanup},
        {"ITc_download_get_error_p",ITc_download_get_error_p,ITs_url_download_get_startup,ITs_url_download_get_cleanup},
+       {"ITc_download_set_get_cache_p",ITc_download_set_get_cache_p,ITs_url_download_cache_startup,ITs_url_download_cache_cleanup},
+       {"ITc_download_reset_cache_p",ITc_download_reset_cache_p,ITs_url_download_cache_startup,ITs_url_download_cache_cleanup},
        {NULL, NULL}
 };
 
index 473856e9a25cc41dfe0f8c1bdf4333abc13dcb44..3cf788c0d31d62129361e4566c6ae5f384f4a0c1 100755 (executable)
@@ -25,6 +25,8 @@ extern void ITs_url_download_set_get_startup(void);
 extern void ITs_url_download_set_get_cleanup(void);
 extern void ITs_url_download_get_startup(void);
 extern void ITs_url_download_get_cleanup(void);
+extern void ITs_url_download_cache_startup(void);
+extern void ITs_url_download_cache_cleanup(void);
 
 extern int ITc_download_create_destroy_p(void);
 extern int ITc_download_add_remove_http_header_field_p(void);
@@ -53,6 +55,8 @@ extern int ITc_download_get_http_status_p(void);
 extern int ITc_download_get_mime_type_p(void);
 extern int ITc_download_get_state_p(void);
 extern int ITc_download_get_error_p(void);
+extern int ITc_download_set_get_cache_p(void);
+extern int ITc_download_reset_cache_p(void);
 
 testcase tc_array[] = {
        {"ITc_download_create_destroy_p",ITc_download_create_destroy_p,ITs_url_download_startup,ITs_url_download_cleanup},
@@ -82,6 +86,8 @@ testcase tc_array[] = {
        {"ITc_download_get_mime_type_p",ITc_download_get_mime_type_p,ITs_url_download_get_startup,ITs_url_download_get_cleanup},
        {"ITc_download_get_state_p",ITc_download_get_state_p,ITs_url_download_get_startup,ITs_url_download_get_cleanup},
        {"ITc_download_get_error_p",ITc_download_get_error_p,ITs_url_download_get_startup,ITs_url_download_get_cleanup},
+       {"ITc_download_set_get_cache_p",ITc_download_set_get_cache_p,ITs_url_download_cache_startup,ITs_url_download_cache_cleanup},
+       {"ITc_download_reset_cache_p",ITc_download_reset_cache_p,ITs_url_download_cache_startup,ITs_url_download_cache_cleanup},
        {NULL, NULL}
 };