From: hyunuk.tak Date: Thu, 4 Jun 2020 07:25:11 +0000 (+0900) Subject: Add unittest for auto coverage X-Git-Tag: submit/tizen/20200619.021002^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=212a4354e080aa44d83b6bd42845c4611efad78b;p=platform%2Fcore%2Fapi%2Fconnection.git Add unittest for auto coverage Success [ 282 / 282] Error [ 0 / 282] Overall coverage rate: lines......: 96.2% (2539 of 2639 lines) functions..: 100.0% (185 of 185 functions) Change-Id: I220aacdaca69f418b59de9f88e165028a09bbb9e Signed-off-by: hyunuk.tak --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 7818ee4..331953c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,12 @@ CONFIGURE_FILE( INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB}/pkgconfig) ADD_SUBDIRECTORY(test) +IF(BUILD_GCOV) +IF(DEBUG_GCOV) + ADD_DEFINITIONS(-DDEBUG_GCOV) +ENDIF(DEBUG_GCOV) + ADD_SUBDIRECTORY(unittest) +ENDIF(BUILD_GCOV) IF(UNIX) diff --git a/packaging/capi-network-connection.spec b/packaging/capi-network-connection.spec index b673b4e..7cb4339 100755 --- a/packaging/capi-network-connection.spec +++ b/packaging/capi-network-connection.spec @@ -13,6 +13,7 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-system-info) %if 0%{?gcov:1} +BuildRequires: gtest-devel BuildRequires: lcov %endif @@ -54,7 +55,8 @@ export LDFLAGS+=" -lgcov" export CFLAGS+=' -Wno-unused-local-typedefs' MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ - -DLIB_PATH=%{_lib} \ + -DLIB_PATH=%{_lib} -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} \ + -DDEBUG_GCOV=%{?debug_gcov:1}%{!?debug_gcov:0} \ %if 0%{?model_build_feature_network_dsds} == 1 -DTIZEN_DUALSIM_ENABLE=1 \ %endif @@ -75,6 +77,13 @@ mkdir -p %{buildroot}%{_datadir}/gcov/obj install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj %endif +%check +%if 0%{?gcov:1} +pushd unittest +./run_coverage.sh +popd +%endif + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig diff --git a/src/connection.c b/src/connection.c index cb6f53f..a00868f 100755 --- a/src/connection.c +++ b/src/connection.c @@ -587,7 +587,6 @@ EXPORT_API int connection_get_wifi_state(connection_h connection, connection_wif return CONNECTION_ERROR_NONE; } -//LCOV_EXCL_START EXPORT_API int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e *state) { CONN_LOCK; @@ -603,7 +602,7 @@ EXPORT_API int connection_get_ethernet_state(connection_h connection, connection int rv = _connection_libnet_get_ethernet_state(connection, state); if (rv != CONNECTION_ERROR_NONE) { CONNECTION_LOG(CONNECTION_ERROR, "Fail to get ethernet state[%d]", rv); //LCOV_EXCL_LINE - CONN_UNLOCK; + CONN_UNLOCK; //LCOV_EXCL_LINE return rv; //LCOV_EXCL_LINE } @@ -626,7 +625,7 @@ EXPORT_API int connection_get_ethernet_cable_state(connection_h connection, conn int rv = _connection_libnet_get_ethernet_cable_state(connection, state); if (rv != CONNECTION_ERROR_NONE) { CONNECTION_LOG(CONNECTION_ERROR, "Fail to get ethernet cable state[%d]", rv); //LCOV_EXCL_LINE - CONN_UNLOCK; + CONN_UNLOCK; //LCOV_EXCL_LINE return rv; //LCOV_EXCL_LINE } @@ -714,7 +713,6 @@ EXPORT_API int connection_unset_ethernet_cable_state_changed_cb(connection_h con CONN_UNLOCK; return CONNECTION_ERROR_NONE; } -//LCOV_EXCL_STOP EXPORT_API int connection_get_bt_state(connection_h connection, connection_bt_state_e *state) { @@ -1446,7 +1444,7 @@ static int __get_cellular_statistic(connection_statistics_type_e statistics_type if (llsize == NULL) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE - return CONNECTION_ERROR_INVALID_PARAMETER; + return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE } switch (statistics_type) { @@ -1532,7 +1530,7 @@ static int __get_statistic(connection_handle_s *conn_handle, connection_type_e c if (llsize == NULL) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE - return CONNECTION_ERROR_INVALID_PARAMETER; + return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE } rv = _connection_libnet_check_get_privilege(); @@ -1540,7 +1538,7 @@ static int __get_statistic(connection_handle_s *conn_handle, connection_type_e c return rv; else if (rv != CONNECTION_ERROR_NONE) { CONNECTION_LOG(CONNECTION_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE - return CONNECTION_ERROR_OPERATION_FAILED; + return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE } if (connection_type == CONNECTION_TYPE_CELLULAR) @@ -1749,6 +1747,8 @@ EXPORT_API int connection_profile_start_tcpdump(connection_h connection) CONN_LOCK; + CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE); + if (!(__connection_check_handle_validity(connection))) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); CONN_UNLOCK; @@ -1757,9 +1757,9 @@ EXPORT_API int connection_profile_start_tcpdump(connection_h connection) ret = _connection_libnet_start_tcpdump(connection); if (ret != CONNECTION_ERROR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "Failed to start tcpdump (%d)", ret); - CONN_UNLOCK; - return ret; + CONNECTION_LOG(CONNECTION_ERROR, "Failed to start tcpdump (%d)", ret); //LCOV_EXCL_LINE + CONN_UNLOCK; //LCOV_EXCL_LINE + return ret; //LCOV_EXCL_LINE } CONN_UNLOCK; @@ -1772,6 +1772,8 @@ EXPORT_API int connection_profile_stop_tcpdump(connection_h connection) CONN_LOCK; + CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE); + if (!(__connection_check_handle_validity(connection))) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); CONN_UNLOCK; @@ -1780,9 +1782,9 @@ EXPORT_API int connection_profile_stop_tcpdump(connection_h connection) ret = _connection_libnet_stop_tcpdump(connection); if (ret != CONNECTION_ERROR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "Failed to stop tcpdump (%d)", ret); - CONN_UNLOCK; - return ret; + CONNECTION_LOG(CONNECTION_ERROR, "Failed to stop tcpdump (%d)", ret); //LCOV_EXCL_LINE + CONN_UNLOCK; //LCOV_EXCL_LINE + return ret; //LCOV_EXCL_LINE } CONN_UNLOCK; @@ -1795,6 +1797,8 @@ EXPORT_API int connection_profile_get_tcpdump_state(connection_h connection, gbo CONN_LOCK; + CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE); + if (!(__connection_check_handle_validity(connection)) || !tcpdump_state) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); CONN_UNLOCK; @@ -1803,9 +1807,9 @@ EXPORT_API int connection_profile_get_tcpdump_state(connection_h connection, gbo ret = _connection_libnet_get_tcpdump_state(connection, tcpdump_state); if (ret != CONNECTION_ERROR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "Failed to get the tcpdump state (%d)", ret); - CONN_UNLOCK; - return ret; + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get the tcpdump state (%d)", ret); //LCOV_EXCL_LINE + CONN_UNLOCK; //LCOV_EXCL_LINE + return ret; //LCOV_EXCL_LINE } CONN_UNLOCK; @@ -1830,9 +1834,9 @@ EXPORT_API int connection_profile_save_ethernet_eap_config(connection_h connecti rv = _connection_libnet_profile_save_ethernet_eap_config(connection, profile); if (rv != CONNECTION_ERROR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "Failed to save ethernet eap config."); - CONN_UNLOCK; - return rv; + CONNECTION_LOG(CONNECTION_ERROR, "Failed to save ethernet eap config."); //LCOV_EXCL_LINE + CONN_UNLOCK; //LCOV_EXCL_LINE + return rv; //LCOV_EXCL_LINE } CONN_UNLOCK; diff --git a/src/connection_mptcp.c b/src/connection_mptcp.c index 9479965..2513d5f 100755 --- a/src/connection_mptcp.c +++ b/src/connection_mptcp.c @@ -23,8 +23,7 @@ #include "net_connection_private.h" #include "net_connection_mptcp_private.h" -//LCOV_EXCL_START -EXPORT_API int connection_mptcp_is_supported(connection_h connection, bool* supported) +EXPORT_API int connection_mptcp_is_supported(connection_h connection, bool *supported) { if (!(_connection_check_handle_validity(connection))) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); @@ -37,17 +36,16 @@ EXPORT_API int connection_mptcp_is_supported(connection_h connection, bool* supp EXPORT_API int connection_mptcp_enable(connection_h connection, connection_mptcp_enable_e enable) { - // check MPTCP support - if (_connection_libnet_mptcp_supported(connection) == FALSE) { - CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE - return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (!(_connection_check_handle_validity(connection))) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } + if (_connection_libnet_mptcp_supported(connection) == FALSE) { + CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE + return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (enable <= CONNECTION_MPTCP_DISABLE || enable > CONNECTION_MPTCP_ENABLE_SOCKOPT) { CONNECTION_LOG(CONNECTION_ERROR, "Use connection_mptcp_disable()"); //LCOV_EXCL_LINE @@ -59,33 +57,31 @@ EXPORT_API int connection_mptcp_enable(connection_h connection, connection_mptcp EXPORT_API int connection_mptcp_disable(connection_h connection) { - // check MPTCP support - if (_connection_libnet_mptcp_supported(connection) == FALSE) { - CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE - return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (!(_connection_check_handle_validity(connection))) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } - return _connection_libnet_mptcp_enable(connection, CONNECTION_MPTCP_DISABLE); -} - -EXPORT_API int connection_mptcp_get_enabled(connection_h connection, connection_mptcp_enable_e* enable) -{ - // check MPTCP support if (_connection_libnet_mptcp_supported(connection) == FALSE) { CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } + return _connection_libnet_mptcp_enable(connection, CONNECTION_MPTCP_DISABLE); +} + +EXPORT_API int connection_mptcp_get_enabled(connection_h connection, connection_mptcp_enable_e* enable) +{ if (!(_connection_check_handle_validity(connection))) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } + if (_connection_libnet_mptcp_supported(connection) == FALSE) { + CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE + return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (enable == NULL) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE @@ -97,33 +93,31 @@ EXPORT_API int connection_mptcp_get_enabled(connection_h connection, connection_ EXPORT_API int connection_mptcp_set_path_manager(connection_h connection, connection_mptcp_path_manager_e pm) { - // check MPTCP support - if (_connection_libnet_mptcp_supported(connection) == FALSE) { - CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE - return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (!(_connection_check_handle_validity(connection))) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } - return _connection_libnet_mptcp_set_path_manager(connection, pm); -} - -EXPORT_API int connection_mptcp_get_path_manager(connection_h connection, connection_mptcp_path_manager_e* pm) -{ - // check MPTCP support if (_connection_libnet_mptcp_supported(connection) == FALSE) { CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } + return _connection_libnet_mptcp_set_path_manager(connection, pm); +} + +EXPORT_API int connection_mptcp_get_path_manager(connection_h connection, connection_mptcp_path_manager_e* pm) +{ if (!(_connection_check_handle_validity(connection))) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } + if (_connection_libnet_mptcp_supported(connection) == FALSE) { + CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE + return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (pm == NULL) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; @@ -135,33 +129,31 @@ EXPORT_API int connection_mptcp_get_path_manager(connection_h connection, connec EXPORT_API int connection_mptcp_set_scheduler(connection_h connection, connection_mptcp_scheduler_e scheduler) { - // check MPTCP support - if (_connection_libnet_mptcp_supported(connection) == FALSE) { - CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE - return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (!(_connection_check_handle_validity(connection))) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } - return _connection_libnet_mptcp_set_scheduler(connection, scheduler); -} - -EXPORT_API int connection_mptcp_get_scheduler(connection_h connection, connection_mptcp_scheduler_e* scheduler) -{ - // check MPTCP support if (_connection_libnet_mptcp_supported(connection) == FALSE) { CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } + return _connection_libnet_mptcp_set_scheduler(connection, scheduler); +} + +EXPORT_API int connection_mptcp_get_scheduler(connection_h connection, connection_mptcp_scheduler_e* scheduler) +{ if (!(_connection_check_handle_validity(connection))) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } + if (_connection_libnet_mptcp_supported(connection) == FALSE) { + CONNECTION_LOG(CONNECTION_ERROR, "MPTCP is not supported"); //LCOV_EXCL_LINE + return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (scheduler == NULL) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; @@ -169,4 +161,3 @@ EXPORT_API int connection_mptcp_get_scheduler(connection_h connection, connectio return _connection_libnet_mptcp_get_scheduler(connection, scheduler); } -//LCOV_EXCL_STOP diff --git a/src/connection_profile.c b/src/connection_profile.c index 4f884ea..f9d4dea 100755 --- a/src/connection_profile.c +++ b/src/connection_profile.c @@ -2675,9 +2675,9 @@ EXPORT_API int connection_profile_is_ethernet_eap_enabled(connection_profile_h p int ret = _connection_libnet_ethernet_eap_enabled(enabled); if (ret != CONNECTION_ERROR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "Failed to get EAP over Ethernet enabled status."); - CONN_UNLOCK; - return ret; + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get EAP over Ethernet enabled status."); //LCOV_EXCL_LINE + CONN_UNLOCK; //LCOV_EXCL_LINE + return ret; //LCOV_EXCL_LINE } CONNECTION_LOG(CONNECTION_INFO, "EAP over Ethernet enabled status: [%s]", enabled ? "true" : "false"); @@ -2703,16 +2703,16 @@ EXPORT_API int connection_profile_enable_ethernet_eap(connection_profile_h profi net_dev_info_t *net_info = __profile_get_net_info(profile_info); if (!net_info) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); - CONN_UNLOCK; - return CONNECTION_ERROR_INVALID_OPERATION; + CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); //LCOV_EXCL_LINE + CONN_UNLOCK; //LCOV_EXCL_LINE + return CONNECTION_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE } int ret = _connection_libnet_enable_ethernet_eap(enable, net_info->ProfileName); if (ret != CONNECTION_ERROR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "Failed to enable EAP over ethernet"); - CONN_UNLOCK; - return ret; + CONNECTION_LOG(CONNECTION_ERROR, "Failed to enable EAP over ethernet"); //LCOV_EXCL_LINE + CONN_UNLOCK; //LCOV_EXCL_LINE + return ret; //LCOV_EXCL_LINE } net_info->use_eapol = enable; @@ -2739,9 +2739,9 @@ EXPORT_API int connection_profile_set_ethernet_eap_type(connection_profile_h pro net_dev_info_t *net_info = __profile_get_net_info(profile_info); if (!net_info || net_info->use_eapol == false) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); - CONN_UNLOCK; - return CONNECTION_ERROR_INVALID_OPERATION; + CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); //LCOV_EXCL_LINE + CONN_UNLOCK; //LCOV_EXCL_LINE + return CONNECTION_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE } net_info->eap.eap_type = type; @@ -2767,9 +2767,9 @@ EXPORT_API int connection_profile_get_ethernet_eap_type(connection_profile_h pro net_dev_info_t *net_info = __profile_get_net_info(profile_info); if (!net_info || net_info->use_eapol == false) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); - CONN_UNLOCK; - return CONNECTION_ERROR_INVALID_OPERATION; + CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); //LCOV_EXCL_LINE + CONN_UNLOCK; //LCOV_EXCL_LINE + return CONNECTION_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE } *type = net_info->eap.eap_type; @@ -2835,8 +2835,8 @@ EXPORT_API int connection_profile_get_ethernet_eap_passphrase(connection_profile *user_name = strdup(net_info->eap.username); if (*user_name == NULL) { - CONN_UNLOCK; - return CONNECTION_ERROR_OUT_OF_MEMORY; + CONN_UNLOCK; //LCOV_EXCL_LINE + return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } if (strlen(net_info->eap.password) > 0) @@ -2867,9 +2867,9 @@ EXPORT_API int connection_profile_set_ethernet_eap_identity(connection_profile_h net_dev_info_t *net_info = __profile_get_net_info(profile_info); if (!net_info || false == __profile_ethernet_validate_eap_identity(net_info)) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); - CONN_UNLOCK; - return CONNECTION_ERROR_INVALID_OPERATION; + CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); //LCOV_EXCL_LINE + CONN_UNLOCK; //LCOV_EXCL_LINE + return CONNECTION_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE } g_strlcpy(net_info->eap.username, identity, NET_USERNAME_LEN+1); @@ -2897,15 +2897,15 @@ EXPORT_API int connection_profile_get_ethernet_eap_identity(connection_profile_h net_dev_info_t *net_info = __profile_get_net_info(profile_info); if (!net_info || false == __profile_ethernet_validate_eap_identity(net_info)) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); - CONN_UNLOCK; - return CONNECTION_ERROR_INVALID_OPERATION; + CONNECTION_LOG(CONNECTION_ERROR, "Invalid operation"); //LCOV_EXCL_LINE + CONN_UNLOCK; //LCOV_EXCL_LINE + return CONNECTION_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE } *identity = strdup(net_info->eap.username); if (*identity == NULL) { - CONN_UNLOCK; - return CONNECTION_ERROR_OUT_OF_MEMORY; + CONN_UNLOCK; //LCOV_EXCL_LINE + return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } CONN_UNLOCK; @@ -2968,8 +2968,8 @@ EXPORT_API int connection_profile_get_ethernet_eap_ca_cert_file(connection_profi *file = strdup(net_info->eap.ca_cert_filename); if (*file == NULL) { - CONN_UNLOCK; - return CONNECTION_ERROR_OUT_OF_MEMORY; + CONN_UNLOCK; //LCOV_EXCL_LINE + return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } CONN_UNLOCK; @@ -3032,8 +3032,8 @@ EXPORT_API int connection_profile_get_ethernet_eap_client_cert_file(connection_p *file = strdup(net_info->eap.client_cert_filename); if (*file == NULL) { - CONN_UNLOCK; - return CONNECTION_ERROR_OUT_OF_MEMORY; + CONN_UNLOCK; //LCOV_EXCL_LINE + return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } CONN_UNLOCK; @@ -3066,8 +3066,8 @@ EXPORT_API int connection_profile_get_ethernet_eap_private_key_file(connection_p *file = strdup(net_info->eap.private_key_filename); if (*file == NULL) { - CONN_UNLOCK; - return CONNECTION_ERROR_OUT_OF_MEMORY; + CONN_UNLOCK; //LCOV_EXCL_LINE + return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } CONN_UNLOCK; @@ -3161,8 +3161,8 @@ EXPORT_API int connection_profile_get_ethernet_eap_anonymous_identity(connection *anonymous_identity= strdup(net_info->eap.anonymous_identity); if (*anonymous_identity== NULL) { - CONN_UNLOCK; - return CONNECTION_ERROR_OUT_OF_MEMORY; + CONN_UNLOCK; //LCOV_EXCL_LINE + return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } CONN_UNLOCK; @@ -3225,8 +3225,8 @@ EXPORT_API int connection_profile_get_ethernet_eap_pac_file(connection_profile_h *file = strdup(net_info->eap.pac_filename); if (*file == NULL) { - CONN_UNLOCK; - return CONNECTION_ERROR_OUT_OF_MEMORY; + CONN_UNLOCK; //LCOV_EXCL_LINE + return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } CONN_UNLOCK; diff --git a/src/libnetwork_mptcp.c b/src/libnetwork_mptcp.c index b9b05f8..42c652c 100755 --- a/src/libnetwork_mptcp.c +++ b/src/libnetwork_mptcp.c @@ -121,7 +121,7 @@ int _connection_libnet_mptcp_get_enabled(connection_handle_s *conn_handle, conne int _connection_libnet_mptcp_set_path_manager(connection_handle_s *conn_handle, connection_mptcp_path_manager_e pm) { int rv = 0; - const char* str = __convert_mptcp_path_manager_enum_to_str(pm); + const char *str = __convert_mptcp_path_manager_enum_to_str(pm); if (str == NULL) { CONNECTION_LOG(CONNECTION_ERROR, "Invalid Parameter"); diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt new file mode 100755 index 0000000..53ee932 --- /dev/null +++ b/unittest/CMakeLists.txt @@ -0,0 +1,46 @@ +#SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib") + +SET(UNITTEST_NAME "tct-connection-core") + +SET(CAPI_LIB "capi-network-connection") +SET(TC_SOURCES + utc-connection-common.c + utc-connection-profile.c + utc-network-connection.c + utc-connection-extension.c +) + +PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED + capi-base-common + dlog + capi-system-info + glib-2.0 + gio-unix-2.0 +) + +INCLUDE_DIRECTORIES( + ${${CAPI_LIB}_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/src/include + ${CMAKE_CURRENT_SOURCE_DIR}/include +) + +ADD_DEFINITIONS( -DMOBILE ) + +SET(CONNECTION_MOCK "connection-mock") +SET(CONNECTION_MOCK_SRCS mock/connection-mock.c) +SET(CONNECTION_MOCK_CFLAGS "${CMAKE_C_FLAGS}" ) +ADD_LIBRARY(${CONNECTION_MOCK} SHARED ${CONNECTION_MOCK_SRCS}) +SET_TARGET_PROPERTIES(${CONNECTION_MOCK} PROPERTIES + COMPILE_FLAGS ${CONNECTION_MOCK_CFLAGS} +) + +ADD_EXECUTABLE(${UNITTEST_NAME} ${UNITTEST_NAME}.cpp ${TC_SOURCES} ) +TARGET_LINK_LIBRARIES(${UNITTEST_NAME} + ${${CAPI_LIB}_LIBRARIES} + ${LIB_NAME} + gtest + capi-network-connection +) + +# INSTALL(PROGRAMS ${UNITTEST_NAME} DESTINATION ${BIN_INSTALL_DIR}) diff --git a/unittest/include/assert_local.h b/unittest/include/assert_local.h new file mode 100755 index 0000000..7c88a02 --- /dev/null +++ b/unittest/include/assert_local.h @@ -0,0 +1,118 @@ +// +// Copyright (c) 2020 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 _ASSERT_H_ +#define _ASSERT_H_ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define assert(exp) \ + do { \ + if (!(exp)) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert Fail; Following expression is not true: %s\n", \ + __FILE__, __LINE__, #exp); \ + return 1; \ + } \ + } while (0) + +#define assert_eq(var, ref) \ + do { \ + if (var != ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) and (%s == 0x%x) are not equal\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return 1; \ + } \ + } while (0) + +#define assert_eq_no_return(var, ref) \ + do { \ + if (var != ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) and (%s == 0x%x) are not equal\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return ; \ + } \ + } while (0) + +#define assert_neq_no_return(var, ref) \ + do { \ + if (var == ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) and (%s == 0x%x) are equal\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return ; \ + } \ + } while (0) + +#define assert_neq(var, ref) \ + do { \ + if (var == ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) and (%s == 0x%x) are equal\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return 1; \ + } \ + } while (0) + +#define assert_gt(var, ref) \ + do { \ + if (var <= ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) is not greater than (%s == 0x%x)\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return 1; \ + } \ + } while (0) + +#define assert_geq(var, ref) \ + do { \ + if (var < ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) is not greater than or equal to (%s == 0x%x)\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return 1; \ + } \ + } while (0) + +#define assert_lt(var, ref) \ + do { \ + if (var >= ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) is not lower than (%s == 0x%x)\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return 1; \ + } \ + } while (0) + +#define assert_leq(var, ref) \ + do { \ + if (var > ref) { \ + fprintf(stderr, \ + "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) is not lower than or equal to (%s == 0x%x)\n", \ + __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \ + return 1; \ + } \ + } while (0) + +#ifdef __cplusplus +} +#endif +#endif // _ASSERT_H_ diff --git a/unittest/include/tct_common.h b/unittest/include/tct_common.h new file mode 100755 index 0000000..e23e7b3 --- /dev/null +++ b/unittest/include/tct_common.h @@ -0,0 +1,56 @@ +// +// Copyright (c) 2020 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_COMMON_H_ +#define _TCT_COMMON_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "assert_local.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef DEBUG_GCOV +#define COMMON_DEBUG 1 +#else +#define COMMON_DEBUG 0 +#endif + +#define FREE_MEMORY_TC(buffer) { \ + if ( buffer != NULL ) \ + { \ + free(buffer); \ + buffer = NULL; \ + } \ +} + +#define PRINT_LOG(type, tag, ...) do { \ + fprintf(stdout, ##__VA_ARGS__ ); \ + fprintf(stdout, "\n" ); \ +} while(0) + +#ifdef __cplusplus +} +#endif + +#endif // _TCT_COMMON_H_ diff --git a/unittest/include/testcase.h b/unittest/include/testcase.h new file mode 100755 index 0000000..febac28 --- /dev/null +++ b/unittest/include/testcase.h @@ -0,0 +1,40 @@ +// +// Copyright (c) 2020 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 _TESTCASE_H_ +#define _TESTCASE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* pointer to startup/cleanup functions */ +typedef void (*void_fun_ptr)(void); + +/* pointer to testcase functions */ +typedef int (*tc_fun_ptr)(void); + +/* struct describing specific testcase */ +typedef struct testcase_s { + const char* name; + tc_fun_ptr function; + void_fun_ptr startup; + void_fun_ptr cleanup; +} testcase; + +#ifdef __cplusplus +} +#endif +#endif // _TESTCASE_H_ diff --git a/unittest/mock/connection-mock.c b/unittest/mock/connection-mock.c new file mode 100755 index 0000000..08f9bba --- /dev/null +++ b/unittest/mock/connection-mock.c @@ -0,0 +1,934 @@ +// +// Copyright (c) 2020 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 +#include +#include + +#include +#include +#include +#include +#include + +#include "net_connection_private.h" + +#ifndef API +#define API __attribute__ ((visibility("default"))) +#endif + +struct cellular_profile_s { + char *obj; + char *name; + net_state_type_t state; + net_state_type_t state6; + char *interface; + char *address; + net_ip_config_type_t ipv4_method; + char *ipv4_address; + char *ipv4_netmask; + char *ipv4_gateway; + net_ip_config_type_t ipv6_method; + net_service_type_t service_type; + char *apn; + char *proxy_addr; + char *home_url; + char *profile_name; + bool hidden; + bool editable; + bool default_conn; +} cellular_profile[] = { + { + "/net/connman/service/cellular_sprdmodem0_45005_534b2054656c65636f6d_1164_1", + "534b2054656c65636f6d_1164_1", + NET_STATE_TYPE_READY, + NET_STATE_TYPE_IDLE, + "seth_w0", + "6A:99:73:18:BF:62", + NET_IP_CONFIG_TYPE_FIXED, + "10.37.107.10", + "255.255.255.255", + "10.37.107.1", + 0, + NET_SERVICE_INTERNET, + "lte.sktelecom.com", + NULL, + NULL, + "SK Telecom", + FALSE, + TRUE, + TRUE, + }, + { + "/net/connman/service/cellular_sprdmodem0_45005_534b2054656c65636f6d_1165_2", + "534b2054656c65636f6d_1165_2", + NET_STATE_TYPE_IDLE, + NET_STATE_TYPE_IDLE, + NULL, + NULL, + 0, + NULL, + NULL, + NULL, + 0, + NET_SERVICE_MMS, + "lte.sktelecom.com", + "lteoma.nate.com:9093", + "http://omms.nate.com:9082/oma_mms", + "SK Telecom", + FALSE, + TRUE, + TRUE, + }, +}; + +struct wifi_profile_s { + char *obj; + wlan_security_mode_type_t sec_mode; + wlan_encryption_mode_type_t enc_mode; + gboolean passpoint; + unsigned char strength; + char essid[NET_WLAN_ESSID_LEN + 1]; + char bssid[NET_MAX_MAC_ADDR_LEN + 1]; + int max_rate; + unsigned int frequency; + unsigned int keymgmt; + net_state_type_t state; + net_state_type_t state6; + char *interface; + char *address; + net_ip_config_type_t ipv4_method; + char *ipv4_address; + char *ipv4_netmask; + char *ipv4_gateway; + net_ip_config_type_t ipv6_method; +} wifi_profile[] = { + { + "/net/connman/service/wifi_f8d11162c728_4e4554474541523839_managed_psk", + WLAN_SEC_MODE_WPA2_PSK, + WLAN_ENC_MODE_AES, + FALSE, + 71, + "NETGEAR89", + "9c:3d:cf:f7:bb:35", + 1, + 2462, + 520, + NET_STATE_TYPE_READY, + NET_STATE_TYPE_CONFIGURATION, + "wlan0", + "F8:D1:11:62:C7:28", + NET_IP_CONFIG_TYPE_DYNAMIC, + "192.168.1.4", + "255.255.255.0", + "192.168.1.1", + NET_IP_CONFIG_TYPE_AUTO_IP, + }, + { + "/net/connman/service/wifi_f8d11162c728_545431_managed_psk", + WLAN_SEC_MODE_WPA2_PSK, + WLAN_ENC_MODE_WEP, + TRUE, + 73, + "TT1", + "60:45:cb:cc:05:d0", + 54000000, + 2457, + 8, + NET_STATE_TYPE_IDLE, + NET_STATE_TYPE_IDLE, + "wlan0", + "F8:D1:11:62:C7:28", + NET_IP_CONFIG_TYPE_DYNAMIC, + NULL, + NULL, + NULL, + NET_IP_CONFIG_TYPE_AUTO_IP, + }, +}; + +struct ethernet_profile_s { + char *obj; + net_state_type_t state; + net_state_type_t state6; + char *interface; + char *address; + net_ip_config_type_t ipv4_method; + char *ipv4_address; + char *ipv4_netmask; + char *ipv4_gateway; + net_ip_config_type_t ipv6_method; +} ethernet_profile[] = { + { + "/net/connman/service/ethernet_dca632888ceb_cable", + NET_STATE_TYPE_READY, + NET_STATE_TYPE_CONFIGURATION, + "eth0", + "DC:A6:32:88:8C:EB", + NET_IP_CONFIG_TYPE_AUTO_IP, + "169.254.104.67", + "255.255.0.0", + NULL, + NET_IP_CONFIG_TYPE_AUTO_IP, + }, +}; + +/* system info */ +API int system_info_get_platform_bool(const char *key, bool *value) +{ + *value = TRUE; + return SYSTEM_INFO_ERROR_NONE; +} + +API int system_info_get_platform_string(const char *key, char **value) +{ + if (g_strcmp0(key, "http://tizen.org/feature/profile") == 0) + *value = g_strdup("m"); + + return SYSTEM_INFO_ERROR_NONE; +} + +/* vconf */ +API char *vconf_get_str(const char *in_key) +{ + if (g_strcmp0(in_key, VCONFKEY_NETWORK_IP) == 0) + return g_strdup("192.168.1.4"); + else if (g_strcmp0(in_key, VCONFKEY_NETWORK_IP6) == 0) + return g_strdup(" "); + else if (g_strcmp0(in_key, VCONFKEY_NETWORK_PROXY) == 0) + return g_strdup(" "); + else if (g_strcmp0(in_key, VCONFKEY_WIFI_BSSID_ADDRESS) == 0) + return g_strdup("f8:d1:11:62:c7:28"); + + return NULL; +} + +API int vconf_get_int(const char *in_key, int *intval) +{ + if (g_strcmp0(in_key, VCONFKEY_NETWORK_STATUS) == 0) + *intval = 1; + else if (g_strcmp0(in_key, VCONFKEY_NETWORK_CELLULAR_STATE) == 0) + *intval = 0; + else if (g_strcmp0(in_key, VCONF_TELEPHONY_DEFAULT_DATA_SERVICE) == 0) + *intval = 0; + else if (g_strcmp0(in_key, VCONFKEY_DNET_STATE) == 0) + *intval = 1; + else if (g_strcmp0(in_key, VCONFKEY_DNET_STATE2) == 0) + *intval = 0; + else if (g_strcmp0(in_key, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT) == 0) + *intval = 0; + else if (g_strcmp0(in_key, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV) == 0) + *intval = 0; + else if (g_strcmp0(in_key, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT) == 0) + *intval = 1024; + else if (g_strcmp0(in_key, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV) == 0) + *intval = 2048; + else if (g_strcmp0(in_key, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2) == 0) + *intval = 0; + else if (g_strcmp0(in_key, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2) == 0) + *intval = 0; + else if (g_strcmp0(in_key, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT2) == 0) + *intval = 0; + else if (g_strcmp0(in_key, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV2) == 0) + *intval = 0; + + return VCONF_OK; +} + +/* libnet-client */ +API int net_check_profile_privilege(void) +{ + return NET_ERR_NONE; +} + +API int net_check_get_privilege(void) +{ + return NET_ERR_NONE; +} + +API int net_check_set_privilege(void) +{ + return NET_ERR_NONE; +} + +API int net_register_client(void **handle, net_event_cb_t event_cb, void *user_data) +{ + return NET_ERR_NONE; +} + +API void net_deregister_client(void *handle) +{ + return; +} + +API int net_get_metered_state(void *handle, int *state) +{ + *state = TRUE; + return NET_ERR_NONE; +} + +API int net_get_wifi_state(void *handle, net_wifi_state_t *current_state) +{ + *current_state = WIFI_CONNECTED; + return NET_ERR_NONE; +} + +static void __net_init_profile_info(net_device_t profile_type, net_profile_info_t *ProfInfo) +{ + int i = 0; + net_dev_info_t *net_info = NULL; + + memset(ProfInfo, 0, sizeof(net_profile_info_t)); + ProfInfo->Favourite = (char)FALSE; + + if (profile_type == NET_DEVICE_WIFI) { + ProfInfo->profile_type = NET_DEVICE_WIFI; + ProfInfo->ProfileInfo.Wlan.Strength = 0; + ProfInfo->ProfileInfo.Wlan.frequency = 0; + ProfInfo->ProfileInfo.Wlan.max_rate = 0; + ProfInfo->ProfileInfo.Wlan.wlan_mode = 0; + ProfInfo->ProfileInfo.Wlan.PassphraseRequired = FALSE; + ProfInfo->ProfileInfo.Wlan.security_info.sec_mode = 0; + ProfInfo->ProfileInfo.Wlan.security_info.enc_mode = 0; + ProfInfo->ProfileInfo.Wlan.security_info.wps_support = FALSE; + + net_info = &(ProfInfo->ProfileInfo.Wlan.net_info); + } else if (profile_type == NET_DEVICE_CELLULAR) { + ProfInfo->profile_type = NET_DEVICE_CELLULAR; + ProfInfo->ProfileInfo.Pdp.ProtocolType = NET_PDP_TYPE_NONE; + ProfInfo->ProfileInfo.Pdp.ServiceType = NET_SERVICE_UNKNOWN; + ProfInfo->ProfileInfo.Pdp.PdnType = NET_PDN_TYPE_UNKNOWN; + ProfInfo->ProfileInfo.Pdp.RoamPdnType = NET_PDN_TYPE_UNKNOWN; + ProfInfo->ProfileInfo.Pdp.AuthInfo.AuthType = NET_PDP_AUTH_NONE; + ProfInfo->ProfileInfo.Pdp.IsStatic = FALSE; + ProfInfo->ProfileInfo.Pdp.Roaming = FALSE; + ProfInfo->ProfileInfo.Pdp.SetupRequired = FALSE; + ProfInfo->ProfileInfo.Pdp.Hidden = FALSE; + ProfInfo->ProfileInfo.Pdp.Editable = TRUE; + ProfInfo->ProfileInfo.Pdp.DefaultConn = FALSE; + + net_info = &(ProfInfo->ProfileInfo.Pdp.net_info); + } else if (profile_type == NET_DEVICE_ETHERNET) { + net_info = &(ProfInfo->ProfileInfo.Ethernet.net_info); + } else if (profile_type == NET_DEVICE_BLUETOOTH) { + net_info = &(ProfInfo->ProfileInfo.Bluetooth.net_info); + } else if (profile_type == NET_DEVICE_MESH) { + ProfInfo->profile_type = NET_DEVICE_MESH; + ProfInfo->ProfileInfo.Mesh.Strength = 0; + ProfInfo->ProfileInfo.Mesh.frequency = 0; + ProfInfo->ProfileInfo.Mesh.PassphraseRequired = FALSE; + ProfInfo->ProfileInfo.Mesh.security_info.sec_mode = 0; + + net_info = &(ProfInfo->ProfileInfo.Mesh.net_info); + } + + if (net_info != NULL) { + net_info->DnsCount = 0; + + for (i = 0; i < NET_DNS_ADDR_MAX; i++) { + net_info->DnsAddr[i].Type = NET_ADDR_IPV4; + net_info->DnsAddr[i].Data.Ipv4.s_addr = 0; + } + + net_info->IpConfigType = 0; + net_info->IpAddr.Type = NET_ADDR_IPV4; + net_info->IpAddr.Data.Ipv4.s_addr = 0; + net_info->BNetmask = FALSE; + net_info->SubnetMask.Type = NET_ADDR_IPV4; + net_info->SubnetMask.Data.Ipv4.s_addr = 0; + net_info->BDefGateway = FALSE; + net_info->GatewayAddr.Type = NET_ADDR_IPV4; + net_info->GatewayAddr.Data.Ipv4.s_addr = 0; + net_info->BServerAddr = FALSE; + net_info->ServerAddr.Type = NET_ADDR_IPV4; + net_info->ServerAddr.Data.Ipv4.s_addr = 0; + + net_info->IpConfigType6 = 0; + net_info->IpAddr6.Type = NET_ADDR_IPV6; + inet_pton(AF_INET6, "::", &net_info->IpAddr6.Data.Ipv6); + net_info->PrefixLen6 = 0; + net_info->BDefGateway6 = FALSE; + net_info->GatewayAddr6.Type = NET_ADDR_IPV6; + inet_pton(AF_INET6, "::", &net_info->GatewayAddr6.Data.Ipv6); + + net_info->ProxyMethod = NET_PROXY_TYPE_UNKNOWN; + } +} + +static void __net_extract_ip(char *ip, net_addr_t *ipAddr) +{ + unsigned char *ipValue = NULL; + char *saveptr = NULL; + char ipString[NETPM_IPV4_STR_LEN_MAX+1]; + char *ipToken[4]; + + ipValue = (unsigned char *)&(ipAddr->Data.Ipv4.s_addr); + + g_strlcpy(ipString, ip, NETPM_IPV4_STR_LEN_MAX+1); + + ipToken[0] = strtok_r(ipString, ".", &saveptr); + + if (ipToken[0] != NULL) { + ipToken[1] = strtok_r(NULL, ".", &saveptr); + + if (ipToken[1] != NULL) { + ipToken[2] = strtok_r(NULL, ".", &saveptr); + + if (ipToken[2] != NULL) { + ipToken[3] = strtok_r(NULL, ".", &saveptr); + + if (ipToken[3] != NULL) { + ipValue[0] = (unsigned char)atoi(ipToken[0]); + ipValue[1] = (unsigned char)atoi(ipToken[1]); + ipValue[2] = (unsigned char)atoi(ipToken[2]); + ipValue[3] = (unsigned char)atoi(ipToken[3]); + } + } + } + } +} + +static int __net_get_prefix_len(char *netmask) +{ + in_addr_t mask = inet_network(netmask); + int prefix_len = 0; + + for (; mask; mask <<= 1) + ++prefix_len; + + return prefix_len; +} + +static void __net_add_profile_cellular(net_profile_info_t **profile_info, int *profile_count) +{ + int i; + net_profile_info_t *ProfilePtr = NULL; + int prof_cnt = sizeof(cellular_profile) / sizeof(struct cellular_profile_s); + + for (i = 0; i < prof_cnt; ++i) { + net_profile_info_t ProfInfo = { 0, }; + memset(&ProfInfo, 0, sizeof(net_profile_info_t)); + + __net_init_profile_info(NET_DEVICE_CELLULAR, &ProfInfo); + + ProfInfo.profile_type = NET_DEVICE_CELLULAR; + g_strlcpy(ProfInfo.ProfileName, cellular_profile[i].obj, NET_PROFILE_NAME_LEN_MAX); + + g_strlcpy(ProfInfo.ProfileInfo.Pdp.net_info.ProfileName, + cellular_profile[i].obj, NET_PROFILE_NAME_LEN_MAX); + g_strlcpy(ProfInfo.ProfileInfo.Pdp.PSModemPath, + cellular_profile[i].name, NET_PROFILE_NAME_LEN_MAX); + ProfInfo.ProfileState = cellular_profile[i].state; + ProfInfo.ProfileState6 = cellular_profile[i].state6; + + net_dev_info_t *net_info = &(ProfInfo.ProfileInfo.Pdp.net_info); + + if (cellular_profile[i].interface) + g_strlcpy(net_info->DevName, cellular_profile[i].interface, NET_MAX_DEVICE_NAME_LEN); + if (cellular_profile[i].address) + g_strlcpy(net_info->MacAddr, cellular_profile[i].address, NET_MAX_MAC_ADDR_LEN); + if (cellular_profile[i].ipv4_method) + net_info->IpConfigType = cellular_profile[i].ipv4_method; + if (cellular_profile[i].ipv4_address) + __net_extract_ip(cellular_profile[i].ipv4_address, &net_info->IpAddr); + if (cellular_profile[i].ipv4_netmask) { + __net_extract_ip(cellular_profile[i].ipv4_netmask, &net_info->SubnetMask); + net_info->PrefixLen = __net_get_prefix_len(cellular_profile[i].ipv4_netmask); + net_info->BNetmask = TRUE; + } + if (cellular_profile[i].ipv4_gateway) { + __net_extract_ip(cellular_profile[i].ipv4_gateway, &net_info->GatewayAddr); + net_info->BDefGateway = TRUE; + } + if (cellular_profile[i].ipv6_method) + net_info->IpConfigType6 = cellular_profile[i].ipv6_method; + + ProfInfo.ProfileInfo.Pdp.ServiceType = cellular_profile[i].service_type; + if (cellular_profile[i].apn) + g_strlcpy(ProfInfo.ProfileInfo.Pdp.Apn, cellular_profile[i].apn, NET_PDP_APN_LEN_MAX); + if (cellular_profile[i].proxy_addr) + g_strlcpy(ProfInfo.ProfileInfo.Pdp.net_info.ProxyAddr, + cellular_profile[i].proxy_addr, NET_PROXY_LEN_MAX); + if (cellular_profile[i].home_url) + g_strlcpy(ProfInfo.ProfileInfo.Pdp.HomeURL, cellular_profile[i].home_url, NET_HOME_URL_LEN_MAX); + if (cellular_profile[i].profile_name) + g_strlcpy(ProfInfo.ProfileInfo.Pdp.Keyword, cellular_profile[i].profile_name, NET_PDP_APN_LEN_MAX); + + ProfInfo.ProfileInfo.Pdp.Hidden = cellular_profile[i].hidden; + ProfInfo.ProfileInfo.Pdp.Editable = cellular_profile[i].editable; + ProfInfo.ProfileInfo.Pdp.DefaultConn = cellular_profile[i].default_conn; + + ProfilePtr = (net_profile_info_t *)realloc(ProfilePtr, (i + 1) * sizeof(net_profile_info_t)); + memcpy(ProfilePtr + i, &ProfInfo, sizeof(net_profile_info_t)); + } + + *profile_count = prof_cnt; + *profile_info = ProfilePtr; +} + +static void __net_add_default_profile_cellular(net_profile_info_t *ProfInfo) +{ + __net_init_profile_info(NET_DEVICE_CELLULAR, ProfInfo); + + ProfInfo->profile_type = NET_DEVICE_CELLULAR; + g_strlcpy(ProfInfo->ProfileName, cellular_profile[0].obj, NET_PROFILE_NAME_LEN_MAX); + + g_strlcpy(ProfInfo->ProfileInfo.Pdp.net_info.ProfileName, + cellular_profile[0].obj, NET_PROFILE_NAME_LEN_MAX); + g_strlcpy(ProfInfo->ProfileInfo.Pdp.PSModemPath, + cellular_profile[0].name, NET_PROFILE_NAME_LEN_MAX); + ProfInfo->ProfileState = cellular_profile[0].state; + ProfInfo->ProfileState6 = cellular_profile[0].state6; + + net_dev_info_t *net_info = &(ProfInfo->ProfileInfo.Pdp.net_info); + + if (cellular_profile[0].interface) + g_strlcpy(net_info->DevName, cellular_profile[0].interface, NET_MAX_DEVICE_NAME_LEN); + if (cellular_profile[0].address) + g_strlcpy(net_info->MacAddr, cellular_profile[0].address, NET_MAX_MAC_ADDR_LEN); + if (cellular_profile[0].ipv4_method) + net_info->IpConfigType = cellular_profile[0].ipv4_method; + if (cellular_profile[0].ipv4_address) + __net_extract_ip(cellular_profile[0].ipv4_address, &net_info->IpAddr); + if (cellular_profile[0].ipv4_netmask) { + __net_extract_ip(cellular_profile[0].ipv4_netmask, &net_info->SubnetMask); + net_info->PrefixLen = __net_get_prefix_len(cellular_profile[0].ipv4_netmask); + net_info->BNetmask = TRUE; + } + if (cellular_profile[0].ipv4_gateway) { + __net_extract_ip(cellular_profile[0].ipv4_gateway, &net_info->GatewayAddr); + net_info->BDefGateway = TRUE; + } + if (cellular_profile[0].ipv6_method) + net_info->IpConfigType6 = cellular_profile[0].ipv6_method; + + ProfInfo->ProfileInfo.Pdp.ServiceType = cellular_profile[0].service_type; + if (cellular_profile[0].apn) + g_strlcpy(ProfInfo->ProfileInfo.Pdp.Apn, cellular_profile[0].apn, NET_PDP_APN_LEN_MAX); + if (cellular_profile[0].proxy_addr) + g_strlcpy(ProfInfo->ProfileInfo.Pdp.net_info.ProxyAddr, + cellular_profile[0].proxy_addr, NET_PROXY_LEN_MAX); + if (cellular_profile[0].home_url) + g_strlcpy(ProfInfo->ProfileInfo.Pdp.HomeURL, cellular_profile[0].home_url, NET_HOME_URL_LEN_MAX); + if (cellular_profile[0].profile_name) + g_strlcpy(ProfInfo->ProfileInfo.Pdp.Keyword, cellular_profile[0].profile_name, NET_PDP_APN_LEN_MAX); + + ProfInfo->ProfileInfo.Pdp.Hidden = cellular_profile[0].hidden; + ProfInfo->ProfileInfo.Pdp.Editable = cellular_profile[0].editable; + ProfInfo->ProfileInfo.Pdp.DefaultConn = cellular_profile[0].default_conn; +} + +static void __net_add_profile_wifi(net_profile_info_t **profile_info, int *profile_count) +{ + int i; + net_profile_info_t *ProfilePtr = NULL; + int prof_cnt = sizeof(wifi_profile) / sizeof(struct wifi_profile_s); + + for (i = 0; i < prof_cnt; ++i) { + net_profile_info_t ProfInfo = { 0, }; + memset(&ProfInfo, 0, sizeof(net_profile_info_t)); + + __net_init_profile_info(NET_DEVICE_WIFI, &ProfInfo); + + ProfInfo.profile_type = NET_DEVICE_WIFI; + g_strlcpy(ProfInfo.ProfileName, wifi_profile[i].obj, NET_PROFILE_NAME_LEN_MAX); + + ProfInfo.ProfileState = wifi_profile[i].state; + ProfInfo.ProfileState6 = wifi_profile[i].state6; + + net_wifi_profile_info_t *Wlan = &(ProfInfo.ProfileInfo.Wlan); + + g_strlcpy(Wlan->net_info.ProfileName, wifi_profile[i].obj, NET_PROFILE_NAME_LEN_MAX); + Wlan->security_info.sec_mode = wifi_profile[i].sec_mode; + Wlan->security_info.enc_mode = wifi_profile[i].enc_mode; + Wlan->passpoint = wifi_profile[i].passpoint; + Wlan->Strength = wifi_profile[i].strength; + if (wifi_profile[i].essid) + g_strlcpy(Wlan->essid, wifi_profile[i].essid, NET_WLAN_ESSID_LEN); + if (wifi_profile[i].bssid) + g_strlcpy(Wlan->bssid, wifi_profile[i].bssid, NET_MAX_MAC_ADDR_LEN); + Wlan->max_rate = wifi_profile[i].max_rate; + Wlan->frequency = wifi_profile[i].frequency; + Wlan->security_info.keymgmt = wifi_profile[i].keymgmt; + + net_dev_info_t *net_info = &(ProfInfo.ProfileInfo.Wlan.net_info); + + if (wifi_profile[i].interface) + g_strlcpy(net_info->DevName, wifi_profile[i].interface, NET_MAX_DEVICE_NAME_LEN); + if (wifi_profile[i].address) + g_strlcpy(net_info->MacAddr, wifi_profile[i].address, NET_MAX_MAC_ADDR_LEN); + if (wifi_profile[i].ipv4_method) + net_info->IpConfigType = wifi_profile[i].ipv4_method; + if (wifi_profile[i].ipv4_address) + __net_extract_ip(wifi_profile[i].ipv4_address, &net_info->IpAddr); + if (wifi_profile[i].ipv4_netmask) { + __net_extract_ip(wifi_profile[i].ipv4_netmask, &net_info->SubnetMask); + net_info->PrefixLen = __net_get_prefix_len(wifi_profile[i].ipv4_netmask); + net_info->BNetmask = TRUE; + } + if (wifi_profile[i].ipv4_gateway) { + __net_extract_ip(wifi_profile[i].ipv4_gateway, &net_info->GatewayAddr); + net_info->BDefGateway = TRUE; + } + if (wifi_profile[i].ipv6_method) + net_info->IpConfigType6 = wifi_profile[i].ipv6_method; + + ProfilePtr = (net_profile_info_t *)realloc(ProfilePtr, (i + 1) * sizeof(net_profile_info_t)); + memcpy(ProfilePtr + i, &ProfInfo, sizeof(net_profile_info_t)); + } + + *profile_count = prof_cnt; + *profile_info = ProfilePtr; +} + +static void __net_add_profile_ethernet(net_profile_info_t **profile_info, int *profile_count) +{ + int i; + net_profile_info_t *ProfilePtr = NULL; + int prof_cnt = sizeof(ethernet_profile) / sizeof(struct ethernet_profile_s); + + for (i = 0; i < prof_cnt; ++i) { + net_profile_info_t ProfInfo = { 0, }; + memset(&ProfInfo, 0, sizeof(net_profile_info_t)); + + __net_init_profile_info(NET_DEVICE_ETHERNET, &ProfInfo); + + ProfInfo.profile_type = NET_DEVICE_ETHERNET; + g_strlcpy(ProfInfo.ProfileName, ethernet_profile[i].obj, NET_PROFILE_NAME_LEN_MAX); + + ProfInfo.ProfileState = ethernet_profile[i].state; + ProfInfo.ProfileState6 = ethernet_profile[i].state6; + + net_dev_info_t *net_info = &(ProfInfo.ProfileInfo.Wlan.net_info); + + if (ethernet_profile[i].interface) + g_strlcpy(net_info->DevName, ethernet_profile[i].interface, NET_MAX_DEVICE_NAME_LEN); + if (ethernet_profile[i].address) + g_strlcpy(net_info->MacAddr, ethernet_profile[i].address, NET_MAX_MAC_ADDR_LEN); + if (ethernet_profile[i].ipv4_method) + net_info->IpConfigType = ethernet_profile[i].ipv4_method; + if (ethernet_profile[i].ipv4_address) + __net_extract_ip(ethernet_profile[i].ipv4_address, &net_info->IpAddr); + if (ethernet_profile[i].ipv4_netmask) { + __net_extract_ip(ethernet_profile[i].ipv4_netmask, &net_info->SubnetMask); + net_info->PrefixLen = __net_get_prefix_len(ethernet_profile[i].ipv4_netmask); + net_info->BNetmask = TRUE; + } + if (ethernet_profile[i].ipv4_gateway) { + __net_extract_ip(ethernet_profile[i].ipv4_gateway, &net_info->GatewayAddr); + net_info->BDefGateway = TRUE; + } + if (ethernet_profile[i].ipv6_method) + net_info->IpConfigType6 = ethernet_profile[i].ipv6_method; + + ProfilePtr = (net_profile_info_t *)realloc(ProfilePtr, (i + 1) * sizeof(net_profile_info_t)); + memcpy(ProfilePtr + i, &ProfInfo, sizeof(net_profile_info_t)); + } + + *profile_count = prof_cnt; + *profile_info = ProfilePtr; +} + +API int net_get_profile_list(void *handle, net_device_t device_type, + net_profile_info_t **profile_list, int *profile_cnt) +{ + int cellular_cnt = 0; + int wifi_cnt = 0; + int ethernet_cnt = 0; + net_profile_info_t *cellular_profiles = NULL; + net_profile_info_t *wifi_profiles = NULL; + net_profile_info_t *ethernet_profiles = NULL; + net_profile_info_t *profiles = NULL; + + *profile_cnt = 0; + + switch (device_type) { + case NET_DEVICE_CELLULAR: + __net_add_profile_cellular(&cellular_profiles, &cellular_cnt); + *profile_cnt += cellular_cnt; + break; + case NET_DEVICE_WIFI: + __net_add_profile_wifi(&wifi_profiles, &wifi_cnt); + *profile_cnt += wifi_cnt; + break; + case NET_DEVICE_ETHERNET: + __net_add_profile_ethernet(ðernet_profiles, ðernet_cnt); + *profile_cnt += ethernet_cnt; + default: + break; + } + + if (*profile_cnt) { + profiles = g_try_new0(net_profile_info_t, *profile_cnt); + if (profiles) { + *profile_list = profiles; + if (cellular_cnt > 0) { + memcpy(profiles, cellular_profiles, + sizeof(net_profile_info_t) * cellular_cnt); + profiles += cellular_cnt; + } + + if (wifi_cnt > 0) { + memcpy(profiles, wifi_profiles, + sizeof(net_profile_info_t) * wifi_cnt); + profiles += wifi_cnt; + } + + if (ethernet_cnt > 0) { + memcpy(profiles, ethernet_profiles, + sizeof(net_profile_info_t) * ethernet_cnt); + profiles += ethernet_cnt; + } + } + } + + return NET_ERR_NONE; +} + +API int net_get_all_profile_list(void *handle, net_profile_info_t **profile_list, int *profile_cnt) +{ + int cellular_cnt = 0; + int wifi_cnt = 0; + int ethernet_cnt = 0; + net_profile_info_t *cellular_profiles = NULL; + net_profile_info_t *wifi_profiles = NULL; + net_profile_info_t *ethernet_profiles = NULL; + net_profile_info_t *profiles = NULL; + + *profile_cnt = 0; + + __net_add_profile_cellular(&cellular_profiles, &cellular_cnt); + *profile_cnt += cellular_cnt; + + __net_add_profile_wifi(&wifi_profiles, &wifi_cnt); + *profile_cnt += wifi_cnt; + + __net_add_profile_ethernet(ðernet_profiles, ðernet_cnt); + *profile_cnt += ethernet_cnt; + + if (*profile_cnt) { + profiles = g_try_new0(net_profile_info_t, *profile_cnt); + if (profiles) { + *profile_list = profiles; + if (cellular_cnt > 0) { + memcpy(profiles, cellular_profiles, + sizeof(net_profile_info_t) * cellular_cnt); + profiles += cellular_cnt; + } + + if (wifi_cnt > 0) { + memcpy(profiles, wifi_profiles, + sizeof(net_profile_info_t) * wifi_cnt); + profiles += wifi_cnt; + } + + if (ethernet_cnt > 0) { + memcpy(profiles, ethernet_profiles, + sizeof(net_profile_info_t) * ethernet_cnt); + profiles += ethernet_cnt; + } + } + } + + return NET_ERR_NONE; +} + +API int net_get_ethernet_cable_state(void *handle, int *state) +{ + *state = 0; + return NET_ERR_NONE; +} + +API int net_get_active_net_info(void *handle, net_profile_info_t *active_profile_info) +{ + __net_add_default_profile_cellular(active_profile_info); + + return NET_ERR_NONE; +} + +API int net_add_profile(void *handle, net_service_type_t network_type, net_profile_info_t *prof_info) +{ + return NET_ERR_NONE; +} + +API int net_delete_profile(void *handle, const char *profile_name) +{ + return NET_ERR_NONE; +} + +API int net_modify_profile(void *handle, const char *profile_name, net_profile_info_t *prof_info) +{ + return NET_ERR_NONE; +} + +API int net_reset_profile(void *handle, int type, int sim_id) +{ + return NET_ERR_NONE; +} + +API int net_open_mesh_connection_with_profile(void *handle, const char *profile_name) +{ + return NET_ERR_NONE; +} + +API int net_open_connection_with_profile(void *handle, const char *profile_name) +{ + return NET_ERR_NONE; +} + +API int net_set_default_cellular_service_profile(void *handle, const char *profile_name) +{ + return NET_ERR_NONE; +} + +API int net_set_default_cellular_service_profile_async(void *handle, const char *profile_name) +{ + return NET_ERR_NONE; +} + +API int net_close_mesh_connection(void *handle, const char *profile_name) +{ + return NET_ERR_NONE; +} + +API int net_close_connection(void *handle, const char *profile_name) +{ + return NET_ERR_NONE; +} + +API int net_add_route(void *handle, const char *ip_addr, const char *interface, int address_family) +{ + return NET_ERR_NONE; +} + +API int net_remove_route(void *handle, const char *ip_addr, const char *interface, int address_family) +{ + return NET_ERR_NONE; +} + +API int net_add_route_ipv6(void *handle, const char *ip_addr, + const char *interface, int address_family, const char *gateway) +{ + return NET_ERR_NONE; +} + +API int net_remove_route_ipv6(void *handle, const char *ip_addr, + const char *interface, int address_family, const char *gateway) +{ + return NET_ERR_NONE; +} + +API int net_add_route_entry(void *handle, const char *ip_addr, + const char *interface, int address_family, const char *gateway) +{ + return NET_ERR_NONE; +} + +API int net_remove_route_entry(void *handle, const char *ip_addr, + const char *interface, int address_family, const char *gateway) +{ + return NET_ERR_NONE; +} + +API int net_set_statistics(void *handle, net_device_t device_type, + net_statistics_type_e statistics_type) +{ + return NET_ERR_NONE; +} + +API int net_get_statistics(void *handle, net_device_t device_type, + net_statistics_type_e statistics_type, unsigned long long *size) +{ + *size = 1024; + return NET_ERR_NONE; +} + +API int net_get_cellular_modem_object_path(char **modem_path, int sim_id) +{ + *modem_path = g_strdup("/sprdmodem0"); + return NET_ERR_NONE; +} + +API int net_ethernet_eap_enable(gboolean enable, const char *profilename) +{ + return NET_ERR_NONE; +} + +API int net_ethernet_eap_supported(gboolean *supported) +{ + *supported = TRUE; + return NET_ERR_NONE; +} + +API int net_save_ethernet_eap_config(void *handle, net_dev_info_t *net_info) +{ + return NET_ERR_NONE; +} + +API int net_start_tcpdump(void *handle) +{ + return NET_ERR_NONE; +} + +API int net_stop_tcpdump(void *handle) +{ + return NET_ERR_NONE; +} + +API gboolean net_get_tcpdump_state(void *handle, gboolean *is_tcpdump_running) +{ + *is_tcpdump_running = TRUE; + return NET_ERR_NONE; +} + +API int net_mptcp_supported(void *handle, gboolean *support) +{ + *support = TRUE; + return NET_ERR_NONE; +} + +API int net_mptcp_set_enabled(void *handle, int enable) +{ + return NET_ERR_NONE; +} + +API int net_mptcp_get_enabled(void *handle, int *enable) +{ + *enable = 1; + return NET_ERR_NONE; +} + +API int net_mptcp_set_path_manager(void *handle, const char *pm) +{ + return NET_ERR_NONE; +} + +API int net_mptcp_get_path_manager(void *handle, char **pm) +{ + *pm = g_strdup("default"); + return NET_ERR_NONE; +} + +API int net_mptcp_set_scheduler(void *handle, const char *scheduler) +{ + return NET_ERR_NONE; +} + +API int net_mptcp_get_scheduler(void *handle, char **scheduler) +{ + *scheduler = g_strdup("default"); + return NET_ERR_NONE; +} \ No newline at end of file diff --git a/unittest/run_coverage.sh b/unittest/run_coverage.sh new file mode 100755 index 0000000..bf4ad63 --- /dev/null +++ b/unittest/run_coverage.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +export LD_LIBRARY_PATH=..:.:$LD_LIBRARY_PATH +pushd ../ +RootDir=$PWD +popd + +unitTestFile=tct-connection-core +if [ ! -x "./$unitTestFile" ] +then + echo "$unitTestFile file does not exist!" + exit -1 +fi + +LD_PRELOAD=./libconnection-mock.so ./$unitTestFile + +CMakeDir=${RootDir}/CMakeFiles/capi-network-connection.dir/ +CoverageDir=${RootDir}/coverage + +pushd $CMakeDir + + for obj in `ls *.o` + do + gcov -b -c $obj + done + + if [ -f /usr/bin/lcov ] + then + lcov -c -d . --exclude "/usr/lib/gcc/armv7l-tizen-linux-gnueabi/9.2.0/include/c++/*" -o cov.info + genhtml cov.info -o ${CoverageDir} + echo "Coverage test result created! [${CoverageDir}]" + else + echo "lcov does not exist!" + fi +popd diff --git a/unittest/tct-connection-core.cpp b/unittest/tct-connection-core.cpp new file mode 100755 index 0000000..674372a --- /dev/null +++ b/unittest/tct-connection-core.cpp @@ -0,0 +1,99 @@ +// +// Copyright (c) 2020 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 +#include "tct_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#include "tct-connection-core.h" + +#ifdef __cplusplus +} +#endif + +#include + +#include +#include +#include +#include +#include +#include + +TEST(connection, connection){ + char *pszGetTCName = NULL; + pszGetTCName = (char*)malloc( 256 ); + memset( pszGetTCName, 0x00, 256); + strcpy( pszGetTCName, "utc_connection"); + int i=0, result=0; + + PRINT_LOG(DLOG_INFO, "NativeTCT", "[%s:%d] Executing TC Name = %s", __FUNCTION__, __LINE__, pszGetTCName); + + int successCnt = 0; + int errorCnt = 0; + for ( i = 0; tc_array[i].name; i++ ) + { + if (COMMON_DEBUG) + PRINT_LOG(DLOG_INFO, "NativeTCT", "==========================================="); + PRINT_LOG(DLOG_INFO, "NativeTCT", "[%s]", tc_array[i].name); + if ( 0 == strncmp(pszGetTCName, tc_array[i].name, strlen(pszGetTCName)) ) + { + if ( tc_array[i].startup ) + { + tc_array[i].startup(); + } + + result = tc_array[i].function(); + + if( result == 0 ){ + successCnt++; + } + else { + PRINT_LOG(DLOG_INFO, "NativeTCT", "[Error][%d] %s returns value = %d", i, tc_array[i].name, result); + errorCnt++; + } + + EXPECT_EQ(result, 0); + // ASSERT_EQ(result, 0); + + if ( tc_array[i].cleanup ) + { + tc_array[i].cleanup(); + } + } + else { + PRINT_LOG(DLOG_INFO, "NativeTCT", "Name check error! [%s][%s]", pszGetTCName, tc_array[i].name); + ASSERT_EQ(0, 1); + } + if (COMMON_DEBUG) + PRINT_LOG(DLOG_INFO, "NativeTCT", "==========================================="); + } + + PRINT_LOG(DLOG_INFO, "NativeTCT", "=========================="); + PRINT_LOG(DLOG_INFO, "NativeTCT", "Success [%4d / %4d]", successCnt, successCnt + errorCnt); + PRINT_LOG(DLOG_INFO, "NativeTCT", "Error [%4d / %4d]", errorCnt, successCnt + errorCnt); + PRINT_LOG(DLOG_INFO, "NativeTCT", "=========================="); + + FREE_MEMORY_TC(pszGetTCName); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/unittest/tct-connection-core.h b/unittest/tct-connection-core.h new file mode 100755 index 0000000..89686fb --- /dev/null +++ b/unittest/tct-connection-core.h @@ -0,0 +1,598 @@ +// +// Copyright (c) 2020 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_connection_profile_startup(void); +extern void utc_connection_profile_cleanup(void); +extern void utc_network_connection_startup(void); +extern void utc_network_connection_cleanup(void); +extern void utc_connection_extension_startup(void); +extern void utc_connection_extension_cleanup(void); + +extern int utc_connection_profile_create_p(void); +extern int utc_connection_profile_create_n(void); +extern int utc_connection_profile_clone_p(void); +extern int utc_connection_profile_clone_n(void); +extern int utc_connection_profile_get_name_p(void); +extern int utc_connection_profile_get_name_n(void); +extern int utc_connection_profile_get_id_p(void); +extern int utc_connection_profile_get_id_n(void); +extern int utc_connection_profile_get_type_p(void); +extern int utc_connection_profile_get_type_n(void); +extern int utc_connection_profile_get_network_interface_name_p(void); +extern int utc_connection_profile_get_network_interface_name_n(void); +extern int utc_connection_profile_get_state_p(void); +extern int utc_connection_profile_get_state_n(void); +extern int utc_connection_profile_get_ip_config_type_p(void); +extern int utc_connection_profile_get_ip_config_type_n(void); +extern int utc_connection_profile_get_ip_address_p(void); +extern int utc_connection_profile_get_ip_address_n(void); +extern int utc_connection_profile_get_subnet_mask_p(void); +extern int utc_connection_profile_get_subnet_mask_n(void); +extern int utc_connection_profile_get_gateway_address_p(void); +extern int utc_connection_profile_get_gateway_address_n(void); +extern int utc_connection_profile_get_dhcp_server_address_p(void); +extern int utc_connection_profile_get_dhcp_server_address_n(void); +extern int utc_connection_profile_get_dhcp_lease_duration_p(void); +extern int utc_connection_profile_get_dhcp_lease_duration_n(void); +extern int utc_connection_profile_get_dns_address_p(void); +extern int utc_connection_profile_get_dns_address_n(void); +extern int utc_connection_profile_get_proxy_type_p(void); +extern int utc_connection_profile_get_proxy_type_n(void); +extern int utc_connection_profile_get_proxy_address_p(void); +extern int utc_connection_profile_get_proxy_address_n(void); +extern int utc_connection_profile_set_ip_config_type_p(void); +extern int utc_connection_profile_set_ip_config_type_n(void); +extern int utc_connection_profile_set_ip_address_p(void); +extern int utc_connection_profile_set_ip_address_n(void); +extern int utc_connection_profile_set_subnet_mask_p(void); +extern int utc_connection_profile_set_subnet_mask_n(void); +extern int utc_connection_profile_set_gateway_address_p(void); +extern int utc_connection_profile_set_gateway_address_n(void); +extern int utc_connection_profile_set_dns_address_p(void); +extern int utc_connection_profile_set_dns_address_n(void); +extern int utc_connection_profile_set_proxy_type_p(void); +extern int utc_connection_profile_set_proxy_type_n(void); +extern int utc_connection_profile_set_proxy_address_p(void); +extern int utc_connection_profile_set_proxy_address_n(void); +extern int utc_connection_profile_set_state_changed_cb_p(void); +extern int utc_connection_profile_set_state_changed_cb_n(void); +extern int utc_connection_profile_unset_state_changed_cb_p(void); +extern int utc_connection_profile_unset_state_changed_cb_n(void); +extern int utc_connection_profile_set_cellular_service_type_p(void); +extern int utc_connection_profile_set_cellular_service_type_n(void); +extern int utc_connection_profile_set_cellular_apn_p(void); +extern int utc_connection_profile_set_cellular_apn_n(void); +extern int utc_connection_profile_set_cellular_auth_info_p(void); +extern int utc_connection_profile_set_cellular_auth_info_n(void); +extern int utc_connection_profile_set_cellular_home_url_p(void); +extern int utc_connection_profile_set_cellular_home_url_n(void); +extern int utc_connection_profile_set_cellular_pdn_type_p(void); +extern int utc_connection_profile_set_cellular_pdn_type_n(void); +extern int utc_connection_profile_set_cellular_roam_pdn_type_p(void); +extern int utc_connection_profile_set_cellular_roam_pdn_type_n(void); +extern int utc_connection_profile_get_cellular_service_type_p(void); +extern int utc_connection_profile_get_cellular_service_type_n(void); +extern int utc_connection_profile_get_cellular_apn_p(void); +extern int utc_connection_profile_get_cellular_apn_n(void); +extern int utc_connection_profile_get_cellular_auth_info_p(void); +extern int utc_connection_profile_get_cellular_auth_info_n(void); +extern int utc_connection_profile_get_cellular_home_url_p(void); +extern int utc_connection_profile_get_cellular_home_url_n(void); +extern int utc_connection_profile_get_cellular_pdn_type_p(void); +extern int utc_connection_profile_get_cellular_pdn_type_n(void); +extern int utc_connection_profile_get_cellular_roam_pdn_type_p(void); +extern int utc_connection_profile_get_cellular_roam_pdn_type_n(void); +extern int utc_connection_profile_is_cellular_roaming_p(void); +extern int utc_connection_profile_is_cellular_roaming_n(void); +extern int utc_connection_profile_is_cellular_hidden_p(void); +extern int utc_connection_profile_is_cellular_hidden_n(void); +extern int utc_connection_profile_is_cellular_editable_p(void); +extern int utc_connection_profile_is_cellular_editable_n(void); +extern int utc_connection_profile_is_cellular_default_p(void); +extern int utc_connection_profile_is_cellular_default_n(void); +extern int utc_connection_profile_refresh_p(void); +extern int utc_connection_profile_refresh_n(void); +extern int utc_connection_profile_get_wifi_essid_p(void); +extern int utc_connection_profile_get_wifi_essid_n(void); +extern int utc_connection_profile_get_wifi_bssid_p(void); +extern int utc_connection_profile_get_wifi_bssid_n(void); +extern int utc_connection_profile_get_wifi_rssi_p(void); +extern int utc_connection_profile_get_wifi_rssi_n(void); +extern int utc_connection_profile_get_wifi_frequency_p(void); +extern int utc_connection_profile_get_wifi_frequency_n(void); +extern int utc_connection_profile_get_wifi_max_speed_p(void); +extern int utc_connection_profile_get_wifi_max_speed_n(void); +extern int utc_connection_profile_get_wifi_security_type_p(void); +extern int utc_connection_profile_get_wifi_security_type_n(void); +extern int utc_connection_profile_get_wifi_encryption_type_p(void); +extern int utc_connection_profile_get_wifi_encryption_type_n(void); +extern int utc_connection_profile_is_wifi_passphrase_required_p(void); +extern int utc_connection_profile_is_wifi_passphrase_required_n(void); +extern int utc_connection_profile_set_wifi_passphrase_p(void); +extern int utc_connection_profile_set_wifi_passphrase_n(void); +extern int utc_connection_profile_is_wifi_wps_supported_p(void); +extern int utc_connection_profile_is_wifi_wps_supported_n(void); +extern int utc_connection_profile_get_ipv6_state_p(void); +extern int utc_connection_profile_get_ipv6_state_n(void); +extern int utc_connection_profile_get_prefix_length_p(void); +extern int utc_connection_profile_get_prefix_length_n(void); +extern int utc_connection_profile_set_prefix_length_p(void); +extern int utc_connection_profile_set_prefix_length_n(void); +extern int utc_connection_profile_get_dns_config_type_p(void); +extern int utc_connection_profile_get_dns_config_type_n(void); +extern int utc_connection_profile_set_dns_config_type_p(void); +extern int utc_connection_profile_set_dns_config_type_n(void); +extern int utc_connection_profile_destroy_p(void); +extern int utc_connection_profile_destroy_n(void); +extern int utc_connection_create_p(void); +extern int utc_connection_create_n(void); +extern int utc_connection_get_ip_address_p(void); +extern int utc_connection_get_ip_address_n(void); +extern int utc_connection_get_proxy_p(void); +extern int utc_connection_get_proxy_n(void); +extern int utc_connection_get_type_n(void); +extern int utc_connection_get_type_p(void); +extern int utc_connection_is_metered_network_n(void); +extern int utc_connection_is_metered_network_p(void); +extern int utc_connection_get_cellular_state_n(void); +extern int utc_connection_get_cellular_state_p(void); +extern int utc_connection_get_ethernet_state_n(void); +extern int utc_connection_get_ethernet_state_p(void); +extern int utc_connection_get_wifi_state_n(void); +extern int utc_connection_get_wifi_state_p(void); +extern int utc_connection_get_bt_state_n(void); +extern int utc_connection_get_bt_state_p(void); +extern int utc_connection_get_mac_address_n(void); +extern int utc_connection_get_mac_address_p(void); +extern int utc_connection_set_ethernet_cable_state_chaged_cb_n(void); +extern int utc_connection_set_ethernet_cable_state_chaged_cb_p(void); +extern int utc_connection_unset_ethernet_cable_state_chaged_cb_n(void); +extern int utc_connection_unset_ethernet_cable_state_chaged_cb_p(void); +extern int utc_connection_get_ethernet_cable_state_n(void); +extern int utc_connection_get_ethernet_cable_state_p(void); +extern int utc_connection_get_current_profile_p(void); +extern int utc_connection_get_current_profile_n(void); +extern int utc_connection_get_default_cellular_service_profile_p(void); +extern int utc_connection_get_default_cellular_service_profile_n(void); +extern int utc_connection_set_default_cellular_service_profile_p(void); +extern int utc_connection_set_default_cellular_service_profile_n(void); +extern int utc_connection_set_default_cellular_service_profile_async_p(void); +extern int utc_connection_set_default_cellular_service_profile_async_n(void); +extern int utc_connection_set_type_changed_cb_n(void); +extern int utc_connection_set_type_changed_cb_p(void); +extern int utc_connection_unset_type_changed_cb_n(void); +extern int utc_connection_unset_type_changed_cb_p(void); +extern int utc_connection_set_ip_address_changed_cb_n(void); +extern int utc_connection_set_ip_address_changed_cb_p(void); +extern int utc_connection_unset_ip_address_changed_cb_n(void); +extern int utc_connection_unset_ip_address_changed_cb_p(void); +extern int utc_connection_set_proxy_address_changed_cb_n(void); +extern int utc_connection_set_proxy_address_changed_cb_p(void); +extern int utc_connection_unset_proxy_address_changed_cb_n(void); +extern int utc_connection_unset_proxy_address_changed_cb_p(void); +extern int utc_connection_get_statistics_p(void); +extern int utc_connection_get_statistics_n(void); +extern int utc_connection_reset_statistics_p(void); +extern int utc_connection_reset_statistics_n(void); +extern int utc_connection_add_route_n(void); +extern int utc_connection_add_route_p(void); +extern int utc_connection_remove_route_n(void); +extern int utc_connection_remove_route_p(void); +extern int utc_connection_add_route_ipv6_n(void); +extern int utc_connection_add_route_ipv6_p(void); +extern int utc_connection_remove_route_ipv6_n(void); +extern int utc_connection_remove_route_ipv6_p(void); +extern int utc_connection_add_route_entry_n(void); +extern int utc_connection_add_route_entry_p(void); +extern int utc_connection_remove_route_entry_n(void); +extern int utc_connection_remove_route_entry_p(void); +extern int utc_connection_get_profile_iterator_n(void); +extern int utc_connection_get_profile_iterator_p(void); +extern int utc_connection_destroy_profile_iterator_n(void); +extern int utc_connection_destroy_profile_iterator_p(void); +extern int utc_connection_profile_iterator_has_next_n(void); +extern int utc_connection_profile_iterator_has_next_p(void); +extern int utc_connection_profile_iterator_next_n(void); +extern int utc_connection_profile_iterator_next_p(void); +extern int utc_connection_add_profile_p(void); +extern int utc_connection_add_profile_n(void); +extern int utc_connection_close_profile_p(void); +extern int utc_connection_close_profile_n(void); +extern int utc_connection_update_profile_p(void); +extern int utc_connection_update_profile_n(void); +extern int utc_connection_remove_profile_p(void); +extern int utc_connection_remove_profile_n(void); +extern int utc_connection_open_profile_p(void); +extern int utc_connection_open_profile_n(void); +extern int utc_connection_reset_profile_p(void); +extern int utc_connection_reset_profile_n(void); +extern int utc_connection_foreach_ipv6_address_p(void); +extern int utc_connection_foreach_ipv6_address_n(void); +extern int utc_connection_set_ethernet_cable_state_changed_cb_n(void); +extern int utc_connection_set_ethernet_cable_state_changed_cb_p(void); +extern int utc_connection_unset_ethernet_cable_state_changed_cb_n(void); +extern int utc_connection_unset_ethernet_cable_state_changed_cb_p(void); +extern int utc_connection_set_internet_state_changed_cb_p(void); +extern int utc_connection_set_internet_state_changed_cb_n1(void); +extern int utc_connection_set_internet_state_changed_cb_n2(void); +extern int utc_connection_unset_internet_state_changed_cb_p(void); +extern int utc_connection_unset_internet_state_changed_cb_n(void); +extern int utc_connection_profile_get_internet_state_p(void); +extern int utc_connection_profile_get_internet_state_n1(void); +extern int utc_connection_profile_get_internet_state_n2(void); +extern int utc_connection_destroy_p(void); +extern int utc_connection_destroy_n(void); +extern int utc_connection_profile_start_tcpdump_p(void); +extern int utc_connection_profile_start_tcpdump_n(void); +extern int utc_connection_profile_stop_tcpdump_p(void); +extern int utc_connection_profile_stop_tcpdump_n(void); +extern int utc_connection_profile_get_tcpdump_state_p(void); +extern int utc_connection_profile_get_tcpdump_state_n(void); +extern int utc_connection_profile_save_ethernet_eap_config_p(void); +extern int utc_connection_profile_save_ethernet_eap_config_n(void); +extern int utc_connection_mptcp_is_supported_p(void); +extern int utc_connection_mptcp_is_supported_n(void); +extern int utc_connection_mptcp_enable_p(void); +extern int utc_connection_mptcp_enable_n(void); +extern int utc_connection_mptcp_disable_p(void); +extern int utc_connection_mptcp_disable_n(void); +extern int utc_connection_mptcp_get_enabled_p(void); +extern int utc_connection_mptcp_get_enabled_n(void); +extern int utc_connection_mptcp_set_path_manager_p(void); +extern int utc_connection_mptcp_set_path_manager_n(void); +extern int utc_connection_mptcp_get_path_manager_p(void); +extern int utc_connection_mptcp_get_path_manager_n(void); +extern int utc_connection_mptcp_set_scheduler_p(void); +extern int utc_connection_mptcp_set_scheduler_n(void); +extern int utc_connection_mptcp_get_scheduler_p(void); +extern int utc_connection_mptcp_get_scheduler_n(void); +extern int utc_connection_profile_is_ethernet_eap_enabled_p(void); +extern int utc_connection_profile_is_ethernet_eap_enabled_n(void); +extern int utc_connection_profile_enable_ethernet_eap_p(void); +extern int utc_connection_profile_enable_ethernet_eap_n(void); +extern int utc_connection_profile_set_ethernet_eap_type_p(void); +extern int utc_connection_profile_set_ethernet_eap_type_n(void); +extern int utc_connection_profile_get_ethernet_eap_type_p(void); +extern int utc_connection_profile_get_ethernet_eap_type_n(void); +extern int utc_connection_profile_set_ethernet_eap_passphrase_p(void); +extern int utc_connection_profile_set_ethernet_eap_passphrase_n(void); +extern int utc_connection_profile_get_ethernet_eap_passphrase_p(void); +extern int utc_connection_profile_get_ethernet_eap_passphrase_n(void); +extern int utc_connection_profile_set_ethernet_eap_identity_p(void); +extern int utc_connection_profile_set_ethernet_eap_identity_n(void); +extern int utc_connection_profile_get_ethernet_eap_identity_p(void); +extern int utc_connection_profile_get_ethernet_eap_identity_n(void); +extern int utc_connection_profile_set_ethernet_eap_ca_cert_file_p(void); +extern int utc_connection_profile_set_ethernet_eap_ca_cert_file_n(void); +extern int utc_connection_profile_get_ethernet_eap_ca_cert_file_p(void); +extern int utc_connection_profile_get_ethernet_eap_ca_cert_file_n(void); +extern int utc_connection_profile_set_ethernet_eap_client_cert_file_p(void); +extern int utc_connection_profile_set_ethernet_eap_client_cert_file_n(void); +extern int utc_connection_profile_get_ethernet_eap_client_cert_file_p(void); +extern int utc_connection_profile_get_ethernet_eap_client_cert_file_n(void); +extern int utc_connection_profile_set_ethernet_eap_private_key_info_p(void); +extern int utc_connection_profile_set_ethernet_eap_private_key_info_n(void); +extern int utc_connection_profile_get_ethernet_eap_private_key_file_p(void); +extern int utc_connection_profile_get_ethernet_eap_private_key_file_n(void); +extern int utc_connection_profile_set_ethernet_eap_anonymous_identity_p(void); +extern int utc_connection_profile_set_ethernet_eap_anonymous_identity_n(void); +extern int utc_connection_profile_get_ethernet_eap_anonymous_identity_p(void); +extern int utc_connection_profile_get_ethernet_eap_anonymous_identity_n(void); +extern int utc_connection_profile_set_ethernet_eap_pac_file_p(void); +extern int utc_connection_profile_set_ethernet_eap_pac_file_n(void); +extern int utc_connection_profile_get_ethernet_eap_pac_file_p(void); +extern int utc_connection_profile_get_ethernet_eap_pac_file_n(void); +extern int utc_connection_profile_set_ethernet_eap_auth_type_p(void); +extern int utc_connection_profile_set_ethernet_eap_auth_type_n(void); +extern int utc_connection_profile_get_ethernet_eap_auth_type_p(void); +extern int utc_connection_profile_get_ethernet_eap_auth_type_n(void); +extern int utc_connection_profile_set_ethernet_eap_peap_version_p(void); +extern int utc_connection_profile_set_ethernet_eap_peap_version_n(void); +extern int utc_connection_profile_get_ethernet_eap_peap_version_p(void); +extern int utc_connection_profile_get_ethernet_eap_peap_version_n(void); + +testcase tc_array[] = { + {"utc_connection_profile_create_p", utc_connection_profile_create_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_create_n", utc_connection_profile_create_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_clone_p", utc_connection_profile_clone_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_clone_n", utc_connection_profile_clone_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_name_p", utc_connection_profile_get_name_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_name_n", utc_connection_profile_get_name_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_id_p", utc_connection_profile_get_id_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_id_n", utc_connection_profile_get_id_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_type_p", utc_connection_profile_get_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_type_n", utc_connection_profile_get_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_network_interface_name_p", utc_connection_profile_get_network_interface_name_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_network_interface_name_n", utc_connection_profile_get_network_interface_name_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_state_p", utc_connection_profile_get_state_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_state_n", utc_connection_profile_get_state_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_ip_config_type_p", utc_connection_profile_get_ip_config_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_ip_config_type_n", utc_connection_profile_get_ip_config_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_ip_address_p", utc_connection_profile_get_ip_address_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_ip_address_n", utc_connection_profile_get_ip_address_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_subnet_mask_p", utc_connection_profile_get_subnet_mask_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_subnet_mask_n", utc_connection_profile_get_subnet_mask_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_gateway_address_p", utc_connection_profile_get_gateway_address_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_gateway_address_n", utc_connection_profile_get_gateway_address_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_dhcp_server_address_p", utc_connection_profile_get_dhcp_server_address_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_dhcp_server_address_n", utc_connection_profile_get_dhcp_server_address_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_dhcp_lease_duration_p", utc_connection_profile_get_dhcp_lease_duration_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_dhcp_lease_duration_n", utc_connection_profile_get_dhcp_lease_duration_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_dns_address_p", utc_connection_profile_get_dns_address_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_dns_address_n", utc_connection_profile_get_dns_address_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_proxy_type_p", utc_connection_profile_get_proxy_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_proxy_type_n", utc_connection_profile_get_proxy_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_proxy_address_p", utc_connection_profile_get_proxy_address_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_proxy_address_n", utc_connection_profile_get_proxy_address_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_ip_config_type_p", utc_connection_profile_set_ip_config_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_ip_config_type_n", utc_connection_profile_set_ip_config_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_ip_address_p", utc_connection_profile_set_ip_address_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_ip_address_n", utc_connection_profile_set_ip_address_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_subnet_mask_p", utc_connection_profile_set_subnet_mask_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_subnet_mask_n", utc_connection_profile_set_subnet_mask_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_gateway_address_p", utc_connection_profile_set_gateway_address_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_gateway_address_n", utc_connection_profile_set_gateway_address_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_dns_address_p", utc_connection_profile_set_dns_address_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_dns_address_n", utc_connection_profile_set_dns_address_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_proxy_type_p", utc_connection_profile_set_proxy_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_proxy_type_n", utc_connection_profile_set_proxy_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_proxy_address_p", utc_connection_profile_set_proxy_address_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_proxy_address_n", utc_connection_profile_set_proxy_address_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_state_changed_cb_p", utc_connection_profile_set_state_changed_cb_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_state_changed_cb_n", utc_connection_profile_set_state_changed_cb_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_unset_state_changed_cb_p", utc_connection_profile_unset_state_changed_cb_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_unset_state_changed_cb_n", utc_connection_profile_unset_state_changed_cb_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_cellular_service_type_p", utc_connection_profile_set_cellular_service_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_cellular_service_type_n", utc_connection_profile_set_cellular_service_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_cellular_apn_p", utc_connection_profile_set_cellular_apn_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_cellular_apn_n", utc_connection_profile_set_cellular_apn_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_cellular_auth_info_p", utc_connection_profile_set_cellular_auth_info_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_cellular_auth_info_n", utc_connection_profile_set_cellular_auth_info_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_cellular_home_url_p", utc_connection_profile_set_cellular_home_url_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_cellular_home_url_n", utc_connection_profile_set_cellular_home_url_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_cellular_pdn_type_p", utc_connection_profile_set_cellular_pdn_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_cellular_pdn_type_n", utc_connection_profile_set_cellular_pdn_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_cellular_roam_pdn_type_p", utc_connection_profile_set_cellular_roam_pdn_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_cellular_roam_pdn_type_n", utc_connection_profile_set_cellular_roam_pdn_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_cellular_service_type_p", utc_connection_profile_get_cellular_service_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_cellular_service_type_n", utc_connection_profile_get_cellular_service_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_cellular_apn_p", utc_connection_profile_get_cellular_apn_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_cellular_apn_n", utc_connection_profile_get_cellular_apn_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_cellular_auth_info_p", utc_connection_profile_get_cellular_auth_info_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_cellular_auth_info_n", utc_connection_profile_get_cellular_auth_info_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_cellular_home_url_p", utc_connection_profile_get_cellular_home_url_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_cellular_home_url_n", utc_connection_profile_get_cellular_home_url_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_cellular_pdn_type_p", utc_connection_profile_get_cellular_pdn_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_cellular_pdn_type_n", utc_connection_profile_get_cellular_pdn_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_cellular_roam_pdn_type_p", utc_connection_profile_get_cellular_roam_pdn_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_cellular_roam_pdn_type_n", utc_connection_profile_get_cellular_roam_pdn_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_is_cellular_roaming_p", utc_connection_profile_is_cellular_roaming_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_is_cellular_roaming_n", utc_connection_profile_is_cellular_roaming_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_is_cellular_hidden_p", utc_connection_profile_is_cellular_hidden_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_is_cellular_hidden_n", utc_connection_profile_is_cellular_hidden_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_is_cellular_editable_p", utc_connection_profile_is_cellular_editable_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_is_cellular_editable_n", utc_connection_profile_is_cellular_editable_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_is_cellular_default_p", utc_connection_profile_is_cellular_default_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_is_cellular_default_n", utc_connection_profile_is_cellular_default_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_refresh_p", utc_connection_profile_refresh_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_refresh_n", utc_connection_profile_refresh_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_wifi_essid_p", utc_connection_profile_get_wifi_essid_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_wifi_essid_n", utc_connection_profile_get_wifi_essid_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_wifi_bssid_p", utc_connection_profile_get_wifi_bssid_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_wifi_bssid_n", utc_connection_profile_get_wifi_bssid_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_wifi_rssi_p", utc_connection_profile_get_wifi_rssi_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_wifi_rssi_n", utc_connection_profile_get_wifi_rssi_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_wifi_frequency_p", utc_connection_profile_get_wifi_frequency_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_wifi_frequency_n", utc_connection_profile_get_wifi_frequency_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_wifi_max_speed_p", utc_connection_profile_get_wifi_max_speed_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_wifi_max_speed_n", utc_connection_profile_get_wifi_max_speed_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_wifi_security_type_p", utc_connection_profile_get_wifi_security_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_wifi_security_type_n", utc_connection_profile_get_wifi_security_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_wifi_encryption_type_p", utc_connection_profile_get_wifi_encryption_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_wifi_encryption_type_n", utc_connection_profile_get_wifi_encryption_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_is_wifi_passphrase_required_p", utc_connection_profile_is_wifi_passphrase_required_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_is_wifi_passphrase_required_n", utc_connection_profile_is_wifi_passphrase_required_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_wifi_passphrase_p", utc_connection_profile_set_wifi_passphrase_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_wifi_passphrase_n", utc_connection_profile_set_wifi_passphrase_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_is_wifi_wps_supported_p", utc_connection_profile_is_wifi_wps_supported_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_is_wifi_wps_supported_n", utc_connection_profile_is_wifi_wps_supported_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_ipv6_state_p", utc_connection_profile_get_ipv6_state_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_ipv6_state_n", utc_connection_profile_get_ipv6_state_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_prefix_length_p", utc_connection_profile_get_prefix_length_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_prefix_length_n", utc_connection_profile_get_prefix_length_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_prefix_length_p", utc_connection_profile_set_prefix_length_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_prefix_length_n", utc_connection_profile_set_prefix_length_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_dns_config_type_p", utc_connection_profile_get_dns_config_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_get_dns_config_type_n", utc_connection_profile_get_dns_config_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_dns_config_type_p", utc_connection_profile_set_dns_config_type_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_set_dns_config_type_n", utc_connection_profile_set_dns_config_type_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_destroy_p", utc_connection_profile_destroy_p, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_profile_destroy_n", utc_connection_profile_destroy_n, utc_connection_profile_startup, utc_connection_profile_cleanup}, + {"utc_connection_create_p", utc_connection_create_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_create_n", utc_connection_create_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_ip_address_p", utc_connection_get_ip_address_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_ip_address_n", utc_connection_get_ip_address_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_proxy_p", utc_connection_get_proxy_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_proxy_n", utc_connection_get_proxy_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_type_n", utc_connection_get_type_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_type_p", utc_connection_get_type_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_is_metered_network_n", utc_connection_is_metered_network_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_is_metered_network_p", utc_connection_is_metered_network_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_cellular_state_n", utc_connection_get_cellular_state_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_cellular_state_p", utc_connection_get_cellular_state_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_ethernet_state_n", utc_connection_get_ethernet_state_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_ethernet_state_p", utc_connection_get_ethernet_state_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_wifi_state_n", utc_connection_get_wifi_state_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_wifi_state_p", utc_connection_get_wifi_state_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_bt_state_n", utc_connection_get_bt_state_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_bt_state_p", utc_connection_get_bt_state_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_mac_address_n", utc_connection_get_mac_address_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_mac_address_p", utc_connection_get_mac_address_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_ethernet_cable_state_chaged_cb_n", utc_connection_set_ethernet_cable_state_chaged_cb_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_ethernet_cable_state_chaged_cb_p", utc_connection_set_ethernet_cable_state_chaged_cb_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_unset_ethernet_cable_state_chaged_cb_n", utc_connection_unset_ethernet_cable_state_chaged_cb_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_unset_ethernet_cable_state_chaged_cb_p", utc_connection_unset_ethernet_cable_state_chaged_cb_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_ethernet_cable_state_n", utc_connection_get_ethernet_cable_state_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_ethernet_cable_state_p", utc_connection_get_ethernet_cable_state_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_current_profile_p", utc_connection_get_current_profile_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_current_profile_n", utc_connection_get_current_profile_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_default_cellular_service_profile_p", utc_connection_get_default_cellular_service_profile_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_default_cellular_service_profile_n", utc_connection_get_default_cellular_service_profile_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_default_cellular_service_profile_p", utc_connection_set_default_cellular_service_profile_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_default_cellular_service_profile_n", utc_connection_set_default_cellular_service_profile_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_default_cellular_service_profile_async_p", utc_connection_set_default_cellular_service_profile_async_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_default_cellular_service_profile_async_n", utc_connection_set_default_cellular_service_profile_async_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_type_changed_cb_n", utc_connection_set_type_changed_cb_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_type_changed_cb_p", utc_connection_set_type_changed_cb_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_unset_type_changed_cb_n", utc_connection_unset_type_changed_cb_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_unset_type_changed_cb_p", utc_connection_unset_type_changed_cb_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_ip_address_changed_cb_n", utc_connection_set_ip_address_changed_cb_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_ip_address_changed_cb_p", utc_connection_set_ip_address_changed_cb_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_unset_ip_address_changed_cb_n", utc_connection_unset_ip_address_changed_cb_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_unset_ip_address_changed_cb_p", utc_connection_unset_ip_address_changed_cb_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_proxy_address_changed_cb_n", utc_connection_set_proxy_address_changed_cb_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_proxy_address_changed_cb_p", utc_connection_set_proxy_address_changed_cb_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_unset_proxy_address_changed_cb_n", utc_connection_unset_proxy_address_changed_cb_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_unset_proxy_address_changed_cb_p", utc_connection_unset_proxy_address_changed_cb_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_statistics_p", utc_connection_get_statistics_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_statistics_n", utc_connection_get_statistics_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_reset_statistics_p", utc_connection_reset_statistics_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_reset_statistics_n", utc_connection_reset_statistics_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_add_route_n", utc_connection_add_route_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_add_route_p", utc_connection_add_route_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_remove_route_n", utc_connection_remove_route_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_remove_route_p", utc_connection_remove_route_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_add_route_ipv6_n", utc_connection_add_route_ipv6_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_add_route_ipv6_p", utc_connection_add_route_ipv6_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_remove_route_ipv6_n", utc_connection_remove_route_ipv6_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_remove_route_ipv6_p", utc_connection_remove_route_ipv6_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_add_route_entry_n", utc_connection_add_route_entry_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_add_route_entry_p", utc_connection_add_route_entry_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_remove_route_entry_n", utc_connection_remove_route_entry_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_remove_route_entry_p", utc_connection_remove_route_entry_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_profile_iterator_n", utc_connection_get_profile_iterator_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_get_profile_iterator_p", utc_connection_get_profile_iterator_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_destroy_profile_iterator_n", utc_connection_destroy_profile_iterator_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_destroy_profile_iterator_p", utc_connection_destroy_profile_iterator_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_profile_iterator_has_next_n", utc_connection_profile_iterator_has_next_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_profile_iterator_has_next_p", utc_connection_profile_iterator_has_next_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_profile_iterator_next_n", utc_connection_profile_iterator_next_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_profile_iterator_next_p", utc_connection_profile_iterator_next_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_add_profile_p", utc_connection_add_profile_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_add_profile_n", utc_connection_add_profile_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_close_profile_p", utc_connection_close_profile_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_close_profile_n", utc_connection_close_profile_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_update_profile_p", utc_connection_update_profile_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_update_profile_n", utc_connection_update_profile_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_remove_profile_p", utc_connection_remove_profile_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_remove_profile_n", utc_connection_remove_profile_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_open_profile_p", utc_connection_open_profile_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_open_profile_n", utc_connection_open_profile_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_reset_profile_p", utc_connection_reset_profile_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_reset_profile_n", utc_connection_reset_profile_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_foreach_ipv6_address_p", utc_connection_foreach_ipv6_address_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_foreach_ipv6_address_n", utc_connection_foreach_ipv6_address_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_ethernet_cable_state_changed_cb_n", utc_connection_set_ethernet_cable_state_changed_cb_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_ethernet_cable_state_changed_cb_p", utc_connection_set_ethernet_cable_state_changed_cb_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_unset_ethernet_cable_state_changed_cb_n", utc_connection_unset_ethernet_cable_state_changed_cb_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_unset_ethernet_cable_state_changed_cb_p", utc_connection_unset_ethernet_cable_state_changed_cb_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_internet_state_changed_cb_p", utc_connection_set_internet_state_changed_cb_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_internet_state_changed_cb_n1", utc_connection_set_internet_state_changed_cb_n1, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_set_internet_state_changed_cb_n2", utc_connection_set_internet_state_changed_cb_n2, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_unset_internet_state_changed_cb_p", utc_connection_unset_internet_state_changed_cb_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_unset_internet_state_changed_cb_n", utc_connection_unset_internet_state_changed_cb_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_profile_get_internet_state_p", utc_connection_profile_get_internet_state_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_profile_get_internet_state_n1", utc_connection_profile_get_internet_state_n1, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_profile_get_internet_state_n2", utc_connection_profile_get_internet_state_n2, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_destroy_p", utc_connection_destroy_p, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_destroy_n", utc_connection_destroy_n, utc_network_connection_startup, utc_network_connection_cleanup}, + {"utc_connection_profile_start_tcpdump_p", utc_connection_profile_start_tcpdump_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_start_tcpdump_n", utc_connection_profile_start_tcpdump_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_stop_tcpdump_p", utc_connection_profile_stop_tcpdump_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_stop_tcpdump_n", utc_connection_profile_stop_tcpdump_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_tcpdump_state_p", utc_connection_profile_get_tcpdump_state_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_tcpdump_state_n", utc_connection_profile_get_tcpdump_state_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_save_ethernet_eap_config_p", utc_connection_profile_save_ethernet_eap_config_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_save_ethernet_eap_config_n", utc_connection_profile_save_ethernet_eap_config_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_is_supported_p", utc_connection_mptcp_is_supported_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_is_supported_n", utc_connection_mptcp_is_supported_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_enable_p", utc_connection_mptcp_enable_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_enable_n", utc_connection_mptcp_enable_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_disable_p", utc_connection_mptcp_disable_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_disable_n", utc_connection_mptcp_disable_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_get_enabled_p", utc_connection_mptcp_get_enabled_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_get_enabled_n", utc_connection_mptcp_get_enabled_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_set_path_manager_p", utc_connection_mptcp_set_path_manager_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_set_path_manager_n", utc_connection_mptcp_set_path_manager_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_get_path_manager_p", utc_connection_mptcp_get_path_manager_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_get_path_manager_n", utc_connection_mptcp_get_path_manager_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_set_scheduler_p", utc_connection_mptcp_set_scheduler_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_set_scheduler_n", utc_connection_mptcp_set_scheduler_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_get_scheduler_p", utc_connection_mptcp_get_scheduler_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_mptcp_get_scheduler_n", utc_connection_mptcp_get_scheduler_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_is_ethernet_eap_enabled_p", utc_connection_profile_is_ethernet_eap_enabled_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_is_ethernet_eap_enabled_n", utc_connection_profile_is_ethernet_eap_enabled_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_enable_ethernet_eap_p", utc_connection_profile_enable_ethernet_eap_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_enable_ethernet_eap_n", utc_connection_profile_enable_ethernet_eap_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_type_p", utc_connection_profile_set_ethernet_eap_type_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_type_n", utc_connection_profile_set_ethernet_eap_type_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_type_p", utc_connection_profile_get_ethernet_eap_type_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_type_n", utc_connection_profile_get_ethernet_eap_type_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_passphrase_p", utc_connection_profile_set_ethernet_eap_passphrase_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_passphrase_n", utc_connection_profile_set_ethernet_eap_passphrase_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_passphrase_p", utc_connection_profile_get_ethernet_eap_passphrase_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_passphrase_n", utc_connection_profile_get_ethernet_eap_passphrase_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_identity_p", utc_connection_profile_set_ethernet_eap_identity_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_identity_n", utc_connection_profile_set_ethernet_eap_identity_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_identity_p", utc_connection_profile_get_ethernet_eap_identity_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_identity_n", utc_connection_profile_get_ethernet_eap_identity_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_ca_cert_file_p", utc_connection_profile_set_ethernet_eap_ca_cert_file_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_ca_cert_file_n", utc_connection_profile_set_ethernet_eap_ca_cert_file_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_ca_cert_file_p", utc_connection_profile_get_ethernet_eap_ca_cert_file_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_ca_cert_file_n", utc_connection_profile_get_ethernet_eap_ca_cert_file_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_client_cert_file_p", utc_connection_profile_set_ethernet_eap_client_cert_file_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_client_cert_file_n", utc_connection_profile_set_ethernet_eap_client_cert_file_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_client_cert_file_p", utc_connection_profile_get_ethernet_eap_client_cert_file_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_client_cert_file_n", utc_connection_profile_get_ethernet_eap_client_cert_file_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_private_key_info_p", utc_connection_profile_set_ethernet_eap_private_key_info_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_private_key_info_n", utc_connection_profile_set_ethernet_eap_private_key_info_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_private_key_file_p", utc_connection_profile_get_ethernet_eap_private_key_file_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_private_key_file_n", utc_connection_profile_get_ethernet_eap_private_key_file_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_anonymous_identity_p", utc_connection_profile_set_ethernet_eap_anonymous_identity_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_anonymous_identity_n", utc_connection_profile_set_ethernet_eap_anonymous_identity_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_anonymous_identity_p", utc_connection_profile_get_ethernet_eap_anonymous_identity_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_anonymous_identity_n", utc_connection_profile_get_ethernet_eap_anonymous_identity_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_pac_file_p", utc_connection_profile_set_ethernet_eap_pac_file_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_pac_file_n", utc_connection_profile_set_ethernet_eap_pac_file_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_pac_file_p", utc_connection_profile_get_ethernet_eap_pac_file_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_pac_file_n", utc_connection_profile_get_ethernet_eap_pac_file_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_auth_type_p", utc_connection_profile_set_ethernet_eap_auth_type_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_auth_type_n", utc_connection_profile_set_ethernet_eap_auth_type_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_auth_type_p", utc_connection_profile_get_ethernet_eap_auth_type_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_auth_type_n", utc_connection_profile_get_ethernet_eap_auth_type_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_peap_version_p", utc_connection_profile_set_ethernet_eap_peap_version_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_set_ethernet_eap_peap_version_n", utc_connection_profile_set_ethernet_eap_peap_version_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_peap_version_p", utc_connection_profile_get_ethernet_eap_peap_version_p, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {"utc_connection_profile_get_ethernet_eap_peap_version_n", utc_connection_profile_get_ethernet_eap_peap_version_n, utc_connection_extension_startup, utc_connection_extension_cleanup}, + {NULL, NULL} +}; + +#endif // __TCT_CONNECTION_CORE_H__ diff --git a/unittest/utc-connection-common.c b/unittest/utc-connection-common.c new file mode 100755 index 0000000..97860f4 --- /dev/null +++ b/unittest/utc-connection-common.c @@ -0,0 +1,130 @@ +// +// Copyright (c) 2020 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 "utc-connection-common.h" + +gboolean test_connection_timeout_callback(gpointer data) +{ + g_CallbackRet = CONNECTION_ERROR_OPERATION_FAILED; + PRINT_RETURN("test_connection_timeout_callback", g_CallbackRet); + + return false; +} + +const char *connection_get_error(connection_error_e error) +{ + switch (error) { + case CONNECTION_ERROR_NONE: + return "CONNECTION_ERROR_NONE"; + case CONNECTION_ERROR_INVALID_PARAMETER: + return "CONNECTION_ERROR_INVALID_PARAMETER"; + case CONNECTION_ERROR_OUT_OF_MEMORY: + return "CONNECTION_ERROR_OUT_OF_MEMORY"; + case CONNECTION_ERROR_INVALID_OPERATION: + return "CONNECTION_ERROR_INVALID_OPERATION"; + case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED: + return "CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED"; + case CONNECTION_ERROR_OPERATION_FAILED: + return "CONNECTION_ERROR_OPERATION_FAILED"; + case CONNECTION_ERROR_ITERATOR_END: + return "CONNECTION_ERROR_ITERATOR_END"; + case CONNECTION_ERROR_NO_CONNECTION: + return "CONNECTION_ERROR_NO_CONNECTION"; + case CONNECTION_ERROR_NOW_IN_PROGRESS: + return "CONNECTION_ERROR_NOW_IN_PROGRESS"; + case CONNECTION_ERROR_ALREADY_EXISTS: + return "CONNECTION_ERROR_ALREADY_EXISTS"; + case CONNECTION_ERROR_OPERATION_ABORTED: + return "CONNECTION_ERROR_OPERATION_ABORTED"; + case CONNECTION_ERROR_DHCP_FAILED: + return "CONNECTION_ERROR_DHCP_FAILED"; + case CONNECTION_ERROR_INVALID_KEY: + return "CONNECTION_ERROR_INVALID_KEY"; + case CONNECTION_ERROR_NO_REPLY: + return "CONNECTION_ERROR_NO_REPLY"; + case CONNECTION_ERROR_PERMISSION_DENIED: + return "CONNECTION_ERROR_PERMISSION_DENIED"; + case CONNECTION_ERROR_NOT_SUPPORTED: + return "CONNECTION_ERROR_NOT_SUPPORTED"; + case CONNECTION_ERROR_ALREADY_INITIALIZED: + return "CONNECTION_ERROR_ALREADY_INITIALIZED"; + case CONNECTION_ERROR_NOT_INITIALIZED: + return "CONNECTION_ERROR_NOT_INITIALIZED"; + default: + return "CONNECTION_ERROR_UNKNOWN"; + } +} + +bool connection_check_feature_supported(char *key) +{ + bool value = false; + int ret = system_info_get_platform_bool(key, &value); + + if (ret != SYSTEM_INFO_ERROR_NONE) { + return false; + } + + return value; +} + +int test_get_any_profile(connection_profile_h *profile) +{ + connection_profile_h profile_h; + connection_profile_iterator_h profile_iter; + + int rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter); + PRINT_RETURN("connection_get_profile_iterator", rv); + if(CONNECTION_ERROR_NONE != rv) + return -1; + + rv = connection_profile_iterator_next(profile_iter, &profile_h); + PRINT_RETURN("connection_profile_iterator_next", rv); + if(CONNECTION_ERROR_NONE != rv) + return -1; + + rv = connection_profile_clone(profile, profile_h); + PRINT_RETURN("connection_profile_clone", rv); + if(CONNECTION_ERROR_NONE != rv) + return -1; + + return 1; +} + +int test_get_profile_by_type(connection_profile_h *profile, connection_profile_type_e type) +{ + connection_profile_h profile_h; + connection_profile_iterator_h profile_iter; + connection_profile_type_e profile_type; + + int rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter); + CHECK_RETURN("connection_get_profile_iterator", rv, CONNECTION_ERROR_NONE); + + while (connection_profile_iterator_has_next(profile_iter)) { + rv = connection_profile_iterator_next(profile_iter, &profile_h); + CHECK_RETURN("connection_profile_iterator_next", rv, CONNECTION_ERROR_NONE); + + rv = connection_profile_get_type(profile_h, &profile_type); + CHECK_RETURN("connection_profile_get_type", rv, CONNECTION_ERROR_NONE); + + if (profile_type == type) { + rv = connection_profile_clone(profile, profile_h); + CHECK_RETURN("connection_profile_clone", rv, CONNECTION_ERROR_NONE); + return CONNECTION_ERROR_NONE; + } + } + + return CONNECTION_ERROR_NONE; +} diff --git a/unittest/utc-connection-common.h b/unittest/utc-connection-common.h new file mode 100755 index 0000000..e1293d5 --- /dev/null +++ b/unittest/utc-connection-common.h @@ -0,0 +1,122 @@ +// +// Copyright (c) 2020 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 _CONNECTION_COMMON_H_ +#define _CONNECTION_COMMON_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "assert_local.h" + +#ifdef DEBUG_GCOV +#define COMMON_DEBUG 1 +#else +#define COMMON_DEBUG 0 +#endif + +#define GMAINTIMEOUT 20000 +#define CUSTOM_PROFILE_NAME "Net" + +#define FEATURE_WIFI "http://tizen.org/feature/network.wifi" +#define FEATURE_ETHERNET "http://tizen.org/feature/network.ethernet" +#define FEATURE_TELEPHONY "http://tizen.org/feature/network.telephony" +#define FEATURE_BT_TETHERING "http://tizen.org/feature/network.tethering.bluetooth" +#define CALLBACK_RETURN "callback return" + +GMainLoop *g_pMainLoop; +guint g_nTimeoutId; +int g_CallbackRet; + +bool wifi_supported; +bool telephony_supported; +bool bt_tethering_supported; +bool ethernet_supported; +bool all_features_not_supported; + +connection_profile_h profile_cellular; +connection_profile_h profile_wifi; +connection_profile_h profile_temp; +connection_h connection; + +#define RUN_GMAIN_LOOP {\ + g_pMainLoop = g_main_loop_new(NULL, false);\ + g_nTimeoutId = g_timeout_add(GMAINTIMEOUT, test_connection_timeout_callback, g_pMainLoop);\ + if (COMMON_DEBUG) {\ + PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] Run mainloop [%p]",\ + __LINE__, __FUNCTION__, g_pMainLoop);\ + }\ + g_main_loop_run(g_pMainLoop);\ + g_source_remove(g_nTimeoutId);\ + g_pMainLoop = NULL;\ +} + +#define QUIT_GMAIN_LOOP {\ + if (g_pMainLoop)\ +{\ + if (COMMON_DEBUG) {\ + PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] Quit mainloop [%p]",\ + __LINE__, __FUNCTION__, g_pMainLoop);\ + }\ + g_main_loop_quit(g_pMainLoop);\ +}\ +} + +#define FREE_RESOURCE(var) {\ + if(var != NULL) {\ + g_free(var);\ + var = NULL;\ + }\ +} + +#define PRINT_RETURN(api, ret) {\ + if (COMMON_DEBUG) {\ + PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] %s returned = %s",\ + __LINE__, __FUNCTION__, api, connection_get_error(ret));\ + }\ +} + +#define CHECK_RETURN(api, ret, val) {\ + if (ret != val) {\ + if (COMMON_DEBUG) {\ + PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] %s failed, error returned = %s",\ + __LINE__, __FUNCTION__, api, connection_get_error(ret));\ + }\ + return 1;\ + } else {\ + if (COMMON_DEBUG) {\ + PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] %s",\ + __LINE__, __FUNCTION__, api);\ + }\ + }\ +} + +#define DEBUG_LOG {\ + PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] ***** DEBUG *****", __LINE__, __FUNCTION__);\ +} + +gboolean test_connection_timeout_callback(gpointer data); +const char *connection_get_error(connection_error_e error); +bool connection_check_feature_supported(char *key); +int test_get_any_profile(connection_profile_h *profile); +int test_get_profile_by_type(connection_profile_h *profile, connection_profile_type_e type); + +#endif /* _CONNECTION_COMMON_H_ */ diff --git a/unittest/utc-connection-extension.c b/unittest/utc-connection-extension.c new file mode 100755 index 0000000..3437878 --- /dev/null +++ b/unittest/utc-connection-extension.c @@ -0,0 +1,1277 @@ +// +// Copyright (c) 2020 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 "utc-connection-common.h" +#include "connection_extension.h" + +#define EAP_USER_NAME "eap_user_name" +#define EAP_PASSPHRASE "eap_passphrase" +#define EAP_IDENTITY "eap_identity" +#define EAP_CA_CERT_FILE "eap_ca_cert_file" +#define EAP_CLIENT_CERT_FILE "eap_client_cert_file" +#define EAP_PRIVATE_KEY_FILENAME "eap_private_key_filename" +#define EAP_PRIVATE_KEY_PASSWD "eap_private_key_passwd" +#define EAP_ANONYMOUS_IDENTITY "eap_anonymous_identity" +#define EAP_PAC_FILENAME "eap_pac_filename" + +void utc_connection_extension_startup(void) +{ + wifi_supported = connection_check_feature_supported(FEATURE_WIFI); + telephony_supported = connection_check_feature_supported(FEATURE_TELEPHONY); + bt_tethering_supported = connection_check_feature_supported(FEATURE_BT_TETHERING); + ethernet_supported = connection_check_feature_supported(FEATURE_ETHERNET); + + if (telephony_supported == false && wifi_supported == false + && bt_tethering_supported == false && ethernet_supported == false) { + all_features_not_supported = true; + return; + } + + int ret = connection_create(&connection); + PRINT_RETURN("connection_create", ret); + + if (ret != CONNECTION_ERROR_NONE) + return; + + if (telephony_supported) { + if (!profile_cellular) { + ret = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, "Net", &profile_cellular); + PRINT_RETURN("connection_profile_create", ret); + } + } + + if (wifi_supported) { + if (!profile_wifi) { + ret = connection_profile_create(CONNECTION_PROFILE_TYPE_WIFI, NULL, &profile_wifi); + PRINT_RETURN("connection_profile_create", ret); + } + } +} + +/** + * @function utc_connection_profile_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void utc_connection_extension_cleanup(void) +{ + int ret; + + if (profile_cellular) { + ret = connection_profile_destroy(profile_cellular); + PRINT_RETURN("connection_profile_destroy", ret); + if (ret == CONNECTION_ERROR_NONE) + profile_cellular = NULL; + } + + if (profile_wifi) { + ret = connection_profile_destroy(profile_wifi); + PRINT_RETURN("connection_profile_destroy", ret); + if (ret == CONNECTION_ERROR_NONE) + profile_wifi = NULL; + } + + if (profile_temp) { + ret = connection_profile_destroy(profile_temp); + PRINT_RETURN("connection_profile_destroy", ret); + if (ret == CONNECTION_ERROR_NONE) + profile_temp = NULL; + } + + if (connection) { + ret = connection_destroy(connection); + PRINT_RETURN("connection_destroy", ret); + if (ret == CONNECTION_ERROR_NONE) + connection = NULL; + } +} + +int utc_connection_profile_start_tcpdump_p(void) +{ + int ret; + + if (telephony_supported) { + ret = connection_profile_start_tcpdump(connection); + CHECK_RETURN("connection_profile_start_tcpdump", ret, CONNECTION_ERROR_NONE); + } else { + ret = connection_profile_start_tcpdump(connection); + CHECK_RETURN("connection_profile_start_tcpdump", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_connection_profile_start_tcpdump_n(void) +{ + int ret; + + if (telephony_supported) { + ret = connection_profile_start_tcpdump(NULL); + CHECK_RETURN("connection_profile_start_tcpdump", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + ret = connection_profile_start_tcpdump(NULL); + CHECK_RETURN("connection_profile_start_tcpdump", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_connection_profile_stop_tcpdump_p(void) +{ + int ret; + + if (telephony_supported) { + ret = connection_profile_stop_tcpdump(connection); + CHECK_RETURN("connection_profile_start_tcpdump", ret, CONNECTION_ERROR_NONE); + } else { + ret = connection_profile_stop_tcpdump(connection); + CHECK_RETURN("connection_profile_start_tcpdump", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_connection_profile_stop_tcpdump_n(void) +{ + int ret; + + if (telephony_supported) { + ret = connection_profile_stop_tcpdump(NULL); + CHECK_RETURN("connection_profile_stop_tcpdump", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + ret = connection_profile_stop_tcpdump(NULL); + CHECK_RETURN("connection_profile_stop_tcpdump", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_connection_profile_get_tcpdump_state_p(void) +{ + int ret; + gboolean state; + + if (telephony_supported) { + ret = connection_profile_get_tcpdump_state(connection, &state); + CHECK_RETURN("connection_profile_get_tcpdump_state", ret, CONNECTION_ERROR_NONE); + } else { + ret = connection_profile_get_tcpdump_state(connection, &state); + CHECK_RETURN("connection_profile_get_tcpdump_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_connection_profile_get_tcpdump_state_n(void) +{ + int ret; + + if (telephony_supported) { + ret = connection_profile_get_tcpdump_state(NULL, NULL); + CHECK_RETURN("connection_profile_get_tcpdump_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + ret = connection_profile_get_tcpdump_state(NULL, NULL); + CHECK_RETURN("connection_profile_get_tcpdump_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_connection_profile_save_ethernet_eap_config_p(void) +{ + connection_profile_h profile_h = NULL; + int ret = test_get_any_profile(&profile_h); + + if (!ethernet_supported) { + ret = connection_profile_save_ethernet_eap_config(connection, profile_temp); + CHECK_RETURN("connection_profile_save_ethernet_eap_config", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + assert(profile_h); + profile_temp = profile_h; + + ret = connection_profile_save_ethernet_eap_config(connection, profile_temp); + CHECK_RETURN("connection_profile_save_ethernet_eap_config", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_save_ethernet_eap_config_n(void) +{ + int ret; + + if (telephony_supported) { + ret = connection_profile_save_ethernet_eap_config(NULL, NULL); + CHECK_RETURN("connection_profile_save_ethernet_eap_config", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + ret = connection_profile_save_ethernet_eap_config(NULL, NULL); + CHECK_RETURN("connection_profile_save_ethernet_eap_config", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_connection_mptcp_is_supported_p(void) +{ + int ret; + bool supported; + + ret = connection_mptcp_is_supported(connection, &supported); + CHECK_RETURN("connection_mptcp_is_supported", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_mptcp_is_supported_n(void) +{ + int ret; + + ret = connection_mptcp_is_supported(NULL, NULL); + CHECK_RETURN("connection_mptcp_is_supported", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_mptcp_enable_p(void) +{ + int ret; + + ret = connection_mptcp_enable(connection, CONNECTION_MPTCP_ENABLE_ALL); + CHECK_RETURN("connection_mptcp_enable", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_mptcp_enable_n(void) +{ + int ret; + + ret = connection_mptcp_enable(NULL, CONNECTION_MPTCP_ENABLE_ALL); + CHECK_RETURN("connection_mptcp_enable", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_mptcp_enable(connection, CONNECTION_MPTCP_DISABLE); + CHECK_RETURN("connection_mptcp_enable", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_mptcp_disable_p(void) +{ + int ret; + + ret = connection_mptcp_disable(connection); + CHECK_RETURN("connection_mptcp_disable", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_mptcp_disable_n(void) +{ + int ret; + + ret = connection_mptcp_disable(NULL); + CHECK_RETURN("connection_mptcp_disable", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_mptcp_get_enabled_p(void) +{ + int ret; + connection_mptcp_enable_e enable; + + ret = connection_mptcp_get_enabled(connection, &enable); + CHECK_RETURN("connection_mptcp_get_enabled", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_mptcp_get_enabled_n(void) +{ + int ret; + + ret = connection_mptcp_get_enabled(NULL, NULL); + CHECK_RETURN("connection_mptcp_get_enabled", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_mptcp_set_path_manager_p(void) +{ + int ret; + + ret = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_DEFAULT); + CHECK_RETURN("connection_mptcp_set_path_manager", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_mptcp_set_path_manager_n(void) +{ + int ret; + + ret = connection_mptcp_set_path_manager(NULL, CONNECTION_MPTCP_PM_DEFAULT); + CHECK_RETURN("connection_mptcp_set_path_manager", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_mptcp_get_path_manager_p(void) +{ + int ret; + connection_mptcp_path_manager_e pm; + + ret = connection_mptcp_get_path_manager(connection, &pm); + CHECK_RETURN("connection_mptcp_get_path_manager", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_mptcp_get_path_manager_n(void) +{ + int ret; + connection_mptcp_path_manager_e pm; + + ret = connection_mptcp_get_path_manager(NULL, &pm); + CHECK_RETURN("connection_mptcp_get_path_manager", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_mptcp_get_path_manager(connection, NULL); + CHECK_RETURN("connection_mptcp_get_path_manager", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_mptcp_set_scheduler_p(void) +{ + int ret; + + ret = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_DEFAULT); + CHECK_RETURN("connection_mptcp_set_scheduler", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_mptcp_set_scheduler_n(void) +{ + int ret; + + ret = connection_mptcp_set_scheduler(NULL, CONNECTION_MPTCP_SCHEDULER_DEFAULT); + CHECK_RETURN("connection_mptcp_set_scheduler", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_mptcp_get_scheduler_p(void) +{ + int ret; + connection_mptcp_scheduler_e scheduler; + + ret = connection_mptcp_get_scheduler(connection, &scheduler); + CHECK_RETURN("connection_mptcp_get_scheduler", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_mptcp_get_scheduler_n(void) +{ + int ret; + connection_mptcp_scheduler_e scheduler; + + ret = connection_mptcp_get_scheduler(NULL, &scheduler); + CHECK_RETURN("connection_mptcp_get_scheduler", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_mptcp_get_scheduler(connection, NULL); + CHECK_RETURN("connection_mptcp_get_scheduler", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_is_ethernet_eap_enabled_p(void) +{ + int ret; + bool enabled; + + if (all_features_not_supported) { + ret = connection_profile_is_ethernet_eap_enabled(NULL, NULL); + CHECK_RETURN("connection_profile_is_ethernet_eap_enabled", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_is_ethernet_eap_enabled(profile_temp, &enabled); + CHECK_RETURN("connection_profile_is_ethernet_eap_enabled", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_is_ethernet_eap_enabled_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_is_ethernet_eap_enabled(NULL, NULL); + CHECK_RETURN("connection_profile_is_ethernet_eap_enabled", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_is_ethernet_eap_enabled(NULL, NULL); + CHECK_RETURN("connection_profile_is_ethernet_eap_enabled", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_enable_ethernet_eap_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_enable_ethernet_eap(NULL, NULL); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_enable_ethernet_eap_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_enable_ethernet_eap(NULL, NULL); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_enable_ethernet_eap(NULL, NULL); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_type_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_type(NULL, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_type_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_type(NULL, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_ethernet_eap_type(NULL, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_type_p(void) +{ + int ret; + connection_ethernet_eap_type_e type; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_type(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_type(profile_temp, &type); + CHECK_RETURN("connection_profile_get_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_type_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_type(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_ethernet_eap_type(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_passphrase_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_passphrase(NULL, NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_passphrase", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_TLS); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_passphrase(profile_temp, EAP_USER_NAME, EAP_PASSPHRASE); + CHECK_RETURN("connection_profile_set_ethernet_eap_passphrase", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_passphrase(profile_temp, EAP_USER_NAME, EAP_PASSPHRASE); + CHECK_RETURN("connection_profile_set_ethernet_eap_passphrase", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_passphrase_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_passphrase(NULL, NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_passphrase", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_ethernet_eap_passphrase(NULL, NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_passphrase", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_passphrase_p(void) +{ + int ret; + char *user_name; + bool is_password_set; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_passphrase(NULL, NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_passphrase", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_TLS); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_passphrase(profile_temp, &user_name, &is_password_set); + CHECK_RETURN("connection_profile_get_ethernet_eap_passphrase", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_passphrase(profile_temp, &user_name, &is_password_set); + CHECK_RETURN("connection_profile_get_ethernet_eap_passphrase", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_passphrase_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_passphrase(NULL, NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_passphrase", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_ethernet_eap_passphrase(NULL, NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_passphrase", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_identity_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_identity(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_identity", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_identity(profile_temp, EAP_IDENTITY); + CHECK_RETURN("connection_profile_set_ethernet_eap_identity", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_identity_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_identity(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_identity", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_ethernet_eap_identity(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_identity", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_identity_p(void) +{ + int ret; + char *identity; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_identity(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_identity", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_identity(profile_temp, &identity); + CHECK_RETURN("connection_profile_get_ethernet_eap_identity", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_identity_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_identity(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_identity", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_ethernet_eap_identity(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_identity", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_ca_cert_file_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_ca_cert_file(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_ca_cert_file", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_MD5); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_ca_cert_file(profile_temp, EAP_CA_CERT_FILE); + CHECK_RETURN("connection_profile_set_ethernet_eap_ca_cert_file", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_ca_cert_file(profile_temp, EAP_CA_CERT_FILE); + CHECK_RETURN("connection_profile_set_ethernet_eap_ca_cert_file", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_ca_cert_file_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_ca_cert_file(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_ca_cert_file", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_ethernet_eap_ca_cert_file(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_ca_cert_file", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_ca_cert_file_p(void) +{ + int ret; + char *file; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_ca_cert_file(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_ca_cert_file", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_MD5); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_ca_cert_file(profile_temp, &file); + CHECK_RETURN("connection_profile_get_ethernet_eap_ca_cert_file", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_ca_cert_file(profile_temp, &file); + CHECK_RETURN("connection_profile_get_ethernet_eap_ca_cert_file", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_ca_cert_file_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_ca_cert_file(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_ca_cert_file", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_ethernet_eap_ca_cert_file(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_ca_cert_file", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_client_cert_file_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_client_cert_file(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_client_cert_file", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_client_cert_file(profile_temp, EAP_CLIENT_CERT_FILE); + CHECK_RETURN("connection_profile_set_ethernet_eap_client_cert_file", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_TLS); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_client_cert_file(profile_temp, EAP_CLIENT_CERT_FILE); + CHECK_RETURN("connection_profile_set_ethernet_eap_client_cert_file", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_client_cert_file_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_client_cert_file(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_client_cert_file", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_ethernet_eap_client_cert_file(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_client_cert_file", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_client_cert_file_p(void) +{ + int ret; + char *file; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_client_cert_file(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_client_cert_file", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_client_cert_file(profile_temp, &file); + CHECK_RETURN("connection_profile_get_ethernet_eap_client_cert_file", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_TLS); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_client_cert_file(profile_temp, &file); + CHECK_RETURN("connection_profile_get_ethernet_eap_client_cert_file", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_client_cert_file_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_client_cert_file(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_client_cert_file", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_ethernet_eap_client_cert_file(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_client_cert_file", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_private_key_info_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_private_key_info(NULL, NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_private_key_info", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_private_key_info(profile_temp, + EAP_PRIVATE_KEY_FILENAME, EAP_PRIVATE_KEY_PASSWD); + CHECK_RETURN("connection_profile_set_ethernet_eap_private_key_info", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_TLS); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_private_key_info(profile_temp, + EAP_PRIVATE_KEY_FILENAME, EAP_PRIVATE_KEY_PASSWD); + CHECK_RETURN("connection_profile_set_ethernet_eap_private_key_info", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_private_key_info_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_private_key_info(NULL, NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_private_key_info", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_ethernet_eap_private_key_info(NULL, NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_private_key_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_private_key_file_p(void) +{ + int ret; + char *file; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_private_key_file(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_private_key_file", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_private_key_file(profile_temp, &file); + CHECK_RETURN("connection_profile_get_ethernet_eap_private_key_file", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_TLS); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_private_key_file(profile_temp, &file); + CHECK_RETURN("connection_profile_get_ethernet_eap_private_key_file", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_private_key_file_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_private_key_file(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_private_key_file", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_ethernet_eap_private_key_file(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_private_key_file", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_anonymous_identity_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_anonymous_identity(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_anonymous_identity", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_MD5); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_anonymous_identity(profile_temp, EAP_ANONYMOUS_IDENTITY); + CHECK_RETURN("connection_profile_set_ethernet_eap_anonymous_identity", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_anonymous_identity(profile_temp, EAP_ANONYMOUS_IDENTITY); + CHECK_RETURN("connection_profile_set_ethernet_eap_anonymous_identity", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_anonymous_identity_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_anonymous_identity(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_anonymous_identity", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_ethernet_eap_anonymous_identity(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_anonymous_identity", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_anonymous_identity_p(void) +{ + int ret; + char *file; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_anonymous_identity(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_anonymous_identity", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_MD5); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_anonymous_identity(profile_temp, &file); + CHECK_RETURN("connection_profile_get_ethernet_eap_anonymous_identity", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_anonymous_identity(profile_temp, &file); + CHECK_RETURN("connection_profile_get_ethernet_eap_anonymous_identity", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_anonymous_identity_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_anonymous_identity(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_anonymous_identity", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_ethernet_eap_anonymous_identity(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_anonymous_identity", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_pac_file_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_pac_file(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_pac_file", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_TLS); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_pac_file(profile_temp, EAP_PAC_FILENAME); + CHECK_RETURN("connection_profile_set_ethernet_eap_pac_file", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_FAST); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_pac_file(profile_temp, EAP_PAC_FILENAME); + CHECK_RETURN("connection_profile_set_ethernet_eap_pac_file", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_pac_file_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_pac_file(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_pac_file", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_ethernet_eap_pac_file(NULL, NULL); + CHECK_RETURN("connection_profile_set_ethernet_eap_pac_file", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_pac_file_p(void) +{ + int ret; + char *file; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_pac_file(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_pac_file", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_TLS); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_pac_file(profile_temp, &file); + CHECK_RETURN("connection_profile_get_ethernet_eap_pac_file", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_FAST); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_pac_file(profile_temp, &file); + CHECK_RETURN("connection_profile_get_ethernet_eap_pac_file", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_pac_file_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_pac_file(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_pac_file", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_ethernet_eap_pac_file(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_pac_file", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_auth_type_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_auth_type(NULL, CONNECTION_ETHERNET_EAP_AUTH_TYPE_MSCHAPV2); + CHECK_RETURN("connection_profile_set_ethernet_eap_auth_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_MD5); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_auth_type(profile_temp, CONNECTION_ETHERNET_EAP_AUTH_TYPE_MSCHAPV2); + CHECK_RETURN("connection_profile_set_ethernet_eap_auth_type", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_FAST); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_auth_type(profile_temp, CONNECTION_ETHERNET_EAP_AUTH_TYPE_MSCHAPV2); + CHECK_RETURN("connection_profile_set_ethernet_eap_auth_type", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_auth_type_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_auth_type(NULL, CONNECTION_ETHERNET_EAP_AUTH_TYPE_MSCHAPV2); + CHECK_RETURN("connection_profile_set_ethernet_eap_auth_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_ethernet_eap_auth_type(NULL, CONNECTION_ETHERNET_EAP_AUTH_TYPE_MSCHAPV2); + CHECK_RETURN("connection_profile_set_ethernet_eap_auth_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_auth_type_p(void) +{ + int ret; + connection_ethernet_eap_auth_type_e type; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_auth_type(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_auth_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_FAST); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_auth_type(profile_temp, &type); + CHECK_RETURN("connection_profile_get_ethernet_eap_auth_type", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_auth_type_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_auth_type(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_auth_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_ethernet_eap_auth_type(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_auth_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_peap_version_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_peap_version(NULL, CONNECTION_ETHERNET_EAP_PEAP_VERSION_0); + CHECK_RETURN("connection_profile_set_ethernet_eap_peap_version", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_MD5); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_peap_version(profile_temp, CONNECTION_ETHERNET_EAP_PEAP_VERSION_0); + CHECK_RETURN("connection_profile_set_ethernet_eap_peap_version", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_peap_version(profile_temp, CONNECTION_ETHERNET_EAP_PEAP_VERSION_0); + CHECK_RETURN("connection_profile_set_ethernet_eap_peap_version", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_set_ethernet_eap_peap_version_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_set_ethernet_eap_peap_version(NULL, CONNECTION_ETHERNET_EAP_PEAP_VERSION_0); + CHECK_RETURN("connection_profile_set_ethernet_eap_peap_version", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_ethernet_eap_peap_version(NULL, CONNECTION_ETHERNET_EAP_PEAP_VERSION_0); + CHECK_RETURN("connection_profile_set_ethernet_eap_peap_version", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_peap_version_p(void) +{ + int ret; + connection_ethernet_eap_peap_version_e version; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_peap_version(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_peap_version", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_enable_ethernet_eap(profile_temp, TRUE); + CHECK_RETURN("connection_profile_enable_ethernet_eap", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_TLS); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_peap_version(profile_temp, &version); + CHECK_RETURN("connection_profile_get_ethernet_eap_peap_version", ret, CONNECTION_ERROR_INVALID_OPERATION); + ret = connection_profile_set_ethernet_eap_type(profile_temp, CONNECTION_ETHERNET_EAP_TYPE_PEAP); + CHECK_RETURN("connection_profile_set_ethernet_eap_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_ethernet_eap_peap_version(profile_temp, &version); + CHECK_RETURN("connection_profile_get_ethernet_eap_peap_version", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +int utc_connection_profile_get_ethernet_eap_peap_version_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_profile_get_ethernet_eap_peap_version(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_peap_version", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_ethernet_eap_peap_version(NULL, NULL); + CHECK_RETURN("connection_profile_get_ethernet_eap_peap_version", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + diff --git a/unittest/utc-connection-profile.c b/unittest/utc-connection-profile.c new file mode 100755 index 0000000..8c0d998 --- /dev/null +++ b/unittest/utc-connection-profile.c @@ -0,0 +1,3364 @@ +// +// Copyright (c) 2020 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 "utc-connection-common.h" + +//& set: ConnectionProfile + +static void test_profile_state_changed_cb(connection_profile_state_e state, void* user_data) +{ + char *profile_name; + connection_profile_h profile = user_data; + + if (profile == NULL) + return; + + int ret = connection_profile_get_name(profile, &profile_name); + PRINT_RETURN("connection_profile_get_name", ret); + if (ret != CONNECTION_ERROR_NONE) { + FREE_RESOURCE(profile_name); + return; + } + + FREE_RESOURCE(profile_name); +} + +/** + * @function utc_connection_profile_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_connection_profile_startup(void) +{ + wifi_supported = connection_check_feature_supported(FEATURE_WIFI); + telephony_supported = connection_check_feature_supported(FEATURE_TELEPHONY); + bt_tethering_supported = connection_check_feature_supported(FEATURE_BT_TETHERING); + ethernet_supported = connection_check_feature_supported(FEATURE_ETHERNET); + + if (telephony_supported == false && wifi_supported == false + && bt_tethering_supported == false && ethernet_supported == false) { + all_features_not_supported = true; + return; + } + + int ret = connection_create(&connection); + PRINT_RETURN("connection_create", ret); + + if (ret != CONNECTION_ERROR_NONE) + return; + + if (telephony_supported) { + if (!profile_cellular) { + ret = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, "Net", &profile_cellular); + PRINT_RETURN("connection_profile_create", ret); + } + } + + if (wifi_supported) { + if (!profile_wifi) { + ret = connection_profile_create(CONNECTION_PROFILE_TYPE_WIFI, NULL, &profile_wifi); + PRINT_RETURN("connection_profile_create", ret); + } + } +} + +/** + * @function utc_connection_profile_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void utc_connection_profile_cleanup(void) +{ + int ret; + + if (profile_cellular) { + ret = connection_profile_destroy(profile_cellular); + PRINT_RETURN("connection_profile_destroy", ret); + if (ret == CONNECTION_ERROR_NONE) + profile_cellular = NULL; + } + + if (profile_wifi) { + ret = connection_profile_destroy(profile_wifi); + PRINT_RETURN("connection_profile_destroy", ret); + if (ret == CONNECTION_ERROR_NONE) + profile_wifi = NULL; + } + + if (profile_temp) { + ret = connection_profile_destroy(profile_temp); + PRINT_RETURN("connection_profile_destroy", ret); + if (ret == CONNECTION_ERROR_NONE) + profile_temp = NULL; + } + + if (connection) { + ret = connection_destroy(connection); + PRINT_RETURN("connection_destroy", ret); + if (ret == CONNECTION_ERROR_NONE) + connection = NULL; + } +} + +/* Common profile operations. */ + +/** + * @testcase utc_connection_profile_create_p + * @since_tizen 2.3 + * @type Positive + * @description Creates a profile handle. + * @scenario Invoking connection_profile_create with valid parameter. + */ +int utc_connection_profile_create_p(void) +{ + int ret; + + if (profile_cellular) { + ret = connection_profile_destroy(profile_cellular); + PRINT_RETURN("connection_profile_destroy", ret); + profile_cellular = NULL; + } + + if (telephony_supported) { + ret = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, "Net", &profile_cellular); + CHECK_RETURN("connection_profile_create", ret, CONNECTION_ERROR_NONE); + } else { + ret = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, "Net", &profile_cellular); + CHECK_RETURN("connection_profile_create", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_create_n + * @since_tizen 2.3 + * @type Negative + * @description should not creates a profile handle. + * @scenario Verify connection_profile_create by passing invalid parameter. + */ +int utc_connection_profile_create_n(void) +{ + int ret; + connection_profile_h profile_temp = NULL; + + if (telephony_supported == false && wifi_supported == false) { + ret = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, "Net", NULL); + CHECK_RETURN("connection_profile_create", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + if (telephony_supported) { + ret = connection_profile_create(-1, "Net", &profile_temp); + CHECK_RETURN("connection_profile_create", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, NULL, &profile_temp); + CHECK_RETURN("connection_profile_create", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, "Net", NULL); + CHECK_RETURN("connection_profile_create", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + ret = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, "Net", NULL); + CHECK_RETURN("connection_profile_create", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_clone_p + * @since_tizen 2.3 + * @type Positive + * @description Clones a profile handle. + * @scenario Verify connection_profile_clone with valid parameter and destroy it. + */ +int utc_connection_profile_clone_p(void) +{ + connection_profile_h profile_temp = NULL; + int ret = 0; + connection_profile_h profile_to_be_cloned = NULL; + + if (all_features_not_supported) { + ret = connection_profile_clone(&profile_temp, profile_to_be_cloned); + CHECK_RETURN("connection_profile_clone", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_any_profile(&profile_to_be_cloned); + if (profile_to_be_cloned != NULL) { + ret = connection_profile_clone(&profile_temp, profile_to_be_cloned); + CHECK_RETURN("connection_profile_clone", ret, CONNECTION_ERROR_NONE); + + ret = connection_profile_destroy(profile_to_be_cloned); + PRINT_RETURN("connection_profile_destroy", ret); + ret = connection_profile_destroy(profile_temp); + PRINT_RETURN("connection_profile_destroy", ret); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_clone_n + * @since_tizen 2.3 + * @type Negative + * @description should not Clones a profile handle. + * @scenario Verify connection_profile_clone by passing invalid parameters. + */ +int utc_connection_profile_clone_n(void) +{ + int ret; + connection_profile_h profile_temp = NULL; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_clone(NULL, profile_inval); + CHECK_RETURN("connection_profile_clone", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_clone(NULL, profile_inval); + CHECK_RETURN("connection_profile_clone", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_clone(NULL, profile_cellular); + CHECK_RETURN("connection_profile_clone", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_clone(&profile_temp, profile_inval); + CHECK_RETURN("connection_profile_clone", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_name_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the profile name. + * @scenario Get the profile name by invoking connection_profile_get_name with a valid parameter. + */ +int utc_connection_profile_get_name_p(void) +{ + int ret; + char *name = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_name(profile_temp, &name); + FREE_RESOURCE(name); + CHECK_RETURN("connection_profile_get_name", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_CELLULAR); + ret = connection_profile_get_name(profile_temp, &name); + CHECK_RETURN("connection_profile_get_name", ret, CONNECTION_ERROR_NONE); + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_WIFI); + ret = connection_profile_get_name(profile_temp, &name); + CHECK_RETURN("connection_profile_get_name", ret, CONNECTION_ERROR_NONE); + + test_get_profile_by_type(&profile_temp, CONNECTION_PROFILE_TYPE_ETHERNET); + ret = connection_profile_get_name(profile_temp, &name); + FREE_RESOURCE(name); + CHECK_RETURN("connection_profile_get_name", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_name_n + * @since_tizen 2.3 + * @type Negative + * @description should not return profile handle. + * @scenario Verify connection_profile_get_name by passing invalid profile handle. + */ +int utc_connection_profile_get_name_n(void) +{ + int ret; + char *name = NULL; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_name(profile_inval, NULL); + FREE_RESOURCE(name); + CHECK_RETURN("connection_profile_get_name", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_name(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_name", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_name(profile_inval, &name); + FREE_RESOURCE(name); + CHECK_RETURN("connection_profile_get_name", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_name(profile_cellular, NULL); + CHECK_RETURN("connection_profile_get_name", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_id_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the profile ID. + * @scenario Invoking connection_profile_get_id with valid profile handle. + */ +int utc_connection_profile_get_id_p(void) +{ + char *id = NULL; + connection_profile_h profile_h = NULL; + int ret = test_get_any_profile(&profile_h); + + if (all_features_not_supported) { + ret = connection_profile_get_id(profile_temp, &id); + FREE_RESOURCE(id); + CHECK_RETURN("connection_profile_get_id", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + profile_temp = profile_h; + assert(profile_temp); + + ret = connection_profile_get_id(profile_temp, &id); + FREE_RESOURCE(id); + CHECK_RETURN("connection_profile_get_id", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_id_n + * @since_tizen 2.3 + * @type Negative + * @description should not return profile ID. + * @scenario Verify connection_profile_get_id by passing invalid parameter.. + */ +int utc_connection_profile_get_id_n(void) +{ + int ret; + char *id = NULL; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_id(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_id", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_id(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_id", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_id(profile_inval, &id); + CHECK_RETURN("connection_profile_get_id", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_id(profile_cellular, NULL); + CHECK_RETURN("connection_profile_get_id", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + + +/** + * @testcase utc_connection_profile_get_type_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the network type. + * @scenario connection_profile_get_type should return profile type. + */ +int utc_connection_profile_get_type_p(void) +{ + connection_profile_type_e type; + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_get_type(profile_temp, &type); + CHECK_RETURN("connection_profile_get_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_get_type(profile_temp, &type); + CHECK_RETURN("connection_profile_get_type", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_type_n + * @since_tizen 2.3 + * @type Negative + * @description should not get the network type. + * @scenario Verify connection_profile_get_type by passing invalid parameter. + */ +int utc_connection_profile_get_type_n(void) +{ + int ret; + connection_profile_type_e type; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_type(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_type(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_type(profile_inval, &type); + CHECK_RETURN("connection_profile_get_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_type(profile_cellular, NULL); + CHECK_RETURN("connection_profile_get_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_network_interface_name_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the name of the network interface, e.g. eth0 and pdp0. + * @scenario Invoking connection_profile_get_network_interface_name with valid parameter. + */ +int utc_connection_profile_get_network_interface_name_p(void) +{ + char *name = NULL; + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_get_network_interface_name(profile_temp, &name); + FREE_RESOURCE(name); + CHECK_RETURN("connection_profile_get_network_interface_name", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_get_network_interface_name(profile_temp, &name); + FREE_RESOURCE(name); + CHECK_RETURN("connection_profile_get_network_interface_name", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_network_interface_name_n + * @since_tizen 2.3 + * @type Negative + * @description should not get the name of the network interface. + * @scenario Verify connection_profile_get_network_interface_name by passing invalid parameter. + */ +int utc_connection_profile_get_network_interface_name_n(void) +{ + int ret; + char *name = NULL; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_network_interface_name(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_network_interface_name", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_network_interface_name(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_network_interface_name", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_network_interface_name(profile_inval, &name); + CHECK_RETURN("connection_profile_get_network_interface_name", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_network_interface_name(profile_cellular, NULL); + CHECK_RETURN("connection_profile_get_network_interface_name", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_state_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the network type and the state of the profile. + * @scenario Verify connection_profile_get_state with valid parameter. + */ +int utc_connection_profile_get_state_p(void) +{ + connection_profile_state_e state; + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_get_state(profile_temp, &state); + CHECK_RETURN("connection_profile_get_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_get_state(profile_temp, &state); + CHECK_RETURN("connection_profile_get_state", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_state_n + * @since_tizen 2.3 + * @type Negative + * @description should not get the state of the profile. + * @scenario Verify connection_profile_get_state by passing invalid parameter. + */ +int utc_connection_profile_get_state_n(void) +{ + int ret; + connection_profile_state_e state; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_state(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_state(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_state(profile_inval, &state); + CHECK_RETURN("connection_profile_get_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_state(profile_cellular, NULL); + CHECK_RETURN("connection_profile_get_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_ip_config_type_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the IP config type.Should return the type of the IP config. + * @scenario Invoking connection_profile_get_ip_config_type with valid parameter. + */ +int utc_connection_profile_get_ip_config_type_p(void) +{ + connection_ip_config_type_e type; + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_get_ip_config_type(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &type); + CHECK_RETURN("connection_profile_get_ip_config_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_get_ip_config_type(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &type); + CHECK_RETURN("connection_profile_get_ip_config_type", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_ip_config_type_n + * @since_tizen 2.3 + * @type Negative + * @description should not return the type of the IP config. + * @scenario Verify connection_profile_get_ip_config_type by passing invalid parameter.. + */ +int utc_connection_profile_get_ip_config_type_n(void) +{ + int ret; + connection_ip_config_type_e type; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_ip_config_type(profile_inval, -1, NULL); + CHECK_RETURN("connection_profile_get_ip_config_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_ip_config_type(profile_inval, -1, NULL); + CHECK_RETURN("connection_profile_get_ip_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_ip_config_type(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, &type); + CHECK_RETURN("connection_profile_get_ip_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_ip_config_type(profile_cellular, -1, &type); + CHECK_RETURN("connection_profile_get_ip_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_ip_config_type(profile_cellular, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_get_ip_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_ip_config_type(profile_inval, -1, &type); + CHECK_RETURN("connection_profile_get_ip_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_ip_config_type(profile_cellular, -1, NULL); + CHECK_RETURN("connection_profile_get_ip_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_ip_address_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the IP address.Shoudl return IP Address. + * @scenario Invoking connection_profile_get_ip_address with valid parameter. + */ +int utc_connection_profile_get_ip_address_p(void) +{ + char *ip_addr = NULL; + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_get_ip_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_ip_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_get_ip_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_ip_address", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_ip_address_n + * @since_tizen 2.3 + * @type Negative + * @description should not return IP Address. + * @scenario Verify connection_profile_get_ip_address by passing invalid parameter. + */ +int utc_connection_profile_get_ip_address_n(void) +{ + int ret; + char *ip_addr = NULL; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_ip_address(profile_inval, -1, NULL); + CHECK_RETURN("connection_profile_get_ip_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_ip_address(profile_inval, -1, NULL); + CHECK_RETURN("connection_profile_get_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_ip_address(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + CHECK_RETURN("connection_profile_get_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_ip_address(profile_cellular, -1, &ip_addr); + CHECK_RETURN("connection_profile_get_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_ip_address(profile_cellular, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_get_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_ip_address(profile_inval, -1, &ip_addr); + CHECK_RETURN("connection_profile_get_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_ip_address(profile_cellular, -1, NULL); + CHECK_RETURN("connection_profile_get_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_subnet_mask_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the Subnet Mask. + * @scenario Invoking connection_profile_get_subnet_mask with valid parameter. + */ +int utc_connection_profile_get_subnet_mask_p(void) +{ + char *ip_addr = NULL; + int ret = test_get_any_profile(&profile_temp); + + if(all_features_not_supported){ + ret = connection_profile_get_subnet_mask(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_subnet_mask", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_get_subnet_mask(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_subnet_mask", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_subnet_mask_n + * @since_tizen 2.3 + * @type Negative + * @description should not return any subnet mask. + * @scenario Verify connection_profile_get_subnet_mask by passing invalid parameter. + */ +int utc_connection_profile_get_subnet_mask_n(void) +{ + int ret; + char *ip_addr = NULL; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_subnet_mask(profile_inval, -1, NULL); + CHECK_RETURN("connection_profile_get_subnet_mask", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_subnet_mask(profile_inval, -1, NULL); + CHECK_RETURN("connection_profile_get_subnet_mask", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_subnet_mask(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + CHECK_RETURN("connection_profile_get_subnet_mask", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_subnet_mask(profile_cellular, -1, &ip_addr); + CHECK_RETURN("connection_profile_get_subnet_mask", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_subnet_mask(profile_cellular, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_get_subnet_mask", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_subnet_mask(profile_inval, -1, &ip_addr); + CHECK_RETURN("connection_profile_get_subnet_mask", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_subnet_mask(profile_cellular, -1, NULL); + CHECK_RETURN("connection_profile_get_subnet_mask", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_gateway_address_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the Gateway address. + * @scenario Invoking connection_profile_get_gateway_address with valid parameter. + */ +int utc_connection_profile_get_gateway_address_p(void) +{ + char *ip_addr = NULL; + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_get_gateway_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_gateway_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_get_gateway_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + CHECK_RETURN("connection_profile_get_gateway_address", ret, CONNECTION_ERROR_NONE); + + ret = connection_profile_get_gateway_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV6, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_gateway_address", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_gateway_address_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_gateway_address should fail with invalid parameter. + * @scenario Verify connection_profile_get_gateway_address by passing invalid parameter. + */ +int utc_connection_profile_get_gateway_address_n(void) +{ + int ret; + char *ip_addr = NULL; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_gateway_address(profile_inval, -1, NULL); + CHECK_RETURN("connection_profile_get_gateway_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_gateway_address(profile_inval, -1, NULL); + CHECK_RETURN("connection_profile_get_gateway_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_gateway_address(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + CHECK_RETURN("connection_profile_get_gateway_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_gateway_address(profile_cellular, -1, &ip_addr); + CHECK_RETURN("connection_profile_get_gateway_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_gateway_address(profile_cellular, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_get_gateway_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_gateway_address(profile_inval, -1, &ip_addr); + CHECK_RETURN("connection_profile_get_gateway_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_gateway_address(profile_cellular, -1, NULL); + CHECK_RETURN("connection_profile_get_gateway_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_dhcp_server_address_p + * @since_tizen 4.0 + * @type Positive + * @description Gets the DHCP server address. + * @scenario Invoking connection_profile_get_dhcp_server_address with valid parameter. + */ +int utc_connection_profile_get_dhcp_server_address_p(void) +{ + char *ip_addr = NULL; + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_get_dhcp_server_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_dhcp_server_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_get_dhcp_server_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV6, &ip_addr); + CHECK_RETURN("connection_profile_get_dhcp_server_address", ret, CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED); + + ret = connection_profile_get_dhcp_server_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_dhcp_server_address", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_gateway_address_n + * @since_tizen 4.0 + * @type Negative + * @description connection_profile_get_dhcp_server_address should fail with invalid parameter. + * @scenario Verify connection_profile_get_dhcp_server_address by passing invalid parameter. + */ +int utc_connection_profile_get_dhcp_server_address_n(void) +{ + int ret; + char *ip_addr = NULL; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_dhcp_server_address(profile_inval, -1, NULL); + CHECK_RETURN("connection_profile_get_dhcp_server_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_dhcp_server_address(profile_inval, -1, NULL); + CHECK_RETURN("connection_profile_get_dhcp_server_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dhcp_server_address(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + CHECK_RETURN("connection_profile_get_dhcp_server_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dhcp_server_address(profile_cellular, -1, &ip_addr); + CHECK_RETURN("connection_profile_get_dhcp_server_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dhcp_server_address(profile_cellular, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_get_dhcp_server_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dhcp_server_address(profile_inval, -1, &ip_addr); + CHECK_RETURN("connection_profile_get_dhcp_server_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dhcp_server_address(profile_cellular, -1, NULL); + CHECK_RETURN("connection_profile_get_dhcp_server_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_dhcp_lease_duration_p + * @since_tizen 4.0 + * @type Positive + * @description Gets the DHCP lease duration. + * @scenario Invoking connection_profile_get_dhcp_lease_duration with valid parameter. + */ +int utc_connection_profile_get_dhcp_lease_duration_p(void) +{ + int dhcp_lease_duration = 0; + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_get_dhcp_lease_duration(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &dhcp_lease_duration); + CHECK_RETURN("connection_profile_get_dhcp_lease_duration", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_get_dhcp_lease_duration(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV6, &dhcp_lease_duration); + CHECK_RETURN("connection_profile_get_dhcp_lease_duration", ret, CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED); + + ret = connection_profile_get_dhcp_lease_duration(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &dhcp_lease_duration); + CHECK_RETURN("connection_profile_get_dhcp_lease_duration", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_dhcp_lease_duration_n + * @since_tizen 4.0 + * @type Negative + * @description connection_profile_get_dhcp_lease_duration should fail with invalid parameter. + * @scenario Verify connection_profile_get_dhcp_lease_duration by passing invalid parameter. + */ +int utc_connection_profile_get_dhcp_lease_duration_n(void) +{ + int ret; + int dhcp_lease_duration = 0; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_dhcp_lease_duration(profile_inval, -1, NULL); + CHECK_RETURN("connection_profile_get_dhcp_lease_duration", ret, CONNECTION_ERROR_NOT_SUPPORTED); + ret = connection_profile_get_dhcp_lease_duration(profile_wifi, CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, &dhcp_lease_duration); + CHECK_RETURN("connection_profile_get_dhcp_lease_duration", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_dhcp_lease_duration(profile_inval, -1, NULL); + CHECK_RETURN("connection_profile_get_dhcp_lease_duration", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dhcp_lease_duration(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, &dhcp_lease_duration); + CHECK_RETURN("connection_profile_get_dhcp_lease_duration", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dhcp_lease_duration(profile_cellular, -1, &dhcp_lease_duration); + CHECK_RETURN("connection_profile_get_dhcp_lease_duration", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dhcp_lease_duration(profile_cellular, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_get_dhcp_lease_duration", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dhcp_lease_duration(profile_inval, -1, &dhcp_lease_duration); + CHECK_RETURN("connection_profile_get_dhcp_lease_duration", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dhcp_lease_duration(profile_cellular, -1, NULL); + CHECK_RETURN("connection_profile_get_dhcp_lease_duration", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_dns_address_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the DNS address. + * @scenario Invoking connection_profile_get_dns_address with valid parameter. + */ +int utc_connection_profile_get_dns_address_p(void) +{ + char *ip_addr = NULL; + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_get_dns_address(profile_temp, 1, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_dns_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_get_dns_address(profile_temp, 1, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_dns_address", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_dns_address(profile_temp, 2, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_dns_address", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_dns_address_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_dns_address should fail with invalid parameter. + * @scenario Verify connection_profile_get_dns_address by passing invalid parameter. + */ +int utc_connection_profile_get_dns_address_n(void) +{ + int ret; + char *ip_addr = NULL; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_dns_address(profile_inval, 1, -1, NULL); + CHECK_RETURN("connection_profile_get_dns_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_dns_address(profile_inval, 1, -1, NULL); + CHECK_RETURN("connection_profile_get_dns_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dns_address(profile_inval, 1, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_dns_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dns_address(profile_cellular, 1, -1, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_dns_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dns_address(profile_cellular, 1, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_get_dns_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dns_address(profile_inval, 1, -1, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_dns_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dns_address(profile_cellular, 1, -1, NULL); + CHECK_RETURN("connection_profile_get_dns_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dns_address(profile_cellular, 99, CONNECTION_ADDRESS_FAMILY_IPV6, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_dns_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_proxy_type_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the Proxy type. + * @scenario Invoking connection_profile_set_proxy_type with valid parameter. + */ +int utc_connection_profile_get_proxy_type_p(void) +{ + connection_proxy_type_e type; + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_get_proxy_type(profile_temp, &type); + CHECK_RETURN("connection_profile_get_proxy_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_set_proxy_type(profile_temp, CONNECTION_PROXY_TYPE_MANUAL); + CHECK_RETURN("connection_profile_get_proxy_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_proxy_type(profile_temp, &type); + CHECK_RETURN("connection_profile_get_proxy_type", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_proxy_type_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_proxy_type should fail with invalid parameter. + * @scenario Verify connection_profile_get_proxy_type by passing invalid parameter. + */ +int utc_connection_profile_get_proxy_type_n(void) +{ + int ret; + connection_proxy_type_e type; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_proxy_type(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_proxy_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_proxy_type(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_proxy_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_proxy_type(profile_inval, &type); + CHECK_RETURN("connection_profile_get_proxy_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_proxy_type(profile_cellular, NULL); + CHECK_RETURN("connection_profile_get_proxy_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_proxy_address_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the Proxy address. + * @scenario Invoking connection_profile_get_proxy_address with valid parameter. + */ +int utc_connection_profile_get_proxy_address_p(void) +{ + char *ip_addr = NULL; + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_get_proxy_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_proxy_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_get_proxy_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + FREE_RESOURCE(ip_addr); + CHECK_RETURN("connection_profile_get_proxy_address", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_proxy_address_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_proxy_address should fail with invalid parameter. + * @scenario Verify connection_profile_get_proxy_address by passing invalid parameter. + */ +int utc_connection_profile_get_proxy_address_n(void) +{ + int ret; + char *ip_addr = NULL; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_get_proxy_address(profile_inval, -1, NULL); + CHECK_RETURN("connection_profile_get_proxy_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_get_proxy_address(profile_inval, -1, NULL); + CHECK_RETURN("connection_profile_get_proxy_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_proxy_address(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); + CHECK_RETURN("connection_profile_get_proxy_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_proxy_address(profile_cellular, -1, &ip_addr); + CHECK_RETURN("connection_profile_get_proxy_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_proxy_address(profile_cellular, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_get_proxy_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_proxy_address(profile_inval, -1, &ip_addr); + CHECK_RETURN("connection_profile_get_proxy_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_proxy_address(profile_cellular, -1, NULL); + CHECK_RETURN("connection_profile_get_proxy_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_ip_config_type_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the IP config type. + * @scenario Invoking connection_profile_set_ip_config_type with valid parameter. + */ +int utc_connection_profile_set_ip_config_type_p(void) +{ + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_set_ip_config_type(profile_temp, + CONNECTION_ADDRESS_FAMILY_IPV4, CONNECTION_IP_CONFIG_TYPE_STATIC); + CHECK_RETURN("connection_profile_set_ip_config_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_set_ip_config_type(profile_temp, + CONNECTION_ADDRESS_FAMILY_IPV4, CONNECTION_IP_CONFIG_TYPE_STATIC); + CHECK_RETURN("connection_profile_set_ip_config_type", ret, CONNECTION_ERROR_NONE); + + ret = connection_profile_set_ip_config_type(profile_temp, + CONNECTION_ADDRESS_FAMILY_IPV6, CONNECTION_IP_CONFIG_TYPE_STATIC); + CHECK_RETURN("connection_profile_set_ip_config_type", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_ip_config_type_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_set_ip_config_type should fail with invalid parameter. + * @scenario Verify connection_profile_set_ip_config_type by passing invalid parameter. + */ +int utc_connection_profile_set_ip_config_type_n(void) +{ + int ret; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_set_ip_config_type(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, -1); + CHECK_RETURN("connection_profile_set_ip_config_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_ip_config_type(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, -1); + CHECK_RETURN("connection_profile_set_ip_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_ip_config_type(profile_inval, + CONNECTION_ADDRESS_FAMILY_IPV4, CONNECTION_IP_CONFIG_TYPE_STATIC); + CHECK_RETURN("connection_profile_set_ip_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_ip_config_type(profile_cellular, CONNECTION_ADDRESS_FAMILY_IPV4, -1); + CHECK_RETURN("connection_profile_set_ip_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_ip_address_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the IP address. + * @scenario Invoking connection_profile_set_ip_address with valid parameter. + */ +int utc_connection_profile_set_ip_address_p(void) +{ + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_set_ip_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, "192.168.11.1"); + CHECK_RETURN("connection_profile_set_ip_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_set_ip_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, "192.168.11.1"); + CHECK_RETURN("connection_profile_set_ip_address", ret, CONNECTION_ERROR_NONE); + + ret = connection_profile_set_ip_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_set_ip_address", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_ip_address_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_set_ip_address should fail with invalid parameter. + * @scenario Verify connection_profile_set_ip_address by passing invalid parameter. + */ +int utc_connection_profile_set_ip_address_n(void) +{ + int ret; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_set_ip_address(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_set_ip_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_ip_address(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_set_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_ip_address(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, "192.168.11.1"); + CHECK_RETURN("connection_profile_set_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_subnet_mask_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the Subnet Mask. + * @scenario Invoking connection_profile_set_subnet_mask with valid parameter. + */ +int utc_connection_profile_set_subnet_mask_p(void) +{ + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_set_subnet_mask(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, "255.255.255.0"); + CHECK_RETURN("connection_profile_set_subnet_mask", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_set_subnet_mask(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, "255.255.255.0"); + CHECK_RETURN("connection_profile_set_subnet_mask", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_subnet_mask_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_set_subnet_mask should fail with invalid parameter. + * @scenario Verify connection_profile_set_subnet_mask by passing invalid parameter. + */ +int utc_connection_profile_set_subnet_mask_n(void) +{ + int ret; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_set_subnet_mask(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_set_subnet_mask", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_subnet_mask(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_set_subnet_mask", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_subnet_mask(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, "255.255.255.0"); + CHECK_RETURN("connection_profile_set_subnet_mask", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_gateway_address_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the Gateway address. + * @scenario Invoking connection_profile_set_gateway_address with valid parameter. + */ +int utc_connection_profile_set_gateway_address_p(void) +{ + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_set_gateway_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, "192.168.11.1"); + CHECK_RETURN("connection_profile_set_gateway_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_set_gateway_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, "192.168.11.1"); + CHECK_RETURN("connection_profile_set_gateway_address", ret, CONNECTION_ERROR_NONE); + + ret = connection_profile_set_gateway_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_set_gateway_address", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_gateway_address_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_set_gateway_address should fail with invalid parameter. + * @scenario Verify connection_profile_set_gateway_address by passing invalid parameter. + */ +int utc_connection_profile_set_gateway_address_n(void) +{ + int ret; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_set_gateway_address(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_set_gateway_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_gateway_address(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_set_gateway_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_gateway_address(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, "192.168.11.1"); + CHECK_RETURN("connection_profile_set_gateway_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_dns_address_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the DNS address. + * @scenario Invoking connection_profile_set_dns_address with valid parameter. + */ +int utc_connection_profile_set_dns_address_p(void) +{ + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_set_dns_address(profile_temp, 1, CONNECTION_ADDRESS_FAMILY_IPV4, "192.168.11.1"); + CHECK_RETURN("connection_profile_set_dns_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_set_dns_address(profile_temp, 1, CONNECTION_ADDRESS_FAMILY_IPV4, "192.168.11.1"); + CHECK_RETURN("connection_profile_set_dns_address", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_dns_address(profile_temp, 2, CONNECTION_ADDRESS_FAMILY_IPV4, "192.168.11.2"); + CHECK_RETURN("connection_profile_set_dns_address", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_dns_address(profile_temp, 1, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_set_dns_address", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_dns_address_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_set_dns_address should fail with invalid parameter. + * @scenario Verify connection_profile_set_dns_address by passing invalid parameter. + */ +int utc_connection_profile_set_dns_address_n(void) +{ + int ret; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_set_dns_address(profile_inval, 1, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_set_dns_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_dns_address(profile_inval, 1, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_set_dns_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_dns_address(profile_inval, 1, CONNECTION_ADDRESS_FAMILY_IPV4, "192.168.11.1"); + CHECK_RETURN("connection_profile_set_dns_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_dns_address(profile_cellular, 99, CONNECTION_ADDRESS_FAMILY_IPV4, "192.168.11.1"); + CHECK_RETURN("connection_profile_set_dns_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_proxy_type_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the Proxy type. + * @scenario Invoking connection_profile_set_proxy_type with valid parameter. + */ +int utc_connection_profile_set_proxy_type_p(void) +{ + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_set_proxy_type(profile_temp, CONNECTION_PROXY_TYPE_MANUAL); + CHECK_RETURN("connection_profile_set_proxy_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_set_proxy_type(profile_temp, CONNECTION_PROXY_TYPE_MANUAL); + CHECK_RETURN("connection_profile_set_proxy_type", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_proxy_type_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_set_proxy_type should fail with invalid parameter. + * @scenario Verify connection_profile_set_proxy_type by passing invalid parameter. + */ +int utc_connection_profile_set_proxy_type_n(void) +{ + int ret; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_set_proxy_type(profile_inval, -1); + CHECK_RETURN("connection_profile_set_proxy_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_proxy_type(profile_inval, -1); + CHECK_RETURN("connection_profile_set_proxy_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_proxy_type(profile_inval, CONNECTION_PROXY_TYPE_MANUAL); + CHECK_RETURN("connection_profile_set_proxy_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_proxy_type(profile_cellular, -1); + CHECK_RETURN("connection_profile_set_proxy_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_proxy_address_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the Proxy address. + * @scenario Invoking connection_profile_set_proxy_address with valid parameter. + */ +int utc_connection_profile_set_proxy_address_p(void) +{ + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_set_proxy_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, "192.168.11.1:8080"); + CHECK_RETURN("connection_profile_set_proxy_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_set_proxy_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, "192.168.11.1:8080"); + CHECK_RETURN("connection_profile_set_proxy_address", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_proxy_address(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_set_proxy_address", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_proxy_address_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_set_proxy_address should fail with invalid parameter. + * @scenario Verify connection_profile_set_proxy_address by passing invalid parameter. + */ +int utc_connection_profile_set_proxy_address_n(void) +{ + int ret; + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + ret = connection_profile_set_proxy_address(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_set_proxy_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_profile_set_proxy_address(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_set_proxy_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_proxy_address(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, "192.168.11.1:8080"); + CHECK_RETURN("connection_profile_set_proxy_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_state_changed_cb_p + * @since_tizen 2.3 + * @type Positive + * @description Registers the callback that is called when the state of profile is changed. + * @scenario Invoking connection_profile_set_state_changed_cb with valid parameter. + */ +int utc_connection_profile_set_state_changed_cb_p(void) +{ + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_set_state_changed_cb(profile_temp, test_profile_state_changed_cb, NULL); + CHECK_RETURN("connection_profile_set_state_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_set_state_changed_cb(profile_temp, test_profile_state_changed_cb, NULL); + CHECK_RETURN("connection_profile_set_state_changed_cb", ret, CONNECTION_ERROR_NONE); + + ret = connection_profile_unset_state_changed_cb(profile_temp); + PRINT_RETURN("connection_profile_unset_state_changed_cb", ret); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_state_changed_cb_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_set_state_changed_cb should fail with invalid parameter. + * @scenario Verify connection_profile_set_state_changed_cb by passing callback and user_data as NULL. + */ +int utc_connection_profile_set_state_changed_cb_n(void) +{ + connection_profile_h profile_inval = NULL; + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_set_state_changed_cb(profile_inval, NULL, NULL); + CHECK_RETURN("connection_profile_set_state_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_set_state_changed_cb(profile_inval, NULL, NULL); + CHECK_RETURN("connection_profile_set_state_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_state_changed_cb(profile_inval, test_profile_state_changed_cb, NULL); + CHECK_RETURN("connection_profile_set_state_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_state_changed_cb(profile_temp, NULL, NULL); + CHECK_RETURN("connection_profile_set_state_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_unset_state_changed_cb_p + * @since_tizen 2.3 + * @type Positive + * @description Unregisters the callback that is called when the state of profile is changed. + * @scenario Invoking connection_profile_unset_state_changed_cb with valid parameter. + */ +int utc_connection_profile_unset_state_changed_cb_p(void) +{ + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_unset_state_changed_cb(profile_temp); + CHECK_RETURN("connection_profile_unset_state_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_set_state_changed_cb(profile_temp, test_profile_state_changed_cb, NULL); + PRINT_RETURN("connection_profile_set_state_changed_cb", ret); + + ret = connection_profile_unset_state_changed_cb(profile_temp); + CHECK_RETURN("connection_profile_unset_state_changed_cb", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_unset_state_changed_cb_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_unset_state_changed_cb should fail with invalid parameter. + * @scenario Verify connection_profile_unset_state_changed_cb by passing invalid profile handle. + */ +int utc_connection_profile_unset_state_changed_cb_n(void) +{ + connection_profile_h profile_inval = NULL; + + int ret = connection_profile_unset_state_changed_cb(profile_inval); + + if (all_features_not_supported) { + CHECK_RETURN("connection_profile_unset_state_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_profile_unset_state_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } + + return 0; +} + + +/* Cellular profile operations. */ + +/** + * @testcase utc_connection_profile_set_cellular_service_type_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the service type. + * @scenario Invoking connection_profile_set_cellular_service_type with valid parameter. + */ +int utc_connection_profile_set_cellular_service_type_p(void) +{ + if(telephony_supported) { + int ret = connection_profile_set_cellular_service_type(profile_cellular, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET); + CHECK_RETURN("connection_profile_set_cellular_service_type", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_set_cellular_service_type(profile_cellular, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET); + CHECK_RETURN("connection_profile_set_cellular_service_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_set_cellular_service_type_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_set_cellular_service_type should fail with invalid parameter. + * @scenario Verify connection_profile_set_cellular_service_type by passing invalid parameter. + */ +int utc_connection_profile_set_cellular_service_type_n(void) +{ + connection_profile_h profile_inval = NULL; + + if (telephony_supported) { + int ret = connection_profile_set_cellular_service_type(profile_inval, -1); + CHECK_RETURN("connection_profile_set_cellular_service_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_service_type(profile_inval, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET); + CHECK_RETURN("connection_profile_set_cellular_service_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_service_type(profile_cellular, -1); + CHECK_RETURN("connection_profile_set_cellular_service_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_service_type(profile_wifi, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET); + CHECK_RETURN("connection_profile_set_cellular_service_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_set_cellular_service_type(profile_inval, -1); + CHECK_RETURN("connection_profile_set_cellular_service_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_set_cellular_apn_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the APN (Access Point Name). + * @scenario Invoking connection_profile_set_cellular_apn with valid parameter. + */ +int utc_connection_profile_set_cellular_apn_p(void) +{ + if (telephony_supported) { + int ret = connection_profile_set_cellular_apn(profile_cellular, "tizen.org"); + CHECK_RETURN("connection_profile_set_cellular_apn", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_set_cellular_apn(profile_cellular, "tizen.org"); + CHECK_RETURN("connection_profile_set_cellular_apn", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_set_cellular_apn_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_set_cellular_apn should fail with invalid parameter. + * @scenario Verify connection_profile_set_cellular_apn by passing invalid parameter. + */ +int utc_connection_profile_set_cellular_apn_n(void) +{ + connection_profile_h profile_inval = NULL; + + if (telephony_supported) { + int ret = connection_profile_set_cellular_apn(profile_inval, NULL); + CHECK_RETURN("connection_profile_set_cellular_apn", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_apn(profile_inval, "tizen.org"); + CHECK_RETURN("connection_profile_set_cellular_apn", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_apn(profile_cellular, NULL); + CHECK_RETURN("connection_profile_set_cellular_apn", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_apn(profile_wifi, "tizen.org"); + CHECK_RETURN("connection_profile_set_cellular_apn", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_set_cellular_apn(profile_inval, NULL); + CHECK_RETURN("connection_profile_set_cellular_apn", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** + * @testcase utc_connection_profile_set_cellular_auth_info_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the Authentication information. + * @scenario Invoking connection_profile_set_cellular_auth_info with valid parameter. + */ +int utc_connection_profile_set_cellular_auth_info_p(void) +{ + if (telephony_supported) { + int ret = connection_profile_set_cellular_auth_info(profile_cellular, + CONNECTION_CELLULAR_AUTH_TYPE_PAP, "tizen", "flower"); + CHECK_RETURN("connection_profile_set_cellular_auth_info", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_set_cellular_auth_info(profile_cellular, + CONNECTION_CELLULAR_AUTH_TYPE_PAP, "tizen", "flower"); + CHECK_RETURN("connection_profile_set_cellular_auth_info", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_set_cellular_auth_info_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_set_cellular_auth_info should fail with invalid parameter. + * @scenario Verify connection_profile_set_cellular_auth_info by passing invalid AUTHENTICATION TYPE/parameter. + */ +int utc_connection_profile_set_cellular_auth_info_n(void) +{ + connection_profile_h profile_inval = NULL; + + if (telephony_supported) { + int ret = connection_profile_set_cellular_auth_info(profile_inval, -1, NULL, NULL); + CHECK_RETURN("connection_profile_set_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_auth_info(profile_inval, + CONNECTION_CELLULAR_AUTH_TYPE_PAP, "tizen", "flower"); + CHECK_RETURN("connection_profile_set_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_auth_info(profile_cellular, -1, "tizen", "flower"); + CHECK_RETURN("connection_profile_set_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_auth_info(profile_cellular, + CONNECTION_CELLULAR_AUTH_TYPE_PAP, NULL, "flower"); + CHECK_RETURN("connection_profile_set_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_auth_info(profile_cellular, + CONNECTION_CELLULAR_AUTH_TYPE_PAP, "tizen", NULL); + CHECK_RETURN("connection_profile_set_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_auth_info(profile_inval, + CONNECTION_CELLULAR_AUTH_TYPE_PAP, NULL, "flower"); + CHECK_RETURN("connection_profile_set_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_auth_info(profile_cellular, + CONNECTION_CELLULAR_AUTH_TYPE_PAP, NULL, NULL); + CHECK_RETURN("connection_profile_set_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_auth_info(profile_wifi, + CONNECTION_CELLULAR_AUTH_TYPE_PAP, "tizen", "flower"); + CHECK_RETURN("connection_profile_set_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_set_cellular_auth_info(profile_inval, -1, NULL, NULL); + CHECK_RETURN("connection_profile_set_cellular_auth_info", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_set_cellular_home_url_p + * @since_tizen 2.3 + * @type Positive + * @description connection_profile_set_cellular_home_url. + * @scenario Invoking connection_profile_set_cellular_home_url with valid parameter. + */ +int utc_connection_profile_set_cellular_home_url_p(void) +{ + if(telephony_supported) { + int ret = connection_profile_set_cellular_home_url(profile_cellular, "www.tizen.org"); + CHECK_RETURN("connection_profile_set_cellular_home_url", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_set_cellular_home_url(profile_cellular, "www.tizen.org"); + CHECK_RETURN("connection_profile_set_cellular_home_url", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_set_cellular_home_url_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_set_cellular_home_url should fail with invalid parameter. + * @scenario Verify connection_profile_set_cellular_home_url by passing invalid profile handle. + */ +int utc_connection_profile_set_cellular_home_url_n(void) +{ + connection_profile_h profile_inval = NULL; + + if (telephony_supported) { + int ret = connection_profile_set_cellular_home_url(profile_inval, NULL); + CHECK_RETURN("connection_profile_set_cellular_home_url", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_home_url(profile_inval, "www.tizen.org"); + CHECK_RETURN("connection_profile_set_cellular_home_url", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_home_url(profile_cellular, NULL); + CHECK_RETURN("connection_profile_set_cellular_home_url", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_home_url(profile_wifi, "www.tizen.org"); + CHECK_RETURN("connection_profile_set_cellular_home_url", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_set_cellular_home_url(profile_inval, NULL); + CHECK_RETURN("connection_profile_set_cellular_home_url", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + return 0; +} + +#if (defined(MOBILE) || defined(WEARABLE) || defined(TIZENIOT)) //Starts MOBILE or WEARABLE or TIZENIOT +/** + * @testcase utc_connection_profile_set_cellular_pdn_type_p + * @since_tizen 3.0 + * @type Positive + * @description Sets the pdn type. + * @scenario Invoking connection_profile_set_cellular_pdn_type with valid parameter. + */ +int utc_connection_profile_set_cellular_pdn_type_p(void) +{ + int ret = connection_profile_set_cellular_pdn_type(profile_cellular, CONNECTION_CELLULAR_PDN_TYPE_IPV4); + + if (telephony_supported) { + CHECK_RETURN("connection_profile_set_cellular_pdn_type", ret, CONNECTION_ERROR_NONE); + } else { + CHECK_RETURN("connection_profile_set_cellular_pdn_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_set_cellular_pdn_type_n + * @since_tizen 3.0 + * @type Negative + * @description connection_profile_set_cellular_pdn_type should fail with invalid parameter. + * @scenario Verify connection_profile_set_cellular_pdn_type by passing invalid profile handle. + */ +int utc_connection_profile_set_cellular_pdn_type_n(void) +{ + connection_profile_h profile_inval = NULL; + connection_cellular_pdn_type_e type = CONNECTION_CELLULAR_PDN_TYPE_IPV4; + + if (telephony_supported) { + int ret = connection_profile_set_cellular_pdn_type(profile_inval, type); + CHECK_RETURN("connection_profile_set_cellular_pdn_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_pdn_type(profile_wifi, type); + CHECK_RETURN("connection_profile_set_cellular_pdn_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_set_cellular_pdn_type(profile_inval, type); + CHECK_RETURN("connection_profile_set_cellular_pdn_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_set_cellular_roam_pdn_type_p + * @since_tizen 3.0 + * @type Positive + * @description Sets the roam pdn type. + * @scenario Invoking connection_profile_set_cellular_roam_pdn_type with valid parameter. + */ +int utc_connection_profile_set_cellular_roam_pdn_type_p(void) +{ + int ret = connection_profile_set_cellular_roam_pdn_type(profile_cellular, CONNECTION_CELLULAR_PDN_TYPE_IPV4); + + if (telephony_supported) { + CHECK_RETURN("connection_profile_set_cellular_roam_pdn_type", ret, CONNECTION_ERROR_NONE); + } else { + CHECK_RETURN("connection_profile_set_cellular_roam_pdn_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_set_cellular_roam_pdn_type_n + * @since_tizen 3.0 + * @type Negative + * @description connection_profile_set_cellular_roam_pdn_type should fail with invalid parameter. + * @scenario Verify connection_profile_set_cellular_roam_pdn_type by passing invalid profile handle. + */ +int utc_connection_profile_set_cellular_roam_pdn_type_n(void) +{ + connection_profile_h profile_inval = NULL; + connection_cellular_pdn_type_e type = CONNECTION_CELLULAR_PDN_TYPE_IPV4; + + if (telephony_supported) { + int ret = connection_profile_set_cellular_roam_pdn_type(profile_inval, type); + CHECK_RETURN("connection_profile_set_cellular_roam_pdn_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_cellular_roam_pdn_type(profile_wifi, type); + CHECK_RETURN("connection_profile_set_cellular_roam_pdn_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_set_cellular_roam_pdn_type(profile_inval, type); + CHECK_RETURN("connection_profile_set_cellular_roam_pdn_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} +#endif // End MOBILE or WEARABLE or TIZENIOT + +/** + * @testcase utc_connection_profile_get_cellular_service_type_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the home URL. + * @scenario Invoking connection_profile_get_cellular_service_type with valid parameter. + */ +int utc_connection_profile_get_cellular_service_type_p(void) +{ + connection_cellular_service_type_e type; + + if (telephony_supported) { + connection_profile_set_cellular_service_type(profile_cellular, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET); + + int ret = connection_profile_get_cellular_service_type(profile_cellular, &type); + CHECK_RETURN("connection_profile_get_cellular_service_type", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_get_cellular_service_type(profile_cellular, &type); + CHECK_RETURN("connection_profile_get_cellular_service_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_cellular_service_type_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_cellular_service_type should fail with invalid parameter. + * @scenario Verify connection_profile_get_cellular_service_type by passing invalid profile handle and home URL. + */ +int utc_connection_profile_get_cellular_service_type_n(void) +{ + connection_profile_h profile_inval = NULL; + connection_cellular_service_type_e type; + + if (telephony_supported) { + int ret = connection_profile_get_cellular_service_type(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_cellular_service_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_service_type(profile_inval, &type); + CHECK_RETURN("connection_profile_get_cellular_service_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_service_type(profile_cellular, NULL); + CHECK_RETURN("connection_profile_get_cellular_service_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_service_type(profile_wifi, &type); + CHECK_RETURN("connection_profile_get_cellular_service_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_get_cellular_service_type(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_cellular_service_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_cellular_apn_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the APN (access point name). + * @scenario Invoking connection_profile_get_cellular_apn with valid parameter. + */ +int utc_connection_profile_get_cellular_apn_p(void) +{ + char *apn = NULL; + + int ret = connection_profile_get_cellular_apn(profile_cellular, &apn); + FREE_RESOURCE(apn); + + if(telephony_supported) { + CHECK_RETURN("connection_profile_get_cellular_apn", ret, CONNECTION_ERROR_NONE); + } else { + CHECK_RETURN("connection_profile_get_cellular_apn", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_cellular_apn_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_cellular_apn should fail with invalid parameter. + * @scenario Verify connection_profile_get_cellular_apn by passing invalid parameter. + */ +int utc_connection_profile_get_cellular_apn_n(void) +{ + connection_profile_h profile_inval = NULL; + char *apn = NULL; + + if (telephony_supported) { + int ret = connection_profile_get_cellular_apn(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_cellular_apn", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_apn(profile_inval, &apn); + CHECK_RETURN("connection_profile_get_cellular_apn", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_apn(profile_cellular, NULL); + CHECK_RETURN("connection_profile_get_cellular_apn", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_apn(profile_wifi, NULL); + CHECK_RETURN("connection_profile_get_cellular_apn", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_get_cellular_apn(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_cellular_apn", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_cellular_auth_info_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the authentication information. + * @scenario Invoking connection_profile_get_cellular_auth_info with valid parameter. + */ +int utc_connection_profile_get_cellular_auth_info_p(void) +{ + connection_cellular_auth_type_e type; + char *name = NULL; + char *pwd = NULL; + + int ret = connection_profile_get_cellular_auth_info(profile_cellular, &type, &name, &pwd); + FREE_RESOURCE(name); FREE_RESOURCE(pwd); + + if (telephony_supported) { + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_NONE); + } else { + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_cellular_auth_info_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_cellular_auth_info should fail with invalid parameter. + * @scenario Verify connection_profile_get_cellular_auth_info by passing invalid parameter. + */ +int utc_connection_profile_get_cellular_auth_info_n(void) +{ + connection_profile_h profile_inval = NULL; + connection_cellular_auth_type_e type; + char *name = NULL; + char *pwd = NULL; + + if (telephony_supported) { + int ret = connection_profile_get_cellular_auth_info(profile_inval, NULL, NULL, NULL); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_auth_info(profile_inval, &type, &name, &pwd); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_auth_info(profile_cellular, NULL, &name, &pwd); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_auth_info(profile_cellular, &type, NULL, &pwd); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_auth_info(profile_cellular, &type, &name, NULL); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_auth_info(profile_inval, NULL, &name, &pwd); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_auth_info(profile_inval, &type, NULL, &pwd); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_auth_info(profile_inval, &type, &name, NULL); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_auth_info(profile_cellular, NULL, NULL, &pwd); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_auth_info(profile_cellular, NULL, &name, NULL); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_auth_info(profile_cellular, &type, NULL, NULL); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_auth_info(profile_inval, NULL, NULL, &pwd); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_auth_info(profile_cellular, NULL, NULL, NULL); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_auth_info(profile_wifi, &type, &name, &pwd); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_get_cellular_auth_info(profile_inval, NULL, NULL, NULL); + CHECK_RETURN("connection_profile_get_cellular_auth_info", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_cellular_home_url_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the home URL. + * @scenario Invoking connection_profile_get_cellular_home_url with valid parameter. + */ +int utc_connection_profile_get_cellular_home_url_p(void) +{ + char *home_url = NULL; + + int ret = connection_profile_get_cellular_home_url(profile_cellular, &home_url); + FREE_RESOURCE(home_url); + + if (telephony_supported) { + CHECK_RETURN("connection_profile_get_cellular_home_url", ret, CONNECTION_ERROR_NONE); + } else { + CHECK_RETURN("connection_profile_get_cellular_home_url", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_cellular_home_url_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_cellular_home_url should fail with invalid parameter. + * @scenario Verify connection_profile_get_cellular_home_url by passing invalid profile handle. + */ +int utc_connection_profile_get_cellular_home_url_n(void) +{ + connection_profile_h profile_inval = NULL; + char *home_url = NULL; + + if (telephony_supported) { + int ret = connection_profile_get_cellular_home_url(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_cellular_home_url", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_home_url(profile_inval, &home_url); + CHECK_RETURN("connection_profile_get_cellular_home_url", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_home_url(profile_cellular, NULL); + CHECK_RETURN("connection_profile_get_cellular_home_url", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_home_url(profile_wifi, &home_url); + CHECK_RETURN("connection_profile_get_cellular_home_url", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_get_cellular_home_url(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_cellular_home_url", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +#if (defined(MOBILE) || defined(WEARABLE) || defined(TIZENIOT)) //Starts MOBILE or WEARABLE or TIZENIOT +/** + * @testcase utc_connection_profile_get_cellular_pdn_type_p + * @since_tizen 3.0 + * @type Positive + * @description Gets the pdn type. + * @scenario Invoking connection_profile_get_cellular_pdn_type with valid parameter. + */ +int utc_connection_profile_get_cellular_pdn_type_p(void) +{ + connection_cellular_pdn_type_e type; + + if (telephony_supported) { + int ret = connection_profile_set_cellular_pdn_type(profile_cellular, CONNECTION_CELLULAR_PDN_TYPE_IPV4); + CHECK_RETURN("connection_profile_set_cellular_pdn_type", ret, CONNECTION_ERROR_NONE); + + ret = connection_profile_get_cellular_pdn_type(profile_cellular, &type); + CHECK_RETURN("connection_profile_set_cellular_pdn_type", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_get_cellular_pdn_type(profile_cellular, &type); + CHECK_RETURN("connection_profile_set_cellular_pdn_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_cellular_pdn_type_n + * @since_tizen 3.0 + * @type Negative + * @description connection_profile_get_cellular_pdn_type should fail with invalid parameter. + * @scenario Verify connection_profile_get_cellular_pdn_type by passing invalid profile handle. + */ +int utc_connection_profile_get_cellular_pdn_type_n(void) +{ + connection_profile_h profile_inval = NULL; + connection_cellular_pdn_type_e type; + + if (telephony_supported) { + int ret = connection_profile_get_cellular_pdn_type(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_cellular_pdn_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_pdn_type(profile_cellular, NULL); + CHECK_RETURN("connection_profile_get_cellular_pdn_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_pdn_type(profile_wifi, &type); + CHECK_RETURN("connection_profile_get_cellular_pdn_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_get_cellular_pdn_type(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_cellular_pdn_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_cellular_roam_pdn_type_p + * @since_tizen 3.0 + * @type Positive + * @description Gets the roam pdn type. + * @scenario Invoking connection_profile_get_cellular_roam_pdn_type with valid parameter. + */ +int utc_connection_profile_get_cellular_roam_pdn_type_p(void) +{ + connection_cellular_pdn_type_e type; + + if(telephony_supported) { + int ret = connection_profile_set_cellular_roam_pdn_type(profile_cellular, CONNECTION_CELLULAR_PDN_TYPE_IPV4); + CHECK_RETURN("connection_profile_set_cellular_roam_pdn_type", ret, CONNECTION_ERROR_NONE); + + ret = connection_profile_get_cellular_roam_pdn_type(profile_cellular, &type); + CHECK_RETURN("connection_profile_set_cellular_roam_pdn_type", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_get_cellular_roam_pdn_type(profile_cellular, &type); + CHECK_RETURN("connection_profile_set_cellular_roam_pdn_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_cellular_roam_pdn_type_n + * @since_tizen 3.0 + * @type Negative + * @description connection_profile_get_cellular_roam_pdn_type should fail with invalid parameter. + * @scenario Verify connection_profile_get_cellular_roam_pdn_type by passing invalid profile handle. + */ +int utc_connection_profile_get_cellular_roam_pdn_type_n(void) +{ + connection_profile_h profile_inval = NULL; + connection_cellular_pdn_type_e type; + + if (telephony_supported) { + int ret = connection_profile_get_cellular_roam_pdn_type(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_cellular_roam_pdn_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_roam_pdn_type(profile_cellular, NULL); + CHECK_RETURN("connection_profile_get_cellular_roam_pdn_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_cellular_roam_pdn_type(profile_wifi, &type); + CHECK_RETURN("connection_profile_get_cellular_roam_pdn_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_get_cellular_roam_pdn_type(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_cellular_roam_pdn_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} +#endif // End MOBILE or WEARABLE or TIZENIOT + +/** + * @testcase utc_connection_profile_is_cellular_roaming_p + * @since_tizen 2.3 + * @type Positive + * @description Checks wheter the connection is in roaming state. + * @scenario Invoking connection_profile_is_cellular_roaming with valid parameter. + */ +int utc_connection_profile_is_cellular_roaming_p(void) +{ + bool roaming; + + if (telephony_supported) { + int ret = connection_profile_is_cellular_roaming(profile_cellular, &roaming); + CHECK_RETURN("connection_profile_is_cellular_roaming", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_is_cellular_roaming(profile_cellular, &roaming); + CHECK_RETURN("connection_profile_is_cellular_roaming", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_is_cellular_roaming_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_is_cellular_roaming should fail with invalid parameter. + * @scenario Verify connection_profile_is_cellular_roaming by passing invalid parameter. + */ +int utc_connection_profile_is_cellular_roaming_n(void) +{ + connection_profile_h profile_inval = NULL; + bool roaming; + + if (telephony_supported) { + int ret = connection_profile_is_cellular_roaming(profile_inval, NULL); + CHECK_RETURN("connection_profile_is_cellular_roaming", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_cellular_roaming(profile_inval, &roaming); + CHECK_RETURN("connection_profile_is_cellular_roaming", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_cellular_roaming(profile_cellular, NULL); + CHECK_RETURN("connection_profile_is_cellular_roaming", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_cellular_roaming(profile_wifi, &roaming); + CHECK_RETURN("connection_profile_is_cellular_roaming", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_is_cellular_roaming(profile_inval, NULL); + CHECK_RETURN("connection_profile_is_cellular_roaming", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_is_cellular_hidden_p + * @since_tizen 2.3 + * @type Positive + * @description Checks whether the profile is hidden. + * @scenario Invoking connection_profile_is_cellular_hidden with valid parameter. + */ +int utc_connection_profile_is_cellular_hidden_p(void) +{ + bool is_hidden; + + if (telephony_supported) { + int ret = connection_profile_is_cellular_hidden(profile_cellular, &is_hidden); + CHECK_RETURN("connection_profile_is_cellular_hidden", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_is_cellular_hidden(profile_cellular, &is_hidden); + CHECK_RETURN("connection_profile_is_cellular_hidden", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; + +} + +/** + * @testcase utc_connection_profile_is_cellular_hidden_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_is_cellular_hidden should fail with invalid parameter. + * @scenario Verify connection_profile_is_cellular_hidden by passing invalid parameter. + */ +int utc_connection_profile_is_cellular_hidden_n(void) +{ + connection_profile_h profile_inval = NULL; + bool is_hidden; + + if (telephony_supported) { + int ret = connection_profile_is_cellular_hidden(profile_inval, NULL); + CHECK_RETURN("connection_profile_is_cellular_hidden", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_cellular_hidden(profile_inval, &is_hidden); + CHECK_RETURN("connection_profile_is_cellular_hidden", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_cellular_hidden(profile_cellular, NULL); + CHECK_RETURN("connection_profile_is_cellular_hidden", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_cellular_hidden(profile_wifi, &is_hidden); + CHECK_RETURN("connection_profile_is_cellular_hidden", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_is_cellular_hidden(profile_inval, NULL); + CHECK_RETURN("connection_profile_is_cellular_hidden", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_is_cellular_editable_p + * @since_tizen 2.3 + * @type Positive + * @description Checks whether the profile is editable. + * @scenario Invoking connection_profile_is_cellular_editable with valid parameter. + */ +int utc_connection_profile_is_cellular_editable_p(void) +{ + bool is_editable; + + if (telephony_supported) { + int ret = connection_profile_is_cellular_editable(profile_cellular, &is_editable); + CHECK_RETURN("connection_profile_is_cellular_editable", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_is_cellular_editable(profile_cellular, &is_editable); + CHECK_RETURN("connection_profile_is_cellular_editable", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_is_cellular_editable_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_is_cellular_editable should fail with invalid parameter. + * @scenario Verify connection_profile_is_cellular_editable by passing invalid parameter. + */ +int utc_connection_profile_is_cellular_editable_n(void) +{ + connection_profile_h profile_inval = NULL; + bool is_editable; + + if (telephony_supported) { + int ret = connection_profile_is_cellular_editable(profile_inval, NULL); + CHECK_RETURN("connection_profile_is_cellular_editable", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_cellular_editable(profile_inval, &is_editable); + CHECK_RETURN("connection_profile_is_cellular_editable", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_cellular_editable(profile_cellular, NULL); + CHECK_RETURN("connection_profile_is_cellular_editable", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_cellular_editable(profile_wifi, &is_editable); + CHECK_RETURN("connection_profile_is_cellular_editable", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_is_cellular_editable(profile_inval, NULL); + CHECK_RETURN("connection_profile_is_cellular_editable", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_is_cellular_default_p + * @since_tizen 2.3 + * @type Positive + * @description Checks whether the profile is default.is_default @c true if the profile is default, + otherwise @c false if the profile is not default + * @scenario Invoking connection_profile_is_cellular_default with valid parameter. + */ +int utc_connection_profile_is_cellular_default_p(void) +{ + bool is_default; + + if (telephony_supported) { + int ret = connection_profile_is_cellular_default(profile_cellular, &is_default); + CHECK_RETURN("connection_profile_is_cellular_default", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_is_cellular_default(profile_cellular, &is_default); + CHECK_RETURN("connection_profile_is_cellular_default", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_is_cellular_default_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_is_cellular_default should fail with invalid parameter. + * @scenario Verify connection_profile_is_cellular_default by passing invalid parameter. + */ +int utc_connection_profile_is_cellular_default_n(void) +{ + bool is_editable; + + if (telephony_supported) { + int ret = connection_profile_is_cellular_default(NULL, &is_editable); + CHECK_RETURN("connection_profile_is_cellular_default", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_profile_is_cellular_default(profile_cellular, NULL); + CHECK_RETURN("connection_profile_is_cellular_default", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_profile_is_cellular_default(profile_wifi, &is_editable); + CHECK_RETURN("connection_profile_is_cellular_default", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_is_cellular_default(NULL, &is_editable); + CHECK_RETURN("connection_profile_is_cellular_default", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_refresh_p + * @since_tizen 2.3 + * @type Positive + * @description Refreshes the profile information. + * @scenario Invoking connection_profile_refresh with valid parameter. + */ +int utc_connection_profile_refresh_p(void) +{ + int ret = test_get_any_profile(&profile_temp); + + if (all_features_not_supported) { + ret = connection_profile_refresh(profile_temp); + CHECK_RETURN("connection_profile_refresh", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + ret = connection_profile_refresh(profile_temp); + CHECK_RETURN("connection_profile_refresh", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_refresh_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_refresh should fail with invalid parameter. + * @scenario Verify connection_profile_refresh by passing invalid profile handle. + */ +int utc_connection_profile_refresh_n(void) +{ + connection_profile_h profile_inval = NULL; + + int ret = connection_profile_refresh(profile_inval); + + if (all_features_not_supported) { + CHECK_RETURN("connection_profile_refresh", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_profile_refresh", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/* Wi-Fi profile operations. */ + +/** + * @testcase utc_connection_profile_get_wifi_essid_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the ESSID (Extended Service Set Identifier). + * @scenario Invoking connection_profile_get_wifi_essid with valid parameter. + */ +int utc_connection_profile_get_wifi_essid_p(void) +{ + char *essid = NULL; + + int ret = connection_profile_get_wifi_essid(profile_wifi, &essid); + FREE_RESOURCE(essid); + + if (wifi_supported) { + CHECK_RETURN("connection_profile_get_wifi_essid", ret, CONNECTION_ERROR_NONE); + } else { + CHECK_RETURN("connection_profile_get_wifi_essid", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_wifi_essid_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_wifi_essid should fail with invalid parameter. + * @scenario Verify connection_profile_get_wifi_essid by passing invalid parameter. + */ +int utc_connection_profile_get_wifi_essid_n(void) +{ + connection_profile_h profile_inval = NULL; + char *essid = NULL; + + if (wifi_supported) { + int ret = connection_profile_get_wifi_essid(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_wifi_essid", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_essid(profile_inval, &essid); + CHECK_RETURN("connection_profile_get_wifi_essid", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_essid(profile_wifi, NULL); + CHECK_RETURN("connection_profile_get_wifi_essid", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_essid(profile_cellular, &essid); + CHECK_RETURN("connection_profile_get_wifi_essid", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_get_wifi_essid(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_wifi_essid", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_wifi_bssid_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the BSSID (Basic Service Set Identifier). + * @scenario Invoking connection_profile_get_wifi_bssid with valid parameter. + */ +int utc_connection_profile_get_wifi_bssid_p(void) +{ + char *bssid = NULL; + + int ret = connection_profile_get_wifi_bssid(profile_wifi, &bssid); + FREE_RESOURCE(bssid); + + if (wifi_supported) { + CHECK_RETURN("connection_profile_get_wifi_bssid", ret, CONNECTION_ERROR_NONE); + } else { + CHECK_RETURN("connection_profile_get_wifi_bssid", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_wifi_bssid_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_wifi_bssid should fail with invalid parameter. + * @scenario Verify connection_profile_get_wifi_bssid by passing invalid parameter. + */ +int utc_connection_profile_get_wifi_bssid_n(void) +{ + connection_profile_h profile_inval = NULL; + char *bssid = NULL; + + if (wifi_supported) { + int ret = connection_profile_get_wifi_bssid(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_wifi_bssid", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_bssid(profile_inval, &bssid); + CHECK_RETURN("connection_profile_get_wifi_bssid", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_bssid(profile_wifi, NULL); + CHECK_RETURN("connection_profile_get_wifi_bssid", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_bssid(profile_cellular, &bssid); + CHECK_RETURN("connection_profile_get_wifi_bssid", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_get_wifi_bssid(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_wifi_bssid", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_wifi_rssi_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the RSSI. + * @scenario Invoking connection_profile_get_wifi_rssi with valid parameter. + */ +int utc_connection_profile_get_wifi_rssi_p(void) +{ + int rssi; + + if (wifi_supported) { + int ret = connection_profile_get_wifi_rssi(profile_wifi, &rssi); + CHECK_RETURN("connection_profile_get_wifi_rssi", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_get_wifi_rssi(profile_wifi, &rssi); + CHECK_RETURN("connection_profile_get_wifi_rssi", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_wifi_rssi_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_wifi_rssi should fail with invalid parameter. + * @scenario Verify connection_profile_get_wifi_rssi by passing invalid parameter. + */ +int utc_connection_profile_get_wifi_rssi_n(void) +{ + connection_profile_h profile_inval = NULL; + int rssi; + + if (wifi_supported) { + int ret = connection_profile_get_wifi_rssi(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_wifi_rssi", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_rssi(profile_inval, &rssi); + CHECK_RETURN("connection_profile_get_wifi_rssi", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_rssi(profile_wifi, NULL); + CHECK_RETURN("connection_profile_get_wifi_rssi", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_rssi(profile_cellular, &rssi); + CHECK_RETURN("connection_profile_get_wifi_rssi", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_get_wifi_rssi(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_wifi_rssi", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_wifi_frequency_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the frequency (MHz). + * @scenario Invoking connection_profile_get_wifi_frequency with valid parameter. + */ +int utc_connection_profile_get_wifi_frequency_p(void) +{ + int frequency; + + if (wifi_supported) { + int ret = connection_profile_get_wifi_frequency(profile_wifi, &frequency); + CHECK_RETURN("connection_profile_get_wifi_frequency", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_get_wifi_frequency(profile_wifi, &frequency); + CHECK_RETURN("connection_profile_get_wifi_frequency", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_wifi_frequency_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_wifi_frequency should fail with invalid parameter. + * @scenario Verify connection_profile_get_wifi_frequency by passing invalid parameter. + */ +int utc_connection_profile_get_wifi_frequency_n(void) +{ + connection_profile_h profile_inval = NULL; + int frequency; + + if (wifi_supported) { + int ret = connection_profile_get_wifi_frequency(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_wifi_frequency", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_frequency(profile_inval, &frequency); + CHECK_RETURN("connection_profile_get_wifi_frequency", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_frequency(profile_wifi, NULL); + CHECK_RETURN("connection_profile_get_wifi_frequency", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_frequency(profile_cellular, &frequency); + CHECK_RETURN("connection_profile_get_wifi_frequency", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_get_wifi_frequency(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_wifi_frequency", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_wifi_max_speed_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the max speed (Mbps). + * @scenario Invoking connection_profile_get_wifi_max_speed with valid parameter. + */ +int utc_connection_profile_get_wifi_max_speed_p(void) +{ + int max_speed; + + if (wifi_supported) { + int ret = connection_profile_get_wifi_max_speed(profile_wifi, &max_speed); + CHECK_RETURN("connection_profile_get_wifi_max_speed", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_get_wifi_max_speed(profile_wifi, &max_speed); + CHECK_RETURN("connection_profile_get_wifi_max_speed", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_wifi_max_speed_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_wifi_max_speed should fail with invalid parameter. + * @scenario Verify connection_profile_get_wifi_max_speed by passing invalid parameter. + */ +int utc_connection_profile_get_wifi_max_speed_n(void) +{ + connection_profile_h profile_inval = NULL; + int max_speed; + + if (wifi_supported) { + int ret = connection_profile_get_wifi_max_speed(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_wifi_max_speed", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_max_speed(profile_inval, &max_speed); + CHECK_RETURN("connection_profile_get_wifi_max_speed", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_max_speed(profile_wifi, NULL); + CHECK_RETURN("connection_profile_get_wifi_max_speed", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_max_speed(profile_cellular, &max_speed); + CHECK_RETURN("connection_profile_get_wifi_max_speed", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_get_wifi_max_speed(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_wifi_max_speed", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_wifi_security_type_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the security mode of Wi-Fi. + * @scenario Invoking connection_profile_get_wifi_security_type with valid parameter. + */ +int utc_connection_profile_get_wifi_security_type_p(void) +{ + connection_wifi_security_type_e sec_type; + + if (wifi_supported) { + int ret = connection_profile_get_wifi_security_type(profile_wifi, &sec_type); + CHECK_RETURN("connection_profile_get_wifi_security_type", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_get_wifi_security_type(profile_wifi, &sec_type); + CHECK_RETURN("connection_profile_get_wifi_security_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_wifi_security_type_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_wifi_security_type should fail with invalid parameter. + * @scenario Verify connection_profile_get_wifi_security_type by passing invalid parameter. + */ +int utc_connection_profile_get_wifi_security_type_n(void) +{ + connection_profile_h profile_inval = NULL; + connection_wifi_security_type_e sec_type; + + if (wifi_supported) { + int ret = connection_profile_get_wifi_security_type(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_wifi_security_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_security_type(profile_inval, &sec_type); + CHECK_RETURN("connection_profile_get_wifi_security_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_security_type(profile_wifi, NULL); + CHECK_RETURN("connection_profile_get_wifi_security_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_security_type(profile_cellular, &sec_type); + CHECK_RETURN("connection_profile_get_wifi_security_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_get_wifi_security_type(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_wifi_security_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_wifi_encryption_type_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the security mode of Wi-Fi. + * @scenario Invoking connection_profile_get_wifi_encryption_type with valid parameter. + */ +int utc_connection_profile_get_wifi_encryption_type_p(void) +{ + connection_wifi_encryption_type_e enc_type; + + if (wifi_supported) { + int ret = connection_profile_get_wifi_encryption_type(profile_wifi, &enc_type); + CHECK_RETURN("connection_profile_get_wifi_encryption_type", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_get_wifi_encryption_type(profile_wifi, &enc_type); + CHECK_RETURN("connection_profile_get_wifi_encryption_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_wifi_encryption_type_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_get_wifi_encryption_type should fail with invalid parameter. + * @scenario Verify connection_profile_get_wifi_encryption_type by passing invalid parameter. + */ +int utc_connection_profile_get_wifi_encryption_type_n(void) +{ + connection_profile_h profile_inval = NULL; + connection_wifi_encryption_type_e enc_type; + + if (wifi_supported) { + int ret = connection_profile_get_wifi_encryption_type(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_wifi_encryption_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_encryption_type(profile_inval, &enc_type); + CHECK_RETURN("connection_profile_get_wifi_encryption_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_encryption_type(profile_wifi, NULL); + CHECK_RETURN("connection_profile_get_wifi_encryption_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_wifi_encryption_type(profile_cellular, &enc_type); + CHECK_RETURN("connection_profile_get_wifi_encryption_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_get_wifi_encryption_type(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_wifi_encryption_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_is_wifi_passphrase_required_p + * @since_tizen 2.3 + * @type Positive + * @description Checks whether passphrase is required. + * @scenario Invoking connection_profile_is_wifi_passphrase_required with valid parameter. + */ +int utc_connection_profile_is_wifi_passphrase_required_p(void) +{ + bool flag; + + if (wifi_supported) { + int ret = connection_profile_is_wifi_passphrase_required(profile_wifi, &flag); + CHECK_RETURN("connection_profile_is_wifi_passphrase_required", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_is_wifi_passphrase_required(profile_wifi, &flag); + CHECK_RETURN("connection_profile_is_wifi_passphrase_required", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_is_wifi_passphrase_required_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_is_wifi_passphrase_required should fail with invalid parameter. + * @scenario Verify connection_profile_is_wifi_passphrase_required by passing invalid parameter. + */ +int utc_connection_profile_is_wifi_passphrase_required_n(void) +{ + connection_profile_h profile_inval = NULL; + bool flag; + + if (wifi_supported) { + int ret = connection_profile_is_wifi_passphrase_required(profile_inval, NULL); + CHECK_RETURN("connection_profile_is_wifi_passphrase_required", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_wifi_passphrase_required(profile_inval, &flag); + CHECK_RETURN("connection_profile_is_wifi_passphrase_required", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_wifi_passphrase_required(profile_wifi, NULL); + CHECK_RETURN("connection_profile_is_wifi_passphrase_required", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_wifi_passphrase_required(profile_cellular, &flag); + CHECK_RETURN("connection_profile_is_wifi_passphrase_required", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_is_wifi_passphrase_required(profile_inval, NULL); + CHECK_RETURN("connection_profile_is_wifi_passphrase_required", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_set_wifi_passphrase_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the passphrase of the Wi-Fi WPA. + * @scenario Invoking connection_profile_set_wifi_passphrase with valid parameter. + */ +int utc_connection_profile_set_wifi_passphrase_p(void) +{ + if(wifi_supported) { + int ret = connection_profile_set_wifi_passphrase(profile_wifi, "keystring"); + CHECK_RETURN("connection_profile_set_wifi_passphrase", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_set_wifi_passphrase(profile_wifi, "keystring"); + CHECK_RETURN("connection_profile_set_wifi_passphrase", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_set_wifi_passphrase_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_set_wifi_passphrase should fail with invalid parameter. + * @scenario Verify connection_profile_set_wifi_passphrase by passing invalid parameter. + */ +int utc_connection_profile_set_wifi_passphrase_n(void) +{ + connection_profile_h profile_inval = NULL; + + if(wifi_supported) { + int ret = connection_profile_set_wifi_passphrase(profile_inval, NULL); + CHECK_RETURN("connection_profile_set_wifi_passphrase", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_wifi_passphrase(profile_inval, "keystring"); + CHECK_RETURN("connection_profile_set_wifi_passphrase", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_wifi_passphrase(profile_wifi, NULL); + CHECK_RETURN("connection_profile_set_wifi_passphrase", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_wifi_passphrase(profile_cellular, "keystring"); + CHECK_RETURN("connection_profile_set_wifi_passphrase", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_set_wifi_passphrase(profile_inval, NULL); + CHECK_RETURN("connection_profile_set_wifi_passphrase", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_is_wifi_wps_supported_p + * @since_tizen 2.3 + * @type Positive + * @description Checks whether the WPS (Wi-Fi Protected Setup) is supported. + * @scenario Invoking connection_profile_is_wifi_wps_supported with valid parameter. + */ +int utc_connection_profile_is_wifi_wps_supported_p(void) +{ + bool flag; + + if(wifi_supported) { + int ret = connection_profile_is_wifi_wps_supported(profile_wifi, &flag); + CHECK_RETURN("connection_profile_set_wifi_passphrase", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_profile_is_wifi_wps_supported(profile_wifi, &flag); + CHECK_RETURN("connection_profile_set_wifi_passphrase", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_is_wifi_wps_supported_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_is_wifi_wps_supported should fail with invalid parameter. + * @scenario Verify connection_profile_is_wifi_wps_supported by passing invalid parameter. + */ +int utc_connection_profile_is_wifi_wps_supported_n(void) +{ + connection_profile_h profile_inval = NULL; + bool flag; + + if(wifi_supported) { + int ret = connection_profile_is_wifi_wps_supported(profile_inval, NULL); + CHECK_RETURN("connection_profile_set_wifi_passphrase", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_wifi_wps_supported(profile_inval, &flag); + CHECK_RETURN("connection_profile_set_wifi_passphrase", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_wifi_wps_supported(profile_wifi, NULL); + CHECK_RETURN("connection_profile_set_wifi_passphrase", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_is_wifi_wps_supported(profile_cellular, &flag); + CHECK_RETURN("connection_profile_set_wifi_passphrase", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_profile_is_wifi_wps_supported(profile_inval, NULL); + CHECK_RETURN("connection_profile_set_wifi_passphrase", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_get_ipv6_state_p + * @since_tizen 4.0 + * @type Positive + * @description Gets IPv6 state + * @scenario Invoking connection_profile_get_ipv6_state with valid parameter. + */ +int utc_connection_profile_get_ipv6_state_p(void) +{ + connection_profile_state_e state; + int ret = test_get_any_profile(&profile_temp); + + if(all_features_not_supported) { + ret = connection_profile_get_ipv6_state(profile_temp, &state); + CHECK_RETURN("connection_profile_get_ipv6_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + + ret = connection_profile_get_ipv6_state(profile_temp, &state); + CHECK_RETURN("connection_profile_get_ipv6_state", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_ipv6_state_n + * @since_tizen 4.0 + * @type Negative + * @description connection_profile_get_ipv6_state should be failed with invalid parameter. + * @scenario Verify connection_profile_get_ipv6_state by passing invalid parameter. + */ +int utc_connection_profile_get_ipv6_state_n(void) +{ + connection_profile_h profile_inval = NULL; + connection_profile_state_e state; + + if(all_features_not_supported) { + int ret = connection_profile_get_ipv6_state(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_ipv6_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = connection_profile_get_ipv6_state(profile_inval, NULL); + CHECK_RETURN("connection_profile_get_ipv6_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_ipv6_state(profile_inval, &state); + CHECK_RETURN("connection_profile_get_ipv6_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_ipv6_state(profile_wifi, NULL); + CHECK_RETURN("connection_profile_get_ipv6_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_prefix_length_p + * @since_tizen 4.0 + * @type Positive + * @description Gets prefix length + * @scenario Invoking connection_profile_get_ipv6_state with valid parameter. + */ +int utc_connection_profile_get_prefix_length_p(void) +{ + int length; + + if (all_features_not_supported) { + int ret = connection_profile_get_prefix_length(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &length); + CHECK_RETURN("connection_profile_get_prefix_length", ret, CONNECTION_ERROR_NOT_SUPPORTED); + ret = connection_profile_get_prefix_length(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV6, &length); + CHECK_RETURN("connection_profile_get_prefix_length", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + int ret = connection_get_current_profile(connection, &profile_temp); + CHECK_RETURN("connection_profile_get_prefix_length", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_prefix_length(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &length); + CHECK_RETURN("connection_profile_get_prefix_length", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_prefix_length(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV6, &length); + CHECK_RETURN("connection_profile_get_prefix_length", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_prefix_length_n + * @since_tizen 4.0 + * @type Negative + * @description connection_profile_get_prefix_length should be failed with invalid parameter. + * @scenario Verify prefix_length by passing invalid parameter. + */ +int utc_connection_profile_get_prefix_length_n(void) +{ + connection_profile_h profile_inval = NULL; + int length; + + if (all_features_not_supported) { + int ret = connection_profile_get_prefix_length(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, &length); + CHECK_RETURN("connection_profile_get_prefix_length", ret, CONNECTION_ERROR_NOT_SUPPORTED); + ret = connection_profile_get_prefix_length(profile_wifi, CONNECTION_ADDRESS_FAMILY_IPV6, NULL); + CHECK_RETURN("connection_profile_get_prefix_length", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + int ret = connection_profile_get_prefix_length(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_get_prefix_length", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_prefix_length(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, &length); + CHECK_RETURN("connection_profile_get_prefix_length", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_prefix_length(profile_wifi, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_get_prefix_length", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_prefix_length_p + * @since_tizen 4.0 + * @type Positive + * @description Sets prefix length + * @scenario Invoking connection_profile_set_ipv6_state with valid parameter. + */ +int utc_connection_profile_set_prefix_length_p(void) +{ + int length = 32; + + if (all_features_not_supported) { + int ret = connection_profile_set_prefix_length(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, length); + CHECK_RETURN("connection_profile_set_prefix_length", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + int ret = connection_get_current_profile(connection, &profile_temp); + CHECK_RETURN("connection_profile_set_prefix_length", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_prefix_length(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, length); + CHECK_RETURN("connection_profile_set_prefix_length", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_prefix_length(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV6, length); + CHECK_RETURN("connection_profile_set_prefix_length", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_prefix_length_n + * @since_tizen 4.0 + * @type Negative + * @description connection_profile_set_prefix_length should be failed with invalid parameter. + * @scenario Verify prefix_length by passing invalid parameter. + */ +int utc_connection_profile_set_prefix_length_n(void) +{ + connection_profile_h profile_inval = NULL; + int length = 32; + + if (all_features_not_supported) { + int ret = connection_profile_set_prefix_length(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, length); + CHECK_RETURN("connection_profile_set_prefix_length", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + int ret = connection_profile_set_prefix_length(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, length); + CHECK_RETURN("connection_profile_set_prefix_length", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_dns_config_type_p + * @since_tizen 4.0 + * @type Positive + * @description Gets DNS configuration type + * @scenario Invoking connection_profile_get_dns_config_typ with valid parameter. + */ +int utc_connection_profile_get_dns_config_type_p(void) +{ + connection_dns_config_type_e config_type; + int ret = connection_get_current_profile(connection, &profile_temp); + PRINT_RETURN("connection_get_current_profile", ret); + + if (all_features_not_supported) { + ret = connection_profile_get_dns_config_type(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &config_type); + CHECK_RETURN("connection_profile_get_dns_config_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_temp); + + ret = connection_profile_get_dns_config_type(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, &config_type); + CHECK_RETURN("connection_profile_get_dns_config_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_get_dns_config_type(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV6, &config_type); + CHECK_RETURN("connection_profile_get_dns_config_type", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_dns_config_type_n + * @since_tizen 4.0 + * @type Negative + * @description connection_profile_get_dns_config_typ should be failed with invalid parameter. + * @scenario Verify connection_profile_get_dns_config_typ by passing invalid parameter. + */ +int utc_connection_profile_get_dns_config_type_n(void) +{ + connection_profile_h profile_inval = NULL; + connection_dns_config_type_e config_type; + + if(all_features_not_supported) { + int ret = connection_profile_get_dns_config_type(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_get_dns_config_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = connection_profile_get_dns_config_type(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_profile_get_dns_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dns_config_type(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV6, &config_type); + CHECK_RETURN("connection_profile_get_dns_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_get_dns_config_type(profile_wifi, CONNECTION_ADDRESS_FAMILY_IPV6, NULL); + CHECK_RETURN("connection_profile_get_dns_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_dns_config_type_p + * @since_tizen 4.0 + * @type Positive + * @description Sets DNS configuration type + * @scenario Invoking connection_profile_set_dns_config_typ with valid parameter. + */ +int utc_connection_profile_set_dns_config_type_p(void) +{ + if (all_features_not_supported) { + int ret = connection_profile_set_dns_config_type(profile_wifi, CONNECTION_ADDRESS_FAMILY_IPV6, CONNECTION_DNS_CONFIG_TYPE_DYNAMIC); + CHECK_RETURN("connection_profile_set_dns_config_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + int ret = connection_get_current_profile(connection, &profile_temp); + CHECK_RETURN("connection_profile_set_dns_config_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_dns_config_type(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, CONNECTION_DNS_CONFIG_TYPE_STATIC); + CHECK_RETURN("connection_profile_set_dns_config_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_dns_config_type(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV4, CONNECTION_DNS_CONFIG_TYPE_DYNAMIC); + CHECK_RETURN("connection_profile_set_dns_config_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_dns_config_type(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV6, CONNECTION_DNS_CONFIG_TYPE_STATIC); + CHECK_RETURN("connection_profile_set_dns_config_type", ret, CONNECTION_ERROR_NONE); + ret = connection_profile_set_dns_config_type(profile_temp, CONNECTION_ADDRESS_FAMILY_IPV6, CONNECTION_DNS_CONFIG_TYPE_DYNAMIC); + CHECK_RETURN("connection_profile_set_dns_config_type", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_set_dns_config_type_n + * @since_tizen 4.0 + * @type Negative + * @description connection_profile_set_dns_config_typ should be failed with invalid parameter. + * @scenario Verify connection_profile_get_dns_config_typ by passing invalid parameter. + */ +int utc_connection_profile_set_dns_config_type_n(void) +{ + connection_profile_h profile_inval = NULL; + + if (all_features_not_supported) { + int ret = connection_profile_set_dns_config_type(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, CONNECTION_DNS_CONFIG_TYPE_DYNAMIC); + CHECK_RETURN("connection_profile_set_dns_config_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + int ret = connection_profile_set_dns_config_type(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, CONNECTION_DNS_CONFIG_TYPE_STATIC); + CHECK_RETURN("connection_profile_set_dns_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_dns_config_type(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV6, CONNECTION_DNS_CONFIG_TYPE_STATIC); + CHECK_RETURN("connection_profile_set_dns_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_profile_set_dns_config_type(profile_inval, CONNECTION_ADDRESS_FAMILY_IPV4, CONNECTION_DNS_CONFIG_TYPE_DYNAMIC); + CHECK_RETURN("connection_profile_set_dns_config_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_internet_state_p + * @since_tizen 5.5 + * @type Positive + * @description Gets internet state. + * @scenario Verify connection_profile_get_internet_state by passing valid parameter. + */ +int utc_connection_profile_get_internet_state_p(void) +{ + connection_internet_state_e internet_state; + + if (all_features_not_supported) { + int ret = connection_profile_get_internet_state(profile_wifi, &internet_state); + CHECK_RETURN("connection_profile_get_internet_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + connection_profile_h profile_h = NULL; + int ret = test_get_any_profile(&profile_h); + ret = connection_profile_get_internet_state(profile_h, &internet_state); + CHECK_RETURN("connection_profile_get_internet_state", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_internet_state_n1 + * @since_tizen 5.5 + * @type Negative + * @description connection_profile_get_internet_state should be failed with invalid parameter. + * @scenario Verify connection_profile_get_internet_state by passing profile as NULL. + */ +int utc_connection_profile_get_internet_state_n1(void) +{ + connection_internet_state_e internet_state; + + if (all_features_not_supported) { + int ret = connection_profile_get_internet_state(NULL, &internet_state); + CHECK_RETURN("connection_profile_get_internet_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + int ret = connection_profile_get_internet_state(NULL, &internet_state); + CHECK_RETURN("connection_profile_get_internet_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_get_internet_state_n2 + * @since_tizen 5.5 + * @type Negative + * @description connection_profile_get_internet_state should be failed with invalid parameter. + * @scenario Verify connection_profile_get_internet_state by passing invalid parameter. + */ +int utc_connection_profile_get_internet_state_n2(void) +{ + if (all_features_not_supported) { + int ret = connection_profile_get_internet_state(profile_temp, NULL); + CHECK_RETURN("connection_profile_get_internet_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + connection_profile_h profile_h = NULL; + int ret = test_get_any_profile(&profile_h); + ret = connection_profile_get_internet_state(profile_h, NULL); + CHECK_RETURN("connection_profile_get_internet_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_profile_destroy_p + * @since_tizen 2.3 + * @type Positive + * @description Destroys a profile handle. + * @scenario Invoking connection_profile_destroy with valid parameter. + */ +int utc_connection_profile_destroy_p(void) +{ + int ret = CONNECTION_ERROR_INVALID_PARAMETER; + + if (all_features_not_supported) { + ret = connection_profile_destroy(profile_temp); + CHECK_RETURN("connection_profile_destroy", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + test_get_any_profile(&profile_temp); + assert(profile_temp); + ret = connection_profile_destroy(profile_temp); + CHECK_RETURN("connection_profile_destroy", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_destroy_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_destroy should fail with invalid parameter. + * @scenario Verify connection_profile_destroy by passing invalid parameter. + */ +int utc_connection_profile_destroy_n(void) +{ + int ret = connection_profile_destroy(NULL); + + if (all_features_not_supported) { + CHECK_RETURN("connection_profile_destroy", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_profile_destroy", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } + + return 0; +} diff --git a/unittest/utc-network-connection.c b/unittest/utc-network-connection.c new file mode 100755 index 0000000..4992003 --- /dev/null +++ b/unittest/utc-network-connection.c @@ -0,0 +1,2654 @@ +// +// Copyright (c) 2020 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 "utc-connection-common.h" + +static void test_network_state_changed_cb(connection_type_e state, void* user_data) +{ + PRINT_RETURN("test_network_state_changed_cb", CONNECTION_ERROR_NONE); +} + +static void test_ip_address_changed_cb(const char* ipv4_address, const char* ipv6_address, void* user_data) +{ + PRINT_RETURN("test_ip_address_changed_cb", CONNECTION_ERROR_NONE); +} + +static void test_proxy_address_changed_cb(const char* ipv4_address, const char* ipv6_address, void* user_data) +{ + PRINT_RETURN("test_proxy_address_changed_cb", CONNECTION_ERROR_NONE); +} + +static void test_connection_opened_callback(connection_error_e result, void* user_data) +{ + PRINT_RETURN("test_connection_opened_callback", result); + g_CallbackRet = result; +} + +static void test_connection_closed_callback(connection_error_e result, void* user_data) +{ + PRINT_RETURN("test_connection_closed_callback", result); + g_CallbackRet = result; +} + +static void test_connection_set_default_callback(connection_error_e result, void* user_data) +{ + PRINT_RETURN("test_connection_set_default_callback", result); + g_CallbackRet = result; +} + +static void test_connection_set_ethernet_callback(connection_ethernet_cable_state_e state, void* user_data) +{ + PRINT_RETURN("test_connection_set_ethernet_callback", state); + g_CallbackRet = CONNECTION_ERROR_NONE; +} + +static void test_connection_reset_profile_callback(connection_error_e result, void* user_data) +{ + PRINT_RETURN("test_connection_reset_profile_callback", result); + g_CallbackRet = result; +} + +static bool test_connection_ipv6_address_callback(char *ipv6_address, void *user_data) +{ + PRINT_RETURN("test_connection_ipv6_address_callback", CONNECTION_ERROR_NONE); + return true; +} + +static void test_connection_internet_state_changed_callback(connection_internet_state_e state, void* user_data) +{ + PRINT_RETURN("test_connection_internet_state_changed_callback", CONNECTION_ERROR_NONE); +} + +/** + * @function utc_network_connection_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_network_connection_startup(void) +{ + wifi_supported = connection_check_feature_supported(FEATURE_WIFI); + telephony_supported = connection_check_feature_supported(FEATURE_TELEPHONY); + bt_tethering_supported = connection_check_feature_supported(FEATURE_BT_TETHERING); + ethernet_supported = connection_check_feature_supported(FEATURE_ETHERNET); + + if (telephony_supported == false && wifi_supported == false + && bt_tethering_supported == false && ethernet_supported == false) { + all_features_not_supported = true; + return; + } + + int ret = connection_create(&connection); + PRINT_RETURN("connection_create", ret); + + if (ret != CONNECTION_ERROR_NONE) + return; + + if (telephony_supported) { + if (!profile_cellular) { + ret = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, CUSTOM_PROFILE_NAME, &profile_cellular); + PRINT_RETURN("connection_profile_create", ret); + } + } +} + +/** + * @function utc_network_connection_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void utc_network_connection_cleanup(void) +{ + int ret; + + if (profile_cellular) { + ret = connection_profile_destroy(profile_cellular); + PRINT_RETURN("connection_profile_destroy", ret); + profile_cellular = NULL; + } + + if (profile_temp) { + ret = connection_profile_destroy(profile_temp); + PRINT_RETURN("connection_profile_destroy", ret); + profile_temp = NULL; + } + + if (connection) { + ret = connection_destroy(connection); + PRINT_RETURN("connection_destroy", ret); + connection = NULL; + } +} + +/** + * @testcase utc_connection_create_p + * @since_tizen 2.3 + * @type Positive + * @description Creates a handle for managing data connections. + * @scenario Invoking connection_create with valid parameter.Destroy and create Connection. + */ +int utc_connection_create_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_create(&connection); + CHECK_RETURN("connection_create", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + if (connection) { + ret = connection_destroy(connection); + PRINT_RETURN("connection_destroy", ret); + connection = NULL; + } + + ret = connection_create(&connection); + CHECK_RETURN("connection_create", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_create_n + * @since_tizen 2.3 + * @type Negative + * @description connection_create should fail with invalid parameter. + * @scenario Verify connection_create by passing NULL parameter. + */ +int utc_connection_create_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_create(&connection); + CHECK_RETURN("connection_create", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + if (connection) { + ret = connection_destroy(connection); + PRINT_RETURN("connection_destroy", ret); + connection = NULL; + } + + ret = connection_create(NULL); + CHECK_RETURN("connection_create", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_get_ip_address_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the IP address of the current connection. + * @scenario Invoking connection_get_ip_address with valid parameter. + */ +int utc_connection_get_ip_address_p(void) +{ + char *ip_address = NULL; + + int ret = connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_address); + FREE_RESOURCE(ip_address); + + if (all_features_not_supported) { + CHECK_RETURN("connection_get_ip_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_get_ip_address", ret, CONNECTION_ERROR_NONE); + } + + ret = connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV6, &ip_address); + FREE_RESOURCE(ip_address); + + if (all_features_not_supported) { + CHECK_RETURN("connection_get_ip_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_get_ip_address", ret, CONNECTION_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_connection_get_ip_address_n + * @since_tizen 2.3 + * @type Negative + * @description connection_get_ip_address should fail with invalid parameter. + * @scenario Verify connection_get_ip_address by passing invalid parameter. + */ +int utc_connection_get_ip_address_n(void) +{ + int ret; + char *ip_address = NULL; + + if (all_features_not_supported) { + ret = connection_get_ip_address(connection, -100, NULL); + CHECK_RETURN("connection_get_ip_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_ip_address(NULL, -100, NULL); + CHECK_RETURN("connection_get_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_ip_address(NULL, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_address); + FREE_RESOURCE(ip_address); + CHECK_RETURN("connection_get_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_ip_address(connection, -100, &ip_address); + FREE_RESOURCE(ip_address); + CHECK_RETURN("connection_get_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_get_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_ip_address(NULL, -100, &ip_address); + FREE_RESOURCE(ip_address); + CHECK_RETURN("connection_get_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_ip_address(NULL, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_get_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_ip_address(connection, -100, NULL); + CHECK_RETURN("connection_get_ip_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_get_proxy_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the proxy address of the current connection. + * @scenario Invoking connection_get_proxy with valid parameter. + */ +int utc_connection_get_proxy_p(void) +{ + char *proxy = NULL; + + int ret = connection_get_proxy(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy); + FREE_RESOURCE(proxy); + + if (all_features_not_supported) { + CHECK_RETURN("connection_get_proxy", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_get_proxy", ret, CONNECTION_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_connection_get_proxy_n + * @since_tizen 2.3 + * @type Negative + * @description connection_get_proxy should fail with invalid parameter. + * @scenario Verify connection_get_proxy by passing invalid parameter. + */ +int utc_connection_get_proxy_n(void) +{ + int ret; + char *proxy = NULL; + + if (all_features_not_supported) { + ret = connection_get_proxy(connection, -100, NULL); + CHECK_RETURN("connection_get_proxy", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_proxy(NULL, -100, NULL); + CHECK_RETURN("connection_get_proxy", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_proxy(NULL, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy); + FREE_RESOURCE(proxy); + CHECK_RETURN("connection_get_proxy", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_proxy(connection, -100, &proxy); + FREE_RESOURCE(proxy); + CHECK_RETURN("connection_get_proxy", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_proxy(connection, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_get_proxy", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_proxy(NULL, -100, &proxy); + FREE_RESOURCE(proxy); + CHECK_RETURN("connection_get_proxy", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_proxy(NULL, CONNECTION_ADDRESS_FAMILY_IPV4, NULL); + CHECK_RETURN("connection_get_proxy", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_proxy(connection, -100, NULL); + CHECK_RETURN("connection_get_proxy", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_get_type_n + * @since_tizen 2.3 + * @type Negative + * @description connection_get_type should fail with invalid parameter. + * @scenario Verify connection_get_type by passing invalid parameter. + */ +int utc_connection_get_type_n(void) +{ + int ret; + connection_type_e state; + + if (all_features_not_supported) { + ret = connection_get_type(connection, NULL); + CHECK_RETURN("connection_get_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_type(NULL, NULL); + CHECK_RETURN("connection_get_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_type(NULL, &state); + CHECK_RETURN("connection_get_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_type(connection, NULL); + CHECK_RETURN("connection_get_type", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_get_type_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the type of the current profile for data connection. + * @scenario Invoking connection_get_type with valid parameter. + */ +int utc_connection_get_type_p(void) +{ + connection_type_e state; + + int ret = connection_get_type(connection, &state); + + if (all_features_not_supported) { + CHECK_RETURN("connection_get_type", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_get_type", ret, CONNECTION_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_connection_is_metered_network_n + * @since_tizen 4.0 + * @type Negative + * @description connection_is_metered_network should fail with invalid parameter. + * @scenario Verify utc_connection_is_metered_network_n by passing invalid parameter. + */ +int utc_connection_is_metered_network_n(void) +{ + int ret; + bool state; + + if (all_features_not_supported) { + ret = connection_is_metered_network(connection, NULL); + CHECK_RETURN("connection_is_metered_network", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_is_metered_network(NULL, NULL); + CHECK_RETURN("connection_is_metered_network", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_is_metered_network(NULL, &state); + CHECK_RETURN("connection_is_metered_network", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_is_metered_network(connection, NULL); + CHECK_RETURN("connection_is_metered_network", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_is_metered_network_p + * @since_tizen 4.0 + * @type Positive + * @description Gets if the current connection is metered. + * @scenario Invoking utc_connection_is_metered_network_p with valid parameter. + */ +int utc_connection_is_metered_network_p(void) +{ + bool state = false; + connection_type_e type; + + int ret = connection_is_metered_network(connection, &state); + connection_get_type(connection, &type); + + if (all_features_not_supported) { + CHECK_RETURN("connection_is_metered_network", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else if (state) { + CHECK_RETURN("connection_is_metered_network", type, CONNECTION_TYPE_CELLULAR); + } else { + CHECK_RETURN("connection_is_metered_network", ret, CONNECTION_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_connection_get_cellular_state_n + * @since_tizen 2.3 + * @type Negative + * @description connection_get_cellular_state should fail with invalid parameter. + * @scenario Verify connection_get_cellular_state by passing invalid parameter. + */ +int utc_connection_get_cellular_state_n(void) +{ + connection_cellular_state_e state; + + if (!telephony_supported) { + int ret = connection_get_cellular_state(NULL, NULL); + CHECK_RETURN("connection_get_cellular_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = connection_get_cellular_state(NULL, NULL); + CHECK_RETURN("connection_get_cellular_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_cellular_state(NULL, &state); + CHECK_RETURN("connection_get_cellular_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_cellular_state(connection, NULL); + CHECK_RETURN("connection_get_cellular_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_get_cellular_state_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the state of cellular connection. + * @scenario Invoking connection_get_cellular_state with valid parameter. + */ +int utc_connection_get_cellular_state_p(void) +{ + connection_cellular_state_e state; + + if (!telephony_supported) { + int ret = connection_get_cellular_state(connection, &state); + CHECK_RETURN("connection_get_cellular_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = connection_get_cellular_state(connection, &state); + CHECK_RETURN("connection_get_cellular_state", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_get_ethernet_state_n + * @since_tizen 2.4 + * @type Negative + * @description connection_get_ethernet_state should fail with invalid parameter. + * @scenario Verify connection_get_ethernet_state by passing invalid parameter. + */ +int utc_connection_get_ethernet_state_n(void) +{ + connection_ethernet_state_e state; + + if (!ethernet_supported) { + int ret = connection_get_ethernet_state(NULL, NULL); + CHECK_RETURN("connection_get_ethernet_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = connection_get_ethernet_state(NULL, NULL); + CHECK_RETURN("connection_get_ethernet_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_ethernet_state(NULL, &state); + CHECK_RETURN("connection_get_ethernet_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_ethernet_state(connection, NULL); + CHECK_RETURN("connection_get_ethernet_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_get_ethernet_state_p + * @since_tizen 2.4 + * @type Positive + * @description Gets the state of the Ethernet. + * @scenario Invoking connection_get_ethernet_state with valid parameter. + */ +int utc_connection_get_ethernet_state_p(void) +{ + connection_ethernet_state_e state; + + if (!ethernet_supported) { + int ret = connection_get_ethernet_state(connection, &state); + CHECK_RETURN("connection_get_ethernet_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = connection_get_ethernet_state(connection, &state); + CHECK_RETURN("connection_get_ethernet_state", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_get_wifi_state_n + * @since_tizen 2.3 + * @type Negative + * @description connection_get_wifi_state should fail with invalid parameter. + * @scenario Verify connection_get_wifi_state by passing invalid parameter. + */ +int utc_connection_get_wifi_state_n(void) +{ + connection_wifi_state_e state; + + if (!wifi_supported) { + int ret = connection_get_wifi_state(NULL, NULL); + CHECK_RETURN("connection_get_wifi_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = connection_get_wifi_state(NULL, NULL); + CHECK_RETURN("connection_get_wifi_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_wifi_state(NULL, &state); + CHECK_RETURN("connection_get_wifi_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_wifi_state(connection, NULL); + CHECK_RETURN("connection_get_wifi_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_get_wifi_state_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the state of the Wi-Fi. + * @scenario Invoking connection_get_wifi_state with valid parameter. + */ +int utc_connection_get_wifi_state_p(void) +{ + connection_wifi_state_e state; + + if (!wifi_supported) { + int ret = connection_get_wifi_state(connection, &state); + CHECK_RETURN("connection_get_wifi_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = connection_get_wifi_state(connection, &state); + CHECK_RETURN("connection_get_wifi_state", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_get_bt_state_n + * @since_tizen 2.3 + * @type Negative + * @description connection_get_bt_state should fail with invalid parameter. + * @scenario Verify connection_get_bt_state by passing invalid parameter. + */ +int utc_connection_get_bt_state_n(void) +{ + connection_bt_state_e state; + + if (!bt_tethering_supported) { + int ret = connection_get_bt_state(NULL, NULL); + CHECK_RETURN("connection_get_bt_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = connection_get_bt_state(NULL, NULL); + CHECK_RETURN("connection_get_bt_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_bt_state(NULL, &state); + CHECK_RETURN("connection_get_bt_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_bt_state(connection, NULL); + CHECK_RETURN("connection_get_bt_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_get_bt_state_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the state of the Bluetooth.The returned state is for the Bluetooth connection state. + * @scenario Invoking connection_get_bt_state with valid parameter. + */ +int utc_connection_get_bt_state_p(void) +{ + connection_bt_state_e state; + + if (!bt_tethering_supported) { + int ret = connection_get_bt_state(connection, &state); + CHECK_RETURN("connection_get_bt_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = connection_get_bt_state(connection, &state); + CHECK_RETURN("connection_get_bt_state", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_get_mac_address_n + * @since_tizen 2.4 + * @type Negative + * @description connection_get_mac_address should fail with invalid parameter. + * @scenario Verify connection_get_mac_address by passing invalid parameter. + */ +int utc_connection_get_mac_address_n(void) +{ + int ret; + char *mac_addr = NULL; + + if (wifi_supported == false && ethernet_supported == false) { + ret = connection_get_mac_address(connection, CONNECTION_TYPE_WIFI, &mac_addr); + CHECK_RETURN("connection_get_mac_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + if (wifi_supported) { + ret = connection_get_mac_address(NULL, CONNECTION_TYPE_WIFI, &mac_addr); + FREE_RESOURCE(mac_addr); + CHECK_RETURN("connection_get_mac_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + ret = connection_get_mac_address(connection, CONNECTION_TYPE_ETHERNET, NULL); + FREE_RESOURCE(mac_addr); + CHECK_RETURN("connection_get_mac_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_connection_get_mac_address_p + * @since_tizen 2.4 + * @type Positive + * @description Gets the MAC address of the Wi-Fi or ethernet. + * @scenario Invoking connection_get_mac_address with valid parameter. + */ +int utc_connection_get_mac_address_p(void) +{ + int ret; + char *mac_addr = NULL; + + if (wifi_supported) { + ret = connection_get_mac_address(connection, CONNECTION_TYPE_WIFI, &mac_addr); + assert(mac_addr); FREE_RESOURCE(mac_addr); + CHECK_RETURN("connection_get_mac_address", ret, CONNECTION_ERROR_NONE); + } else if(ethernet_supported) { + ret = connection_get_mac_address(connection, CONNECTION_TYPE_ETHERNET, &mac_addr); + assert(mac_addr); FREE_RESOURCE(mac_addr); + CHECK_RETURN("connection_get_mac_address", ret, CONNECTION_ERROR_NONE); + } else { + ret = connection_get_mac_address(connection, CONNECTION_TYPE_WIFI, &mac_addr); + FREE_RESOURCE(mac_addr); + CHECK_RETURN("connection_get_mac_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_set_ethernet_cable_state_chaged_cb_n + * @since_tizen 2.4 + * @type Negative + * @description connection_set_ethernet_cable_state_chaged_cb should fail with invalid parameter. + * @scenario Verify connection_set_ethernet_cable_state_chaged_cb by passing invalid parameter. + */ +int utc_connection_set_ethernet_cable_state_chaged_cb_n(void) +{ + int ret; + if (ethernet_supported == false) { + ret = connection_set_ethernet_cable_state_chaged_cb(NULL, NULL, NULL); + CHECK_RETURN("connection_set_ethernet_cable_state_chaged_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_set_ethernet_cable_state_chaged_cb(NULL, + test_connection_set_ethernet_callback, NULL); + CHECK_RETURN("connection_set_ethernet_cable_state_chaged_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_set_ethernet_cable_state_chaged_cb(connection, NULL, NULL); + CHECK_RETURN("connection_set_ethernet_cable_state_chaged_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_set_ethernet_cable_state_chaged_cb_p(void) +{ + int ret; + if (ethernet_supported == false) { + ret = connection_set_ethernet_cable_state_chaged_cb(NULL, NULL, NULL); + CHECK_RETURN("connection_set_ethernet_cable_state_chaged_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_set_ethernet_cable_state_chaged_cb(connection, test_connection_set_ethernet_callback, NULL); + CHECK_RETURN("connection_set_ethernet_cable_state_chaged_cb", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_unset_ethernet_cable_state_chaged_cb_n + * @since_tizen 2.4 + * @type Negative + * @description connection_unset_ethernet_cable_state_chaged_cb should fail with invalid parameter. + * @scenario Verify connection_unset_ethernet_cable_state_chaged_cb by passing invalid parameter. + */ +int utc_connection_unset_ethernet_cable_state_chaged_cb_n(void) +{ + int ret; + ret = connection_unset_ethernet_cable_state_chaged_cb(NULL); + + if (ethernet_supported == false) { + CHECK_RETURN("connection_unset_ethernet_cable_state_chaged_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_unset_ethernet_cable_state_chaged_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +int utc_connection_unset_ethernet_cable_state_chaged_cb_p(void) +{ + int ret; + ret = connection_unset_ethernet_cable_state_chaged_cb(connection); + + if (ethernet_supported == false) { + CHECK_RETURN("connection_unset_ethernet_cable_state_chaged_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_unset_ethernet_cable_state_chaged_cb", ret, CONNECTION_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_connection_get_ethernet_cable_state_n + * @since_tizen 2.4 + * @type Negative + * @description connection_get_ethernet_cable_state should fail with invalid parameter. + * @scenario Verify connection_get_ethernet_cable_state by passing invalid parameter. + */ +int utc_connection_get_ethernet_cable_state_n(void) +{ + int ret; + connection_ethernet_cable_state_e cable_state; + + if (ethernet_supported == false) { + ret = connection_get_ethernet_cable_state(NULL, NULL); + CHECK_RETURN("connection_get_ethernet_cable_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_ethernet_cable_state(NULL, &cable_state); + CHECK_RETURN("connection_get_ethernet_cable_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_ethernet_cable_state(connection, NULL); + CHECK_RETURN("connection_get_ethernet_cable_state", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_get_ethernet_cable_state_p + * @since_tizen 2.4 + * @type Positive + * @description Checks for ethernet cable is attached or not. + * @scenario Invoking connection_get_ethernet_cable_state with valid parameter. + */ +int utc_connection_get_ethernet_cable_state_p(void) +{ + int ret; + connection_ethernet_cable_state_e cable_state; + + ret = connection_get_ethernet_cable_state(connection, &cable_state); + if (ethernet_supported == false) { + CHECK_RETURN("connection_get_ethernet_cable_state", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_get_ethernet_cable_state", ret, CONNECTION_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_connection_get_current_profile_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the name of the default profile. + * @scenario Invoking connection_get_current_profile with valid parameter. + */ +int utc_connection_get_current_profile_p(void) +{ + int ret = connection_get_current_profile(connection, &profile_temp); + + if (all_features_not_supported) { + CHECK_RETURN("connection_get_current_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_get_current_profile", ret, CONNECTION_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_connection_get_current_profile_n + * @since_tizen 2.3 + * @type Negative + * @description connection_get_current_profile should fail with invalid parameter. + * @scenario Verify connection_get_current_profile by passing invalid parameter. + */ +int utc_connection_get_current_profile_n(void) +{ + int ret; + connection_profile_h profile = NULL; + + if (all_features_not_supported) { + ret = connection_get_current_profile(connection, NULL); + CHECK_RETURN("connection_get_current_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_current_profile(NULL, NULL); + CHECK_RETURN("connection_get_current_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_current_profile(connection, NULL); + CHECK_RETURN("connection_get_current_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_current_profile(NULL, &profile); + CHECK_RETURN("connection_get_current_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_get_default_cellular_service_profile_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the default profile which provides the given cellular service. + * @scenario Invoking connection_get_default_cellular_service_profile with valid parameter. + */ +int utc_connection_get_default_cellular_service_profile_p(void) +{ + connection_profile_h profile = NULL; + + if(!telephony_supported) { + int ret = connection_get_default_cellular_service_profile(connection, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET, &profile); + CHECK_RETURN("connection_get_default_cellular_service_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + connection_cellular_state_e state; + int ret = connection_get_cellular_state(connection, &state); + PRINT_RETURN("connection_get_cellular_state", ret); + if (state == CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE) + return 0; + + int service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET; + ret = connection_get_default_cellular_service_profile(connection, service_type, &profile); + CHECK_RETURN("connection_get_default_cellular_service_profile", ret, CONNECTION_ERROR_NONE); + + service_type = CONNECTION_CELLULAR_SERVICE_TYPE_MMS; + ret = connection_get_default_cellular_service_profile(connection, service_type, &profile); + CHECK_RETURN("connection_get_default_cellular_service_profile", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_get_default_cellular_service_profile_n + * @since_tizen 2.3 + * @type Negative + * @description connection_get_default_cellular_service_profile should fail with invalid parameter. + * @scenario Verify connection_get_default_cellular_service_profile by passing invalid parameter. + */ +int utc_connection_get_default_cellular_service_profile_n(void) +{ + connection_profile_h profile = NULL; + + if (!telephony_supported) { + int ret = connection_get_default_cellular_service_profile(NULL, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET, NULL); + CHECK_RETURN("connection_get_default_cellular_service_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + int service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET; + int ret = connection_get_default_cellular_service_profile(NULL, service_type, NULL); + CHECK_RETURN("connection_get_default_cellular_service_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + service_type = CONNECTION_CELLULAR_SERVICE_TYPE_MMS; + ret = connection_get_default_cellular_service_profile(connection, service_type, NULL); + CHECK_RETURN("connection_get_default_cellular_service_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET; + ret = connection_get_default_cellular_service_profile(NULL, service_type, &profile); + CHECK_RETURN("connection_get_default_cellular_service_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_set_default_cellular_service_profile_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the default profile which provides the given cellular service. + * @scenario Invoking connection_set_default_cellular_service_profile with valid parameter. + */ +int utc_connection_set_default_cellular_service_profile_p(void) +{ + int service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET; + + if (!telephony_supported) { + int ret = connection_set_default_cellular_service_profile(connection, service_type, profile_cellular); + CHECK_RETURN("connection_set_default_cellular_service_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + connection_cellular_state_e state; + int ret = connection_get_cellular_state(connection, &state); + PRINT_RETURN("connection_get_cellular_state", ret); + if (state == CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE) + return 0; + + ret = connection_get_default_cellular_service_profile(connection, service_type, &profile_cellular); + CHECK_RETURN("connection_set_default_cellular_service_profile", ret, CONNECTION_ERROR_NONE); + + ret = connection_set_default_cellular_service_profile(connection, service_type, profile_cellular); + CHECK_RETURN("connection_set_default_cellular_service_profile", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_set_default_cellular_service_profile_n + * @since_tizen 2.3 + * @type Negative + * @description connection_set_default_cellular_service_profile should fail with invalid parameter. + * @scenario Verify connection_set_default_cellular_service_profile by passing invalid parameter. + */ +int utc_connection_set_default_cellular_service_profile_n(void) +{ + int service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET; + + if (!telephony_supported) { + int ret = connection_set_default_cellular_service_profile(NULL, service_type, NULL); + CHECK_RETURN("connection_set_default_cellular_service_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = connection_set_default_cellular_service_profile(NULL, service_type, NULL); + CHECK_RETURN("connection_set_default_cellular_service_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_set_default_cellular_service_profile(connection, service_type, NULL); + CHECK_RETURN("connection_set_default_cellular_service_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + service_type = CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING; + ret = connection_get_default_cellular_service_profile(NULL, service_type, profile_cellular); + CHECK_RETURN("connection_set_default_cellular_service_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_set_default_cellular_service_profile_async_p + * @since_tizen 2.3 + * @type Positive + * @description Sets the default profile which provides the given cellular service, asynchronously. + * @scenario Invoking connection_set_default_cellular_service_profile_async with valid parameter. + */ +int utc_connection_set_default_cellular_service_profile_async_p(void) +{ + int service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET; + + if (!telephony_supported) { + int ret = connection_set_default_cellular_service_profile_async(connection, service_type, NULL, test_connection_set_default_callback, NULL); + CHECK_RETURN("connection_set_default_cellular_service_profile_async", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + connection_cellular_state_e state; + int ret = connection_get_cellular_state(connection, &state); + PRINT_RETURN("connection_get_cellular_state", ret); + if (state == CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE) + return 0; + + ret = connection_get_default_cellular_service_profile(connection, service_type, &profile_cellular); + CHECK_RETURN("connection_set_default_cellular_service_profile_async", ret, CONNECTION_ERROR_NONE); + + ret = connection_set_default_cellular_service_profile_async(connection, service_type, profile_cellular, test_connection_set_default_callback, NULL); + CHECK_RETURN("connection_set_default_cellular_service_profile_async", ret, CONNECTION_ERROR_NONE); + test_connection_set_default_callback(CONNECTION_ERROR_NONE, NULL); + + return 0; +} + +/** + * @testcase utc_connection_set_default_cellular_service_profile_async_n + * @since_tizen 2.3 + * @type Negative + * @description connection_set_default_cellular_service_profile_async should fail with invalid parameter. + * @scenario Verify connection_set_default_cellular_service_profile_async by passing invalid parameter. + */ +int utc_connection_set_default_cellular_service_profile_async_n(void) +{ + int service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET; + + if (!telephony_supported) { + int ret = connection_set_default_cellular_service_profile_async(NULL, service_type, NULL, NULL, NULL); + CHECK_RETURN("connection_set_default_cellular_service_profile_async", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + int ret = connection_set_default_cellular_service_profile_async(NULL, service_type, NULL, NULL, NULL); + CHECK_RETURN("connection_set_default_cellular_service_profile_async", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_set_default_cellular_service_profile_async(connection, service_type, profile_cellular, NULL, NULL); + CHECK_RETURN("connection_set_default_cellular_service_profile_async", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_set_default_cellular_service_profile_async(connection, service_type, NULL, test_connection_set_default_callback, NULL); + CHECK_RETURN("connection_set_default_cellular_service_profile_async", ret, CONNECTION_ERROR_INVALID_PARAMETER); + service_type = CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING; + ret = connection_set_default_cellular_service_profile_async(NULL, service_type, profile_cellular, test_connection_set_default_callback, NULL); + CHECK_RETURN("connection_set_default_cellular_service_profile_async", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_set_type_changed_cb_n + * @since_tizen 2.3 + * @type Negative + * @description connection_set_type_changed_cb should fail with invalid parameter. + * @scenario Verify connection_set_type_changed_cb by passing invalid parameter. + */ +int utc_connection_set_type_changed_cb_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_set_type_changed_cb(connection, NULL, NULL); + CHECK_RETURN("connection_set_type_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_set_type_changed_cb(NULL, NULL, NULL); + CHECK_RETURN("connection_set_type_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_set_type_changed_cb(NULL, test_network_state_changed_cb, NULL); + CHECK_RETURN("connection_set_type_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_set_type_changed_cb(connection, NULL, NULL); + CHECK_RETURN("connection_set_type_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_set_type_changed_cb_p + * @since_tizen 2.3 + * @type Positive + * @description Registers the callback that is called when the type of the current connection is changed. + * @scenario Invoking connection_set_type_changed_cb with valid parameter. + */ +int utc_connection_set_type_changed_cb_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_set_type_changed_cb(connection, NULL, NULL); + CHECK_RETURN("connection_set_type_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_set_type_changed_cb(connection, test_network_state_changed_cb, NULL); + CHECK_RETURN("connection_set_type_changed_cb", ret, CONNECTION_ERROR_NONE); + test_network_state_changed_cb(CONNECTION_TYPE_CELLULAR, NULL); + + return 0; +} + +/** + * @testcase utc_connection_unset_type_changed_cb_n + * @since_tizen 2.3 + * @type Negative + * @description connection_unset_type_changed_cb should fail with invalid parameter. + * @scenario Verify connection_unset_type_changed_cb by passing invalid parameter. + */ +int utc_connection_unset_type_changed_cb_n(void) +{ + int ret = connection_unset_type_changed_cb(NULL); + + if (all_features_not_supported) { + CHECK_RETURN("connection_unset_type_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_unset_type_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_connection_unset_type_changed_cb_p + * @since_tizen 2.3 + * @type Positive + * @description Unregisters the callback that is called when the type of current connection is changed. + * @scenario Invoking connection_unset_type_changed_cb with valid parameter. + */ +int utc_connection_unset_type_changed_cb_p(void) +{ + int ret = connection_unset_type_changed_cb(connection); + + if (all_features_not_supported) { + CHECK_RETURN("connection_unset_type_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_unset_type_changed_cb", ret, CONNECTION_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_connection_set_ip_address_changed_cb_n + * @since_tizen 2.3 + * @type Negative + * @description connection_set_ip_address_changed_cb should fail with invalid parameter. + * @scenario Verify connection_set_ip_address_changed_cb by passing invalid parameter. + */ +int utc_connection_set_ip_address_changed_cb_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_set_ip_address_changed_cb(connection, NULL, NULL); + CHECK_RETURN("connection_set_ip_address_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_set_ip_address_changed_cb(NULL, NULL, NULL); + CHECK_RETURN("connection_set_ip_address_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_set_ip_address_changed_cb(NULL, test_ip_address_changed_cb, NULL); + CHECK_RETURN("connection_set_ip_address_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_set_ip_address_changed_cb(connection, NULL, NULL); + CHECK_RETURN("connection_set_ip_address_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_set_ip_address_changed_cb_p + * @since_tizen 2.3 + * @type Positive + * @description Registers the callback that is called when the IP address is changed. + * @scenario Invoking connection_set_ip_address_changed_cb with valid parameter. + */ +int utc_connection_set_ip_address_changed_cb_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_set_ip_address_changed_cb(connection, NULL, NULL); + CHECK_RETURN("connection_set_ip_address_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_set_ip_address_changed_cb(connection, test_ip_address_changed_cb, NULL); + CHECK_RETURN("connection_set_ip_address_changed_cb", ret, CONNECTION_ERROR_NONE); + test_ip_address_changed_cb(NULL, NULL, NULL); + + return 0; +} + +/** + * @testcase utc_connection_unset_ip_address_changed_cb_n + * @since_tizen 2.3 + * @type Negative + * @description connection_unset_ip_address_changed_cb should fail with invalid parameter. + * @scenario Verify connection_unset_ip_address_changed_cb by passing invalid parameter. + */ +int utc_connection_unset_ip_address_changed_cb_n(void) +{ + int ret = connection_unset_ip_address_changed_cb(NULL); + + if (all_features_not_supported) { + CHECK_RETURN("connection_set_ip_address_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_set_ip_address_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_connection_unset_ip_address_changed_cb_p + * @since_tizen 2.3 + * @type Positive + * @description Unregisters the callback that is called when the IP address is changed. + * @scenario Invoking connection_unset_ip_address_changed_cb with valid parameter. + */ +int utc_connection_unset_ip_address_changed_cb_p(void) +{ + int ret = connection_unset_ip_address_changed_cb(connection); + + if (all_features_not_supported) { + CHECK_RETURN("connection_unset_ip_address_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_unset_ip_address_changed_cb", ret, CONNECTION_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_connection_set_proxy_address_changed_cb_n + * @since_tizen 2.3 + * @type Negative + * @description connection_set_proxy_address_changed_cb should fail with invalid parameter. + * @scenario Verify connection_set_proxy_address_changed_cb by passing invalid parameter. + */ +int utc_connection_set_proxy_address_changed_cb_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_set_proxy_address_changed_cb(connection, NULL, NULL); + CHECK_RETURN("connection_set_proxy_address_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_set_proxy_address_changed_cb(NULL, NULL, NULL); + CHECK_RETURN("connection_set_proxy_address_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_set_proxy_address_changed_cb(NULL, test_proxy_address_changed_cb, NULL); + CHECK_RETURN("connection_set_proxy_address_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_set_proxy_address_changed_cb(connection, NULL, NULL); + CHECK_RETURN("connection_set_proxy_address_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_set_proxy_address_changed_cb_p + * @since_tizen 2.3 + * @type Positive + * @description Registers the callback that is called when the proxy address is changed. + * @scenario Invoking connection_set_proxy_address_changed_cb with valid parameter. + */ +int utc_connection_set_proxy_address_changed_cb_p(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_set_proxy_address_changed_cb(connection, NULL, NULL); + CHECK_RETURN("connection_set_proxy_address_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_set_proxy_address_changed_cb(connection, test_proxy_address_changed_cb, NULL); + CHECK_RETURN("connection_set_proxy_address_changed_cb", ret, CONNECTION_ERROR_NONE); + test_proxy_address_changed_cb(NULL, NULL, NULL); + + return 0; +} + +/** + * @testcase utc_connection_unset_proxy_address_changed_cb_n + * @since_tizen 2.3 + * @type Negative + * @description connection_unset_proxy_address_changed_cb should fail with invalid parameter. + * @scenario Verify connection_unset_proxy_address_changed_cb by passing invalid parameter. + */ +int utc_connection_unset_proxy_address_changed_cb_n(void) +{ + int ret = connection_unset_proxy_address_changed_cb(NULL); + + if (all_features_not_supported) { + CHECK_RETURN("connection_unset_proxy_address_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_unset_proxy_address_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_connection_unset_proxy_address_changed_cb_p + * @since_tizen 2.3 + * @type Positive + * @description Unregisters the callback that is called when the proxy address is changed. + * @scenario Invoking connection_unset_proxy_address_changed_cb with valid parameter. + */ +int utc_connection_unset_proxy_address_changed_cb_p(void) +{ + int ret = connection_unset_proxy_address_changed_cb(connection); + + if (all_features_not_supported) { + CHECK_RETURN("connection_unset_proxy_address_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_unset_proxy_address_changed_cb", ret, CONNECTION_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_connection_get_statistics_p + * @since_tizen 2.3 + * @type Positive + * @description Gets the statistics information. + * @scenario Invoking connection_get_statistics with valid parameter. + */ +int utc_connection_get_statistics_p(void) +{ + long long stat; + + if (telephony_supported) { + int ret = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_NONE); + ret = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_NONE); + ret = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_NONE); + ret = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + if (wifi_supported) { + int ret = connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_NONE); + ret = connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_NONE); + ret = connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_NONE); + ret = connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_get_statistics_n + * @since_tizen 2.3 + * @type Negative + * @description connection_get_statistics should fail with invalid parameter. + * @scenario Verify connection_get_statistics by passing invalid parameter. + */ +int utc_connection_get_statistics_n(void) +{ + int ret; + long long stat; + + if (telephony_supported == false && wifi_supported == false){ + ret = connection_get_statistics(NULL, -1, -1, NULL); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_statistics(NULL, -1, -1, NULL); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_statistics(connection, -1, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_statistics(connection, -1, -1, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + if (telephony_supported) { + ret = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, -1, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, NULL); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, -1, NULL); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + ret = connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, -1, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + if (wifi_supported) { + ret = connection_get_statistics(connection, CONNECTION_TYPE_WIFI, -1, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, NULL); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_statistics(connection, CONNECTION_TYPE_WIFI, -1, NULL); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + ret = connection_get_statistics(connection, CONNECTION_TYPE_WIFI, -1, &stat); + CHECK_RETURN("connection_get_statistics", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_reset_statistics_p + * @since_tizen 2.3 + * @type Positive + * @description Resets the statistics information. + * @scenario Invoking connection_reset_statistics with valid parameter. + */ +int utc_connection_reset_statistics_p(void) +{ + int ret = 0; + if (telephony_supported) { + ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_NONE); + ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_NONE); + ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_NONE); + ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_NONE); + } else { + ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + if (wifi_supported) { + ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_NONE); + ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_NONE); + ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_NONE); + ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_NONE); + } else { + ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_reset_statistics_n + * @since_tizen 2.3 + * @type Negative + * @description connection_reset_statistics should fail with invalid parameter. + * @scenario Verify connection_reset_statistics by passing invalid parameter. + */ +int utc_connection_reset_statistics_n(void) +{ + int ret; + if (telephony_supported == false && wifi_supported == false) { + ret = connection_reset_statistics(NULL, -1, -1); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_reset_statistics(NULL, -1, -1); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_reset_statistics(connection, -1, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + if (telephony_supported) { + ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, -1); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, -1); + CHECK_RETURN("connection_reset_statistics", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_add_route_n + * @since_tizen 2.3 + * @type Negative + * @description connection_add_route should fail with invalid parameter. + * @scenario Verify connection_add_route by passing invalid parameter. + */ +int utc_connection_add_route_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_add_route(connection, NULL, NULL); + CHECK_RETURN("connection_add_route", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_add_route(NULL, NULL, NULL); + CHECK_RETURN("connection_add_route", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_add_route(NULL, "pdp0", "192.168.129.3"); + CHECK_RETURN("connection_add_route", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_add_route(connection, "pdp0", NULL); + CHECK_RETURN("connection_add_route", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_add_route(connection, NULL, "192.168.129.3"); + CHECK_RETURN("connection_add_route", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_add_route_p + * @since_tizen 2.3 + * @type Positive + * @description Adds a IPv4 route to the routing table.You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile. + * @scenario Invoking connection_add_route with valid parameter. + */ +int utc_connection_add_route_p(void) +{ + int ret; + char* interface_name = NULL; + + if (all_features_not_supported) { + ret = connection_add_route(connection, interface_name, "192.168.129.3"); + CHECK_RETURN("connection_add_route", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_current_profile(connection, &profile_temp); + PRINT_RETURN("connection_get_current_profile", ret); + + ret = connection_profile_get_network_interface_name(profile_temp, &interface_name); + PRINT_RETURN("connection_get_current_profile", ret); + + ret = connection_add_route(connection, interface_name, "192.168.129.3"); + FREE_RESOURCE(interface_name); + CHECK_RETURN("connection_add_route", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_remove_route_n + * @since_tizen 2.3 + * @type Negative + * @description connection_remove_route should fail with invalid parameter. + * @scenario Verify connection_remove_route by passing invalid parameter. + */ +int utc_connection_remove_route_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_remove_route(NULL, NULL, NULL); + CHECK_RETURN("connection_remove_route", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_remove_route(NULL, NULL, NULL); + CHECK_RETURN("connection_remove_route", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_remove_route(NULL, "pdp0", "192.168.129.3"); + CHECK_RETURN("connection_remove_route", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_remove_route(connection, "pdp0", NULL); + CHECK_RETURN("connection_remove_route", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_add_route(connection, NULL, "192.168.129.3"); + CHECK_RETURN("connection_remove_route", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_remove_route_p + * @since_tizen 2.3 + * @type Positive + * @description Removes a IPv4 route from the routing table.get the @a interface_name from connection_profile_get_network_interface_name() of opened profile. + * @scenario Invoking connection_remove_route with valid parameter. + */ +int utc_connection_remove_route_p(void) +{ + int ret; + char* interface_name = NULL; + + if (all_features_not_supported) { + ret = connection_remove_route(connection, interface_name, "192.168.129.3"); + CHECK_RETURN("connection_remove_route", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_current_profile(connection, &profile_temp); + PRINT_RETURN("connection_get_current_profile", ret); + + ret = connection_profile_get_network_interface_name(profile_temp, &interface_name); + PRINT_RETURN("connection_profile_get_network_interface_name", ret); + + ret = connection_remove_route(connection, interface_name, "192.168.129.3"); + FREE_RESOURCE(interface_name); + CHECK_RETURN("connection_remove_route", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_add_route_ipv6_n + * @since_tizen 2.3.1 + * @type Negative + * @description connection_add_route_ipv6 should fail with invalid parameter. + * @scenario Verify connection_add_route_ipv6 by passing invalid parameter. + */ +int utc_connection_add_route_ipv6_n(void) +{ + int ret; + + if (telephony_supported == false && wifi_supported == false && ethernet_supported == false) { + ret = connection_add_route_ipv6(NULL, NULL, NULL, NULL); + CHECK_RETURN("connection_add_route_ipv6", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_add_route_ipv6(NULL, NULL, NULL, NULL); + CHECK_RETURN("connection_add_route_ipv6", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_add_route_ipv6(connection, NULL, "2001:db8:1:0::1", "fe80::"); + CHECK_RETURN("connection_add_route_ipv6", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_add_route_ipv6(connection, NULL, NULL, "fe80::"); + CHECK_RETURN("connection_add_route_ipv6", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_add_route_ipv6_p + * @since_tizen 2.3.1 + * @type Positive + * @description Adds a IPv6 route to the routing table. + * @scenario Invoking connection_add_route_ipv6 with valid parameter. + */ +int utc_connection_add_route_ipv6_p(void) +{ + int ret; + char* interface_name = NULL; + + if (telephony_supported == false && wifi_supported == false && ethernet_supported == false) { + ret = connection_add_route_ipv6(connection, interface_name, "2001:db8:1:0::1", "fe80::"); + CHECK_RETURN("connection_add_route_ipv6", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_current_profile(connection, &profile_temp); + PRINT_RETURN("connection_get_current_profile", ret); + ret = connection_profile_get_network_interface_name(profile_temp, &interface_name); + PRINT_RETURN("connection_profile_get_network_interface_name", ret); + + ret = connection_add_route_ipv6(connection, interface_name, "2001:db8:1:0::1", "fe80::"); + FREE_RESOURCE(interface_name); + CHECK_RETURN("connection_add_route_ipv6", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_remove_route_ipv6_n + * @since_tizen 2.3.1 + * @type Negative + * @description connection_add_route_ipv6 should fail with invalid parameter. + * @scenario Verify connection_add_route_ipv6 by passing invalid parameter. + */ +int utc_connection_remove_route_ipv6_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_remove_route_ipv6(NULL, NULL, NULL, NULL); + CHECK_RETURN("connection_remove_route_ipv6", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_remove_route_ipv6(NULL, NULL, NULL, NULL); + CHECK_RETURN("connection_remove_route_ipv6", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_remove_route_ipv6(connection, NULL, "2001:db8:1:0::1", "fe80::"); + CHECK_RETURN("connection_remove_route_ipv6", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_remove_route_ipv6(connection, NULL, NULL, "fe80::"); + CHECK_RETURN("connection_remove_route_ipv6", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_remove_route_ipv6_p + * @since_tizen 2.3.1 + * @type Positive + * @description Removes a IPV6 route from the routing table. + * @scenario Invoking connection_remove_route_ipv6 with valid parameter. + */ +int utc_connection_remove_route_ipv6_p(void) +{ + int ret; + char* interface_name = NULL; + + if (telephony_supported == false && wifi_supported == false && ethernet_supported == false) { + ret = connection_remove_route_ipv6(connection, interface_name, "2001:db8:1:0::1", "fe80::"); + FREE_RESOURCE(interface_name); + CHECK_RETURN("connection_remove_route_ipv6", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_current_profile(connection, &profile_temp); + PRINT_RETURN("connection_get_current_profile", ret); + ret = connection_profile_get_network_interface_name(profile_temp, &interface_name); + PRINT_RETURN("connection_profile_get_network_interface_name", ret); + + ret = connection_remove_route_ipv6(connection, interface_name, "2001:db8:1:0::1", "fe80::"); + FREE_RESOURCE(interface_name); + CHECK_RETURN("connection_remove_route_ipv6", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_add_route_entry_n + * @since_tizen 4.0 + * @type Negative + * @description connection_add_route_entry should fail with invalid parameter. + * @scenario Verify connection_add_route_entry by passing invalid parameter. + */ +int utc_connection_add_route_entry_n(void) +{ + int ret; + + if (telephony_supported == false && wifi_supported == false && ethernet_supported == false) { + ret = connection_add_route_entry(NULL, -1, NULL, NULL, NULL); + CHECK_RETURN("connection_add_route_entry", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_add_route_entry(NULL, -1, NULL, NULL, NULL); + CHECK_RETURN("connection_add_route_entry", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_add_route_entry(connection, -1, NULL, "2001:db8:1:0::1", "fe80::"); + CHECK_RETURN("connection_add_route_entry", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_add_route_entry(connection, -1, NULL, NULL, "fe80::"); + CHECK_RETURN("connection_add_route_entry", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_add_route_entry_p + * @since_tizen 4.0 + * @type Positive + * @description Adds a route to the routing table. + * @scenario Invoking connection_add_route_entry with valid parameter. + */ +int utc_connection_add_route_entry_p(void) +{ + int ret; + char* interface_name = NULL; + + if (telephony_supported == false && wifi_supported == false && ethernet_supported == false) { + ret = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, interface_name, "2001:db8:1:0::1", "fe80::"); + CHECK_RETURN("connection_add_route_entry", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_current_profile(connection, &profile_temp); + PRINT_RETURN("connection_get_current_profile", ret); + connection_profile_get_network_interface_name(profile_temp, &interface_name); + PRINT_RETURN("connection_profile_get_network_interface_name", ret); + + ret = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, interface_name, "192.168.10.30", "192.168.10.1"); + CHECK_RETURN("connection_add_route_entry", ret, CONNECTION_ERROR_NONE); + + ret = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, interface_name, "2001:db8:1:0::1", "fe80::"); + FREE_RESOURCE(interface_name); + CHECK_RETURN("connection_add_route_entry", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_remove_route_entry_n + * @since_tizen 4.0 + * @type Negative + * @description connection_add_route_entry should fail with invalid parameter. + * @scenario Verify connection_add_route_entry by passing invalid parameter. + */ +int utc_connection_remove_route_entry_n(void) +{ + int ret; + + if (all_features_not_supported) { + ret = connection_remove_route_entry(NULL, -1, NULL, NULL, NULL); + CHECK_RETURN("connection_remove_route_entry", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_remove_route_entry(NULL, -1, NULL, NULL, NULL); + CHECK_RETURN("connection_remove_route_entry", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_remove_route_entry(connection, -1, NULL, "2001:db8:1:0::1", "fe80::"); + CHECK_RETURN("connection_remove_route_entry", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + ret = connection_remove_route_entry(connection, -1, NULL, NULL, "fe80::"); + CHECK_RETURN("connection_remove_route_entry", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_remove_route_entry_p + * @since_tizen 4.0 + * @type Positive + * @description Removes a route from the routing table. + * @scenario Invoking connection_remove_route_entry with valid parameter. + */ +int utc_connection_remove_route_entry_p(void) +{ + int ret; + char* interface_name = NULL; + + if (telephony_supported == false && wifi_supported == false && ethernet_supported == false) { + ret = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, interface_name, "2001:db8:1:0::1", "fe80::"); + FREE_RESOURCE(interface_name); + CHECK_RETURN("connection_remove_route_entry", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_current_profile(connection, &profile_temp); + PRINT_RETURN("connection_get_current_profile", ret); + connection_profile_get_network_interface_name(profile_temp, &interface_name); + PRINT_RETURN("connection_profile_get_network_interface_name", ret); + + ret = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, interface_name, "192.168.10.30", "192.168.10.1"); + CHECK_RETURN("connection_remove_route_entry", ret, CONNECTION_ERROR_NONE); + + ret = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, interface_name, "2001:db8:1:0::1", "fe80::"); + FREE_RESOURCE(interface_name); + CHECK_RETURN("connection_remove_route_entry", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_get_profile_iterator_n + * @since_tizen 2.3 + * @type Negative + * @description connection_get_profile_iterator should fail with invalid parameter. + * @scenario Verify connection_get_profile_iterator by passing invalid parameter. + */ +int utc_connection_get_profile_iterator_n(void) +{ + int ret; + connection_profile_iterator_h profile_iter; + + if (all_features_not_supported) { + ret = connection_get_profile_iterator(connection, 3, &profile_iter); + CHECK_RETURN("connection_get_profile_iterator", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_profile_iterator(NULL, 3, NULL); + CHECK_RETURN("connection_get_profile_iterator", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_profile_iterator(NULL, CONNECTION_ITERATOR_TYPE_CONNECTED, &profile_iter); + CHECK_RETURN("connection_get_profile_iterator", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_get_profile_iterator(connection, 3, &profile_iter); + CHECK_RETURN("connection_get_profile_iterator", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_get_profile_iterator_p + * @since_tizen 2.3 + * @type Positive + * @description Gets a profiles iterator. + * @scenario Invoking connection_get_profile_iterator with valid parameter. + */ +int utc_connection_get_profile_iterator_p(void) +{ + int ret; + connection_profile_iterator_h profile_iter; + + if (all_features_not_supported) { + ret = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_CONNECTED, &profile_iter); + CHECK_RETURN("connection_get_profile_iterator", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_CONNECTED, &profile_iter); + CHECK_RETURN("connection_get_profile_iterator", ret, CONNECTION_ERROR_NONE); + ret = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter); + CHECK_RETURN("connection_get_profile_iterator", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_destroy_profile_iterator_n + * @since_tizen 2.3 + * @type Negative + * @description connection_destroy_profile_iterator should fail with invalid parameter. + * @scenario Verify connection_destroy_profile_iterator by passing invalid parameter. + */ +int utc_connection_destroy_profile_iterator_n(void) +{ + int ret = connection_destroy_profile_iterator(NULL); + + if (all_features_not_supported) { + CHECK_RETURN("connection_destroy_profile_iterator", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_destroy_profile_iterator", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_connection_destroy_profile_iterator_p + * @since_tizen 2.3 + * @type Positive + * @description Destroys a profiles iterator. + * @scenario Invoking connection_destroy_profile_iterator with valid parameter. + */ +int utc_connection_destroy_profile_iterator_p(void) +{ + int ret; + connection_profile_iterator_h profile_iter = NULL; + + if (all_features_not_supported) { + ret = connection_destroy_profile_iterator(profile_iter); + CHECK_RETURN("connection_destroy_profile_iterator", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_CONNECTED, &profile_iter); + PRINT_RETURN("connection_get_profile_iterator", ret); + + ret = connection_destroy_profile_iterator(profile_iter); + CHECK_RETURN("connection_destroy_profile_iterator", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_profile_iterator_has_next_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_iterator_has_next should fail with invalid parameter. + * @scenario Verify connection_profile_iterator_has_next by passing invalid parameter. + */ +int utc_connection_profile_iterator_has_next_n(void) +{ + int ret = connection_profile_iterator_has_next(NULL); + if (all_features_not_supported) { + CHECK_RETURN("connection_profile_iterator_has_next", get_last_result(), CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_profile_iterator_has_next", ret, false); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_iterator_has_next_p + * @since_tizen 2.3 + * @type Positive + * @description Checks whether the next element of a profile iterator exists or not. + * @scenario Invoking connection_profile_iterator_has_next with valid parameter. + */ +int utc_connection_profile_iterator_has_next_p(void) +{ + int ret; + connection_profile_iterator_h profile_iter = NULL; + + if (all_features_not_supported) { + ret = connection_profile_iterator_has_next(profile_iter); + CHECK_RETURN("connection_profile_iterator_has_next", get_last_result(), CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter); + PRINT_RETURN("connection_get_profile_iterator", ret); + + ret = connection_profile_iterator_has_next(profile_iter); + CHECK_RETURN("connection_profile_iterator_has_next", ret, true); + + ret = connection_destroy_profile_iterator(profile_iter); + PRINT_RETURN("connection_destroy_profile_iterator", ret); + + return 0; +} + +/** + * @testcase utc_connection_profile_iterator_next_n + * @since_tizen 2.3 + * @type Negative + * @description connection_profile_iterator_next should fail with invalid parameter. + * @scenario Verify connection_profile_iterator_next by passing invalid parameter. + */ +int utc_connection_profile_iterator_next_n(void) +{ + connection_profile_h profile_h; + + int ret = connection_profile_iterator_next(NULL, &profile_h); + + if (all_features_not_supported) { + CHECK_RETURN("connection_profile_iterator_next", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_profile_iterator_next", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_connection_profile_iterator_next_p + * @since_tizen 2.3 + * @type Positive + * @description Moves the profile iterator to the next position and gets a profile handle. + * @scenario Invoking connection_profile_iterator_next with valid parameter. + */ +int utc_connection_profile_iterator_next_p(void) +{ + int ret; + connection_profile_iterator_h profile_iter = NULL; + connection_profile_h profile_h = NULL; + + if (all_features_not_supported) { + ret = connection_profile_iterator_next(profile_iter, &profile_h); + CHECK_RETURN("connection_profile_iterator_next", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_CONNECTED, &profile_iter); + PRINT_RETURN("connection_get_profile_iterator", ret); + + while (connection_profile_iterator_has_next(profile_iter)) { + ret = connection_profile_iterator_next(profile_iter, &profile_h); + CHECK_RETURN("connection_profile_iterator_next", ret, CONNECTION_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_connection_add_profile_p + * @since_tizen 2.3 + * @type Positive + * @description Creates a profile handle.The profile name, which you get from connection_profile_get_name(), will include the keyword you set. + * @scenario Invoking connection_profile_create with valid parameter. + */ +int utc_connection_add_profile_p(void) +{ + if (telephony_supported) { + int ret = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, CUSTOM_PROFILE_NAME, &profile_cellular); + PRINT_RETURN("connection_profile_create", ret); + ret = connection_profile_set_cellular_service_type(profile_cellular, CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION); + PRINT_RETURN("connection_profile_set_cellular_service_type", ret); + + connection_cellular_state_e state; + ret = connection_get_cellular_state(connection, &state); + PRINT_RETURN("connection_get_cellular_state", ret); + + ret = connection_add_profile(connection, profile_cellular); + CHECK_RETURN("connection_add_profile", ret, CONNECTION_ERROR_NONE); + } else { + int ret = connection_add_profile(connection, profile_cellular); + CHECK_RETURN("connection_add_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_add_profile_n + * @since_tizen 2.3 + * @type Negative + * @description connection_add_profile should fail with invalid parameter. + * @scenario Verify connection_add_profile by passing invalid parameter. + */ +int utc_connection_add_profile_n(void) +{ + connection_profile_h profile = NULL; + + if (telephony_supported) { + int ret = connection_add_profile(NULL, NULL); + CHECK_RETURN("connection_add_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_add_profile(NULL, &profile); + CHECK_RETURN("connection_add_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_add_profile(connection, NULL); + CHECK_RETURN("connection_add_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_add_profile(NULL, NULL); + CHECK_RETURN("connection_add_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** + * @testcase utc_connection_close_profile_p + * @since_tizen 2.3 + * @type Positive + * @description Closes a connection of profile. + * @scenario Invoking connection_close_profile with valid parameter. + */ +int utc_connection_close_profile_p(void) +{ + int ret; + connection_cellular_state_e state; + + if (!telephony_supported && !wifi_supported && !bt_tethering_supported) { + ret = connection_close_profile(connection, profile_temp, test_connection_closed_callback, NULL); + CHECK_RETURN("connection_close_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + if (telephony_supported) { + ret = connection_get_cellular_state(connection, &state); + PRINT_RETURN("connection_get_cellular_state", ret); + if (state == CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE) { + fprintf(stderr, "Cellular state is out of service at %s:%d", __FILE__, __LINE__); + return 0; + } + } + + ret = connection_get_current_profile(connection, &profile_temp); + PRINT_RETURN("connection_get_current_profile", ret); + + ret = connection_close_profile(connection, profile_temp, test_connection_closed_callback, NULL); + PRINT_RETURN("connection_close_profile", ret); + test_connection_closed_callback(CONNECTION_ERROR_NONE, NULL); + CHECK_RETURN(CALLBACK_RETURN, g_CallbackRet, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_close_profile_n + * @since_tizen 2.3 + * @type Negative + * @description connection_close_profile should fail with invalid parameter. + * @scenario Verify connection_close_profile by passing invalid parameter. + */ +int utc_connection_close_profile_n(void) +{ + int ret; + connection_profile_h profile = NULL; + + if (!telephony_supported && !wifi_supported && !bt_tethering_supported) { + ret = connection_close_profile(NULL, NULL, NULL, NULL); + CHECK_RETURN("connection_close_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_close_profile(NULL, NULL, NULL, NULL); + CHECK_RETURN("connection_close_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_close_profile(NULL, profile, test_connection_closed_callback, NULL); + CHECK_RETURN("connection_close_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_close_profile(connection, profile, NULL, NULL); + CHECK_RETURN("connection_close_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_remove_profile_p + * @since_tizen 2.3 + * @type Positive + * @description Removes an existing profile. + * @scenario Invoking connection_remove_profile with valid parameter. + */ +int utc_connection_remove_profile_p(void) +{ + int ret; + + if (!telephony_supported && !wifi_supported) { + ret = connection_remove_profile(connection, profile_temp); + CHECK_RETURN("connection_remove_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_remove_profile(connection, profile_cellular); + CHECK_RETURN("connection_remove_profile", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_remove_profile_n + * @since_tizen 2.3 + * @type Negative + * @description connection_remove_profile should fail with invalid parameter. + * @scenario Verify connection_remove_profile by passing invalid parameter. + */ +int utc_connection_remove_profile_n(void) +{ + int ret; + connection_profile_h profile = NULL; + + if (!telephony_supported && !wifi_supported) { + ret = connection_remove_profile(NULL, NULL); + CHECK_RETURN("connection_remove_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_remove_profile(NULL, NULL); + CHECK_RETURN("connection_remove_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_remove_profile(NULL, profile); + CHECK_RETURN("connection_remove_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_remove_profile(connection, NULL); + CHECK_RETURN("connection_remove_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_update_profile_p + * @since_tizen 2.3 + * @type Positive + * @description Updates an existing profile. + * @scenario Invoking connection_update_profile with valid parameter. + */ +int utc_connection_update_profile_p(void) +{ + connection_profile_h profile_h = NULL; + int ret = test_get_any_profile(&profile_h); + + if (!telephony_supported && !wifi_supported && !ethernet_supported) { + ret = connection_update_profile(connection, profile_temp); + CHECK_RETURN("connection_update_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_h); + profile_temp = profile_h; + + ret = connection_update_profile(connection, profile_temp); + CHECK_RETURN("connection_update_profile", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_update_profile_n + * @since_tizen 2.3 + * @type Negative + * @description connection_update_profile should fail with invalid parameter. + * @scenario Verify connection_update_profile by passing invalid parameter. + */ +int utc_connection_update_profile_n(void) +{ + int ret; + connection_profile_h profile = NULL; + + if (!telephony_supported && !wifi_supported && !ethernet_supported) { + ret = connection_update_profile(NULL, NULL); + CHECK_RETURN("connection_update_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_update_profile(NULL, NULL); + CHECK_RETURN("connection_update_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_update_profile(NULL, profile); + CHECK_RETURN("connection_update_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_update_profile(connection, NULL); + CHECK_RETURN("connection_update_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_open_profile_p + * @since_tizen 2.3 + * @type Positive + * @description Opens a connection of profile, asynchronously. + * @scenario Invoking connection_open_profile with valid parameter. + */ +int utc_connection_open_profile_p(void) +{ + connection_profile_h profile_h = NULL; + int ret = test_get_any_profile(&profile_h); + + if (!telephony_supported && !wifi_supported && !bt_tethering_supported) { + ret = connection_open_profile(connection, profile_temp, test_connection_opened_callback, NULL); + CHECK_RETURN("connection_open_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + assert(profile_h); + profile_temp = profile_h; + + ret = connection_open_profile(connection, profile_temp, test_connection_opened_callback, NULL); + CHECK_RETURN("connection_open_profile", ret, CONNECTION_ERROR_NONE); + test_connection_opened_callback(CONNECTION_ERROR_NONE, NULL); + + return 0; +} + +/** + * @testcase utc_connection_open_profile_n + * @since_tizen 2.3 + * @type Negative + * @description connection_open_profile should fail with invalid parameter. + * @scenario Verify connection_open_profile by passing invalid parameter. + */ +int utc_connection_open_profile_n(void) +{ + int ret; + connection_profile_h profile = NULL; + + if (!telephony_supported && !wifi_supported && !bt_tethering_supported) { + ret = connection_open_profile(NULL, NULL, NULL, NULL); + CHECK_RETURN("connection_open_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_open_profile(NULL, NULL, NULL, NULL); + CHECK_RETURN("connection_open_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_open_profile(NULL, profile, test_connection_opened_callback, NULL); + CHECK_RETURN("connection_open_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_open_profile(connection, profile, NULL, NULL); + CHECK_RETURN("connection_open_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_reset_profile_p + * @since_tizen 2.3 + * @type Positive + * @description Resets the cellular profile. + * @scenario Invoking connection_reset_profile with valid parameter. + */ +int utc_connection_reset_profile_p(void) +{ + if (telephony_supported) { + connection_reset_profile(connection, CONNECTION_RESET_DEFAULT_PROFILE, + 0, test_connection_reset_profile_callback, NULL); + CHECK_RETURN(CALLBACK_RETURN, g_CallbackRet, CONNECTION_ERROR_NONE); + test_connection_reset_profile_callback(CONNECTION_ERROR_NONE, NULL); + } else { + int ret = connection_reset_profile(connection, CONNECTION_RESET_DEFAULT_PROFILE, + 0, test_connection_reset_profile_callback, NULL); + CHECK_RETURN("connection_reset_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + test_connection_reset_profile_callback(CONNECTION_ERROR_NONE, NULL); + } + + return 0; +} + +/** + * @testcase utc_connection_reset_profile_n + * @since_tizen 2.3 + * @type Negative + * @description connection_reset_profile should fail with invalid parameter. + * @scenario Verify connection_reset_profile by passing invalid parameter. + */ +int utc_connection_reset_profile_n(void) +{ + if (telephony_supported) { + int ret = connection_reset_profile(NULL, CONNECTION_RESET_DEFAULT_PROFILE, + 0, test_connection_reset_profile_callback, NULL); + CHECK_RETURN("connection_reset_profile", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + int ret = connection_reset_profile(NULL, CONNECTION_RESET_DEFAULT_PROFILE, + 0, test_connection_reset_profile_callback, NULL); + CHECK_RETURN("connection_reset_profile", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_foreach_ipv6_address_p + * @since_tizen 4.0 + * @type Positive + * @description Gets IPv6 addresses + * @scenario Invoking connection_foreach_ipv6_address with valid parameter. + */ +int utc_connection_foreach_ipv6_address_p(void) +{ + int ret; + + if (telephony_supported) { + ret = connection_foreach_ipv6_address(connection, CONNECTION_TYPE_CELLULAR, + test_connection_ipv6_address_callback, NULL); + CHECK_RETURN("connection_foreach_ipv6_address", ret, CONNECTION_ERROR_NONE); + } else if (wifi_supported) { + ret = connection_foreach_ipv6_address(connection, CONNECTION_TYPE_WIFI, + test_connection_ipv6_address_callback, NULL); + CHECK_RETURN("connection_foreach_ipv6_address", ret, CONNECTION_ERROR_NONE); + } else if (ethernet_supported) { + ret = connection_foreach_ipv6_address(connection, CONNECTION_TYPE_ETHERNET, + test_connection_ipv6_address_callback, NULL); + CHECK_RETURN("connection_foreach_ipv6_address", ret, CONNECTION_ERROR_NONE); + } else { + ret = connection_foreach_ipv6_address(connection, CONNECTION_TYPE_WIFI, + test_connection_ipv6_address_callback, NULL); + CHECK_RETURN("connection_foreach_ipv6_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_foreach_ipv6_address_n + * @since_tizen 4.0 + * @type Negative + * @description connection_foreach_ipv6_address should fail with invalid parameter. + * @scenario Verify connection_foreach_ipv6_address by passing invalid parameter. + */ +int utc_connection_foreach_ipv6_address_n(void) +{ + int ret; + + if (telephony_supported) { + ret = connection_foreach_ipv6_address(NULL, CONNECTION_TYPE_CELLULAR, + test_connection_ipv6_address_callback, NULL); + CHECK_RETURN("connection_foreach_ipv6_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else if (wifi_supported) { + ret = connection_foreach_ipv6_address(NULL, CONNECTION_TYPE_WIFI, + test_connection_ipv6_address_callback, NULL); + CHECK_RETURN("connection_foreach_ipv6_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else if (ethernet_supported) { + ret = connection_foreach_ipv6_address(NULL, CONNECTION_TYPE_ETHERNET, + test_connection_ipv6_address_callback, NULL); + CHECK_RETURN("connection_foreach_ipv6_address", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } else { + ret = connection_foreach_ipv6_address(NULL, CONNECTION_TYPE_WIFI, + test_connection_ipv6_address_callback, NULL); + CHECK_RETURN("connection_foreach_ipv6_address", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_connection_set_ethernet_cable_state_changed_cb_n + * @since_tizen 4.0 + * @type Negative + * @description connection_set_ethernet_cable_state_changed_cb should fail with invalid parameter. + * @scenario Verify connection_set_ethernet_cable_state_changed_cb by passing invalid parameter. + */ +int utc_connection_set_ethernet_cable_state_changed_cb_n(void) +{ + int ret; + if (ethernet_supported == false) { + ret = connection_set_ethernet_cable_state_changed_cb(NULL, NULL, NULL); + CHECK_RETURN("connection_set_ethernet_cable_state_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_set_ethernet_cable_state_changed_cb(NULL, + test_connection_set_ethernet_callback, NULL); + CHECK_RETURN("connection_set_ethernet_cable_state_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + ret = connection_set_ethernet_cable_state_changed_cb(connection, NULL, NULL); + CHECK_RETURN("connection_set_ethernet_cable_state_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +int utc_connection_set_ethernet_cable_state_changed_cb_p(void) +{ + int ret; + if (ethernet_supported == false) { + ret = connection_set_ethernet_cable_state_changed_cb(NULL, NULL, NULL); + CHECK_RETURN("connection_set_ethernet_cable_state_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + return 0; + } + + ret = connection_set_ethernet_cable_state_changed_cb(connection, test_connection_set_ethernet_callback, NULL); + CHECK_RETURN("connection_set_ethernet_cable_state_changed_cb", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_unset_ethernet_cable_state_changed_cb_n + * @since_tizen 4.0 + * @type Negative + * @description connection_unset_ethernet_cable_state_changed_cb should fail with invalid parameter. + * @scenario Verify connection_unset_ethernet_cable_state_changed_cb by passing invalid parameter. + */ +int utc_connection_unset_ethernet_cable_state_changed_cb_n(void) +{ + int ret; + ret = connection_unset_ethernet_cable_state_changed_cb(NULL); + + if (ethernet_supported == false) { + CHECK_RETURN("connection_unset_ethernet_cable_state_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_unset_ethernet_cable_state_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +int utc_connection_unset_ethernet_cable_state_changed_cb_p(void) +{ + int ret; + ret = connection_unset_ethernet_cable_state_changed_cb(connection); + + if (ethernet_supported == false) { + CHECK_RETURN("connection_unset_ethernet_cable_state_changed_cb", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_unset_ethernet_cable_state_changed_cb", ret, CONNECTION_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_connection_set_internet_state_changed_cb_p + * @since_tizen 5.5 + * @type Positive + * @description Set internet state changed callback. + * @scenario Verify connection_set_internet_state_changed_cb by passing valid parameter. + */ +int utc_connection_set_internet_state_changed_cb_p(void) +{ + int ret; + ret = connection_set_internet_state_changed_cb(connection, + test_connection_internet_state_changed_callback, NULL); + + CHECK_RETURN("connection_set_internet_state_changed_cb", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_set_internet_state_changed_cb_n1 + * @since_tizen 5.5 + * @type Negative + * @description connection_set_internet_state_changed_cb should fail when connection is NULL. + * @scenario Verify connection_set_internet_state_changed_cb by passing connection as NULL. + */ +int utc_connection_set_internet_state_changed_cb_n1(void) +{ + int ret; + ret = connection_set_internet_state_changed_cb(NULL, + test_connection_internet_state_changed_callback, NULL); + + CHECK_RETURN("connection_set_internet_state_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_set_internet_state_changed_cb_n2 + * @since_tizen 5.5 + * @type Negative + * @description connection_set_internet_state_changed_cb should fail when callback is NULL. + * @scenario Verify connection_set_internet_state_changed_cb by passing callback as NULL. + */ +int utc_connection_set_internet_state_changed_cb_n2(void) +{ + int ret; + ret = connection_set_internet_state_changed_cb(connection, NULL, NULL); + + CHECK_RETURN("connection_set_internet_state_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_unset_internet_state_changed_cb_p + * @since_tizen 5.5 + * @type Positive + * @description Unset internet state changed callback. + * @scenario Verify connection_unset_internet_state_changed_cb by passing valid parameter. + */ +int utc_connection_unset_internet_state_changed_cb_p(void) +{ + int ret; + ret = connection_unset_internet_state_changed_cb(connection); + + CHECK_RETURN("connection_unset_internet_state_changed_cb", ret, CONNECTION_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_connection_unset_internet_state_changed_cb_n + * @since_tizen 5.5 + * @type Negative + * @description connection_unset_internet_state_changed_cb should fail when connection is NULL. + * @scenario Verify connection_unset_internet_state_changed_cb by passing connection as NULL. + */ +int utc_connection_unset_internet_state_changed_cb_n(void) +{ + int ret; + ret = connection_unset_internet_state_changed_cb(NULL); + + CHECK_RETURN("connection_unset_internet_state_changed_cb", ret, CONNECTION_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_connection_destroy_p + * @since_tizen 2.3 + * @type Positive + * @description Destroys the connection handle. + * @scenario Invoking connection_destroy with valid parameter. + */ +int utc_connection_destroy_p(void) +{ + int ret = connection_destroy(connection); + + if (all_features_not_supported) { + CHECK_RETURN("connection_destroy", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_destroy", ret, CONNECTION_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_connection_destroy_n + * @since_tizen 2.3 + * @type Negative + * @description connection_destroy should fail with invalid parameter. + * @scenario Verify connection_destroy by passing invalid parameter. + */ +int utc_connection_destroy_n(void) +{ + int ret = connection_destroy(NULL); + + if (all_features_not_supported) { + CHECK_RETURN("connection_destroy", ret, CONNECTION_ERROR_NOT_SUPPORTED); + } else { + CHECK_RETURN("connection_destroy", ret, CONNECTION_ERROR_INVALID_PARAMETER); + } + + return 0; +}