[ITC][http][ACR-825][Added TC for new APIs upload file and transaction cancel]
authorAmritanshu Pandia <a.pandia1@samsung.com>
Mon, 5 Dec 2016 06:39:35 +0000 (12:09 +0530)
committerShilpa Jindal <shilpa.j@samsung.com>
Tue, 6 Dec 2016 09:34:05 +0000 (01:34 -0800)
Change-Id: Ic8f71047e61f046058ae5c19e0ead0706b375c5b
Signed-off-by: Amritanshu Pandia <a.pandia1@samsung.com>
src/itc/http/ITs-http-common.c
src/itc/http/ITs-http-transaction.c
src/itc/http/res/mobile/test.txt [new file with mode: 0755]
src/itc/http/res/tv/test.txt [new file with mode: 0755]
src/itc/http/res/wearable/test.txt [new file with mode: 0755]
src/itc/http/tct-http-native_mobile.h
src/itc/http/tct-http-native_tv.h
src/itc/http/tct-http-native_wearable.h

index d6837fb34ad28129b18b66dfd3032b9fdb491f3f..1910a2344541576b53c605f081fd2ef1da9b108a 100755 (executable)
@@ -45,6 +45,7 @@ char* HttpGetError(int nRet)
                case HTTP_ERROR_OPERATION_TIMEDOUT:             szErrorVal = "HTTP_ERROR_OPERATION_TIMEDOUT";           break;
                case HTTP_ERROR_SSL_CONNECT_ERROR:              szErrorVal = "HTTP_ERROR_SSL_CONNECT_ERROR";            break;
                case HTTP_ERROR_NOT_SUPPORTED:                  szErrorVal = "HTTP_ERROR_NOT_SUPPORTED";                        break;
+               case HTTP_ERROR_CANCELED:                               szErrorVal = "HTTP_ERROR_CANCELED";                                     break;
                default:                                                                szErrorVal = "Unknown Error";                                           break;
        }
        return szErrorVal;
index def34b02a37334e7945c5bd0490033b3f99c8ef8..46271c6913271c3e04a71eaa0fce08c8c787d54b 100755 (executable)
@@ -1309,5 +1309,51 @@ int ITc_http_transaction_get_status_code_text_version_realm_p(void)
        
        return 0;
 }
+
+//& purpose: Sets the file path for uploading a file.
+//& type: auto 
+/**
+* @testcase                    ITc_http_transaction_request_set_upload_file_cancel_p
+* @since_tizen                 3.0
+* @author              SRID(a.pandia1)
+* @reviewer            SRID(shobhit.v)
+* @type                                auto
+* @description                 Sets the file path for uploading a file
+* @scenario                            Sets the file path for uploading a file
+* @apicovered                  http_transaction_request_set_upload_file and http_transaction_cancel
+* @passcase                            When http_transaction_request_set_upload_file and http_transaction_cancel success.
+* @failcase                            If API http_transaction_request_set_upload_file or http_transaction_cancel fail.
+* @precondition                        http_session_open_transaction() should be successfully called
+* @postcondition               NA
+*/
+int ITc_http_transaction_request_set_upload_file_cancel_p(void)
+{
+       START_TEST;
+       
+       char *pszFilePath = NULL;
+       char pszValue[CONFIG_VALUE_LEN_MAX] = {0,};
+       if ( true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE ))
+       {
+               FPRINTF("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received = %s\\n", __LINE__, API_NAMESPACE,  pszValue);
+               int path_size = strlen(pszValue)+strlen("/res/test.txt")+1;
+               pszFilePath=(char*)calloc(path_size, sizeof(char));
+               snprintf(pszFilePath, path_size, "%s/res/test.txt", pszValue);
+       }
+       else
+       {
+               FPRINTF("[Line : %d][%s] GetValueForTCTSetting returned error for 'DEVICE_SUITE_TARGET_30'\\n", __LINE__, API_NAMESPACE);
+               return 1;
+       }
+       
+       //Target API
+       int nRet = http_transaction_request_set_upload_file(g_hHttpTransaction, pszFilePath);
+       PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_request_set_upload_file", HttpGetError(nRet),FREE_MEMORY(pszFilePath));
+       
+       nRet = http_transaction_cancel(g_hHttpTransaction);
+       PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_cancel", HttpGetError(nRet),FREE_MEMORY(pszFilePath));
+       
+       FREE_MEMORY(pszFilePath);
+       return 0;
+}
 /** @} */
 /** @} */
diff --git a/src/itc/http/res/mobile/test.txt b/src/itc/http/res/mobile/test.txt
new file mode 100755 (executable)
index 0000000..5191669
--- /dev/null
@@ -0,0 +1 @@
+This is a test file for HTTP APIs.
diff --git a/src/itc/http/res/tv/test.txt b/src/itc/http/res/tv/test.txt
new file mode 100755 (executable)
index 0000000..5191669
--- /dev/null
@@ -0,0 +1 @@
+This is a test file for HTTP APIs.
diff --git a/src/itc/http/res/wearable/test.txt b/src/itc/http/res/wearable/test.txt
new file mode 100755 (executable)
index 0000000..5191669
--- /dev/null
@@ -0,0 +1 @@
+This is a test file for HTTP APIs.
index bf19aee2841c746d21b229b7018a7ea1dda48bd0..2e2c432681d7cb645c0c2f5721991e7fa1e72f8b 100755 (executable)
@@ -49,6 +49,7 @@ extern int ITc_http_trasaction_open_authentication_p(void);
 extern int ITc_http_transaction_set_get_credentials_p(void);
 extern int ITc_http_transaction_set_get_http_auth_scheme_p(void);
 extern int ITc_http_transaction_get_status_code_text_version_realm_p(void);
+extern int ITc_http_transaction_request_set_upload_file_cancel_p(void);
 extern int ITc_http_init_deinit_p(void);
 
 
@@ -78,6 +79,7 @@ testcase tc_array[] = {
        {"ITc_http_transaction_set_get_credentials_p", ITc_http_transaction_set_get_credentials_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup},
        {"ITc_http_transaction_set_get_http_auth_scheme_p", ITc_http_transaction_set_get_http_auth_scheme_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup},
        {"ITc_http_transaction_get_status_code_text_version_realm_p", ITc_http_transaction_get_status_code_text_version_realm_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup},
+       {"ITc_http_transaction_request_set_upload_file_cancel_p", ITc_http_transaction_request_set_upload_file_cancel_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup},
     {"ITc_http_init_deinit_p", ITc_http_init_deinit_p, ITs_http_startup, ITs_http_cleanup},
     {NULL, NULL}
 };
index 20884b4a505b179e30ffbd67c4451e5ad57912b0..5525a4ef72389b3062a67f73632de4dc39efb4cb 100755 (executable)
@@ -51,6 +51,7 @@ extern int ITc_http_trasaction_open_authentication_p(void);
 extern int ITc_http_transaction_set_get_credentials_p(void);
 extern int ITc_http_transaction_set_get_http_auth_scheme_p(void);
 extern int ITc_http_transaction_get_status_code_text_version_realm_p(void);
+extern int ITc_http_transaction_request_set_upload_file_cancel_p(void);
 
 testcase tc_array[] = {
     {"ITc_http_init_deinit_p", ITc_http_init_deinit_p, ITs_http_startup, ITs_http_cleanup},
@@ -79,6 +80,7 @@ testcase tc_array[] = {
        {"ITc_http_transaction_set_get_credentials_p", ITc_http_transaction_set_get_credentials_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup},
        {"ITc_http_transaction_set_get_http_auth_scheme_p", ITc_http_transaction_set_get_http_auth_scheme_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup},
        {"ITc_http_transaction_get_status_code_text_version_realm_p", ITc_http_transaction_get_status_code_text_version_realm_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup},
+       {"ITc_http_transaction_request_set_upload_file_cancel_p", ITc_http_transaction_request_set_upload_file_cancel_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup},
     {NULL, NULL}
 };
 
index 68b508c683c0f487101bfabb4f54e911cc4d0a9b..87e7e7b689768a35415d8686cd2570fbbc0b87f6 100755 (executable)
@@ -50,6 +50,7 @@ extern int ITc_http_trasaction_open_authentication_p(void);
 extern int ITc_http_transaction_set_get_credentials_p(void);
 extern int ITc_http_transaction_set_get_http_auth_scheme_p(void);
 extern int ITc_http_transaction_get_status_code_text_version_realm_p(void);
+extern int ITc_http_transaction_request_set_upload_file_cancel_p(void);
 
 testcase tc_array[] = {
     {"ITc_http_init_deinit_p", ITc_http_init_deinit_p, ITs_http_startup, ITs_http_cleanup},
@@ -78,6 +79,7 @@ testcase tc_array[] = {
        {"ITc_http_transaction_set_get_credentials_p", ITc_http_transaction_set_get_credentials_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup},
        {"ITc_http_transaction_set_get_http_auth_scheme_p", ITc_http_transaction_set_get_http_auth_scheme_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup},
        {"ITc_http_transaction_get_status_code_text_version_realm_p", ITc_http_transaction_get_status_code_text_version_realm_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup},
+       {"ITc_http_transaction_request_set_upload_file_cancel_p", ITc_http_transaction_request_set_upload_file_cancel_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup},
     {NULL, NULL}
 };