From: gaurav.m2 Date: Wed, 3 Aug 2016 12:34:42 +0000 (+0530) Subject: [ITC][http][ACR-548,663,675][DPTTIZEN-2179, Added new module] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e24d28c22f601942d9258e90e4a912f0857bbbe3;p=test%2Ftct%2Fnative%2Fapi.git [ITC][http][ACR-548,663,675][DPTTIZEN-2179, Added new module] Change-Id: Ie106664e2aa7d446c668b9f57fc8e974e75726ed Signed-off-by: gaurav.m2 --- diff --git a/packaging/itc/native-http-itc.spec b/packaging/itc/native-http-itc.spec new file mode 100755 index 0000000..b4c9020 --- /dev/null +++ b/packaging/itc/native-http-itc.spec @@ -0,0 +1,82 @@ +%define MODULE_NAME http +%define MODULE_LIBNAME capi-network-http +Name: native-%{MODULE_NAME}-itc +Summary: Native API Integration TC (%{name}) +Version: 0.1 +Release: 0 +Group: Development/Tools +License: Apache-2.0 +Source0: %{name}-%{version}.tar.gz +BuildRequires: pkgconfig(%{MODULE_LIBNAME}) +BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(elementary) +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: cmake +BuildRequires: pkgconfig(bundle) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(gobject-2.0) +BuildRequires: pkgconfig(capi-system-info) + +%description +Native API Integration TC (%{name}) + +%prep +%setup -q + +%build + +%define PREFIX "%{_libdir}/%{name}" + +export LDFLAGS+="-Wl,--rpath=%{PREFIX} -Wl,--as-needed" + +%if %{?ASAN_BUILD:1}0 + %if %{?DEVICE_BUILD_TYPE_MOBILE:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="itc" -DDEVICE_BUILD_TYPE="mobile" -DASANBUILD="true" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_WEARABLE:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="itc" -DDEVICE_BUILD_TYPE="wearable" -DASANBUILD="true" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_TV:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="itc" -DDEVICE_BUILD_TYPE="tv" -DASANBUILD="true" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_COMMON_IOT:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="itc" -DDEVICE_BUILD_TYPE="common_iot" -DASANBUILD="true" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif +%else + %if %{?DEVICE_BUILD_TYPE_MOBILE:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="itc" -DDEVICE_BUILD_TYPE="mobile" -DASANBUILD="false" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_WEARABLE:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="itc" -DDEVICE_BUILD_TYPE="wearable" -DASANBUILD="false" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_TV:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="itc" -DDEVICE_BUILD_TYPE="tv" -DASANBUILD="false" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_COMMON_IOT:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="itc" -DDEVICE_BUILD_TYPE="common_iot" -DASANBUILD="false" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif +%endif + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{buildroot}/usr/share/license/%{name} + +mkdir -p %{buildroot}/usr/share/packages/ +cp packaging/itc/native-%{MODULE_NAME}-itc.xml %{buildroot}/usr/share/packages/ +mkdir -p %{buildroot}%{APP_PATH}%{name}/bin +#cp templates/external_wrapper.sh %{buildroot}%{APP_PATH}%{name}/bin +%post +chown -R 5000:5000 %{APP_PATH}%{name}/data +chsmack -a %{name} %{APP_PATH}%{name}/data +%postun + + +%files +%{APP_PATH}%{name}/* +/usr/share/packages/native-%{MODULE_NAME}-itc.xml +/usr/share/license/%{name} diff --git a/packaging/itc/native-http-itc.xml b/packaging/itc/native-http-itc.xml new file mode 100755 index 0000000..51c53b7 --- /dev/null +++ b/packaging/itc/native-http-itc.xml @@ -0,0 +1,12 @@ + + + + test + Native API test Application + + + + http://tizen.org/privilege/network.get + http://tizen.org/privilege/internet + + diff --git a/src/itc/http/CMakeLists.txt b/src/itc/http/CMakeLists.txt new file mode 100755 index 0000000..973bf1f --- /dev/null +++ b/src/itc/http/CMakeLists.txt @@ -0,0 +1,42 @@ +SET(PKG_NAME "http") + +SET(EXEC_NAME "tct-${PKG_NAME}-native") +SET(RPM_NAME "native-${PKG_NAME}-itc") + +SET(CAPI_LIB "capi-network-http") +SET(TC_SOURCES + ITs-http-common.c + ITs-http.c + ITs-http-transaction.c +) + +PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED + ${CAPI_LIB} + capi-appfw-application + glib-2.0 + bundle + capi-system-info + dlog elementary +) + +INCLUDE_DIRECTORIES( + ${${CAPI_LIB}_INCLUDE_DIRS} +) + +ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.c ${TC_SOURCES} ${COMMON_FILE}) +TARGET_LINK_LIBRARIES(${EXEC_NAME} + ${${CAPI_LIB}_LIBRARIES} + bundle +) + +INSTALL(PROGRAMS ${EXEC_NAME} + DESTINATION ${BIN_DIR}/${RPM_NAME}/bin +) + +IF( DEFINED ASAN ) +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -pie -g -fsanitize=address -fsanitize-recover=address -U_FORTIFY_SOURCE -fno-omit-frame-pointer") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib -Wl,-fsanitize=address") +ELSE() +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fPIE -Wall") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib -pie") +ENDIF() diff --git a/src/itc/http/ITs-http-common.c b/src/itc/http/ITs-http-common.c new file mode 100755 index 0000000..d6837fb --- /dev/null +++ b/src/itc/http/ITs-http-common.c @@ -0,0 +1,73 @@ +// +// Copyright (c) 2014 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-http-common.h" + +/** @addtogroup itc-http +* @ingroup itc +* @{ +*/ + +//Add helper function definitions here + +/** +* @function HttpGetError +* @description Maps error enumerators to string values +* @parameter nRet : error code returned +* @return error string +*/ +char* HttpGetError(int nRet) +{ + char *szErrorVal = NULL; + + switch ( nRet ) + { + case HTTP_ERROR_NONE: szErrorVal = "HTTP_ERROR_NONE"; break; + case HTTP_ERROR_OUT_OF_MEMORY: szErrorVal = "HTTP_ERROR_OUT_OF_MEMORY"; break; + case HTTP_ERROR_PERMISSION_DENIED: szErrorVal = "HTTP_ERROR_PERMISSION_DENIED"; break; + case HTTP_ERROR_INVALID_PARAMETER: szErrorVal = "HTTP_ERROR_INVALID_PARAMETER"; break; + case HTTP_ERROR_INVALID_OPERATION: szErrorVal = "HTTP_ERROR_INVALID_OPERATION"; break; + case HTTP_ERROR_OPERATION_FAILED: szErrorVal = "HTTP_ERROR_OPERATION_FAILED"; break; + case HTTP_ERROR_COULDNT_RESOLVE_HOST: szErrorVal = "HTTP_ERROR_COULDNT_RESOLVE_HOST"; break; + case HTTP_ERROR_COULDNT_CONNECT: szErrorVal = "HTTP_ERROR_COULDNT_CONNECT"; break; + 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; + default: szErrorVal = "Unknown Error"; break; + } + return szErrorVal; +} + + +/** +* @function httpTimeout +* @description Called if some callback is not invoked for a particular timeout +* @parameter gpointer data +* @return gboolean +*/ +gboolean httpTimeout(gpointer data) +{ + GMainLoop *pMainLoop = NULL; + pMainLoop = (GMainLoop *)data; + if ( pMainLoop != NULL ) + { + g_main_loop_quit(pMainLoop); + } + FPRINTF("[Line : %d][%s] Callback Timeout\\n", __LINE__, API_NAMESPACE); + return false; +} + +/** @} */ + diff --git a/src/itc/http/ITs-http-common.h b/src/itc/http/ITs-http-common.h new file mode 100755 index 0000000..c430818 --- /dev/null +++ b/src/itc/http/ITs-http-common.h @@ -0,0 +1,97 @@ +// +// Copyright (c) 2014 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. +// +#ifndef _ITS_HTTP_COMMON_H_ +#define _ITS_HTTP_COMMON_H_ + +//Add test package related includes here +#include "tct_common.h" +#include +#include +#include +#include +#include + +#define API_NAMESPACE "HTTP_ITC" +#define MICROSECONDS_PER_SECOND 1000000 +#define MINCOUNT 1 +#define TIMEOUT_CB 30000 +#define HTTP_FEATURE "http://tizen.org/feature/network.internet" + +GMainLoop *g_pHttpMainLoop; +bool g_bFeatureUnsupported; +bool g_bHttpInit; +bool g_bCallbackHit; + +#ifdef WEARABLE +#define START_TEST {\ + FPRINTF("[Line : %d][%s] Starting test : %s\\n", __LINE__, API_NAMESPACE, __FUNCTION__);\ + if(g_bFeatureUnsupported)\ + {\ + FPRINTF("[Line : %d][%s] Leaving test\\n", __LINE__, API_NAMESPACE);\ + return 0;\ + }\ + if ( !g_bHttpInit )\ + {\ + FPRINTF("[Line : %d][%s] Iotcon connection failed , Leaving test\\n", __LINE__, API_NAMESPACE);\ + return 1;\ + }\ +} +#else +#define START_TEST {\ + FPRINTF("[Line : %d][%s] Starting test : %s\\n", __LINE__, API_NAMESPACE, __FUNCTION__);\ + if ( !g_bHttpInit )\ +{\ + FPRINTF("[Line : %d][%s] Precondition of http failed so leaving test\\n", __LINE__, API_NAMESPACE);\ + return 1;\ +}\ +} +#endif + +#define CHECK_HANDLE_CLEANUP(Handle, API, FreeResource) {\ + if ( Handle == NULL )\ +{\ + FPRINTF("[Line : %d][%s] %s failed, error returned = Handle returned is NULL\\n", __LINE__, API_NAMESPACE, API);\ + FreeResource;\ + return 1;\ +}\ +} + +#define RUN_POLLING_LOOP {\ + if ( !g_bCallbackHit )\ +{\ + g_pHttpMainLoop = g_main_loop_new(NULL, false);\ + nTimeoutId = g_timeout_add(TIMEOUT_CB, httpTimeout, g_pHttpMainLoop);\ + g_main_loop_run(g_pHttpMainLoop);\ + g_source_remove(nTimeoutId);\ + g_pHttpMainLoop = NULL;\ +}\ +} + + +/** @addtogroup itc-%{MODULE_NAME} +* @ingroup itc +* @{ +*/ + +//Add helper function declarations here + + + +gboolean httpTimeout(gpointer data); +char* HttpGetError(int nRet); + +/** @} */ +#endif //_ITS_HTTP_COMMON_H_ diff --git a/src/itc/http/ITs-http-transaction.c b/src/itc/http/ITs-http-transaction.c new file mode 100755 index 0000000..74b3543 --- /dev/null +++ b/src/itc/http/ITs-http-transaction.c @@ -0,0 +1,1313 @@ +// +// Copyright (c) 2014 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-http-common.h" + +http_session_h g_hHttpSession; +http_transaction_h g_hHttpTransaction; +bool b_HttpTransactionHeaderCB = false; +bool b_HttpTransactionBodyCB = false; +bool b_HttpTransactionWriteCB = false; +bool b_HttpTransactionCompletedCB = false; +bool b_HttpTransactionProgressCB = false; +bool b_HttpTransactionProgressPauseResumeCB = false; +bool g_bIsValid = true; +//& set: Http + +/** @addtogroup itc-http +* @ingroup itc +* @{ +*/ + + +/** +* @function HttpTransactionHeaderCB +* @description Called when the http header is received +* @parameter http_transaction_h, char *header, size_t header_len, void *user_data +* @return NA +*/ +static void HttpTransactionHeaderCB(http_transaction_h http_transaction, char *header, size_t header_len, void *user_data) +{ + + FPRINTF("[Line : %d][%s] HttpTransactionHeaderCB callback called\\n", __LINE__, API_NAMESPACE); + + b_HttpTransactionHeaderCB = true; + + g_bCallbackHit = true; + + if ( g_pHttpMainLoop ) + { + g_main_loop_quit(g_pHttpMainLoop); + } + + return; +} + +/** +* @function HttpTransactionBodyCB +* @description Called when the http response is received +* @parameter http_transaction_h, char *body, size_t header_len, void *user_data +* @return NA +*/ +static void HttpTransactionBodyCB(http_transaction_h http_transaction, char *body, size_t size, size_t count, void *user_data) +{ + + FPRINTF("[Line : %d][%s] HttpTransactionBodyCB callback called\\n", __LINE__, API_NAMESPACE); + + b_HttpTransactionBodyCB = true; + + g_bCallbackHit = true; + + if ( g_pHttpMainLoop ) + { + g_main_loop_quit(g_pHttpMainLoop); + } + + return; +} + +/** +* @function HttpTransactionWriteCB +* @description Called when the http ready to write event is received +* @parameter http_transaction_h, int recommended_chunk_size, void *user_data +* @return NA +*/ +static void HttpTransactionWriteCB(http_transaction_h http_transaction, int recommended_chunk_size, void *user_data) +{ + + FPRINTF("[Line : %d][%s] HttpTransactionWriteCB callback called\\n", __LINE__, API_NAMESPACE); + + b_HttpTransactionWriteCB = true; + g_bCallbackHit = true; + + if ( g_pHttpMainLoop ) + { + g_main_loop_quit(g_pHttpMainLoop); + } + + return; +} + +/** +* @function HttpTransactionCompletedCB +* @description Called when the http transaction is completed +* @parameter http_transaction_h, void *user_data +* @return NA +*/ +static void HttpTransactionCompletedCB(http_transaction_h transaction, void *user_data) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] HttpTransactionCompletedCB callback called\\n", __LINE__, API_NAMESPACE); +#endif + b_HttpTransactionCompletedCB = true; + g_bCallbackHit = true; + + if ( g_pHttpMainLoop ) + { + g_main_loop_quit(g_pHttpMainLoop); + } + + return; +} + +/** +* @function HttpTransactionCompletedGetStatusTextVersionRealmCB +* @description Called when the http transaction is completed +* @parameter http_transaction_h, void *user_data +* @return NA +*/ +static void HttpTransactionCompletedGetStatusTextVersionRealmCB(http_transaction_h transaction, void *user_data) +{ + int nRet; + + FPRINTF("[Line : %d][%s] HttpTransactionCompletedGetStatusTextVersionRealmCB callback called\\n", __LINE__, API_NAMESPACE); + b_HttpTransactionCompletedCB = true; + g_bCallbackHit = true; + http_version_e r_version = -1; + http_status_code_e r_status = -1; + char *r_status_text = NULL; + char *r_realm = NULL; + g_bIsValid = true; + + + //Target API + nRet = http_transaction_response_get_status_code(transaction, &r_status); + if(nRet != HTTP_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] http_transaction_response_get_status_code failed : [%s]\\n", __LINE__, API_NAMESPACE,HttpGetError(nRet)); + g_bIsValid = false; + g_main_loop_quit(g_pHttpMainLoop); + return; + } + if(r_status < HTTP_STATUS_UNDEFINED || r_status > HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED ) + { + FPRINTF("[Line : %d][%s] status code is not set\\n", __LINE__, API_NAMESPACE); + g_bIsValid = false; + return; + } + FPRINTF("[Line : %d][%s] status code[%d]\\n", __LINE__, API_NAMESPACE, r_status); + + + //Target API + nRet = http_transaction_response_get_status_text(transaction, &r_status_text); + if(nRet != HTTP_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] http_transaction_response_get_status_text failed : [%s]\\n", __LINE__, API_NAMESPACE,HttpGetError(nRet)); + g_bIsValid = false; + g_main_loop_quit(g_pHttpMainLoop); + return; + } + if( r_status_text == NULL) + { + FPRINTF("[Line : %d][%s] r_status_text is not set\\n", __LINE__, API_NAMESPACE); + g_bIsValid = false; + return; + } + FPRINTF("[Line : %d][%s] status text[%s]\\n", __LINE__, API_NAMESPACE, r_status_text); + + + //Target API + nRet = http_transaction_response_get_version(transaction, &r_version); + if(nRet != HTTP_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] http_transaction_response_get_version failed : [%s]\\n", __LINE__, API_NAMESPACE,HttpGetError(nRet)); + if (r_status_text) { + g_free(r_status_text); + r_status_text = NULL; + } + g_bIsValid = false; + g_main_loop_quit(g_pHttpMainLoop); + + return; + } + if( r_version < HTTP_VERSION_1_0 || r_version > HTTP_VERSION_1_1 ) + { + FPRINTF("[Line : %d][%s]http_transaction_response_get_version returned invalid value(%d)\\n", __LINE__, API_NAMESPACE, r_version); + g_bIsValid = false; + return; + } + FPRINTF("[Line : %d][%s] version[%d]\\n", __LINE__, API_NAMESPACE, r_version); + + + //Target API + if (r_status == HTTP_STATUS_UNAUTHORIZED) { + nRet = http_transaction_get_realm(transaction, &r_realm); + if(nRet != HTTP_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] http_transaction_get_realm failed : [%s]\\n", __LINE__, API_NAMESPACE,HttpGetError(nRet)); + if (r_status_text) { + g_free(r_status_text); + r_status_text = NULL; + } + g_bIsValid = false; + g_main_loop_quit(g_pHttpMainLoop); + + return; + } + if( r_realm == NULL) + { + FPRINTF("[Line : %d][%s] r_realm is not set\\n", __LINE__, API_NAMESPACE); + g_bIsValid = false; + return; + } + FPRINTF("[Line : %d][%s] realm[%s]\\n", __LINE__, API_NAMESPACE, r_realm); + } + + + if (r_realm) { + g_free(r_realm); + r_realm = NULL; + } + if (r_status_text) { + g_free(r_status_text); + r_status_text = NULL; + } + + if ( g_pHttpMainLoop ) + { + g_main_loop_quit(g_pHttpMainLoop); + } + + return; +} + +/** +* @function HttpTransactionProgressCB +* @description Called to notify when the content body of the response message is being downloaded or uploaded +* @parameter http_transaction_h http_transaction, double download_total, double download_now, double upload_total, double upload_now, void *user_data +* @return NA +*/ +static void HttpTransactionProgressCB(http_transaction_h http_transaction, double download_total, double download_now, double upload_total, double upload_now, void *user_data) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] HttpTransactionProgressCB callback called\\n", __LINE__, API_NAMESPACE); +#endif + b_HttpTransactionProgressCB = true; + g_bCallbackHit = true; + + if ( g_pHttpMainLoop ) + { + g_main_loop_quit(g_pHttpMainLoop); + } + + return; +} + +/** +* @function HttpTransactionProgressCB +* @description Called to notify when the content body of the response message is being downloaded or uploaded +* @parameter http_transaction_h http_transaction, double download_total, double download_now, double upload_total, double upload_now, void *user_data +* @return NA +*/ +static void HttpTransactionProgressPauseResumeCB(http_transaction_h http_transaction, double download_total, double download_now, double upload_total, double upload_now, void *user_data) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] HttpTransactionProgressPauseResumeCB callback called\\n", __LINE__, API_NAMESPACE); +#endif + double pDownloadRate = download_now / download_total * 100; + b_HttpTransactionProgressPauseResumeCB = true; + g_bCallbackHit = true; + g_bIsValid = true; + + FPRINTF("[Line : %d][%s] pDownloadRate(%lf)\\n", __LINE__, API_NAMESPACE, pDownloadRate); + + //Target API + int nRet = http_transaction_pause(http_transaction, HTTP_PAUSE_ALL); + if(nRet != HTTP_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] http_transaction_pause failed : [%s]\\n", __LINE__, API_NAMESPACE,HttpGetError(nRet)); + g_bIsValid = false; + g_main_loop_quit(g_pHttpMainLoop); + return; + } + + //Target API + nRet = http_transaction_resume(http_transaction) ; + if(nRet != HTTP_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] http_transaction_resume failed : [%s]\\n", __LINE__, API_NAMESPACE,HttpGetError(nRet)); + g_bIsValid = false; + g_main_loop_quit(g_pHttpMainLoop); + return; + } + + if ( g_pHttpMainLoop ) + { + g_main_loop_quit(g_pHttpMainLoop); + } + + return; +} +/** + * @function ITs_http_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void ITs_http_transaction_startup(void) +{ + struct stat stBuff; + if ( stat(ERR_LOG, &stBuff) == 0 ) + { + remove(ERR_LOG); + } + + int nRet; + g_bFeatureUnsupported = false; + + if(!g_bHttpInit) { + nRet = http_init(); + g_bHttpInit = true; + +#ifdef WEARABLE + if ( !TCTCheckSystemInfoFeatureSupported(HTTP_FEATURE, API_NAMESPACE) ) + { + + if ( nRet != TIZEN_ERROR_NOT_SUPPORTED ) + { + FPRINTF("[Line : %d][%s] http_init API call returned mismatch %s error for unsupported feature\\n", __LINE__, API_NAMESPACE, HttpGetError(nRet)); + g_bHttpInit = false; + } + else + { + FPRINTF("[Line : %d][%s] http_init API call correctly returned %s error for unsupported feature\\n", __LINE__, API_NAMESPACE, HttpGetError(nRet)); + g_bFeatureUnsupported = true; + } + return; + } +#endif + + if ( nRet != HTTP_ERROR_NONE ) + { + FPRINTF("[Line : %d][%s] http_init failed API return %s error \\n", __LINE__, API_NAMESPACE, HttpGetError(nRet)); + g_bHttpInit = false; + return; + } + } + + nRet = http_session_create(HTTP_SESSION_MODE_NORMAL, &g_hHttpSession); + if( nRet != HTTP_ERROR_NONE ) + { + FPRINTF("[Line : %d][%s] http_session_create failed API return %s error \\n", __LINE__, API_NAMESPACE, HttpGetError(nRet)); + g_bHttpInit = false; + return; + } + + if(g_hHttpSession == NULL) + { + FPRINTF("[Line : %d][%s] http_session_create failed g_hHttpSession is NULL \\n", __LINE__, API_NAMESPACE); + g_bHttpInit = false; + return; + } + + nRet = http_session_open_transaction(g_hHttpSession, HTTP_METHOD_GET, &g_hHttpTransaction); + if( nRet != HTTP_ERROR_NONE ) + { + FPRINTF("[Line : %d][%s] http_session_create failed API return %s error \\n", __LINE__, API_NAMESPACE, HttpGetError(nRet)); + g_bHttpInit = false; + return; + } + if(g_hHttpTransaction == NULL) + { + FPRINTF("[Line : %d][%s] g_hHttpTransaction handle is null \\n", __LINE__, API_NAMESPACE); + g_bHttpInit = false; + return; + } + return; +} + + +/** + * @function ITs_http_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void ITs_http_transaction_cleanup(void) +{ + int nRet = 0; + if(g_hHttpTransaction != NULL) + { + nRet = http_transaction_destroy(g_hHttpTransaction); + if (nRet != HTTP_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] http_transaction_destroy failed API return %s error \\n", __LINE__, API_NAMESPACE, HttpGetError(nRet)); + } + g_hHttpTransaction = NULL; + } + + if(g_hHttpSession != NULL) + { + nRet = http_session_destroy(g_hHttpSession); + if (nRet != HTTP_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] http_session_destroy failed API return %s error \\n", __LINE__, API_NAMESPACE, HttpGetError(nRet)); + } + g_hHttpSession = NULL; + } + + return; +} + +/** @addtogroup itc-http-testcases +* @brief Integration testcases for module http +* @ingroup itc-http +* @{ +*/ + +//& purpose: Registers and submit callback called when receive header +//& type: auto +/** +* @testcase ITc_http_transaction_register_callbacks_p +* @since_tizen 3.0 +* @author SRID(gaurav.m2) +* @reviewer SRID(a.pandia1) +* @type auto +* @description Registers and submit callback called when receive header +* @scenario call http_transaction_set_received_header_cb +* @apicovered http_transaction_set_received_header_cb +* @passcase When http_transaction_set_received_header_cb is successful. +* @failcase If API http_transaction_set_received_header_cb fails. +* @precondition http_session_open_transaction() should be successfully called +* @postcondition NA +*/ +int ITc_http_transaction_register_callbacks_p(void) +{ + START_TEST; + int nTimeoutId = 0; + g_bCallbackHit = false; + http_method_e method; + const char uri[100] = "http://www.google.com"; + http_transaction_h transaction = NULL; + b_HttpTransactionHeaderCB = false; + b_HttpTransactionBodyCB = false; + b_HttpTransactionWriteCB = false; + b_HttpTransactionCompletedCB = false; + b_HttpTransactionProgressCB = false; + + int nRet = http_session_open_transaction(g_hHttpSession, HTTP_METHOD_GET, &transaction); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_session_open_transaction", HttpGetError(nRet)); + CHECK_HANDLE(transaction,"http_session_open_transaction"); + + nRet = http_transaction_request_get_method(transaction, &method); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_request_get_method", HttpGetError(nRet),http_transaction_destroy(transaction)); + + nRet = http_transaction_request_set_uri(transaction, uri); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_request_set_uri", HttpGetError(nRet),http_transaction_destroy(transaction)); + + //Target API + nRet = http_transaction_set_received_header_cb(transaction, HttpTransactionHeaderCB, NULL); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_set_received_header_cb", HttpGetError(nRet),http_transaction_destroy(transaction)); + + //Target API + nRet = http_transaction_set_received_body_cb(transaction, HttpTransactionBodyCB, NULL); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_set_received_body_cb", HttpGetError(nRet),http_transaction_destroy(transaction)); + + //Target API + nRet = http_transaction_set_completed_cb(transaction, HttpTransactionCompletedCB, NULL); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_set_completed_cb", HttpGetError(nRet),http_transaction_destroy(transaction)); + + //Target API + nRet = http_transaction_submit(transaction); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_submit", HttpGetError(nRet),http_transaction_destroy(transaction)); + + RUN_POLLING_LOOP; + + if (transaction) { + http_transaction_destroy(transaction); + transaction = NULL; + } + if ( b_HttpTransactionHeaderCB == false ) + { + FPRINTF("[Line : %d][%s] b_HttpTransactionHeaderCB failed\\n", __LINE__, API_NAMESPACE); + return 1; + } + if ( b_HttpTransactionBodyCB == false ) + { + FPRINTF("[Line : %d][%s] b_HttpTransactionBodyCB failed\\n", __LINE__, API_NAMESPACE); + return 1; + } + if ( b_HttpTransactionCompletedCB == false ) + { + FPRINTF("[Line : %d][%s] b_HttpTransactionCompletedCB failed\\n", __LINE__, API_NAMESPACE); + return 1; + } + + return 0; +} + +//& purpose:Registers callback called when write data +//& type: auto +/** +* @testcase ITc_http_transaction_set_uploaded_cb_p +* @since_tizen 3.0 +* @author SRID(gaurav.m2) +* @reviewer SRID(a.pandia1) +* @type auto +* @description Registers callback called when write data +* @scenario call http_transaction_set_uploaded_cb +* @apicovered http_transaction_set_uploaded_cb +* @passcase When http_transaction_set_uploaded_cb is successful. +* @failcase If API http_transaction_set_uploaded_cb fails. +* @precondition http_session_open_transaction() should be successfully called +* @postcondition NA +*/ +int ITc_http_transaction_set_uploaded_cb_p(void) +{ + START_TEST; + int nRet; + int nTimeoutId = 0; + http_transaction_h transaction; + const char* post_msg = "name=tizen&project=capi-network-curl"; + b_HttpTransactionWriteCB = false; + g_bCallbackHit = false; + + if (g_hHttpTransaction) { + http_transaction_destroy(g_hHttpTransaction); + g_hHttpTransaction = NULL; + } + + nRet = http_session_open_transaction(g_hHttpSession, HTTP_METHOD_POST, &transaction); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_session_open_transaction", HttpGetError(nRet)); + CHECK_HANDLE(transaction,"http_session_open_transaction"); + + nRet = http_transaction_request_set_uri(transaction, "http://posttestserver.com/post.php"); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_request_set_uri", HttpGetError(nRet),http_transaction_destroy(transaction)); + + nRet = http_transaction_set_ready_to_write(transaction, TRUE); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_set_ready_to_write", HttpGetError(nRet),http_transaction_destroy(transaction)); + + nRet = http_transaction_request_write_body(transaction, post_msg); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_request_write_body", HttpGetError(nRet),http_transaction_destroy(transaction)); + + //Target API + nRet = http_transaction_set_uploaded_cb(transaction, HttpTransactionWriteCB, NULL); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_set_uploaded_cb", HttpGetError(nRet),http_transaction_destroy(transaction)); + + nRet = http_transaction_submit(transaction); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_submit", HttpGetError(nRet),http_transaction_destroy(transaction)); + + RUN_POLLING_LOOP; + + if ( g_bCallbackHit == false ) + { + FPRINTF("[Line : %d][%s] HttpTransactionWriteCB failed\\n", __LINE__, API_NAMESPACE); + return 1; + } + + http_transaction_destroy(transaction); + transaction = NULL; + + return 0; +} + +//& purpose: Registers callback that is called when data is uploaded/downloaded +//& type: auto +/** +* @testcase ITc_http_transaction_set_progress_cb_p +* @since_tizen 3.0 +* @author SRID(gaurav.m2) +* @reviewer SRID(a.pandia1) +* @type auto +* @description Registers callback that is called when data is uploaded/downloaded +* @scenario call http_transaction_set_progress_cb +* @apicovered http_transaction_set_progress_cb +* @passcase When http_transaction_set_progress_cb is successful. +* @failcase If API http_transaction_set_progress_cb fails. +* @precondition http_session_open_transaction() should be successfully called +* @postcondition NA +*/ +int ITc_http_transaction_set_progress_cb_p(void) +{ + START_TEST; + int nTimeoutId = 0; + g_bCallbackHit = false; + const char uri[100] = "http://www.tizen.org"; + + int nRet = http_transaction_request_set_uri(g_hHttpTransaction, uri); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_transaction_request_set_uri", HttpGetError(nRet)); + + //Target API + nRet = http_transaction_set_progress_cb(g_hHttpTransaction, HttpTransactionProgressCB, NULL); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_transaction_set_progress_cb", HttpGetError(nRet)); + + nRet = http_transaction_submit(g_hHttpTransaction); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_transaction_submit", HttpGetError(nRet)); + + RUN_POLLING_LOOP; + + if ( g_bCallbackHit == false ) + { + FPRINTF("[Line : %d][%s] HttpTransactionProgressCB failed\\n", __LINE__, API_NAMESPACE); + return 1; + } + + return 0; +} + +//& purpose: Sets/Gets the timeout in seconds that is the timeout for waiting the transaction +//& type: auto +/** +* @testcase ITc_http_transaction_set_get_timeout_p +* @since_tizen 3.0 +* @author SRID(gaurav.m2) +* @reviewer SRID(a.pandia1) +* @type auto +* @description Sets/Gets the timeout in seconds that is the timeout for waiting the transaction +* @scenario call http_transaction_set_timeout, http_transaction_get_timeout +* @apicovered http_transaction_set_timeout, http_transaction_get_timeout +* @passcase When http_transaction_set_timeout, http_transaction_get_timeout is successful. +* @failcase If API http_transaction_set_timeout, http_transaction_get_timeout fails. +* @precondition http_session_open_transaction() should be successfully called +* @postcondition NA +*/ +int ITc_http_transaction_set_get_timeout_p(void) +{ + START_TEST; + + int nTimeout = 10; + int nGetTimout = -1; + + //Target API + int nRet = http_transaction_set_timeout(g_hHttpTransaction, nTimeout); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_transaction_set_timeout", HttpGetError(nRet)); + + //Target API + nRet = http_transaction_get_timeout(g_hHttpTransaction, &nGetTimout); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_transaction_get_timeout", HttpGetError(nRet)); + + if( nTimeout != nGetTimout) + { + FPRINTF("[Line : %d][%s] nGetTimout value not set!! \\n", __LINE__, API_NAMESPACE); + return 1; + } + + return 0; +} + +//& purpose: Sets ready to write event for a transaction +//& type: auto +/** +* @testcase ITc_http_transaction_set_ready_to_write_p +* @since_tizen 3.0 +* @author SRID(gaurav.m2) +* @reviewer SRID(a.pandia1) +* @type auto +* @description Sets ready to write event for a transaction +* @scenario call http_transaction_set_ready_to_write +* @apicovered http_transaction_set_ready_to_write +* @passcase When http_transaction_set_ready_to_write is successful. +* @failcase If API http_transaction_set_ready_to_write fails. +* @precondition http_session_open_transaction() should be successfully called +* @postcondition NA +*/ +int ITc_http_transaction_set_ready_to_write_p(void) +{ + START_TEST; + + bool bReadyToWrite = true; + + //Target API + int nRet = http_transaction_set_ready_to_write(g_hHttpTransaction, bReadyToWrite); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_transaction_set_ready_to_write", HttpGetError(nRet)); + + return 0; +} + +//& purpose: Sets/Gets the interface name +//& type: auto +/** +* @testcase ITc_http_transaction_set_get_interface_name_p +* @since_tizen 3.0 +* @author SRID(gaurav.m2) +* @reviewer SRID(a.pandia1) +* @type auto +* @description Sets/Gets the interface name +* @scenario call http_transaction_set_interface_name , http_transaction_get_interface_name +* @apicovered http_transaction_set_interface_name, http_transaction_get_interface_name +* @passcase When http_transaction_set_interface_name, http_transaction_get_interface_name is successful. +* @failcase If API http_transaction_set_interface_name, http_transaction_get_interface_name fails. +* @precondition http_session_open_transaction() should be successfully called +* @postcondition NA +*/ +int ITc_http_transaction_set_get_interface_name_p(void) +{ + START_TEST; + + const char pInterfaceName[10] = "wlan0"; + char *pGetInterfaceName; + + //Target API + int nRet = http_transaction_set_interface_name(g_hHttpTransaction, pInterfaceName); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_transaction_set_interface_name", HttpGetError(nRet)); + + //Target API + nRet = http_transaction_get_interface_name(g_hHttpTransaction, &pGetInterfaceName); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_transaction_get_interface_name", HttpGetError(nRet)); + + if ( strcmp( pGetInterfaceName, pInterfaceName ) != 0 ) + { + FPRINTF("[Line : %d][%s] pGetInterfaceName in http_transaction_get_interface_name is not same, as set\\n", __LINE__, API_NAMESPACE); + FREE_MEMORY(pGetInterfaceName); + return 1; + } + FREE_MEMORY(pGetInterfaceName); + + return 0; +} + +//& purpose: Sets/Gets the flag to verify a server certificate +//& type: auto +/** +* @testcase ITc_http_transaction_set_get_server_certificate_verification_p +* @since_tizen 3.0 +* @author SRID(gaurav.m2) +* @reviewer SRID(a.pandia1) +* @type auto +* @description Sets/Gets the flag to verify a server certificate +* @scenario call http_transaction_set_server_certificate_verification, http_transaction_get_server_certificate_verification +* @apicovered http_transaction_set_server_certificate_verification, http_transaction_get_server_certificate_verification +* @passcase When http_transaction_set_server_certificate_verification, http_transaction_get_server_certificate_verification is successful. +* @failcase If API http_transaction_set_server_certificate_verification, http_transaction_get_server_certificate_verification fails. +* @precondition http_session_open_transaction() should be successfully called +* @postcondition NA +*/ +int ITc_http_transaction_set_get_server_certificate_verification_p(void) +{ + START_TEST; + + bool bVerify = true; + bool bGetVerify = false; + + //Target API + int nRet = http_transaction_set_server_certificate_verification(g_hHttpTransaction, bVerify); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_transaction_set_server_certificate_verification", HttpGetError(nRet)); + + //Target API + nRet = http_transaction_get_server_certificate_verification(g_hHttpTransaction, &bGetVerify); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_transaction_get_server_certificate_verification", HttpGetError(nRet)); + + if ( bGetVerify != bVerify ) + { + FPRINTF("[Line : %d][%s] bGetVerify in http_transaction_get_server_certificate_verification is not same, as set\\n", __LINE__, API_NAMESPACE); + return 1; + } + + return 0; +} + +//& purpose: Pauses/resume the transaction +//& type: auto +/** +* @testcase ITc_http_transaction_pause_resume_p +* @since_tizen 3.0 +* @author SRID(gaurav.m2) +* @reviewer SRID(a.pandia1) +* @type auto +* @description Pauses/resume the transaction +* @scenario call http_transaction_pause, http_transaction_resume +* @apicovered http_transaction_pause, http_transaction_resume +* @passcase When http_transaction_pause, http_transaction_resume is successful. +* @failcase If API http_transaction_pause, http_transaction_resume fails. +* @precondition http_session_open_transaction() should be successfully called +* @postcondition NA +*/ +int ITc_http_transaction_pause_resume_p(void) +{ + + START_TEST; + int nTimeoutId = 0; + int nRet; + http_transaction_h transaction; + const char* post_msg = "name=tizen&project=capi-network-curl"; + const char pField[20] = "Content-Length"; + char pValue[10]; + b_HttpTransactionProgressCB = true; + g_bCallbackHit = false; + + if (g_hHttpTransaction) { + http_transaction_destroy(g_hHttpTransaction); + g_hHttpTransaction = NULL; + } + + nRet = http_session_open_transaction(g_hHttpSession, HTTP_METHOD_POST, &transaction); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_session_open_transaction", HttpGetError(nRet)); + CHECK_HANDLE(transaction,"http_session_open_transaction"); + + nRet = http_transaction_request_set_uri(transaction, "http://posttestserver.com/post.php"); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_request_set_uri", HttpGetError(nRet),http_transaction_destroy(transaction)); + + nRet = http_transaction_set_ready_to_write(transaction, TRUE); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_set_ready_to_write", HttpGetError(nRet),http_transaction_destroy(transaction)); + + nRet = http_transaction_request_write_body(transaction, post_msg); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_request_write_body", HttpGetError(nRet),http_transaction_destroy(transaction)); + + snprintf(pValue, sizeof(pValue), "%d", (int)strlen(post_msg)); + nRet = http_transaction_header_add_field(transaction, pField, pValue); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_header_add_field", HttpGetError(nRet),http_transaction_destroy(transaction)); + + //Target API + nRet = http_transaction_set_progress_cb(transaction, HttpTransactionProgressPauseResumeCB, NULL); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_set_progress_cb", HttpGetError(nRet),http_transaction_destroy(transaction)); + + nRet = http_transaction_submit(transaction); + PRINT_RESULT_CLEANUP(HTTP_ERROR_NONE, nRet, "http_transaction_submit", HttpGetError(nRet),http_transaction_destroy(transaction)); + + RUN_POLLING_LOOP; + if ( b_HttpTransactionProgressCB == false ) + { + FPRINTF("[Line : %d][%s] b_HttpTransactionWriteCB failed\\n", __LINE__, API_NAMESPACE); + http_transaction_destroy(transaction); + return 1; + } + if(!g_bIsValid) + { + FPRINTF("[Line : %d][%s] API failed in HttpTransactionProgressPauseResumeCB \\n", __LINE__, API_NAMESPACE); + http_transaction_destroy(transaction); + return 1; + } + + nRet = http_transaction_destroy(transaction); + PRINT_RESULT_NORETURN(HTTP_ERROR_NONE, nRet, "http_transaction_destroy", HttpGetError(nRet)); + + return 0; +} +//& purpose: Gets the Http Header Field value from custom header +//& type: auto +/** +* @testcase ITc_http_transaction_header_add_remove_field_p +* @since_tizen 3.0 +* @author SRID(shilpa.j) +* @reviewer SRID(a.pandia1) +* @type auto +* @description Gets the Http Header Field value from custom header +* @scenario call http_transaction_header_add_field and http_transaction_header_remove_field +* @apicovered http_transaction_header_add_field .http_transaction_header_remove_field +* @passcase When http_transaction_header_add_field and http_transaction_header_remove_field is successful. +* @failcase If API http_transaction_header_add_field or http_transaction_header_remove_field fails. +* @precondition http_session_open_transaction() should be successfully called +* @postcondition NA +*/ +int ITc_http_transaction_header_add_remove_field_p(void) +{ + START_TEST; + + const char szfield[20] = "Content-Length"; + const char szvalue[10] = "10"; + + //Target API + int nRet = http_transaction_header_add_field(g_hHttpTransaction,szfield,szvalue); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_transaction_header_add_field", HttpGetError(nRet)); + + //Target API + nRet = http_transaction_header_remove_field(g_hHttpTransaction, szfield); + PRINT_RESULT(HTTP_ERROR_NONE, nRet, "http_transaction_header_remove_field", HttpGetError(nRet)); + + return 0; +} + +//& purpose: Gets & Sets an HTTP method of the request header. +//& type: auto +/** +* @testcase ITc_http_transaction_request_set_get_method_p +* @since_tizen 3.0 +* @author SRID(shilpa.j) +* @reviewer SRID(a.pandia1) +* @type auto +* @description Sets and gets HTTP method of the request header. +* @scenario call http_transaction_request_set_method and http_transaction_request_get_method +* @apicovered http_transaction_request_set_method ,http_transaction_request_get_method +* @passcase When http_transaction_request_set_method and http_transaction_request_get_method is successful. +* @failcase If API http_transaction_request_set_method or http_transaction_request_get_method fails. +* @precondition http_session_open_transaction() should be successfully called +* @postcondition NA +*/ +int ITc_http_transaction_request_set_get_method_p(void) +{ + START_TEST; + + http_method_e method; + + http_method_e eHttpMethodType[] = { + HTTP_METHOD_GET, + HTTP_METHOD_OPTIONS, + HTTP_METHOD_HEAD, + HTTP_METHOD_DELETE, + HTTP_METHOD_TRACE, + HTTP_METHOD_POST, + HTTP_METHOD_PUT, + HTTP_METHOD_CONNECT + }; + + int nEnumSize = sizeof(eHttpMethodType) / sizeof(eHttpMethodType[0]); + int nEnumCounter = 0; + + for ( nEnumCounter=0;nEnumCounter +#include +#include "tct_common.h" + +#ifdef MOBILE //Starts MOBILE +#include "tct-http-native_mobile.h" +#endif //MOBILE //End MOBILE + +#ifdef WEARABLE //Starts WEARABLE +#include "tct-http-native_wearable.h" +#endif //WEARABLE //End WEARABLE + +#ifdef TV //Starts TV +#include "tct-http-native_tv.h" +#endif //TV //End TV + +#ifdef COMMON_IOT //Starts COMMON_IOT +#include "tct-http-native_common_iot.h" +#endif //COMMON_IOT //End COMMON_IOT + + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + +typedef struct appdata { + Evas_Object *win; + Evas_Object *conform; + Evas_Object *label; +} appdata_s; + +static bool app_create(void *data) +{ + return true; +} + +static void app_control(app_control_h app_control, void *data) +{ + char* pszGetTCName = NULL; + int i=0, result=0, nRet=0; + nRet = app_control_get_extra_data(app_control, "testcase_name", &pszGetTCName); + if(nRet != APP_CONTROL_ERROR_NONE) + { + dlog_print(DLOG_ERROR, "NativeTCT", "[%s:%d] app_control_get_extra_data returns error = %d", __FUNCTION__, __LINE__, nRet); + PRINT_UTC_LOG("\\n[%s][Line : %d]Unable to fetch test case name: app_control_get_extra_data API call fails\\n", __FILE__, __LINE__); + PRINT_TC_RESULT("%d",1); + FREE_MEMORY_TC(pszGetTCName); + return; + } + + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Executing TC Name = %s", __FUNCTION__, __LINE__, pszGetTCName); + for ( i = 0; tc_array[i].name; i++ ) + { + if ( 0 == strncmp(pszGetTCName, tc_array[i].name, strlen(pszGetTCName)) ) + { + if ( tc_array[i].startup ) + { + dlog_print(DLOG_INFO, "NativeTCT", "%s : Start up", pszGetTCName); + tc_array[i].startup(); + } + + dlog_print(DLOG_INFO, "NativeTCT", "%s : Body", pszGetTCName); + result = tc_array[i].function(); + dlog_print(DLOG_INFO, "NativeTCT", "%s returns value = %d", pszGetTCName, result); + + if ( tc_array[i].cleanup ) + { + dlog_print(DLOG_INFO, "NativeTCT", "%s : Clean up", pszGetTCName); + tc_array[i].cleanup(); + } + + PRINT_TC_RESULT("%d",result); + FREE_MEMORY_TC(pszGetTCName); + return; + } + } + + dlog_print(DLOG_ERROR, "NativeTCT", "[%s:%d] Unable to execute %s : Unknown Test Case Name", __FUNCTION__, __LINE__, pszGetTCName); + PRINT_UTC_LOG("\\n[%s][Line : %d]Unable to execute %s : Unknown Test Case Name\\n", __FILE__, __LINE__, pszGetTCName); + PRINT_TC_RESULT("%d",1); + FREE_MEMORY_TC(pszGetTCName); + return; +} + +static void app_terminate(void *data) +{ + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Package is now Terminating", __FUNCTION__, __LINE__); +} + +int main(int argc, char *argv[]) +{ + int ret = 0; + appdata_s ad = {0,}; + + ui_app_lifecycle_callback_s event_callback = {0,}; + event_callback.create = app_create; + event_callback.terminate = app_terminate; + event_callback.app_control = app_control; + + //setting gcda file location for coverage + setenv("GCOV_PREFIX","/tmp",1); + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Coverage *.gcda File location set to /tmp/home/abuild/rpmbuild/BUILD/ ", __FUNCTION__, __LINE__); + + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Main Function is Invoked", __FUNCTION__, __LINE__); + ret = ui_app_main(argc, argv, &event_callback, &ad); + if (ret != APP_ERROR_NONE) + { + dlog_print(DLOG_ERROR, "NativeTCT", "Application ui_app_main call gets failed. err = %d", ret); + PRINT_UTC_LOG("\\n[%s][Line : %d]Application ui_app_main call gets failed. err = %d\\n", __FILE__, __LINE__, ret); + PRINT_TC_RESULT("%d",1); + return ret; + } + + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Package is Terminated", __FUNCTION__, __LINE__); + return ret; +} diff --git a/src/itc/http/tct-http-native_common_iot.h b/src/itc/http/tct-http-native_common_iot.h new file mode 100755 index 0000000..68b508c --- /dev/null +++ b/src/itc/http/tct-http-native_common_iot.h @@ -0,0 +1,84 @@ +// +// Copyright (c) 2014 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. +// +#ifndef __TCT_HTTP_NATIVE_H__ +#define __TCT_HTTP_NATIVE_H__ + +#include "testcase.h" +#include "tct_common.h" + +extern void ITs_http_startup(void); +extern void ITs_http_cleanup(void); +extern void ITs_http_transaction_startup(void); +extern void ITs_http_transaction_cleanup(void); + +extern int ITc_http_init_deinit_p(void); +extern int ITc_http_session_create_destroy_p(void); +extern int ITc_http_session_set_get_auto_redirection_p(void); +extern int ITc_http_session_get_active_transaction_count_p(void); +extern int ITc_http_session_get_max_transaction_count_p(void); +extern int ITc_http_session_open_destroy_transaction_p(void); +extern int ITc_http_session_destroy_all_transactions_p(void); +extern int ITc_http_transaction_register_callbacks_p(void); +extern int ITc_http_transaction_set_uploaded_cb_p(void); +extern int ITc_http_transaction_set_progress_cb_p(void); +extern int ITc_http_transaction_set_get_timeout_p(void); +extern int ITc_http_transaction_set_ready_to_write_p(void); +extern int ITc_http_transaction_set_get_interface_name_p(void); +extern int ITc_http_transaction_set_get_server_certificate_verification_p(void); +extern int ITc_http_transaction_pause_resume_p(void); +extern int ITc_http_transaction_header_add_remove_field_p(void); +extern int ITc_http_transaction_request_set_get_method_p(void); +extern int ITc_http_transaction_request_set_get_version_p(void); +extern int ITc_http_transaction_request_set_get_uri_p(void); +extern int ITc_http_transaction_request_set_get_accept_encoding_p(void); +extern int ITc_http_transaction_request_set_get_cookie_p(void); +extern int ITc_http_transaction_request_write_body_p(void); +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); + +testcase tc_array[] = { + {"ITc_http_init_deinit_p", ITc_http_init_deinit_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_create_destroy_p", ITc_http_session_create_destroy_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_set_get_auto_redirection_p", ITc_http_session_set_get_auto_redirection_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_get_active_transaction_count_p", ITc_http_session_get_active_transaction_count_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_get_max_transaction_count_p", ITc_http_session_get_max_transaction_count_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_open_destroy_transaction_p", ITc_http_session_open_destroy_transaction_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_destroy_all_transactions_p", ITc_http_session_destroy_all_transactions_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_transaction_register_callbacks_p", ITc_http_transaction_register_callbacks_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_uploaded_cb_p", ITc_http_transaction_set_uploaded_cb_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_progress_cb_p", ITc_http_transaction_set_progress_cb_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_get_timeout_p", ITc_http_transaction_set_get_timeout_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_ready_to_write_p", ITc_http_transaction_set_ready_to_write_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_get_interface_name_p", ITc_http_transaction_set_get_interface_name_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_get_server_certificate_verification_p", ITc_http_transaction_set_get_server_certificate_verification_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_pause_resume_p", ITc_http_transaction_pause_resume_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_header_add_remove_field_p", ITc_http_transaction_header_add_remove_field_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_method_p", ITc_http_transaction_request_set_get_method_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_version_p", ITc_http_transaction_request_set_get_version_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_uri_p", ITc_http_transaction_request_set_get_uri_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_accept_encoding_p", ITc_http_transaction_request_set_get_accept_encoding_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_cookie_p", ITc_http_transaction_request_set_get_cookie_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_write_body_p", ITc_http_transaction_request_write_body_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_trasaction_open_authentication_p", ITc_http_trasaction_open_authentication_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"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}, + {NULL, NULL} +}; + +#endif // __TCT_HTTP_NATIVE_H__ diff --git a/src/itc/http/tct-http-native_mobile.h b/src/itc/http/tct-http-native_mobile.h new file mode 100755 index 0000000..68b508c --- /dev/null +++ b/src/itc/http/tct-http-native_mobile.h @@ -0,0 +1,84 @@ +// +// Copyright (c) 2014 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. +// +#ifndef __TCT_HTTP_NATIVE_H__ +#define __TCT_HTTP_NATIVE_H__ + +#include "testcase.h" +#include "tct_common.h" + +extern void ITs_http_startup(void); +extern void ITs_http_cleanup(void); +extern void ITs_http_transaction_startup(void); +extern void ITs_http_transaction_cleanup(void); + +extern int ITc_http_init_deinit_p(void); +extern int ITc_http_session_create_destroy_p(void); +extern int ITc_http_session_set_get_auto_redirection_p(void); +extern int ITc_http_session_get_active_transaction_count_p(void); +extern int ITc_http_session_get_max_transaction_count_p(void); +extern int ITc_http_session_open_destroy_transaction_p(void); +extern int ITc_http_session_destroy_all_transactions_p(void); +extern int ITc_http_transaction_register_callbacks_p(void); +extern int ITc_http_transaction_set_uploaded_cb_p(void); +extern int ITc_http_transaction_set_progress_cb_p(void); +extern int ITc_http_transaction_set_get_timeout_p(void); +extern int ITc_http_transaction_set_ready_to_write_p(void); +extern int ITc_http_transaction_set_get_interface_name_p(void); +extern int ITc_http_transaction_set_get_server_certificate_verification_p(void); +extern int ITc_http_transaction_pause_resume_p(void); +extern int ITc_http_transaction_header_add_remove_field_p(void); +extern int ITc_http_transaction_request_set_get_method_p(void); +extern int ITc_http_transaction_request_set_get_version_p(void); +extern int ITc_http_transaction_request_set_get_uri_p(void); +extern int ITc_http_transaction_request_set_get_accept_encoding_p(void); +extern int ITc_http_transaction_request_set_get_cookie_p(void); +extern int ITc_http_transaction_request_write_body_p(void); +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); + +testcase tc_array[] = { + {"ITc_http_init_deinit_p", ITc_http_init_deinit_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_create_destroy_p", ITc_http_session_create_destroy_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_set_get_auto_redirection_p", ITc_http_session_set_get_auto_redirection_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_get_active_transaction_count_p", ITc_http_session_get_active_transaction_count_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_get_max_transaction_count_p", ITc_http_session_get_max_transaction_count_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_open_destroy_transaction_p", ITc_http_session_open_destroy_transaction_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_destroy_all_transactions_p", ITc_http_session_destroy_all_transactions_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_transaction_register_callbacks_p", ITc_http_transaction_register_callbacks_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_uploaded_cb_p", ITc_http_transaction_set_uploaded_cb_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_progress_cb_p", ITc_http_transaction_set_progress_cb_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_get_timeout_p", ITc_http_transaction_set_get_timeout_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_ready_to_write_p", ITc_http_transaction_set_ready_to_write_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_get_interface_name_p", ITc_http_transaction_set_get_interface_name_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_get_server_certificate_verification_p", ITc_http_transaction_set_get_server_certificate_verification_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_pause_resume_p", ITc_http_transaction_pause_resume_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_header_add_remove_field_p", ITc_http_transaction_header_add_remove_field_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_method_p", ITc_http_transaction_request_set_get_method_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_version_p", ITc_http_transaction_request_set_get_version_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_uri_p", ITc_http_transaction_request_set_get_uri_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_accept_encoding_p", ITc_http_transaction_request_set_get_accept_encoding_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_cookie_p", ITc_http_transaction_request_set_get_cookie_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_write_body_p", ITc_http_transaction_request_write_body_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_trasaction_open_authentication_p", ITc_http_trasaction_open_authentication_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"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}, + {NULL, NULL} +}; + +#endif // __TCT_HTTP_NATIVE_H__ diff --git a/src/itc/http/tct-http-native_tv.h b/src/itc/http/tct-http-native_tv.h new file mode 100755 index 0000000..20884b4 --- /dev/null +++ b/src/itc/http/tct-http-native_tv.h @@ -0,0 +1,86 @@ +// +// Copyright (c) 2014 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. +// +#ifndef __TCT_HTTP_NATIVE_H__ +#define __TCT_HTTP_NATIVE_H__ + +#include "testcase.h" +#include "tct_common.h" + + +extern void ITs_http_startup(void); +extern void ITs_http_cleanup(void); +extern void ITs_http_transaction_startup(void); +extern void ITs_http_transaction_cleanup(void); + +extern int ITc_http_init_deinit_p(void); +extern int ITc_http_session_create_destroy_p(void); +extern int ITc_http_session_set_get_auto_redirection_p(void); +extern int ITc_http_session_get_active_transaction_count_p(void); +extern int ITc_http_session_get_max_transaction_count_p(void); +extern int ITc_http_session_open_destroy_transaction_p(void); +extern int ITc_http_session_destroy_all_transactions_p(void); +extern int ITc_http_transaction_register_callbacks_p(void); +extern int ITc_http_transaction_set_uploaded_cb_p(void); +extern int ITc_http_transaction_set_progress_cb_p(void); +extern int ITc_http_transaction_set_get_timeout_p(void); +extern int ITc_http_transaction_set_ready_to_write_p(void); +extern int ITc_http_transaction_set_get_interface_name_p(void); +extern int ITc_http_transaction_set_get_server_certificate_verification_p(void); +extern int ITc_http_transaction_pause_resume_p(void); +extern int ITc_http_transaction_header_add_remove_field_p(void); +extern int ITc_http_transaction_request_set_get_method_p(void); +extern int ITc_http_transaction_request_set_get_version_p(void); +extern int ITc_http_transaction_request_set_get_uri_p(void); +extern int ITc_http_transaction_request_set_get_accept_encoding_p(void); +extern int ITc_http_transaction_request_set_get_cookie_p(void); +extern int ITc_http_transaction_request_write_body_p(void); +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); + +testcase tc_array[] = { + {"ITc_http_init_deinit_p", ITc_http_init_deinit_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_create_destroy_p", ITc_http_session_create_destroy_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_set_get_auto_redirection_p", ITc_http_session_set_get_auto_redirection_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_get_active_transaction_count_p", ITc_http_session_get_active_transaction_count_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_get_max_transaction_count_p", ITc_http_session_get_max_transaction_count_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_open_destroy_transaction_p", ITc_http_session_open_destroy_transaction_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_destroy_all_transactions_p", ITc_http_session_destroy_all_transactions_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_transaction_register_callbacks_p", ITc_http_transaction_register_callbacks_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_uploaded_cb_p", ITc_http_transaction_set_uploaded_cb_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_progress_cb_p", ITc_http_transaction_set_progress_cb_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_get_timeout_p", ITc_http_transaction_set_get_timeout_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_ready_to_write_p", ITc_http_transaction_set_ready_to_write_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_get_interface_name_p", ITc_http_transaction_set_get_interface_name_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_get_server_certificate_verification_p", ITc_http_transaction_set_get_server_certificate_verification_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_pause_resume_p", ITc_http_transaction_pause_resume_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_header_add_remove_field_p", ITc_http_transaction_header_add_remove_field_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_method_p", ITc_http_transaction_request_set_get_method_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_version_p", ITc_http_transaction_request_set_get_version_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_uri_p", ITc_http_transaction_request_set_get_uri_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_accept_encoding_p", ITc_http_transaction_request_set_get_accept_encoding_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_cookie_p", ITc_http_transaction_request_set_get_cookie_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_write_body_p", ITc_http_transaction_request_write_body_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_trasaction_open_authentication_p", ITc_http_trasaction_open_authentication_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"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}, + {NULL, NULL} +}; + + +#endif // __TCT_HTTP_NATIVE_H__ diff --git a/src/itc/http/tct-http-native_wearable.h b/src/itc/http/tct-http-native_wearable.h new file mode 100755 index 0000000..68b508c --- /dev/null +++ b/src/itc/http/tct-http-native_wearable.h @@ -0,0 +1,84 @@ +// +// Copyright (c) 2014 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. +// +#ifndef __TCT_HTTP_NATIVE_H__ +#define __TCT_HTTP_NATIVE_H__ + +#include "testcase.h" +#include "tct_common.h" + +extern void ITs_http_startup(void); +extern void ITs_http_cleanup(void); +extern void ITs_http_transaction_startup(void); +extern void ITs_http_transaction_cleanup(void); + +extern int ITc_http_init_deinit_p(void); +extern int ITc_http_session_create_destroy_p(void); +extern int ITc_http_session_set_get_auto_redirection_p(void); +extern int ITc_http_session_get_active_transaction_count_p(void); +extern int ITc_http_session_get_max_transaction_count_p(void); +extern int ITc_http_session_open_destroy_transaction_p(void); +extern int ITc_http_session_destroy_all_transactions_p(void); +extern int ITc_http_transaction_register_callbacks_p(void); +extern int ITc_http_transaction_set_uploaded_cb_p(void); +extern int ITc_http_transaction_set_progress_cb_p(void); +extern int ITc_http_transaction_set_get_timeout_p(void); +extern int ITc_http_transaction_set_ready_to_write_p(void); +extern int ITc_http_transaction_set_get_interface_name_p(void); +extern int ITc_http_transaction_set_get_server_certificate_verification_p(void); +extern int ITc_http_transaction_pause_resume_p(void); +extern int ITc_http_transaction_header_add_remove_field_p(void); +extern int ITc_http_transaction_request_set_get_method_p(void); +extern int ITc_http_transaction_request_set_get_version_p(void); +extern int ITc_http_transaction_request_set_get_uri_p(void); +extern int ITc_http_transaction_request_set_get_accept_encoding_p(void); +extern int ITc_http_transaction_request_set_get_cookie_p(void); +extern int ITc_http_transaction_request_write_body_p(void); +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); + +testcase tc_array[] = { + {"ITc_http_init_deinit_p", ITc_http_init_deinit_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_create_destroy_p", ITc_http_session_create_destroy_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_set_get_auto_redirection_p", ITc_http_session_set_get_auto_redirection_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_get_active_transaction_count_p", ITc_http_session_get_active_transaction_count_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_get_max_transaction_count_p", ITc_http_session_get_max_transaction_count_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_open_destroy_transaction_p", ITc_http_session_open_destroy_transaction_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_session_destroy_all_transactions_p", ITc_http_session_destroy_all_transactions_p, ITs_http_startup, ITs_http_cleanup}, + {"ITc_http_transaction_register_callbacks_p", ITc_http_transaction_register_callbacks_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_uploaded_cb_p", ITc_http_transaction_set_uploaded_cb_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_progress_cb_p", ITc_http_transaction_set_progress_cb_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_get_timeout_p", ITc_http_transaction_set_get_timeout_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_ready_to_write_p", ITc_http_transaction_set_ready_to_write_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_get_interface_name_p", ITc_http_transaction_set_get_interface_name_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_set_get_server_certificate_verification_p", ITc_http_transaction_set_get_server_certificate_verification_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_pause_resume_p", ITc_http_transaction_pause_resume_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_header_add_remove_field_p", ITc_http_transaction_header_add_remove_field_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_method_p", ITc_http_transaction_request_set_get_method_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_version_p", ITc_http_transaction_request_set_get_version_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_uri_p", ITc_http_transaction_request_set_get_uri_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_accept_encoding_p", ITc_http_transaction_request_set_get_accept_encoding_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_set_get_cookie_p", ITc_http_transaction_request_set_get_cookie_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_transaction_request_write_body_p", ITc_http_transaction_request_write_body_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"ITc_http_trasaction_open_authentication_p", ITc_http_trasaction_open_authentication_p, ITs_http_transaction_startup, ITs_http_transaction_cleanup}, + {"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}, + {NULL, NULL} +}; + +#endif // __TCT_HTTP_NATIVE_H__