From 154d3bf441a4d0be265a6f9bc81e14270434f053 Mon Sep 17 00:00:00 2001 From: perforce Date: Wed, 8 Jun 2016 14:04:23 +0900 Subject: [PATCH] [UTC][http][ACR-548][Add test cases for http capi] Change-Id: Ibd03ee8a9d3e4ca72c51cd08121f90e08f127380 Signed-off-by: perforce --- packaging/utc/core-http-tests.spec | 65 + packaging/utc/core-http-tests.xml | 11 + src/utc/http/CMakeLists.txt | 34 + src/utc/http/public.list | 42 + src/utc/http/tct-http-core.c | 141 +++ src/utc/http/tct-http-core_mobile.h | 180 +++ src/utc/http/tct-http-core_wearable.h | 180 +++ src/utc/http/utc-network-http.c | 2244 +++++++++++++++++++++++++++++++++ 8 files changed, 2897 insertions(+) create mode 100755 packaging/utc/core-http-tests.spec create mode 100755 packaging/utc/core-http-tests.xml create mode 100755 src/utc/http/CMakeLists.txt create mode 100755 src/utc/http/public.list create mode 100755 src/utc/http/tct-http-core.c create mode 100755 src/utc/http/tct-http-core_mobile.h create mode 100755 src/utc/http/tct-http-core_wearable.h create mode 100755 src/utc/http/utc-network-http.c diff --git a/packaging/utc/core-http-tests.spec b/packaging/utc/core-http-tests.spec new file mode 100755 index 0000000..c6e0fbd --- /dev/null +++ b/packaging/utc/core-http-tests.spec @@ -0,0 +1,65 @@ +%define MODULE_NAME http +%define MODULE_LIBNAME capi-network-http +Name: core-%{MODULE_NAME}-tests +Summary: Core API unit TC (%{name}) +Version: 0.1 +Release: 0 +Group: Development/Tools +License: Apache License, Version 2.0 +Source0: %{name}-%{version}.tar.gz +BuildRequires: pkgconfig(%{MODULE_LIBNAME}) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: cmake +BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(elementary) +BuildRequires: pkgconfig(capi-system-info) + +%description +Core API unit TC (%{name}) + +%prep +%setup -q + +%build + +%define PREFIX "%{_libdir}/%{name}" + +export LDFLAGS+="-Wl,--rpath=%{PREFIX} -Wl,--as-needed" + +#cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DCMAKE_INSTALL_PREFIX=%{_prefix} +%if %{?DEVICE_BUILD_TYPE_MOBILE:1}0 +cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="mobile" -DCMAKE_INSTALL_PREFIX=%{_prefix} +%endif + +%if %{?DEVICE_BUILD_TYPE_WEARABLE:1}0 +cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="wearable" -DCMAKE_INSTALL_PREFIX=%{_prefix} +%endif + +%if %{?DEVICE_BUILD_TYPE_TV:1}0 +cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="tv" -DCMAKE_INSTALL_PREFIX=%{_prefix} +%endif + +%if %{?DEVICE_BUILD_TYPE_COMMON_IOT:1}0 +cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="common_iot" -DCMAKE_INSTALL_PREFIX=%{_prefix} +%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/utc/%{name}.xml %{buildroot}/usr/share/packages/ +mkdir -p %{buildroot}/usr/apps/%{name}/bin +%post + +%postun + + +%files +/usr/apps/%{name}/* +/usr/share/packages/%{name}.xml +/usr/share/license/%{name} diff --git a/packaging/utc/core-http-tests.xml b/packaging/utc/core-http-tests.xml new file mode 100755 index 0000000..91d5c92 --- /dev/null +++ b/packaging/utc/core-http-tests.xml @@ -0,0 +1,11 @@ + + + + test + Core API test Application + + + + http://tizen.org/privilege/internet + + diff --git a/src/utc/http/CMakeLists.txt b/src/utc/http/CMakeLists.txt new file mode 100755 index 0000000..eae4483 --- /dev/null +++ b/src/utc/http/CMakeLists.txt @@ -0,0 +1,34 @@ +SET(PKG_NAME "http") + +SET(EXEC_NAME "tct-${PKG_NAME}-core") +SET(RPM_NAME "core-${PKG_NAME}-tests") + +SET(CAPI_LIB "capi-network-http") +SET(TC_SOURCES + utc-network-http.c +) + +PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED + ${CAPI_LIB} + capi-appfw-application + capi-system-info + glib-2.0 + dlog elementary + ) + +INCLUDE_DIRECTORIES( + ${${CAPI_LIB}_INCLUDE_DIRS} +) + +ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.c ${TC_SOURCES}) +TARGET_LINK_LIBRARIES(${EXEC_NAME} + ${${CAPI_LIB}_LIBRARIES} +) + +INSTALL(PROGRAMS ${EXEC_NAME} + DESTINATION ${BIN_DIR}/${RPM_NAME}/bin +) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fPIE -Wall") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib -pie") + diff --git a/src/utc/http/public.list b/src/utc/http/public.list new file mode 100755 index 0000000..600e82f --- /dev/null +++ b/src/utc/http/public.list @@ -0,0 +1,42 @@ +int http_init +int http_deinit +int http_session_create +int http_session_destroy +int http_session_set_auto_redirection +int http_session_get_auto_redirection +int http_session_get_active_transaction_count +int http_session_get_max_transaction_count +int http_session_open_transaction +int http_session_destroy_all_transactions +int http_transaction_submit +int http_transaction_destroy +int http_transaction_set_received_header_cb +int http_transaction_set_received_body_cb +int http_transaction_set_uploaded_cb +int http_transaction_set_completed_cb +int http_transaction_set_progress_cb +int http_transaction_set_timeout +int http_transaction_get_timeout +int http_transaction_resume +int http_transaction_pause +int http_transaction_set_ready_to_write +int http_transaction_set_interface_name +int http_transaction_get_interface_name +int http_transaction_set_server_certificate_verification +int http_transaction_get_server_certificate_verification +int http_transaction_header_add_field +int http_transaction_header_remove_field +int http_transaction_request_set_method +int http_transaction_request_get_method +int http_transaction_request_set_version +int http_transaction_request_get_version +int http_transaction_request_set_uri +int http_transaction_request_get_uri +int http_transaction_request_set_accept_encoding +int http_transaction_request_get_accept_encoding +int http_transaction_request_set_cookie +int http_transaction_request_get_cookie +int http_transaction_request_write_body +int http_transaction_response_get_status_code +int http_transaction_response_get_status_text +int http_transaction_response_get_version diff --git a/src/utc/http/tct-http-core.c b/src/utc/http/tct-http-core.c new file mode 100755 index 0000000..c222628 --- /dev/null +++ b/src/utc/http/tct-http-core.c @@ -0,0 +1,141 @@ +// +// 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 +#include + +#ifdef MOBILE +#include "tct-http-core_mobile.h" +#endif + +#ifdef WEARABLE +#include "tct-http-core_wearable.h" +#endif + +#ifdef TV +#include "tct-http-core_tv.h" +#endif + +#ifdef COMMON_IOT +#include "tct-http-core_common_iot.h" +#endif //COMMON_IOT + +#include +#include +#include +#include +#include +#include +#include +#include "tct_common.h" +#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)) ) + { + DUMP_UTC_ERRLOG(); + 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(); + dlog_print(DLOG_INFO, "NativeTCT", "%s : End - Clean up", pszGetTCName); + } + + CLOSE_UTC_ERRLOG(); + 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/utc/http/tct-http-core_mobile.h b/src/utc/http/tct-http-core_mobile.h new file mode 100755 index 0000000..68f274d --- /dev/null +++ b/src/utc/http/tct-http-core_mobile.h @@ -0,0 +1,180 @@ +// +// 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_CONNECTION_CORE_H__ +#define __TCT_CONNECTION_CORE_H__ + +#include "testcase.h" +#include "tct_common.h" + +extern void utc_http_startup(void); +extern void utc_http_cleanup(void); +extern int utc_http_session_create_p(void); +extern int utc_http_session_create_n(void); +extern int utc_http_session_destroy_n(void); +extern int utc_http_session_destroy_p(void); +extern int utc_http_session_set_auto_redirection_n(void); +extern int utc_http_session_set_auto_redirection_p(void); +extern int utc_http_session_get_auto_redirection_n(void); +extern int utc_http_session_get_auto_redirection_p(void); +extern int utc_http_session_get_active_transaction_count_n(void); +extern int utc_http_session_get_active_transaction_count_p(void); +extern int utc_http_session_get_max_transaction_count_n(void); +extern int utc_http_session_get_max_transaction_count_p(void); +extern int utc_http_session_open_transaction_n(void); +extern int utc_http_session_open_transaction_p(void); +extern int utc_http_transaction_destroy_n(void); +extern int utc_http_transaction_destroy_p(void); +extern int utc_http_transaction_set_progress_cb_n(void); +extern int utc_http_transaction_set_progress_cb_p(void); +extern int utc_http_transaction_set_received_header_cb_n(void); +extern int utc_http_transaction_set_received_header_cb_p(void); +extern int utc_http_transaction_set_received_body_cb_n(void); +extern int utc_http_transaction_set_received_body_cb_p(void); +extern int utc_http_transaction_set_uploaded_cb_n(void); +extern int utc_http_transaction_set_uploaded_cb_p(void); +extern int utc_http_transaction_set_completed_cb_n(void); +extern int utc_http_transaction_set_completed_cb_p(void); +extern int utc_http_transaction_set_aborted_cb_n(void); +extern int utc_http_transaction_set_aborted_cb_p(void); +extern int utc_http_transaction_set_timeout_n(void); +extern int utc_http_transaction_set_timeout_p(void); +extern int utc_http_transaction_get_timeout_n(void); +extern int utc_http_transaction_get_timeout_p(void); +extern int utc_http_transaction_set_interface_name_n(void); +extern int utc_http_transaction_set_interface_name_p(void); +extern int utc_http_transaction_get_interface_name_n(void); +extern int utc_http_transaction_get_interface_name_p(void); +extern int utc_http_transaction_set_ready_to_write_n(void); +extern int utc_http_transaction_set_ready_to_write_p(void); +extern int utc_http_transaction_get_server_certificate_verification_n(void); +extern int utc_http_transaction_get_server_certificate_verification_p(void); +extern int utc_http_transaction_set_server_certificate_verification_n(void); +extern int utc_http_transaction_set_server_certificate_verification_p(void); +extern int utc_http_session_destroy_all_transactions_n(void); +extern int utc_http_session_destroy_all_transactions_p(void); +extern int utc_http_transaction_header_add_field_n(void); +extern int utc_http_transaction_header_add_field_p(void); +extern int utc_http_transaction_header_remove_field_n(void); +extern int utc_http_transaction_header_remove_field_p(void); +extern int utc_http_transaction_header_get_field_value_n(void); +extern int utc_http_transaction_header_get_field_value_p(void); +extern int utc_http_transaction_request_set_method_n(void); +extern int utc_http_transaction_request_set_method_p(void); +extern int utc_http_transaction_request_get_method_n(void); +extern int utc_http_transaction_request_get_method_p(void); +extern int utc_http_transaction_request_set_version_n(void); +extern int utc_http_transaction_request_set_version_p(void); +extern int utc_http_transaction_request_get_version_n(void); +extern int utc_http_transaction_request_get_version_p(void); +extern int utc_http_transaction_request_set_uri_n(void); +extern int utc_http_transaction_request_set_uri_p(void); +extern int utc_http_transaction_request_get_uri_n(void); +extern int utc_http_transaction_request_get_uri_p(void); +extern int utc_http_transaction_request_set_accept_encoding_n(void); +extern int utc_http_transaction_request_set_accept_encoding_p(void); +extern int utc_http_transaction_request_get_accept_encoding_n(void); +extern int utc_http_transaction_request_get_accept_encoding_p(void); +extern int utc_http_transaction_request_set_cookie_n(void); +extern int utc_http_transaction_request_set_cookie_p(void); +extern int utc_http_transaction_request_get_cookie_n(void); +extern int utc_http_transaction_request_get_cookie_p(void); +extern int utc_http_transaction_request_write_body_n(void); +extern int utc_http_transaction_request_write_body_p(void); +extern int utc_http_transaction_submit_n(void); +extern int utc_http_transaction_submit_p(void); +extern int utc_http_deinit_n(void); +extern int utc_http_deinit_p(void); + +testcase tc_array[] = { + {"utc_http_session_create_p", utc_http_session_create_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_create_n", utc_http_session_create_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_destroy_n", utc_http_session_destroy_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_destroy_p", utc_http_session_destroy_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_set_auto_redirection_n", utc_http_session_set_auto_redirection_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_set_auto_redirection_p", utc_http_session_set_auto_redirection_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_get_auto_redirection_n", utc_http_session_get_auto_redirection_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_get_auto_redirection_p", utc_http_session_get_auto_redirection_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_get_active_transaction_count_n", utc_http_session_get_active_transaction_count_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_get_active_transaction_count_p", utc_http_session_get_active_transaction_count_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_get_max_transaction_count_n", utc_http_session_get_max_transaction_count_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_get_max_transaction_count_p", utc_http_session_get_max_transaction_count_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_open_transaction_n", utc_http_session_open_transaction_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_open_transaction_p", utc_http_session_open_transaction_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_destroy_n", utc_http_transaction_destroy_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_destroy_p", utc_http_transaction_destroy_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_progress_cb_n", utc_http_transaction_set_progress_cb_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_progress_cb_p", utc_http_transaction_set_progress_cb_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_received_header_cb_n", utc_http_transaction_set_received_header_cb_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_received_header_cb_p", utc_http_transaction_set_received_header_cb_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_received_body_cb_n", utc_http_transaction_set_received_body_cb_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_received_body_cb_p", utc_http_transaction_set_received_body_cb_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_uploaded_cb_n", utc_http_transaction_set_uploaded_cb_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_uploaded_cb_p", utc_http_transaction_set_uploaded_cb_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_completed_cb_n", utc_http_transaction_set_completed_cb_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_completed_cb_p", utc_http_transaction_set_completed_cb_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_aborted_cb_n", utc_http_transaction_set_aborted_cb_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_aborted_cb_p", utc_http_transaction_set_aborted_cb_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_timeout_n", utc_http_transaction_set_timeout_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_timeout_p", utc_http_transaction_set_timeout_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_get_timeout_n", utc_http_transaction_get_timeout_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_get_timeout_p", utc_http_transaction_get_timeout_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_interface_name_n", utc_http_transaction_set_interface_name_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_interface_name_p", utc_http_transaction_set_interface_name_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_get_interface_name_n", utc_http_transaction_get_interface_name_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_get_interface_name_p", utc_http_transaction_get_interface_name_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_ready_to_write_n", utc_http_transaction_set_ready_to_write_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_ready_to_write_p", utc_http_transaction_set_ready_to_write_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_get_server_certificate_verification_n", utc_http_transaction_get_server_certificate_verification_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_get_server_certificate_verification_p", utc_http_transaction_get_server_certificate_verification_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_server_certificate_verification_n", utc_http_transaction_set_server_certificate_verification_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_server_certificate_verification_p", utc_http_transaction_set_server_certificate_verification_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_destroy_all_transactions_n", utc_http_session_destroy_all_transactions_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_destroy_all_transactions_p", utc_http_session_destroy_all_transactions_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_header_add_field_n", utc_http_transaction_header_add_field_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_header_add_field_p", utc_http_transaction_header_add_field_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_header_remove_field_n", utc_http_transaction_header_remove_field_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_header_remove_field_p", utc_http_transaction_header_remove_field_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_header_get_field_value_n", utc_http_transaction_header_get_field_value_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_header_get_field_value_p", utc_http_transaction_header_get_field_value_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_method_n", utc_http_transaction_request_set_method_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_method_p", utc_http_transaction_request_set_method_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_method_n", utc_http_transaction_request_get_method_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_method_p", utc_http_transaction_request_get_method_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_version_n", utc_http_transaction_request_set_version_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_version_p", utc_http_transaction_request_set_version_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_version_n", utc_http_transaction_request_get_version_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_version_p", utc_http_transaction_request_get_version_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_uri_n", utc_http_transaction_request_set_uri_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_uri_p", utc_http_transaction_request_set_uri_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_uri_n", utc_http_transaction_request_get_uri_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_uri_p", utc_http_transaction_request_get_uri_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_accept_encoding_n", utc_http_transaction_request_set_accept_encoding_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_accept_encoding_p", utc_http_transaction_request_set_accept_encoding_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_accept_encoding_n", utc_http_transaction_request_get_accept_encoding_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_accept_encoding_p", utc_http_transaction_request_get_accept_encoding_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_cookie_n", utc_http_transaction_request_set_cookie_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_cookie_p", utc_http_transaction_request_set_cookie_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_cookie_n", utc_http_transaction_request_get_cookie_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_cookie_p", utc_http_transaction_request_get_cookie_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_write_body_n", utc_http_transaction_request_write_body_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_write_body_p", utc_http_transaction_request_write_body_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_submit_n", utc_http_transaction_submit_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_submit_p", utc_http_transaction_submit_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_deinit_p", utc_http_deinit_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_deinit_n", utc_http_deinit_n, utc_http_startup, utc_http_cleanup}, +}; + +#endif // __TCT_CONNECTION_CORE_H__ diff --git a/src/utc/http/tct-http-core_wearable.h b/src/utc/http/tct-http-core_wearable.h new file mode 100755 index 0000000..68f274d --- /dev/null +++ b/src/utc/http/tct-http-core_wearable.h @@ -0,0 +1,180 @@ +// +// 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_CONNECTION_CORE_H__ +#define __TCT_CONNECTION_CORE_H__ + +#include "testcase.h" +#include "tct_common.h" + +extern void utc_http_startup(void); +extern void utc_http_cleanup(void); +extern int utc_http_session_create_p(void); +extern int utc_http_session_create_n(void); +extern int utc_http_session_destroy_n(void); +extern int utc_http_session_destroy_p(void); +extern int utc_http_session_set_auto_redirection_n(void); +extern int utc_http_session_set_auto_redirection_p(void); +extern int utc_http_session_get_auto_redirection_n(void); +extern int utc_http_session_get_auto_redirection_p(void); +extern int utc_http_session_get_active_transaction_count_n(void); +extern int utc_http_session_get_active_transaction_count_p(void); +extern int utc_http_session_get_max_transaction_count_n(void); +extern int utc_http_session_get_max_transaction_count_p(void); +extern int utc_http_session_open_transaction_n(void); +extern int utc_http_session_open_transaction_p(void); +extern int utc_http_transaction_destroy_n(void); +extern int utc_http_transaction_destroy_p(void); +extern int utc_http_transaction_set_progress_cb_n(void); +extern int utc_http_transaction_set_progress_cb_p(void); +extern int utc_http_transaction_set_received_header_cb_n(void); +extern int utc_http_transaction_set_received_header_cb_p(void); +extern int utc_http_transaction_set_received_body_cb_n(void); +extern int utc_http_transaction_set_received_body_cb_p(void); +extern int utc_http_transaction_set_uploaded_cb_n(void); +extern int utc_http_transaction_set_uploaded_cb_p(void); +extern int utc_http_transaction_set_completed_cb_n(void); +extern int utc_http_transaction_set_completed_cb_p(void); +extern int utc_http_transaction_set_aborted_cb_n(void); +extern int utc_http_transaction_set_aborted_cb_p(void); +extern int utc_http_transaction_set_timeout_n(void); +extern int utc_http_transaction_set_timeout_p(void); +extern int utc_http_transaction_get_timeout_n(void); +extern int utc_http_transaction_get_timeout_p(void); +extern int utc_http_transaction_set_interface_name_n(void); +extern int utc_http_transaction_set_interface_name_p(void); +extern int utc_http_transaction_get_interface_name_n(void); +extern int utc_http_transaction_get_interface_name_p(void); +extern int utc_http_transaction_set_ready_to_write_n(void); +extern int utc_http_transaction_set_ready_to_write_p(void); +extern int utc_http_transaction_get_server_certificate_verification_n(void); +extern int utc_http_transaction_get_server_certificate_verification_p(void); +extern int utc_http_transaction_set_server_certificate_verification_n(void); +extern int utc_http_transaction_set_server_certificate_verification_p(void); +extern int utc_http_session_destroy_all_transactions_n(void); +extern int utc_http_session_destroy_all_transactions_p(void); +extern int utc_http_transaction_header_add_field_n(void); +extern int utc_http_transaction_header_add_field_p(void); +extern int utc_http_transaction_header_remove_field_n(void); +extern int utc_http_transaction_header_remove_field_p(void); +extern int utc_http_transaction_header_get_field_value_n(void); +extern int utc_http_transaction_header_get_field_value_p(void); +extern int utc_http_transaction_request_set_method_n(void); +extern int utc_http_transaction_request_set_method_p(void); +extern int utc_http_transaction_request_get_method_n(void); +extern int utc_http_transaction_request_get_method_p(void); +extern int utc_http_transaction_request_set_version_n(void); +extern int utc_http_transaction_request_set_version_p(void); +extern int utc_http_transaction_request_get_version_n(void); +extern int utc_http_transaction_request_get_version_p(void); +extern int utc_http_transaction_request_set_uri_n(void); +extern int utc_http_transaction_request_set_uri_p(void); +extern int utc_http_transaction_request_get_uri_n(void); +extern int utc_http_transaction_request_get_uri_p(void); +extern int utc_http_transaction_request_set_accept_encoding_n(void); +extern int utc_http_transaction_request_set_accept_encoding_p(void); +extern int utc_http_transaction_request_get_accept_encoding_n(void); +extern int utc_http_transaction_request_get_accept_encoding_p(void); +extern int utc_http_transaction_request_set_cookie_n(void); +extern int utc_http_transaction_request_set_cookie_p(void); +extern int utc_http_transaction_request_get_cookie_n(void); +extern int utc_http_transaction_request_get_cookie_p(void); +extern int utc_http_transaction_request_write_body_n(void); +extern int utc_http_transaction_request_write_body_p(void); +extern int utc_http_transaction_submit_n(void); +extern int utc_http_transaction_submit_p(void); +extern int utc_http_deinit_n(void); +extern int utc_http_deinit_p(void); + +testcase tc_array[] = { + {"utc_http_session_create_p", utc_http_session_create_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_create_n", utc_http_session_create_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_destroy_n", utc_http_session_destroy_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_destroy_p", utc_http_session_destroy_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_set_auto_redirection_n", utc_http_session_set_auto_redirection_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_set_auto_redirection_p", utc_http_session_set_auto_redirection_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_get_auto_redirection_n", utc_http_session_get_auto_redirection_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_get_auto_redirection_p", utc_http_session_get_auto_redirection_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_get_active_transaction_count_n", utc_http_session_get_active_transaction_count_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_get_active_transaction_count_p", utc_http_session_get_active_transaction_count_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_get_max_transaction_count_n", utc_http_session_get_max_transaction_count_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_get_max_transaction_count_p", utc_http_session_get_max_transaction_count_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_open_transaction_n", utc_http_session_open_transaction_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_open_transaction_p", utc_http_session_open_transaction_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_destroy_n", utc_http_transaction_destroy_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_destroy_p", utc_http_transaction_destroy_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_progress_cb_n", utc_http_transaction_set_progress_cb_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_progress_cb_p", utc_http_transaction_set_progress_cb_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_received_header_cb_n", utc_http_transaction_set_received_header_cb_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_received_header_cb_p", utc_http_transaction_set_received_header_cb_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_received_body_cb_n", utc_http_transaction_set_received_body_cb_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_received_body_cb_p", utc_http_transaction_set_received_body_cb_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_uploaded_cb_n", utc_http_transaction_set_uploaded_cb_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_uploaded_cb_p", utc_http_transaction_set_uploaded_cb_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_completed_cb_n", utc_http_transaction_set_completed_cb_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_completed_cb_p", utc_http_transaction_set_completed_cb_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_aborted_cb_n", utc_http_transaction_set_aborted_cb_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_aborted_cb_p", utc_http_transaction_set_aborted_cb_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_timeout_n", utc_http_transaction_set_timeout_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_timeout_p", utc_http_transaction_set_timeout_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_get_timeout_n", utc_http_transaction_get_timeout_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_get_timeout_p", utc_http_transaction_get_timeout_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_interface_name_n", utc_http_transaction_set_interface_name_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_interface_name_p", utc_http_transaction_set_interface_name_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_get_interface_name_n", utc_http_transaction_get_interface_name_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_get_interface_name_p", utc_http_transaction_get_interface_name_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_ready_to_write_n", utc_http_transaction_set_ready_to_write_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_ready_to_write_p", utc_http_transaction_set_ready_to_write_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_get_server_certificate_verification_n", utc_http_transaction_get_server_certificate_verification_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_get_server_certificate_verification_p", utc_http_transaction_get_server_certificate_verification_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_server_certificate_verification_n", utc_http_transaction_set_server_certificate_verification_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_set_server_certificate_verification_p", utc_http_transaction_set_server_certificate_verification_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_destroy_all_transactions_n", utc_http_session_destroy_all_transactions_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_session_destroy_all_transactions_p", utc_http_session_destroy_all_transactions_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_header_add_field_n", utc_http_transaction_header_add_field_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_header_add_field_p", utc_http_transaction_header_add_field_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_header_remove_field_n", utc_http_transaction_header_remove_field_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_header_remove_field_p", utc_http_transaction_header_remove_field_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_header_get_field_value_n", utc_http_transaction_header_get_field_value_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_header_get_field_value_p", utc_http_transaction_header_get_field_value_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_method_n", utc_http_transaction_request_set_method_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_method_p", utc_http_transaction_request_set_method_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_method_n", utc_http_transaction_request_get_method_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_method_p", utc_http_transaction_request_get_method_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_version_n", utc_http_transaction_request_set_version_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_version_p", utc_http_transaction_request_set_version_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_version_n", utc_http_transaction_request_get_version_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_version_p", utc_http_transaction_request_get_version_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_uri_n", utc_http_transaction_request_set_uri_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_uri_p", utc_http_transaction_request_set_uri_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_uri_n", utc_http_transaction_request_get_uri_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_uri_p", utc_http_transaction_request_get_uri_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_accept_encoding_n", utc_http_transaction_request_set_accept_encoding_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_accept_encoding_p", utc_http_transaction_request_set_accept_encoding_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_accept_encoding_n", utc_http_transaction_request_get_accept_encoding_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_accept_encoding_p", utc_http_transaction_request_get_accept_encoding_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_cookie_n", utc_http_transaction_request_set_cookie_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_set_cookie_p", utc_http_transaction_request_set_cookie_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_cookie_n", utc_http_transaction_request_get_cookie_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_get_cookie_p", utc_http_transaction_request_get_cookie_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_write_body_n", utc_http_transaction_request_write_body_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_request_write_body_p", utc_http_transaction_request_write_body_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_submit_n", utc_http_transaction_submit_n, utc_http_startup, utc_http_cleanup}, + {"utc_http_transaction_submit_p", utc_http_transaction_submit_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_deinit_p", utc_http_deinit_p, utc_http_startup, utc_http_cleanup}, + {"utc_http_deinit_n", utc_http_deinit_n, utc_http_startup, utc_http_cleanup}, +}; + +#endif // __TCT_CONNECTION_CORE_H__ diff --git a/src/utc/http/utc-network-http.c b/src/utc/http/utc-network-http.c new file mode 100755 index 0000000..4085b1e --- /dev/null +++ b/src/utc/http/utc-network-http.c @@ -0,0 +1,2244 @@ +// +// 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 "assert.h" +#include +#include +#include +#include +#include +#include +#include + +#define FREE_RESOURCE(var)\ + if (var != NULL) {\ + g_free(var);\ + var = NULL;\ + } + +http_session_h session = NULL; +http_transaction_h transaction = NULL; + +static GMainLoop *g_pMainLoop; +static int g_CallbackRet = HTTP_ERROR_NONE; +static bool is_init = false; +#ifdef WEARABLE +static bool g_internet_supported = true; +#endif + +void __transaction_header_cb(http_transaction_h transaction, char *header, size_t header_len, void *user_data) +{ +} + +void __transaction_body_cb(http_transaction_h transaction, char *body, size_t size, size_t nmemb, void *user_data) +{ +} + +void __transaction_write_cb(http_transaction_h transaction, int recommended_chunk_size, void *user_data) +{ +} + +void __transaction_completed_cb(http_transaction_h transaction, void *user_data) +{ + int ret; + http_status_code_e status = 0; + + ret = http_transaction_response_get_status_code(transaction, &status); + + if (status < HTTP_STATUS_BAD_REQUEST) + g_CallbackRet = HTTP_ERROR_NONE; + else + g_CallbackRet = HTTP_ERROR_OPERATION_FAILED; + + if (g_pMainLoop) + g_main_loop_quit(g_pMainLoop); +} + +void __transaction_aborted_cb(http_transaction_h transaction, int reason, void *user_data) +{ +} + +void __transaction_progress_cb(http_transaction_h transaction, double download_total, double download_now, double upload_total, double upload_now, void *user_data) +{ +} + +void _register_callbacks(http_transaction_h transaction) +{ + http_transaction_set_received_header_cb(transaction, __transaction_header_cb, NULL); + http_transaction_set_received_body_cb(transaction, __transaction_body_cb, NULL); + http_transaction_set_uploaded_cb(transaction, __transaction_write_cb, NULL); + http_transaction_set_completed_cb(transaction, __transaction_completed_cb, NULL); + http_transaction_set_aborted_cb(transaction, __transaction_aborted_cb, NULL); +} + + +/** + * @function utc_network_http_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_http_startup(void) +{ + int ret; + +#ifdef WEARABLE + system_info_get_platform_bool("http://tizen.org/feature/network.internet", &g_internet_supported); +#endif + if (!is_init) { + ret = http_init(); + if (ret != HTTP_ERROR_NONE) + fprintf(stderr, "http_init() error at %s:%d\n", __FILE__, __LINE__); + + is_init = true; + } + + ret = http_session_create(HTTP_SESSION_MODE_NORMAL, &session); + if (ret != HTTP_ERROR_NONE) + fprintf(stderr, "http_session_create() error at %s:%d\n", __FILE__, __LINE__); + + if (transaction == NULL) { + ret = http_session_open_transaction(session, HTTP_METHOD_GET, &transaction); + if (ret != HTTP_ERROR_NONE) + fprintf(stderr, "http_session_open_transaction() error at %s:%d\n", __FILE__, __LINE__); + } +} + +/** + * @function utc_network_http_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void utc_http_cleanup(void) +{ + int ret; + + if (transaction) { + http_transaction_destroy(transaction); + transaction = NULL; + } + + if (session) { + http_session_destroy(session); + session = NULL; + } + + if (is_init) { + ret = http_deinit(); + if (ret != HTTP_ERROR_NONE) + fprintf(stderr, "http_deinit error at %s:%d\n", __FILE__, __LINE__); + is_init = false; + } +} + +/** + * @testcase utc_http_sesssion_create_p + * @since_tizen 3.0 + * @type Positive + * @description Creates the Http session handle. + * @scenario Invoking http_session_create with valid parameter. + */ +int utc_http_session_create_p(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_create(HTTP_SESSION_MODE_NORMAL, &session); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + if (transaction) { + ret = http_transaction_destroy(transaction); + assert_eq(ret, HTTP_ERROR_NONE); + transaction = NULL; + } + + if (session) { + ret = http_session_destroy(session); + assert_eq(ret, HTTP_ERROR_NONE); + session = NULL; + } + + ret = http_session_create(HTTP_SESSION_MODE_NORMAL, &session); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + + +/** + * @testcase utc_http_session_create_n + * @since_tizen 3.0 + * @type Negative + * @description Creates the Http session handle.. + * @scenario Invoking http_session_create with invalid parameter. + */ +int utc_http_session_create_n(void) +{ + int ret; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_create(HTTP_SESSION_MODE_NORMAL, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_session_create(HTTP_SESSION_MODE_NORMAL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_session_destroy_n + * @since_tizen 3.0 + * @type Negative + * @description Destroys the Http session handle. + * @scenario Invoking http_session_destroy with invalid parameter. + */ +int utc_http_session_destroy_n(void) +{ + int ret; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_destroy(NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_session_destroy(NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_session_destroy_p + * @since_tizen 3.0 + * @type Negative + * @description Destroys the Http session handle. + * @scenario Invoking http_session_destroy with valid parameter. + */ +int utc_http_session_destroy_p(void) +{ + int ret; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_destroy(NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_destroy(transaction); + assert_eq(ret, HTTP_ERROR_NONE); + transaction = NULL; + + ret = http_session_destroy(session); + session = NULL; + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_session_set_auto_redirection_n + * @since_tizen 3.0 + * @type Negative + * @description Sets the value to redirect the HTTP request automatically. + * @scenario Invoking http_session_set_auto_redirection with invalid parameter. + */ +int utc_http_session_set_auto_redirection_n(void) +{ + int ret; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_set_auto_redirection(HTTP_SESSION_MODE_NORMAL, &session); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_session_set_auto_redirection(NULL, true); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_session_set_auto_redirection_p + * @since_tizen 3.0 + * @type Positive + * @description Sets the value to redirect the HTTP request automatically. + * @scenario Invoking http_session_set_auto_redirection with valid parameter. + */ +int utc_http_session_set_auto_redirection_p(void) +{ + int ret; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_set_auto_redirection(session, true); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_session_set_auto_redirection(session, true); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_session_get_auto_redirection_n + * @since_tizen 3.0 + * @type Negative + * @description Gets the auto redirection for the HTTP request. + * @scenario Invoking http_session_get_auto_redirection with invalid parametner. + */ +int utc_http_session_get_auto_redirection_n(void) +{ + int ret; + bool auto_redirect; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_get_auto_redirection(session, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_session_get_auto_redirection(NULL, &auto_redirect); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_session_get_auto_redirection(session, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_session_get_auto_redirection(NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_session_get_auto_redirection_n + * @since_tizen 3.0 + * @type Positive + * @description Gets the auto redirection for the HTTP request. + * @scenario Invoking http_session_get_auto_redirection with valid parametner. + */ +int utc_http_session_get_auto_redirection_p(void) +{ + int ret; + bool auto_redirect; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_get_auto_redirection(session, &auto_redirect); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_session_get_auto_redirection(session, &auto_redirect); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_session_get_active_transaction_count_n + * @since_tizen 3.0 + * @type Negative + * @description Gets the number of active transactions in the current session. + * @scenario Invoking http_seession_get_active_transaction_count with invalid parameter. + */ +int utc_http_session_get_active_transaction_count_n(void) +{ + int ret; + int cnt; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_get_active_transaction_count(session, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_session_get_active_transaction_count(session, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_session_get_active_transaction_count(NULL, &cnt); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_session_get_active_transaction_count(NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_session_get_active_transaction_count_p + * @since_tizen 3.0 + * @type Positve + * @description Gets the number of active transactions in the current session. + * @scenario Invoking http_seession_get_active_transaction_count with valid parameter. + */ +int utc_http_session_get_active_transaction_count_p(void) +{ + int ret; + int cnt; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_get_active_transaction_count(session, &cnt); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_session_get_active_transaction_count(session, &cnt); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_session_get_max_transaction_count_n + * @since_tizen 3.0 + * @type Negative + * @description Gets the maximum number of transactions for the current session. + * @scenario Invoking http_session_get_mac_transaction_count with invalid parameter. + */ +int utc_http_session_get_max_transaction_count_n(void) +{ + int ret, cnt; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_get_max_transaction_count(session, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_session_get_max_transaction_count(session, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_session_get_max_transaction_count(NULL, &cnt); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_session_get_max_transaction_count(NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_session_get_max_transaction_count_p + * @since_tizen 3.0 + * @type Positive + * @description Gets the maximum number of transactions for the current session. + * @scenario Invoking http_session_get_mac_transaction_count with valid parameter. + */ +int utc_http_session_get_max_transaction_count_p(void) +{ + int ret; + int cnt; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_get_max_transaction_count(session, &cnt); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_session_get_max_transaction_count(session, &cnt); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + + +/** + * @testcase utc_http_session_open_transaction_n + * @since_tizen 3.0 + * @type Negative + * @description Opens Http transaction from the Http Session. + * @scenario Invoking http_session_open_transaction with invalid parameter. + */ +int utc_http_session_open_transaction_n(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_open_transaction(NULL, HTTP_METHOD_GET, &transaction); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_session_open_transaction(NULL, HTTP_METHOD_GET, &transaction); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_session_open_transaction_p + * @since_tizen 3.0 + * @type Positive + * @description Opens Http transaction from the Http Session. + * @scenario Invoking http_session_open_transaction with valid parameter. + */ +int utc_http_session_open_transaction_p(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_open_transaction(session, HTTP_METHOD_GET, &transaction); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + if (transaction) { + ret = http_transaction_destroy(transaction); + transaction = NULL; + } + ret = http_session_open_transaction(session, HTTP_METHOD_GET, &transaction); + assert_eq(ret, HTTP_ERROR_NONE); + + if (transaction) { + ret = http_transaction_destroy(transaction); + transaction = NULL; + } + ret = http_session_open_transaction(session, HTTP_METHOD_OPTIONS, &transaction); + assert_eq(ret, HTTP_ERROR_NONE); + + if (transaction) { + ret = http_transaction_destroy(transaction); + transaction = NULL; + } + ret = http_session_open_transaction(session, HTTP_METHOD_HEAD, &transaction); + assert_eq(ret, HTTP_ERROR_NONE); + + if (transaction) { + ret = http_transaction_destroy(transaction); + transaction = NULL; + } + ret = http_session_open_transaction(session, HTTP_METHOD_DELETE, &transaction); + assert_eq(ret, HTTP_ERROR_NONE); + + if (transaction) { + ret = http_transaction_destroy(transaction); + transaction = NULL; + } + ret = http_session_open_transaction(session, HTTP_METHOD_TRACE, &transaction); + assert_eq(ret, HTTP_ERROR_NONE); + + if (transaction) { + ret = http_transaction_destroy(transaction); + transaction = NULL; + } + ret = http_session_open_transaction(session, HTTP_METHOD_POST, &transaction); + assert_eq(ret, HTTP_ERROR_NONE); + + if (transaction) { + ret = http_transaction_destroy(transaction); + transaction = NULL; + } + ret = http_session_open_transaction(session, HTTP_METHOD_PUT, &transaction); + assert_eq(ret, HTTP_ERROR_NONE); + + if (transaction) { + ret = http_transaction_destroy(transaction); + transaction = NULL; + } + ret = http_session_open_transaction(session, HTTP_METHOD_CONNECT, &transaction); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_destroy_n + * @since_tizen 3.0 + * @type Negative + * @description Closes the http transaction handle. + * @scenario Invoking http_transaction_destroy with invalid parameter. + */ +int utc_http_transaction_destroy_n(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_destroy(NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_destroy(NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + return 0; +} + +/** + * @testcase utc_http_transaction_destroy_p + * @since_tizen 3.0 + * @type Positive + * @description Closes the http transaction handle. + * @scenario Invoking http_transaction_destroy with valid parameter. + */ +int utc_http_transaction_destroy_p(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_destroy(transaction); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_destroy(transaction); + transaction = NULL; + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_progress_cb_n + * @since_tizen 3.0 + * @type Negative + * @description Registers the progress callbacks. + * @scenario Invoking http_transaction_set_progress_cb with invalid parameter. + */ +int utc_http_transaction_set_progress_cb_n(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_progress_cb(NULL, __transaction_progress_cb, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_progress_cb(NULL, __transaction_progress_cb, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_set_progress_cb(transaction, NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_progress_cb_p + * @since_tizen 3.0 + * @type Positive + * @description Registers the progress callbacks. + * @scenario Invoking http_transaction_set_progress_cb with valid parameter. + */ +int utc_http_transaction_set_progress_cb_p(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_progress_cb(transaction, __transaction_progress_cb, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_progress_cb(transaction, __transaction_progress_cb, NULL); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_received_header_cb_n + * @since_tizen 3.0 + * @type Negative + * @description Registers callback called when receive header. + * @scenario Invoking http_transaction_set_received_header_cb with invalid parameter. + */ +int utc_http_transaction_set_received_header_cb_n(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_received_header_cb(NULL, __transaction_progress_cb, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_received_header_cb(NULL, __transaction_progress_cb, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_set_received_header_cb(transaction, NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + return 0; +} + +/** + * @testcase utc_http_transaction_set_received_header_cb_p + * @since_tizen 3.0 + * @type Positive + * @description Registers callback called when receive header. + * @scenario Invoking http_transaction_set_received_header_cb with valid parameter. + */ +int utc_http_transaction_set_received_header_cb_p(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_received_header_cb(transaction, __transaction_header_cb, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_received_header_cb(transaction, __transaction_header_cb, NULL); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_received_body_cb_n + * @since_tizen 3.0 + * @type Negative + * @description Registers callback called when receive body. + * @scenario Invoking http_transaction_set_received_body_cb with invalid parameter. + */ +int utc_http_transaction_set_received_body_cb_n(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_received_body_cb(NULL, __transaction_body_cb, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_received_body_cb(NULL, __transaction_body_cb, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_set_received_body_cb(transaction, NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + return 0; +} + +/** + * @testcase utc_http_transaction_set_received_body_cb_p + * @since_tizen 3.0 + * @type Positive + * @description Registers callback called when receive body. + * @scenario Invoking http_transaction_set_received_body_cb with valid parameter. + */ +int utc_http_transaction_set_received_body_cb_p(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_received_body_cb(transaction, __transaction_body_cb, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_received_body_cb(transaction, __transaction_body_cb, NULL); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + + + +/** + * @testcase utc_http_transaction_set_uploaded_cb_n + * @since_tizen 3.0 + * @type Negative + * @description Registers callback called when write data. + * @scenario Invoking http_transaction_set_uploaded_cb with invalid parameter. + */ +int utc_http_transaction_set_uploaded_cb_n(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_uploaded_cb(NULL, __transaction_write_cb, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_uploaded_cb(NULL, __transaction_write_cb, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_set_uploaded_cb(transaction, NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + return 0; +} + +/** + * @testcase utc_http_transaction_set_uploaded_cb_p + * @since_tizen 3.0 + * @type Positive + * @description Registers callback called when write data. + * @scenario Invoking http_transaction_set_uploaded_cb with valid parameter. + */ +int utc_http_transaction_set_uploaded_cb_p(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_uploaded_cb(transaction, __transaction_write_cb, NULL); + + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_uploaded_cb(transaction, __transaction_write_cb, NULL); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_completed_cb_n + * @since_tizen 3.0 + * @type Negative + * @description Registers callback called when transaction is completed. + * @scenario Invoking http_transaction_set_completed_cb with invalid parameter. + */ +int utc_http_transaction_set_completed_cb_n(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_completed_cb(NULL, __transaction_completed_cb, NULL); + + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_completed_cb(NULL, __transaction_completed_cb, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_set_completed_cb(transaction, NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + return 0; +} + +/** + * @testcase utc_http_transaction_set_completed_cb_p + * @since_tizen 3.0 + * @type Positive + * @description Registers callback called when transaction is completed. + * @scenario Invoking http_transaction_set_completed_cb with valid parameter. + */ +int utc_http_transaction_set_completed_cb_p(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_completed_cb(transaction, __transaction_completed_cb, NULL); + + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_completed_cb(transaction, __transaction_completed_cb, NULL); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_aborted_cb_n + * @since_tizen 3.0 + * @type Negative + * @description Registers callback called when transaction is aborted. + * @scenario Invoking http_transaction_set_aborted_cb with invalid parameter. + */ +int utc_http_transaction_set_aborted_cb_n(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_aborted_cb(NULL, __transaction_aborted_cb, NULL); + + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_aborted_cb(NULL, __transaction_aborted_cb, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_set_aborted_cb(transaction, NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_set_aborted_cb(NULL, NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_aborted_cb_p + * @since_tizen 3.0 + * @type Positive + * @description Registers callback called when transaction is aborted. + * @scenario Invoking http_transaction_set_aborted_cb with valid parameter. + */ +int utc_http_transaction_set_aborted_cb_p(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_aborted_cb(transaction, __transaction_aborted_cb, NULL); + + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_aborted_cb(transaction, __transaction_aborted_cb, NULL); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_timeout_n + * @since_tizen 3.0 + * @type Negative + * @description Sets the timeout in seconds that is the timeout for waiting the transaction. + * @scenario Invoking http_transaction_set_timeout with invalid parameter. + */ +int utc_http_transaction_set_timeout_n(void) +{ + int ret; + int timeout = 10; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_timeout(NULL, timeout); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_timeout(NULL, timeout); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_timeout_p + * @since_tizen 3.0 + * @type Positive + * @description Sets the timeout in seconds that is the timeout for waiting the transaction. + * @scenario Invoking http_transaction_set_timeout with valid parameter. + */ +int utc_http_transaction_set_timeout_p(void) +{ + int ret; + int timeout = 10; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_timeout(transaction, timeout); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_timeout(transaction, timeout); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_get_timeout_n + * @since_tizen 3.0 + * @type Negative + * @description Gets the time out in seconds for the transaction. + * @scenario Invoking http_transaction_get_timeout with invalid parameter. + */ +int utc_http_transaction_get_timeout_n(void) +{ + int ret; + int timeout; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_get_timeout(NULL, &timeout); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_get_timeout(NULL, &timeout); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_get_timeout_p + * @since_tizen 3.0 + * @type Positive + * @description Gets the time out in seconds for the transaction. + * @scenario Invoking http_transaction_get_timeout with valid parameter. + */ +int utc_http_transaction_get_timeout_p(void) +{ + int ret; + int timeout; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_get_timeout(transaction, &timeout); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_get_timeout(transaction, &timeout); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_interface_name_n + * @since_tizen 3.0 + * @type Negative + * @description Sets the interface name. + * @scenario Invoking http_transaction_set_interface_name with invalid parameter. + */ +int utc_http_transaction_set_interface_name_n(void) +{ + int ret; + const char interface_name[10] = "wlan0"; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_interface_name(transaction, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_interface_name(transaction, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_set_interface_name(NULL, interface_name); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_set_interface_name(NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_interface_name_p + * @since_tizen 3.0 + * @type Positive + * @description Sets the interface name. + * @scenario Invoking http_transaction_set_interface_name with valid parameter. + */ +int utc_http_transaction_set_interface_name_p(void) +{ + int ret; + const char interface_name[10] = "wlan0"; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_interface_name(transaction, interface_name); + + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_interface_name(transaction, interface_name); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_get_interface_name_n + * @since_tizen 3.0 + * @type Negative + * @description Gets the interface name. + * @scenario Invoking http_transaction_get_interface_name with invalid parameter. + */ +int utc_http_transaction_get_interface_name_n(void) +{ + int ret; + const char interface_name[10]; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_get_interface_name(NULL, &interface_name); + + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_get_interface_name(NULL, &interface_name); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_get_interface_name_p + * @since_tizen 3.0 + * @type Positive + * @description Gets the interface name. + * @scenario Invoking http_transaction_get_interface_name with valid parameter. + */ +int utc_http_transaction_get_interface_name_p(void) +{ + int ret; + char *interface_name; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_get_interface_name(transaction, &interface_name); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_get_interface_name(transaction, &interface_name); + assert_eq(ret, HTTP_ERROR_NONE); + + if (interface_name) + free(interface_name); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_ready_to_write_n + * @since_tizen 3.0 + * @type Negative + * @description Sets ready to write event for a transaction. + * @scenario Invoking http_transaction_set_ready_to_write with invalid parameter. + */ +int utc_http_transaction_set_ready_to_write_n(void) +{ + int ret; + bool ready = true; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_ready_to_write(NULL, ready); + + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_ready_to_write(NULL, ready); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_ready_to_write_p + * @since_tizen 3.0 + * @type Positive + * @description Sets ready to write event for a transaction. + * @scenario Invoking http_transaction_set_ready_to_write with valid parameter. + */ +int utc_http_transaction_set_ready_to_write_p(void) +{ + int ret; + bool ready = true; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_ready_to_write(transaction, ready); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_ready_to_write(transaction, ready); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_get_server_certificate_verification_n + * @since_tizen 3.0 + * @type Negative + * @description Gets the flag to verify a server certificate. + * @scenario Invoking http_transaction_get_server_certificate_verification with invalid parameter. + */ +int utc_http_transaction_get_server_certificate_verification_n(void) +{ + int ret; + bool verify; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_get_server_certificate_verification(NULL, &verify); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_get_server_certificate_verification(NULL, &verify); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_get_server_certificate_verification_p + * @since_tizen 3.0 + * @type Positive + * @description Gets the flag to verify a server certificate. + * @scenario Invoking http_transaction_get_server_certificate_verification with valid parameter. + */ +int utc_http_transaction_get_server_certificate_verification_p(void) +{ + int ret; + bool verify; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_get_server_certificate_verification(transaction, &verify); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_get_server_certificate_verification(transaction, &verify); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_server_certificate_verification_n + * @since_tizen 3.0 + * @type Negative + * @description Sets the flag to verify a server certificate. + * @scenario Invoking http_transaction_set_server_certificate_verification with invalid parameter. + */ +int utc_http_transaction_set_server_certificate_verification_n(void) +{ + int ret; + bool verify = false; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_server_certificate_verification(NULL, verify); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_server_certificate_verification(NULL, verify); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_set_server_certificate_verification_p + * @since_tizen 3.0 + * @type Positive + * @description Sets the flag to verify a server certificate. + * @scenario Invoking http_transaction_set_server_certificate_verification with valid parameter. + */ +int utc_http_transaction_set_server_certificate_verification_p(void) +{ + int ret; + bool verify = false; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_set_server_certificate_verification(transaction, verify); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_set_server_certificate_verification(transaction, verify); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_session_destroy_all_transactions_n + * @since_tizen 3.0 + * @type Negative + * @description Destroys all transaction. + * @scenario Invoking http_session_destroy_all_transactions with invalid parameter. + */ +int utc_http_session_destroy_all_transactions_n(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_destroy_all_transactions(NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_session_destroy_all_transactions(NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_session_destroy_all_transactions_p + * @since_tizen 3.0 + * @type Positive + * @description Destroys all transaction. + * @scenario Invoking http_session_destroy_all_transactions with valid parameter. + */ +int utc_http_session_destroy_all_transactions_p(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_session_destroy_all_transactions(session); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_session_destroy_all_transactions(session); + assert_eq(ret, HTTP_ERROR_NONE); + + if (transaction) + transaction = NULL; + + return 0; +} + +/** + * @testcase utc_http_transaction_header_add_field_n + * @since_tizen 3.0 + * @type Negative + * @description Adds a named field to header. + * @scenario Invoking http_transaction_header_add_field with invalid parameter. + */ +int utc_http_transaction_header_add_field_n(void) +{ + int ret; + const char field[20] = "Content-Length"; + const char value[10] = "10"; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_header_add_field(transaction, field, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_header_add_field(transaction, field, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_header_add_field(transaction, NULL, value); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_header_add_field(NULL, field, value); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_header_add_field(NULL, NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_header_add_field_p + * @since_tizen 3.0 + * @type Positive + * @description Adds a named field to header. + * @scenario Invoking http_transaction_header_add_field with valid parameter. + */ +int utc_http_transaction_header_add_field_p(void) +{ + int ret; + const char field[20] = "Content-Length"; + const char value[10] = "10"; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_header_add_field(transaction, field, value); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_header_add_field(transaction, field, value); + assert_eq(ret, HTTP_ERROR_NONE); + return 0; +} + +/** + * @testcase utc_http_transaction_header_remove_field_n + * @since_tizen 3.0 + * @type Negative + * @description Removes the named field from header. + * @scenario Invoking http_transaction_header_remove_field with invalid parameter. + */ +int utc_http_transaction_header_remove_field_n(void) +{ + int ret; + const char field[20] = "Content-Length"; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_header_remove_field(transaction, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_header_remove_field(transaction, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_header_remove_field(NULL, field); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_header_remove_field(NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + + return 0; +} + +/** + * @testcase utc_http_transaction_header_remove_field_p + * @since_tizen 3.0 + * @type Positive + * @description Removes the named field from header. + * @scenario Invoking http_transaction_header_remove_field with valid parameter. + */ +int utc_http_transaction_header_remove_field_p(void) +{ + int ret; + const char field[20] = "Content-Length"; + const char value[10] = "10"; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_header_add_field(transaction , field, value); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_header_add_field(transaction , field, value); + assert_eq(ret, HTTP_ERROR_NONE); + ret = http_transaction_header_remove_field(transaction, field); + assert_eq(ret, HTTP_ERROR_NONE); + return 0; +} + +/** + * @testcase utc_http_transaction_header_get_field_value_n + * @since_tizen 3.0 + * @type Negative + * @description Gets the Http Header Field value from custom header. + * @scenario Invoking http_transaction_header_get_field_value with invalid parameter. + */ +int utc_http_transaction_header_get_field_value_n(void) +{ + int ret; + const char field[20] = "Content-Length"; + char *value; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_header_get_field_value(NULL, field, &value); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_header_get_field_value(NULL, field, &value); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_header_get_field_value(transaction, NULL, &value); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_header_get_field_value(NULL, NULL, &value); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_header_get_field_value_p + * @since_tizen 3.0 + * @type Positive + * @description Gets the Http Header Field value from custom header. + * @scenario Invoking http_transaction_header_get_field_value with valid parameter. + */ +int utc_http_transaction_header_get_field_value_p(void) +{ + int ret; + const char field[20] = "Content-Length"; + char value[10]; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_header_add_field(transaction, field, "10"); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_header_add_field(transaction, field, "10"); + assert_eq(ret, HTTP_ERROR_NONE); + ret = http_transaction_header_get_field_value(transaction, field, &value); + assert_eq(ret, HTTP_ERROR_NONE); + + if (value) + free(value); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_set_method_n + * @since_tizen 3.0 + * @type Negative + * @description Sets an HTTP method of the request header. + * @scenario Invoking http_transaction_request_set_method with invalid parameter. + */ +int utc_http_transaction_request_set_method_n(void) +{ + int ret; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_set_method(NULL, HTTP_METHOD_GET); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_set_method(NULL, HTTP_METHOD_GET); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_set_method_p + * @since_tizen 3.0 + * @type Positive + * @description Sets an HTTP method of the request header. + * @scenario Invoking http_transaction_request_set_method with valid parameter. + */ +int utc_http_transaction_request_set_method_p(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_set_method(transaction, HTTP_METHOD_GET); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_set_method(transaction, HTTP_METHOD_GET); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_get_method_n + * @since_tizen 3.0 + * @type Negative + * @description Gets the Http method from request header. + * @scenario Invoking http_transaction_request_get_method with invalid parameter. + */ +int utc_http_transaction_request_get_method_n(void) +{ + int ret; + http_method_e method; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_get_method(transaction, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_get_method(transaction, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_get_method(NULL, &method); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_get_method(NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_get_method_p + * @since_tizen 3.0 + * @type Positive + * @description Gets the Http method from request header. + * @scenario Invoking http_transaction_request_get_method with valid parameter. + */ +int utc_http_transaction_request_get_method_p(void) +{ + int ret; + http_method_e method; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_get_method(transaction, &method); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_get_method(transaction, &method); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_set_version_n + * @since_tizen 3.0 + * @type Negative + * @description Sets an HTTP version of the request header. + * @scenario Invoking http_transaction_request_set_version with invalid parameter. + */ +int utc_http_transaction_request_set_version_n(void) +{ + int ret; + http_version_e version = HTTP_VERSION_1_1; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_set_version(NULL, version); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_set_version(NULL, version); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_set_version_p + * @since_tizen 3.0 + * @type Positive + * @description Sets an HTTP version of the request header. + * @scenario Invoking http_transaction_request_set_version with valid parameter. + */ +int utc_http_transaction_request_set_version_p(void) +{ + int ret; + http_version_e version = HTTP_VERSION_1_1; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_set_version(transaction, version); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_set_version(transaction, version); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_get_version_n + * @since_tizen 3.0 + * @type Negative + * @description Gets the Http version from request header. + * @scenario Invoking http_transaction_request_get_version with invalid parameter. + */ +int utc_http_transaction_request_get_version_n(void) +{ + int ret; + http_version_e version; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_get_version(transaction, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_get_version(transaction, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_get_version(NULL, &version); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_get_version(NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_get_version_p + * @since_tizen 3.0 + * @type Positive + * @description Gets the Http version from request header. + * @scenario Invoking http_transaction_request_get_version with valid parameter. + */ +int utc_http_transaction_request_get_version_p(void) +{ + int ret; + http_version_e version; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_get_version(transaction, &version); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_get_version(transaction, &version); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_set_uri_n + * @since_tizen 3.0 + * @type Negative + * @description Sets a URI of the request header. + * @scenario Invoking http_transaction_request_set_uri with invalid parameter. + */ +int utc_http_transaction_request_set_uri_n(void) +{ + int ret; + const char host_uri[100] = "http://www.tizen.org"; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_set_uri(transaction, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_set_uri(transaction, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_set_uri(NULL, host_uri); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_set_uri(NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_set_uri_p + * @since_tizen 3.0 + * @type Positive + * @description Sets a URI of the request header. + * @scenario Invoking http_transaction_request_set_uri with valid parameter. + */ +int utc_http_transaction_request_set_uri_p(void) +{ + int ret; + const char host_uri[100] = "http://www.tizen.org"; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_set_uri(transaction, host_uri); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_set_uri(transaction, host_uri); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_get_uri_n + * @since_tizen 3.0 + * @type Negative + * @description Gets the uri. + * @scenario Invoking http_transaction_request_get_uri with invalid parameter. + */ +int utc_http_transaction_request_get_uri_n(void) +{ + int ret; + char *host_uri; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_get_uri(transaction, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_get_uri(transaction, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_get_uri(NULL, &host_uri); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_get_uri(NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_get_uri_p + * @since_tizen 3.0 + * @type Positive + * @description Gets the uri. + * @scenario Invoking http_transaction_request_get_uri with valid parameter. + */ +int utc_http_transaction_request_get_uri_p(void) +{ + int ret; + char *host_uri; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_set_uri(transaction, "http://www.tizen.org"); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_set_uri(transaction, "http://www.tizen.org"); + assert_eq(ret, HTTP_ERROR_NONE); + ret = http_transaction_request_get_uri(transaction, &host_uri); + assert_eq(ret, HTTP_ERROR_NONE); + + if (host_uri) + free(host_uri); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_set_accept_encoding_n + * @since_tizen 3.0 + * @type Negative + * @description Sets the Accept-Encoding header field of HttpRequest. + * @scenario Invoking http_transaction_request_set_accept_encoding with invalid parameter. + */ +int utc_http_transaction_request_set_accept_encoding_n(void) +{ + int ret; + const char encoding[100] = "gzip, deflate"; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_set_accept_encoding(transaction, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_set_accept_encoding(transaction, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_set_accept_encoding(NULL, encoding); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_set_accept_encoding(NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + + + return 0; +} + +/** + * @testcase utc_http_transaction_request_set_accept_encoding_p + * @since_tizen 3.0 + * @type Positive + * @description Sets the Accept-Encoding header field of HttpRequest. + * @scenario Invoking http_transaction_request_set_accept_encoding with valid parameter. + */ +int utc_http_transaction_request_set_accept_encoding_p(void) +{ + int ret; + const char encoding[100] = "gzip, deflate"; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_set_accept_encoding(transaction, encoding); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_set_accept_encoding(transaction, encoding); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_get_accept_encoding_n + * @since_tizen 3.0 + * @type Negative + * @description Gets the Accept-Encoding header field of HttpRequest. + * @scenario Invoking http_transaction_request_get_accept_encoding with invalid parameter. + */ +int utc_http_transaction_request_get_accept_encoding_n(void) +{ + int ret; + char *encoding; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_get_accept_encoding(transaction, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_get_accept_encoding(transaction, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_get_accept_encoding(NULL, &encoding); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_get_accept_encoding(NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_get_accept_encoding_p + * @since_tizen 3.0 + * @type Positive + * @description Gets the Accept-Encoding header field of HttpRequest. + * @scenario Invoking http_transaction_request_get_accept_encoding with valid parameter. + */ +int utc_http_transaction_request_get_accept_encoding_p(void) +{ + int ret; + char *encoding; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_set_accept_encoding(transaction, "gzip, deflate"); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_set_accept_encoding(transaction, "gzip, deflate"); + assert_eq(ret, HTTP_ERROR_NONE); + ret = http_transaction_request_get_accept_encoding(transaction, &encoding); + assert_eq(ret, HTTP_ERROR_NONE); + + if (encoding) + free(encoding); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_set_cookie_n + * @since_tizen 3.0 + * @type Negative + * @description Sets a cookie in the HTTP request. + * @scenario Invoking http_transaction_request_set_cookie with invalid parameter. + */ +int utc_http_transaction_request_set_cookie_n(void) +{ + int ret; + const char cookie[100] = "tool=tizen; fun=yes;"; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_set_cookie(transaction, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_set_cookie(transaction, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_set_cookie(NULL, cookie); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_set_cookie(NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_set_cookie_p + * @since_tizen 3.0 + * @type Positive + * @description Sets a cookie in the HTTP request. + * @scenario Invoking http_transaction_request_set_cookie with valid parameter. + */ +int utc_http_transaction_request_set_cookie_p(void) +{ + int ret; + const char cookie[100] = "tool=tizen; fun=yes;"; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_set_cookie(transaction, cookie); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_set_cookie(transaction, cookie); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_get_cookie_n + * @since_tizen 3.0 + * @type Negative + * @description Gets a cookie in the HTT request. + * @scenario Invoking http_transaction_request_get_cookie with invalid parameter. + */ +int utc_http_transaction_request_get_cookie_n(void) +{ + int ret; + char *cookie; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_get_cookie(transaction, &cookie); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_get_cookie(transaction, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_get_cookie(NULL, &cookie); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_get_cookie(NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + + return 0; +} + +/** + * @testcase utc_http_transaction_request_get_cookie_p + * @since_tizen 3.0 + * @type Positive + * @description Gets a cookie in the HTT request. + * @scenario Invoking http_transaction_request_get_cookie with valid parameter. + */ +int utc_http_transaction_request_get_cookie_p(void) +{ + int ret; + char *cookie; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_get_cookie(transaction, &cookie); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_set_cookie(transaction, "tool=tizen; fun=yes;"); + assert_eq(ret, HTTP_ERROR_NONE); + ret = http_transaction_request_get_cookie(transaction, &cookie); + assert_eq(ret, HTTP_ERROR_NONE); + + if (cookie) + free(cookie); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_write_body_n + * @since_tizen 3.0 + * @type Negative + * @description Writes the request message body. + * @scenario Invoking http_transaction_request_write_body with invalid parameter. + */ +int utc_http_transaction_request_write_body_n(void) +{ + int ret; + const char body[100] = "data"; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_write_body(transaction, NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_write_body(transaction, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_write_body(NULL, body); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + ret = http_transaction_request_write_body(NULL, NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_request_write_body_p + * @since_tizen 3.0 + * @type Positive + * @description Writes the request message body. + * @scenario Invoking http_transaction_request_write_body with valid parameter. + */ +int utc_http_transaction_request_write_body_p(void) +{ + int ret; + const char body[100] = "data"; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_write_body(transaction, body); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_write_body(transaction, body); + assert_eq(ret, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_transaction_submit_n + * @since_tizen 3.0 + * @type Negative + * @description Submits the Http request. + * @scenario Invoking http_transaction_submit with invalid parameter. + */ +int utc_http_transaction_submit_n(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_submit(NULL); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_submit(NULL); + assert_eq(ret, HTTP_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_http_transaction_submit_p + * @since_tizen 3.0 + * @type Positive + * @description Submits the Http request. + * @scenario Invoking http_transaction_submit with valid parameter. + */ +int utc_http_transaction_submit_p(void) +{ + int ret; + const char uri[100] = "http://www.tizen.org"; +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_transaction_request_set_uri(transaction, uri); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_transaction_request_set_uri(transaction, uri); + assert_eq(ret, HTTP_ERROR_NONE); + ret = http_transaction_submit(transaction); + g_main_loop_run(g_pMainLoop); + + assert_eq(g_CallbackRet, HTTP_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_http_deinit_n + * @since_tizen 3.0 + * @type Negative + * @description Deinitializes the Http module. + * @scenario Invoking http_deinit with invalid parameter. + */ +int utc_http_deinit_n(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_deinit(); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_deinit(); + assert_eq(ret, HTTP_ERROR_NONE); + ret = http_deinit(); + assert_eq(ret, HTTP_ERROR_INVALID_OPERATION); + + return 0; +} + +/** + * @testcase utc_http_deinit_p + * @since_tizen 3.0 + * @type Positive + * @description Deinitializes the Http module. + * @scenario Invoking http_deinit with valid parameter. + */ +int utc_http_deinit_p(void) +{ + int ret; + +#ifdef WEARABLE + if (g_internet_supported == false) { + ret = http_deinit(); + assert_eq(ret, TIZEN_ERROR_NOT_SUPPORTED); + return 0; + } +#endif + + ret = http_deinit(); + assert_eq(ret, HTTP_ERROR_NONE); + is_init = false; + + return 0; +} + -- 2.7.4