From: Amritanshu Pandia Date: Mon, 5 Dec 2016 06:39:35 +0000 (+0530) Subject: [ITC][http][ACR-825][Added TC for new APIs upload file and transaction cancel] X-Git-Tag: Public_Final_RC6~32^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=043773cacacd9a002eb845ab80d96c8529df8310;p=test%2Ftct%2Fnative%2Fapi.git [ITC][http][ACR-825][Added TC for new APIs upload file and transaction cancel] Change-Id: Ic8f71047e61f046058ae5c19e0ead0706b375c5b Signed-off-by: Amritanshu Pandia --- diff --git a/src/itc/http/ITs-http-common.c b/src/itc/http/ITs-http-common.c index d6837fb34..1910a2344 100755 --- a/src/itc/http/ITs-http-common.c +++ b/src/itc/http/ITs-http-common.c @@ -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; diff --git a/src/itc/http/ITs-http-transaction.c b/src/itc/http/ITs-http-transaction.c index def34b02a..46271c691 100755 --- a/src/itc/http/ITs-http-transaction.c +++ b/src/itc/http/ITs-http-transaction.c @@ -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 index 000000000..51916697c --- /dev/null +++ b/src/itc/http/res/mobile/test.txt @@ -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 index 000000000..51916697c --- /dev/null +++ b/src/itc/http/res/tv/test.txt @@ -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 index 000000000..51916697c --- /dev/null +++ b/src/itc/http/res/wearable/test.txt @@ -0,0 +1 @@ +This is a test file for HTTP APIs. diff --git a/src/itc/http/tct-http-native_mobile.h b/src/itc/http/tct-http-native_mobile.h index bf19aee28..2e2c43268 100755 --- a/src/itc/http/tct-http-native_mobile.h +++ b/src/itc/http/tct-http-native_mobile.h @@ -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} }; diff --git a/src/itc/http/tct-http-native_tv.h b/src/itc/http/tct-http-native_tv.h index 20884b4a5..5525a4ef7 100755 --- a/src/itc/http/tct-http-native_tv.h +++ b/src/itc/http/tct-http-native_tv.h @@ -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} }; diff --git a/src/itc/http/tct-http-native_wearable.h b/src/itc/http/tct-http-native_wearable.h index 68b508c68..87e7e7b68 100755 --- a/src/itc/http/tct-http-native_wearable.h +++ b/src/itc/http/tct-http-native_wearable.h @@ -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} };