From: Wootak Jung Date: Tue, 16 Jun 2020 08:09:14 +0000 (+0900) Subject: Add unittest for auto coverage X-Git-Tag: submit/tizen/20200724.011403^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24077ac6efec91660a426d63aa80fddac95df0e6;p=platform%2Fcore%2Fapi%2Fbluetooth.git Add unittest for auto coverage Make tests folder and include test and unittest folder Change-Id: I7f9a9dc72a5d8b4710bf24e55fe0fc11fb197a99 Signed-off-by: Wootak Jung --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 61f17c7..cf95802 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,16 +88,17 @@ CONFIGURE_FILE( ) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) -ADD_SUBDIRECTORY(test) +ADD_SUBDIRECTORY(tests/test) +ADD_SUBDIRECTORY(tests/unittest) IF(UNIX) ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) ADD_CUSTOM_COMMAND( - DEPENDS clean + DEPENDS clean COMMENT "distribution clean" COMMAND find - ARGS . + ARGS . -not -name config.cmake -and \( -name tester.c -or -name Testing -or diff --git a/packaging/capi-network-bluetooth.spec b/packaging/capi-network-bluetooth.spec index b90b392..df1d5ef 100644 --- a/packaging/capi-network-bluetooth.spec +++ b/packaging/capi-network-bluetooth.spec @@ -18,6 +18,7 @@ BuildRequires: pkgconfig(capi-appfw-app-control) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-system-info) BuildRequires: cmake +BuildRequires: gtest-devel %if 0%{?gcov:1} BuildRequires: lcov %endif @@ -88,26 +89,29 @@ export FFLAGS+=" -DARCH64" %cmake MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} +%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} make %{?jobs:-j%jobs} -%if 0%{?gcov:1} -mkdir -p gcov-obj -find . -name '*.gcno' -exec cp '{}' gcov-obj ';' -%endif - %install rm -rf %{buildroot} %make_install %if 0%{?gcov:1} -mkdir -p %{buildroot}%{_datadir}/gcov/obj -install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj +find .. -name '*.gcno' | tar cf %{name}-gcov.tar -T - +install -d -m 755 %{buildroot}%{_datadir}/gcov/obj +tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj +%endif + +%check +LD_LIBRARY_PATH=. LD_PRELOAD=tests/unittest/libbluetooth-mock.so tests/unittest/tct-bluetooth-core +%if 0%{?gcov:1} +lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info --exclude "*/unittest/*" +genhtml %{name}.info -o out --legend --show-details %endif mkdir -p %{buildroot}%{_unitdir} -install -m 0644 test/bt_infinite_spp_test_server.service %{buildroot}%{_unitdir}/bt_infinite_spp_test_server.service +install -m 0644 tests/test/bt_infinite_spp_test_server.service %{buildroot}%{_unitdir}/bt_infinite_spp_test_server.service %post -p /sbin/ldconfig diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c index 889696d..a2f45d9 100644 --- a/src/bluetooth-common.c +++ b/src/bluetooth-common.c @@ -495,7 +495,6 @@ int _bt_get_error_code(int origin_error) return BT_ERROR_OPERATION_FAILED; /* LCOV_EXCL_LINE */ } -/* LCOV_EXCL_START */ int _bt_get_bt_device_info_s(bt_device_info_s **dest_dev, bluetooth_device_info_t *source_dev) { int i = 0; @@ -582,6 +581,7 @@ void _bt_free_bt_device_info_s(bt_device_info_s *device_info) device_info = NULL; } +/* LCOV_EXCL_START */ int _bt_get_ad_data_by_type(char *in_data, int in_len, char in_type, char **data, int *data_len) { @@ -688,6 +688,7 @@ char *_bt_convert_error_to_string(int error) return "UNKNOWN"; /* LCOV_EXCL_LINE */ } +/* LCOV_EXCL_START */ bool _bt_get_random_bytes(void *buf, size_t num_bytes) { ssize_t len; @@ -706,6 +707,7 @@ bool _bt_get_random_bytes(void *buf, size_t num_bytes) return true; } +/* LCOV_EXCL_STOP */ /* LCOV_EXCL_START */ char *_bt_convert_uuid_to_uuid128(const char *uuid) @@ -1488,7 +1490,6 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us ((bt_adapter_state_changed_cb) bt_event_slot_container[event_index].callback) (_bt_get_error_code(param->result), BT_ADAPTER_ENABLED, bt_event_slot_container[event_index].user_data); break; -/* LCOV_EXCL_START */ case BLUETOOTH_EVENT_DISABLED: BT_INFO("bt_adapter_state_changed_cb() will be called with BT_ADAPTER_DISABLED"); ((bt_adapter_state_changed_cb) bt_event_slot_container[event_index].callback) @@ -1503,6 +1504,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us ((bt_adapter_name_changed_cb)bt_event_slot_container[event_index].callback) ((char *)(param->param_data), bt_event_slot_container[event_index].user_data); break; +/* LCOV_EXCL_START */ case BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED: BT_INFO("bt_adapter_visibility_mode_changed_cb() will be called"); ((bt_adapter_visibility_mode_changed_cb)bt_event_slot_container[event_index].callback) @@ -4097,7 +4099,7 @@ static void __bt_le_event_proxy(int event, bluetooth_event_param_t *param, void ((bt_adapter_le_state_changed_cb) bt_event_slot_container[event_index].callback) /* LCOV_EXCL_LINE */ (_bt_get_error_code(param->result), BT_ADAPTER_LE_DISABLED, bt_event_slot_container[event_index].user_data); break; - case BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND: /* LCOV_EXCL_START */ + case BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND: event_index = BT_EVENT_LE_SCAN_RESULT_UPDATED; if (bt_event_slot_container[event_index].callback != NULL) { if (__bt_get_bt_adapter_le_device_scan_info_s(&scan_info, (bluetooth_le_device_info_t *)(param->param_data)) == BT_ERROR_NONE) { @@ -4146,7 +4148,6 @@ static void __bt_le_event_proxy(int event, bluetooth_event_param_t *param, void break; } } -/* LCOV_EXCL_STOP */ /* LCOV_EXCL_START */ static int __bt_get_bt_adapter_device_discovery_info_s(bt_adapter_device_discovery_info_s **discovery_info, bluetooth_device_info_t *source_info) diff --git a/src/bluetooth-hrp.c b/src/bluetooth-hrp.c index 59e9448..cf95587 100644 --- a/src/bluetooth-hrp.c +++ b/src/bluetooth-hrp.c @@ -112,6 +112,7 @@ static bt_hrp_collector_s *_bt_hrp_collector_find(const char *remote_address); Heart Rate Server - Utility ========================================================================================================*/ +/* LCOV_EXCL_START */ /*Internal Functions*/ static void __bt_hrp_sensor_read_value_requested_cb( const char *remote_address, int request_id, @@ -1178,4 +1179,4 @@ int bt_hrp_collector_get_body_sensor_location(bt_hrp_collector_h collector, return error_code; } - +/* LCOV_EXCL_STOP */ diff --git a/test/CMakeLists.txt b/tests/test/CMakeLists.txt similarity index 100% rename from test/CMakeLists.txt rename to tests/test/CMakeLists.txt diff --git a/test/ble_mouse.c b/tests/test/ble_mouse.c similarity index 100% rename from test/ble_mouse.c rename to tests/test/ble_mouse.c diff --git a/test/bt_chat_client.c b/tests/test/bt_chat_client.c similarity index 100% rename from test/bt_chat_client.c rename to tests/test/bt_chat_client.c diff --git a/test/bt_chat_server.c b/tests/test/bt_chat_server.c similarity index 100% rename from test/bt_chat_server.c rename to tests/test/bt_chat_server.c diff --git a/test/bt_infinite_spp_test.c b/tests/test/bt_infinite_spp_test.c similarity index 100% rename from test/bt_infinite_spp_test.c rename to tests/test/bt_infinite_spp_test.c diff --git a/test/bt_infinite_spp_test_server.service b/tests/test/bt_infinite_spp_test_server.service similarity index 100% rename from test/bt_infinite_spp_test_server.service rename to tests/test/bt_infinite_spp_test_server.service diff --git a/test/bt_mesh_unit_test.c b/tests/test/bt_mesh_unit_test.c similarity index 100% rename from test/bt_mesh_unit_test.c rename to tests/test/bt_mesh_unit_test.c diff --git a/test/bt_mesh_unit_test.h b/tests/test/bt_mesh_unit_test.h similarity index 100% rename from test/bt_mesh_unit_test.h rename to tests/test/bt_mesh_unit_test.h diff --git a/test/bt_onoff.c b/tests/test/bt_onoff.c similarity index 100% rename from test/bt_onoff.c rename to tests/test/bt_onoff.c diff --git a/test/bt_unit_test.c b/tests/test/bt_unit_test.c similarity index 100% rename from test/bt_unit_test.c rename to tests/test/bt_unit_test.c diff --git a/test/bt_unit_test.h b/tests/test/bt_unit_test.h similarity index 100% rename from test/bt_unit_test.h rename to tests/test/bt_unit_test.h diff --git a/test/hid_keyboard.c b/tests/test/hid_keyboard.c similarity index 100% rename from test/hid_keyboard.c rename to tests/test/hid_keyboard.c diff --git a/test/spp_test_addr b/tests/test/spp_test_addr similarity index 100% rename from test/spp_test_addr rename to tests/test/spp_test_addr diff --git a/tests/unittest/CMakeLists.txt b/tests/unittest/CMakeLists.txt new file mode 100644 index 0000000..cc88149 --- /dev/null +++ b/tests/unittest/CMakeLists.txt @@ -0,0 +1,21 @@ +SET(UNITTEST_NAME "tct-bluetooth-core") + +FILE(GLOB TEST_SRCS *.c) + +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/tests/unittest/include +) + +ADD_DEFINITIONS(-DMOBILE) + +SET(BLUETOOTH_MOCK "bluetooth-mock") +SET(BLUETOOTH_MOCK_SRCS + mock/bluetooth-mock.c) +ADD_LIBRARY(${BLUETOOTH_MOCK} SHARED ${BLUETOOTH_MOCK_SRCS}) + +ADD_EXECUTABLE(${UNITTEST_NAME} ${UNITTEST_NAME}.cpp ${TEST_SRCS}) +TARGET_LINK_LIBRARIES(${UNITTEST_NAME} + gtest + ${fw_name} +) diff --git a/tests/unittest/include/assert_local.h b/tests/unittest/include/assert_local.h new file mode 100644 index 0000000..492224a --- /dev/null +++ b/tests/unittest/include/assert_local.h @@ -0,0 +1,118 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#ifndef _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/tests/unittest/include/tct_common.h b/tests/unittest/include/tct_common.h new file mode 100644 index 0000000..a8a7b4e --- /dev/null +++ b/tests/unittest/include/tct_common.h @@ -0,0 +1,219 @@ +// +// 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 + +#define CONFIG_LINE_LEN_MAX 2048 +#define CONFIG_VALUE_LEN_MAX 1024 + +#define UTC_LOG "utc.log" +#define ERR_UTC_LOG "utc_error.log" +#define TC_RESULT "tc_result.log" + +FILE *g_fpLog; +FILE *g_fpLogDump; +int g_Serr; + +int old_Serr; + +#define FPRINTF(...) {\ + g_fpLog = fopen(ERR_LOG, "a");\ + fprintf(g_fpLog, __VA_ARGS__);\ + fclose(g_fpLog);\ +} + +#define DUMP_UTC_ERRLOG() {\ + g_Serr = dup(fileno(stderr));\ + g_fpLogDump = freopen(ERR_UTC_LOG, "w", stderr);\ + fflush(stderr);\ +} + +#define CLOSE_UTC_ERRLOG() {\ + if(g_fpLogDump) \ + {\ + if (g_Serr != -1)\ + {\ + old_Serr = fileno(stderr);\ + if(old_Serr != -1)\ + {\ + dup2(g_Serr, old_Serr);\ + }\ + close(g_Serr);\ + }\ + fclose(g_fpLogDump);\ + }\ +} + +#define PRINT_TC_RESULT(...) {\ + g_fpLog = fopen(TC_RESULT, "w");\ + fprintf(g_fpLog, __VA_ARGS__);\ + fclose(g_fpLog);\ +} + +#define FREE_MEMORY_TC(buffer) {\ + if ( buffer != NULL )\ +{\ + free(buffer);\ + buffer = NULL;\ +}\ +} + +#define IS_FEATURE_SUPPORTED(feature_name, featureFlag, ModuleName)\ +{\ + if ( !(TCTCheckSystemInfoFeatureSupported(feature_name, ModuleName)) )\ +{\ + featureFlag = false;\ +}\ + else\ +{\ + featureFlag = true;\ +}\ +} + +#define PRINT_RESULT(eCompare, eRetVal, API, Error) {\ + if ( eRetVal == eCompare )\ +{\ + if ( DEBUG )\ +{\ + FPRINTF("[Line : %d][%s] %s passed\\n", __LINE__, API_NAMESPACE, API);\ +}\ +}\ + else \ +{\ + FPRINTF("[Line : %d][%s] %s failed, error returned = %s [%d]\\n", __LINE__, API_NAMESPACE, API, Error, eRetVal);\ + return 1;\ +}\ +} + +#define PRINT_RESULT_NORETURN(eCompare, eRetVal, API, Error) {\ + if ( eRetVal == eCompare )\ +{\ + if ( DEBUG )\ +{\ + FPRINTF("[Line : %d][%s] %s passed\\n", __LINE__, API_NAMESPACE, API);\ +}\ +}\ + else \ +{\ + FPRINTF("[Line : %d][%s] %s failed, error returned = %s [%d]\\n", __LINE__, API_NAMESPACE, API, Error, eRetVal);\ +}\ +} + +#define PRINT_RESULT_CLEANUP(eCompare, eRetVal, API, Error, FreeResource) {\ + if ( eRetVal == eCompare )\ +{\ + if ( DEBUG )\ +{\ + FPRINTF("[Line : %d][%s] %s passed\\n", __LINE__, API_NAMESPACE, API);\ +}\ +}\ +else \ +{\ + FPRINTF("[Line : %d][%s] %s failed, error returned = %s [%d]\\n", __LINE__, API_NAMESPACE, API, Error, eRetVal);\ + FreeResource;\ + return 1;\ +}\ +} + +#define CHECK_VALUE_STRING(StringVariable, API) {\ + if ( StringVariable == NULL )\ +{\ + FPRINTF("[Line : %d][%s] %s failed, error returned = value returned is NULL\\n", __LINE__, API_NAMESPACE, API);\ + return 1;\ +}\ + else if ( DEBUG )\ +{\ + FPRINTF("[Line : %d][%s] value returned = %s\\n", __LINE__, API_NAMESPACE, StringVariable);\ +}\ + free(StringVariable);\ + StringVariable = NULL;\ +} + +#define CHECK_VALUE_INT(Variable, API) {\ + if ( Variable == 0 )\ +{\ + FPRINTF("[Line : %d][%s] %s failed, error returned = value returned is Zero\\n", __LINE__, API_NAMESPACE, API);\ + return 1;\ +}\ + else if ( DEBUG )\ +{\ + FPRINTF("[Line : %d][%s] value returned = %d\\n", __LINE__, API_NAMESPACE, Variable);\ +}\ +} + +#define CHECK_HANDLE(Handle, API) {\ + if ( Handle == NULL )\ +{\ + FPRINTF("[Line : %d][%s] %s failed, error returned = Handle returned is NULL\\n", __LINE__, API_NAMESPACE, API);\ + return 1;\ +}\ +} + +#define FREE_MEMORY(buffer) {\ + if ( buffer != NULL )\ +{\ + free(buffer);\ + buffer = NULL;\ +}\ +} + +bool TCTCheckSystemInfoFeatureSupported(char* pszKey, char* pszModuleName){ + return false; +} +char* TCTSystemInfoGetError(int nRet){ + return NULL; +} +bool GetValueFromConfigFile(char* pstrKeyString, char* pstrValue, char* pstrModule){ + return false; +} +bool GetValueForTCTSetting(char* pstrKeyString, char* pstrValue, char* pstrModule){ + return false; +} + +//======================================================================================= +// changed logging macro +//======================================================================================= +#define dlog_print( type, tag, ...) do{ \ + fprintf(stdout, ##__VA_ARGS__ ); \ + fprintf(stdout, "\n" ); \ +} while(0) + +#define PRINT_UTC_LOG(...) do{ \ + fprintf(stdout, ##__VA_ARGS__ ); \ + fprintf(stdout, "\n" ); \ +} while(0) +//======================================================================================= + + +#ifdef __cplusplus +} +#endif + +#endif // _TCT_COMMON_H_ diff --git a/tests/unittest/include/testcase.h b/tests/unittest/include/testcase.h new file mode 100644 index 0000000..d828c90 --- /dev/null +++ b/tests/unittest/include/testcase.h @@ -0,0 +1,40 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#ifndef _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/tests/unittest/mock/bluetooth-mock.c b/tests/unittest/mock/bluetooth-mock.c new file mode 100644 index 0000000..df900d8 --- /dev/null +++ b/tests/unittest/mock/bluetooth-mock.c @@ -0,0 +1,760 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef API +#define API __attribute__ ((visibility("default"))) +#endif + +static const char g_remote_addr[BLUETOOTH_ADDRESS_LENGTH] = {0x00, 0x02, 0x33, 0xA9, 0xE7, 0xF6}; +static const char g_uuid1[BLUETOOTH_UUID_STRING_MAX] = "00001105-0000-1000-8000-00805F9B34FB"; +static const char g_uuid2[BLUETOOTH_UUID_STRING_MAX] = "0000110A-0000-1000-8000-00805F9B34FB"; +static bluetooth_device_info_t g_device_info; +static bluetooth_le_device_info_t g_le_device_info; +static int g_adv_handle; +static guint g_adv_ind_data[BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX] = {0x01, 0x02, 0x03}; +static guint g_scan_resp_data[BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX] = {0x04, 0x05, 0x06}; + +static bluetooth_cb_func_ptr adapter_event_cb; +static bluetooth_cb_func_ptr le_adapter_event_cb; + +static gboolean __adapter_event_cb(gpointer user_data) +{ + bluetooth_event_param_t *bt_event = user_data; + adapter_event_cb(bt_event->event, bt_event, NULL); + g_free(bt_event); + return FALSE; +} + +static gboolean __adapter_le_event_cb(gpointer user_data) +{ + bluetooth_event_param_t *bt_event = user_data; + le_adapter_event_cb(bt_event->event, bt_event, NULL); + g_free(bt_event); + return FALSE; +} + +API int system_info_get_platform_bool(const char *key, bool *value) +{ + *value = true; + return SYSTEM_INFO_ERROR_NONE; +} + +API int bluetooth_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data) +{ + adapter_event_cb = callback_ptr; + + /* Initialize device info */ + memcpy(g_device_info.device_address.addr, g_remote_addr, BLUETOOTH_ADDRESS_LENGTH); + strncpy(g_device_info.device_name.name, "Tizen", BLUETOOTH_DEVICE_NAME_LENGTH_MAX); + g_device_info.device_class.major_class = BLUETOOTH_DEVICE_MAJOR_CLASS_PHONE; + g_device_info.device_class.minor_class = BLUETOOTH_DEVICE_MINOR_CLASS_DESKTOP_WORKSTATION; + g_device_info.device_class.service_class = BLUETOOTH_DEVICE_SERVICE_CLASS_OBJECT_TRANSFER; + g_device_info.paired = TRUE; + g_device_info.connected = FALSE; + g_device_info.service_index = 2; + strncpy(g_device_info.uuids[0], g_uuid1, BLUETOOTH_UUID_STRING_MAX); + strncpy(g_device_info.uuids[1], g_uuid2, BLUETOOTH_UUID_STRING_MAX); + + /* Initialize le device info */ + memcpy(g_le_device_info.device_address.addr, g_remote_addr, BLUETOOTH_ADDRESS_LENGTH); + g_le_device_info.addr_type = BLUETOOTH_BDADDR_LE_PUBLIC; + g_le_device_info.rssi = -70; + g_le_device_info.adv_ind_data.data_len = 3; + memcpy(g_le_device_info.adv_ind_data.data.data, g_adv_ind_data, BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX); + g_le_device_info.scan_resp_data.data_len = 3; + memcpy(g_le_device_info.scan_resp_data.data.data, g_scan_resp_data, BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX); + + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_unregister_callback(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_le_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data) +{ + le_adapter_event_cb = callback_ptr; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_le_unregister_callback(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_check_adapter(void) +{ + return BLUETOOTH_ADAPTER_ENABLED; +} + +API int bluetooth_get_local_address(bluetooth_device_address_t *local_address) +{ + memcpy(local_address->addr, g_remote_addr, BLUETOOTH_ADDRESS_LENGTH); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_get_local_name(bluetooth_device_name_t *local_name) +{ + memset(local_name->name, 0x00, sizeof(local_name->name)); + strncpy(local_name->name, "Tizen", sizeof(local_name->name)); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_set_local_name(const bluetooth_device_name_t *local_name) +{ + bluetooth_event_param_t *bt_event = NULL; + + bt_event = g_malloc0(sizeof(bluetooth_event_param_t)); + bt_event->event = BLUETOOTH_EVENT_LOCAL_NAME_CHANGED; + bt_event->result = BLUETOOTH_ERROR_NONE; + bt_event->param_data = (void *)local_name; + + g_timeout_add(500, __adapter_event_cb, bt_event); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_start_le_discovery(void) +{ + bluetooth_event_param_t *bt_event = NULL; + + bt_event = g_malloc0(sizeof(bluetooth_event_param_t)); + bt_event->event = BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND; + bt_event->result = BLUETOOTH_ERROR_NONE; + bt_event->param_data = &g_le_device_info; + + g_timeout_add(500, __adapter_le_event_cb, bt_event); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_start_discovery(unsigned short max_response, + unsigned short discovery_duration, + unsigned int classOfDeviceMask) +{ + bluetooth_event_param_t *bt_event = NULL; + + bt_event = g_malloc0(sizeof(bluetooth_event_param_t)); + bt_event->event = BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED; + bt_event->result = BLUETOOTH_ERROR_NONE; + bt_event->param_data = &g_device_info; + + g_timeout_add(500, __adapter_event_cb, bt_event); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t *discoverable_mode_ptr) +{ + *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_is_service_used(const char *service_uuid, gboolean *used) +{ + *used = TRUE; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_oob_read_local_data(bt_oob_data_t *local_oob_data) +{ + char buf[] = {0x01, 0x02, 0x03, 0x04}; + memset(local_oob_data, 0x00, sizeof(bt_oob_data_t)); + + memcpy(local_oob_data->hash, buf, sizeof(BLUETOOTH_OOB_DATA_LENGTH)); + local_oob_data->hash_len = sizeof(buf); + memcpy(local_oob_data->randomizer, buf, sizeof(BLUETOOTH_OOB_DATA_LENGTH)); + local_oob_data->randomizer_len = sizeof(buf); + + memcpy(local_oob_data->hash256, buf, sizeof(BLUETOOTH_OOB_DATA_LENGTH)); + local_oob_data->hash256_len = sizeof(buf); + memcpy(local_oob_data->randomizer256, buf, sizeof(BLUETOOTH_OOB_DATA_LENGTH)); + local_oob_data->randomizer256_len = sizeof(buf); + + memcpy(local_oob_data->eir, buf, sizeof(BLUETOOTH_OOB_DATA_LENGTH)); + local_oob_data->eir_len = sizeof(buf); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_set_scan_parameters(bluetooth_le_scan_params_t *params) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_set_custom_advertising(int handle, gboolean enable, bluetooth_advertising_params_t *params) +{ + g_adv_handle = handle; + bluetooth_event_param_t *bt_event = NULL; + + bt_event = g_malloc0(sizeof(bluetooth_event_param_t)); + bt_event->event = BLUETOOTH_EVENT_ADVERTISING_STARTED; + bt_event->result = BLUETOOTH_ERROR_NONE; + bt_event->param_data = (void *)&g_adv_handle; + + g_timeout_add(500, __adapter_event_cb, bt_event); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_set_advertising_data(int handle, const bluetooth_advertising_data_t *value, int length) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_set_scan_response_data(int handle, const bluetooth_scan_resp_data_t *value, int length) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_set_advertising(int handle, gboolean enable) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_is_advertising(gboolean *is_advertising) +{ + *is_advertising = TRUE; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_stop_le_discovery(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *filter) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_is_le_2m_phy_supported(gboolean *is_supported) +{ + *is_supported = TRUE; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_is_le_coded_phy_supported(gboolean *is_supported) +{ + *is_supported = TRUE; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_av_connect(bluetooth_device_address_t *remote_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_av_disconnect(bluetooth_device_address_t *remote_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_audio_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hf_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_telephony_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_media_player_change_property( + media_player_property_type type, + unsigned int value) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_media_player_change_track( + media_metadata_attributes_t *metadata) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_audio_init(bt_audio_func_ptr cb, void *user_data) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hf_init(bt_hf_func_ptr cb, void *user_data) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_telephony_init(bt_telephony_func_ptr cb, void *user_data) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_bond_device(const bluetooth_device_address_t *device_address) +{ + bluetooth_event_param_t *bt_event = NULL; + + bt_event = g_malloc0(sizeof(bluetooth_event_param_t)); + bt_event->event = BLUETOOTH_EVENT_BONDING_FINISHED; + bt_event->result = BLUETOOTH_ERROR_NONE; + bt_event->param_data = &g_device_info; + + g_timeout_add(500, __adapter_event_cb, bt_event); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_cancel_bonding(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_unbond_device(const bluetooth_device_address_t *device_address) +{ + bluetooth_event_param_t *bt_event = NULL; + + bt_event = g_malloc0(sizeof(bluetooth_event_param_t)); + bt_event->event = BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED; + bt_event->result = BLUETOOTH_ERROR_NONE; + bt_event->param_data = (void *)&g_remote_addr; + + g_timeout_add(500, __adapter_event_cb, bt_event); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_get_bonded_device_list(GPtrArray **dev_list) +{ +// g_ptr_array_add(*dev_list, &g_device_info); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_set_alias(const bluetooth_device_address_t *device_address, + const char *alias) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_authorize_device(const bluetooth_device_address_t *device_address, + gboolean authorized) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_is_device_connected(const bluetooth_device_address_t *device_address, + bluetooth_service_type_t type, gboolean *is_connected) +{ + *is_connected = TRUE; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_update_le_connection_mode(const bluetooth_device_address_t *address, + const bluetooth_le_connection_mode_t mode) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_is_discovering(void) +{ + return TRUE; +} + +API int bluetooth_cancel_discovery(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_connect_le(const bluetooth_device_address_t *device_address, + gboolean auto_connect, int client_id) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_disconnect_le(const bluetooth_device_address_t *device_address, + int client_id) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_server_update_characteristic(int instance_id, + const bluetooth_gatt_server_update_value_t *value) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_client_get_characteristics_property( + const char *address, + bt_gatt_handle_property_t *service_handle, + bt_gatt_handle_property_t *char_handle, + bt_gatt_char_property_t *char_property) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_client_get_char_descriptor_property( + const char *address, + bt_gatt_handle_property_t *service_handle, + bt_gatt_handle_property_t *char_handle, + bt_gatt_handle_property_t *descriptor_handle, + bt_gatt_char_descriptor_property_t *desc_prop) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *char_pty) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_client_set_service_change_watcher( + const bluetooth_device_address_t *address, gboolean enable) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_set_service_change_watcher( + const bluetooth_device_address_t *address, gboolean enable) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_client_deinit(int client_id) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_server_init(int *instance_id, gatt_server_cb_func_ptr callback_ptr, + void *user_data) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_server_add_service(const char *svc_uuid, int type, int numhandles, + int instance_id, int *service_handle) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_server_add_new_characteristic(const char *char_uuid, + const bluetooth_gatt_server_attribute_params_t *param, + int *char_handle) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_server_add_descriptor(const char *desc_uuid, bt_gatt_permission_t permissions, + int service_handle, int instance_id, int *descriptor_handle) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_register_application(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_unregister_application(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_server_start_service(int service_handle, int instance_id) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_server_send_response(const bluetooth_gatt_server_response_params_t *param, + const bluetooth_gatt_att_data_t *value) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_ipsp_init(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_ipsp_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_ipsp_connect(const ipsp_device_address_t *device_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_ipsp_disconnect(const ipsp_device_address_t *device_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_request_att_mtu(const bluetooth_device_address_t *device_address, unsigned int mtu) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_get_att_mtu(const bluetooth_device_address_t *device_address, + unsigned int *mtu) +{ + *mtu = 512; + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_gatt_client_init( + int *client_id, + const bluetooth_device_address_t *address, + gatt_client_cb_func_ptr callback_ptr) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hdp_disconnect(unsigned int channel_id, + const bluetooth_device_address_t *device_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hdp_connect(const char *app_handle, + bt_hdp_qos_type_t channel_type, + const bluetooth_device_address_t *device_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hdp_activate(unsigned short data_type, + bt_hdp_role_type_t role, + bt_hdp_qos_type_t channel_type, + char **app_handle) +{ + *app_handle = g_strdup("1234"); + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hdp_deactivate(const char *app_handle) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hdp_send_data(unsigned int channel_id, + const char *buffer, + unsigned int size) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, void *user_data) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_connect(hid_device_address_t *device_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_disconnect(hid_device_address_t *device_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_init(hid_cb_func_ptr callback_ptr, void *user_data) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_activate(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_deactivate(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_connect(const char *remote_addr) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_disconnect(const char *remote_addr) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_send_mouse_event(const char *remote_addr, + hid_send_mouse_event_t send_event) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_send_key_event(const char *remote_addr, + hid_send_key_event_t send_event) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_hid_device_reply_to_report(const char *remote_addr, + bt_hid_header_type_t htype, + bt_hid_param_type_t ptype, + const char *data, + unsigned int data_len) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_opc_init(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_opc_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_opc_push_files(bluetooth_device_address_t *remote_address, + char **file_name_array) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_opc_cancel_push(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_init(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_connect(const bluetooth_device_address_t *address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_disconnect(const bluetooth_device_address_t *address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_get_phonebook_size(const bluetooth_device_address_t *address, + bt_pbap_folder_t *folder) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_get_phonebook(const bluetooth_device_address_t *address, + bt_pbap_folder_t *folder, bt_pbap_pull_parameters_t *app_param) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_get_list(const bluetooth_device_address_t *address, + bt_pbap_folder_t *folder, bt_pbap_list_parameters_t *app_param) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_pull_vcard(const bluetooth_device_address_t *address, + bt_pbap_folder_t *folder, bt_pbap_pull_vcard_parameters_t *app_param) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_pbap_phonebook_search(const bluetooth_device_address_t *address, + bt_pbap_folder_t *folder, bt_pbap_search_parameters_t *app_param) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_search_service(const bluetooth_device_address_t *device_address) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_rfcomm_create_socket(const char *uuid) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_rfcomm_remove_socket(int id) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_rfcomm_listen_and_accept(int id, int max_pending_connection) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_rfcomm_connect( + const bluetooth_device_address_t *remote_bt_address, + const char *remote_uuid) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_rfcomm_disconnect(int socket_fd) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_rfcomm_write(int fd, const char *buf, int length) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_obex_server_init_without_agent(const char *dst_path) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_obex_server_deinit(void) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_obex_server_set_destination_path(const char *dst_path) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_obex_server_cancel_transfer(int transfer_id) +{ + return BLUETOOTH_ERROR_NONE; +} + +API int bluetooth_obex_server_deinit_without_agent(void) +{ + return BLUETOOTH_ERROR_NONE; +} diff --git a/tests/unittest/tct-bluetooth-core.cpp b/tests/unittest/tct-bluetooth-core.cpp new file mode 100644 index 0000000..aff0030 --- /dev/null +++ b/tests/unittest/tct-bluetooth-core.cpp @@ -0,0 +1,89 @@ +// +// 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 + +#ifdef MOBILE +#include "tct-bluetooth-core_mobile.h" +#endif + +#ifdef __cplusplus +} +#endif + +#include +#include +#include +#include +#include +#include + +#include + +TEST(bluetooth, bluetooth) +{ + char *pszGetTCName = NULL; + pszGetTCName = (char *)malloc(256); + memset(pszGetTCName, 0x00, 256); + strcpy(pszGetTCName, "utc_bluetooth"); + int i = 0, result = 0; + + dlog_print(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 (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 { + dlog_print(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 { + dlog_print(DLOG_INFO, "NativeTCT", "Name check error! [%s][%s]", pszGetTCName, tc_array[i].name); + ASSERT_EQ(0, 1); + } + } + + dlog_print(DLOG_INFO, "NativeTCT", "=========================="); + dlog_print(DLOG_INFO, "NativeTCT", "Success [%4d / %4d]", successCnt, successCnt + errorCnt); + dlog_print(DLOG_INFO, "NativeTCT", "Error [%4d / %4d]", errorCnt, successCnt + errorCnt); + dlog_print(DLOG_INFO, "NativeTCT", "=========================="); + + FREE_MEMORY_TC(pszGetTCName); + return; +} + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/tests/unittest/tct-bluetooth-core_mobile.h b/tests/unittest/tct-bluetooth-core_mobile.h new file mode 100644 index 0000000..dbcdae8 --- /dev/null +++ b/tests/unittest/tct-bluetooth-core_mobile.h @@ -0,0 +1,946 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#ifndef __TCT_BLUETOOTH_NATIVE_H__ +#define __TCT_BLUETOOTH_NATIVE_H__ + +#include "testcase.h" +#include "tct_common.h" + +extern void utc_bluetooth_adapter_negative_startup(void); +extern void utc_bluetooth_adapter_negative_cleanup(void); +extern void utc_bluetooth_adapter_positive_startup(void); +extern void utc_bluetooth_adapter_positive_cleanup(void); +extern void utc_bluetooth_bt_audio_negative_startup(void); +extern void utc_bluetooth_bt_audio_negative_cleanup(void); +extern void utc_bluetooth_audio_positive_startup(void); +extern void utc_bluetooth_audio_positive_cleanup(void); +extern void utc_bluetooth_avrcp_callback_positive_startup(void); +extern void utc_bluetooth_avrcp_callback_positive_cleanup(void); +extern void utc_bluetooth_common_startup(void); +extern void utc_bluetooth_common_cleanup(void); +extern void utc_bluetooth_device_discovery_negative_startup(void); +extern void utc_bluetooth_device_discovery_negative_cleanup(void); +extern void utc_bluetooth_device_discovery_positive_startup(void); +extern void utc_bluetooth_device_discovery_positive_cleanup(void); +extern void utc_bluetooth_device_negative_startup(void); +extern void utc_bluetooth_device_negative_cleanup(void); +extern void utc_bluetooth_device_positive_startup(void); +extern void utc_bluetooth_device_positive_cleanup(void); +extern void utc_bluetooth_gatt_negative_startup(void); +extern void utc_bluetooth_gatt_negative_cleanup(void); +extern void utc_bluetooth_gatt_positive_startup(void); +extern void utc_bluetooth_gatt_positive_cleanup(void); +extern void utc_bluetooth_hdp_negative_startup(void); +extern void utc_bluetooth_hdp_negative_cleanup(void); +extern void utc_bluetooth_hdp_positive_startup(void); +extern void utc_bluetooth_hdp_positive_cleanup(void); +extern void utc_bluetooth_hid_negative_startup(void); +extern void utc_bluetooth_hid_negative_cleanup(void); +extern void utc_bluetooth_hid_positive_startup(void); +extern void utc_bluetooth_hid_positive_cleanup(void); +extern void utc_bluetooth_opp_client_negative_startup(void); +extern void utc_bluetooth_opp_client_negative_cleanup(void); +extern void utc_bluetooth_opp_client_positive_startup(void); +extern void utc_bluetooth_opp_client_positive_cleanup(void); +extern void utc_bluetooth_bt_opp_server_negative_startup(void); +extern void utc_bluetooth_bt_opp_server_negative_cleanup(void); +extern void utc_bluetooth_opp_server_positive_startup(void); +extern void utc_bluetooth_opp_server_positive_cleanup(void); +extern void utc_bluetooth_service_search_negative_startup(void); +extern void utc_bluetooth_service_search_negative_cleanup(void); +extern void utc_bluetooth_service_search_positive_startup(void); +extern void utc_bluetooth_service_search_positive_cleanup(void); +extern void utc_bluetooth_socket_negative_startup(void); +extern void utc_bluetooth_socket_negative_cleanup(void); +extern void utc_bluetooth_bt_socket_positive_startup(void); +extern void utc_bluetooth_bt_socket_positive_cleanup(void); +extern void utc_bluetooth_avrcp_control_positive_startup(void); +extern void utc_bluetooth_avrcp_control_positive_cleanup(void); +extern void utc_bluetooth_avrcp_control_negative_startup(void); +extern void utc_bluetooth_avrcp_control_negative_cleanup(void); + +extern int utc_bluetooth_bt_deinitialize_n(void); +extern int utc_bluetooth_bt_adapter_le_is_discovering_n(void); +extern int utc_bluetooth_bt_adapter_set_state_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_set_state_changed_cb_n1(void); +extern int utc_bluetooth_bt_adapter_set_name_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_set_name_changed_cb_n1(void); +extern int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n1(void); +extern int utc_bluetooth_bt_adapter_get_state_n(void); +extern int utc_bluetooth_bt_adapter_get_state_n1(void); +extern int utc_bluetooth_bt_adapter_get_address_n(void); +extern int utc_bluetooth_bt_adapter_get_address_n1(void); +extern int utc_bluetooth_bt_adapter_get_name_n(void); +extern int utc_bluetooth_bt_adapter_get_name_n1(void); +extern int utc_bluetooth_bt_adapter_get_visibility_n(void); +extern int utc_bluetooth_bt_adapter_get_visibility_n1(void); +extern int utc_bluetooth_bt_adapter_set_name_n(void); +extern int utc_bluetooth_bt_adapter_set_name_n1(void); +extern int utc_bluetooth_bt_adapter_unset_state_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_unset_name_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_get_local_oob_data_n(void); +extern int utc_bluetooth_bt_adapter_is_service_used_n(void); +extern int utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_le_create_advertiser_n(void); +extern int utc_bluetooth_bt_adapter_le_destroy_advertiser_n(void); +extern int utc_bluetooth_bt_adapter_le_stop_advertising_n(void); +extern int utc_bluetooth_bt_adapter_le_clear_advertising_data_n(void); +extern int utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_get_bonded_device_info_n(void); +extern int utc_bluetooth_bt_adapter_free_device_info_n(void); +extern int utc_bluetooth_bt_adapter_set_remote_oob_data_n(void); +extern int utc_bluetooth_bt_adapter_remove_remote_oob_data_n(void); +extern int utc_bluetooth_bt_adapter_le_start_scan_n(void); +extern int utc_bluetooth_bt_adapter_le_stop_scan_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_service_uuids_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_device_name_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_tx_power_level_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_service_solicitation_uuids_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_service_data_list_n(void); +extern int utc_bluetooth_bt_adapter_le_free_service_data_list_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_appearance_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_manufacturer_data_n(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_n(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_n(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_service_data_n(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_appearance_n(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_n(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_device_name_n(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_n(void); +extern int utc_bluetooth_bt_adapter_le_start_advertising_new_n(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_mode_n(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_connectable_n(void); +extern int utc_bluetooth_bt_get_uuid_name_n(void); +extern int utc_bluetooth_bt_adapter_le_set_scan_mode_n(void); +extern int utc_bluetooth_bt_adapter_get_local_oob_ext_data_n(void); +extern int utc_bluetooth_bt_adapter_set_remote_oob_ext_data_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_create_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_destroy_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_device_address_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_device_name_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_with_mask_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_with_mask_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_with_mask_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_with_mask_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_register_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_unregister_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_unregister_all_n(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_type_n(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_n(void); +extern int utc_bluetooth_bt_adapter_le_free_ibeacon_report_n(void); +extern int utc_bluetooth_bt_adapter_le_is_2m_phy_supported_n(void); +extern int utc_bluetooth_bt_adapter_le_is_coded_phy_supported_n(void); +extern int utc_bluetooth_bt_adapter_le_is_discovering_p(void); +extern int utc_bluetooth_bt_adapter_set_state_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_set_name_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_set_name_changed_cb_p1(void); +extern int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p1(void); +extern int utc_bluetooth_bt_adapter_get_state_p(void); +extern int utc_bluetooth_bt_adapter_get_address_p(void); +extern int utc_bluetooth_bt_adapter_get_name_p(void); +extern int utc_bluetooth_bt_adapter_get_visibility_p(void); +extern int utc_bluetooth_bt_adapter_set_name_p(void); +extern int utc_bluetooth_bt_adapter_unset_state_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_unset_name_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_get_local_oob_data_p(void); +extern int utc_bluetooth_bt_adapter_is_service_used_p(void); +extern int utc_bluetooth_bt_adapter_le_clear_advertising_data_p(void); +extern int utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_le_create_advertiser_p(void); +extern int utc_bluetooth_bt_adapter_le_destroy_advertiser_p(void); +extern int utc_bluetooth_bt_adapter_le_stop_advertising_p(void); +extern int utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_le_start_scan_p(void); +extern int utc_bluetooth_bt_adapter_le_stop_scan_p(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_p(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_p(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_service_data_p(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_appearance_p(void); +extern int utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_p(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_device_name_p(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_p(void); +extern int utc_bluetooth_bt_adapter_le_start_advertising_new_p(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_mode_p(void); +extern int utc_bluetooth_bt_adapter_le_set_advertising_connectable_p(void); +extern int utc_bluetooth_bt_adapter_le_is_2m_phy_supported_p(void); +extern int utc_bluetooth_bt_adapter_le_is_coded_phy_supported_p(void); +extern int utc_bluetooth_bt_get_uuid_name_p(void); +extern int utc_bluetooth_bt_adapter_le_set_scan_mode_p(void); +extern int utc_bluetooth_bt_adapter_get_local_oob_ext_data_p(void); +extern int utc_bluetooth_bt_adapter_le_scan_filter_set_type_p(void); +extern int utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_p(void); +extern int utc_bluetooth_bt_adapter_le_free_ibeacon_report_p(void); +extern int utc_bluetooth_bt_audio_connect_n(void); +extern int utc_bluetooth_bt_audio_disconnect_n(void); +extern int utc_bluetooth_bt_audio_set_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_audio_set_connection_state_changed_cb_n1(void); +extern int utc_bluetooth_bt_audio_deinitialize_n(void); +extern int utc_bluetooth_bt_audio_initialize_n(void); +extern int utc_bluetooth_bt_audio_unset_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_set_equalizer_state_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_set_repeat_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_set_scan_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_set_position_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_set_play_status_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_set_track_info_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_target_deinitialize_n(void); +extern int utc_bluetooth_bt_avrcp_target_initialize_n(void); +extern int utc_bluetooth_bt_avrcp_target_notify_equalizer_state_n(void); +extern int utc_bluetooth_bt_avrcp_target_notify_player_state_n(void); +extern int utc_bluetooth_bt_avrcp_target_notify_position_n(void); +extern int utc_bluetooth_bt_avrcp_target_notify_repeat_mode_n(void); +extern int utc_bluetooth_bt_avrcp_target_notify_scan_mode_n(void); +extern int utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_n(void); +extern int utc_bluetooth_bt_avrcp_target_notify_track_n(void); +extern int utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_unset_scan_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_unset_position_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_n(void); +extern int utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_n(void); +extern int utc_bluetooth_bt_audio_initialize_p(void); +extern int utc_bluetooth_bt_audio_set_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_audio_unset_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_audio_deinitialize_p(void); +extern int utc_bluetooth_bt_avrcp_target_initialize_p(void); +extern int utc_bluetooth_bt_avrcp_target_deinitialize_p(void); +extern int utc_bluetooth_bt_avrcp_target_notify_equalizer_state_p(void); +extern int utc_bluetooth_bt_avrcp_target_notify_repeat_mode_p(void); +extern int utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_p(void); +extern int utc_bluetooth_bt_avrcp_target_notify_scan_mode_p(void); +extern int utc_bluetooth_bt_avrcp_target_notify_player_state_p(void); +extern int utc_bluetooth_bt_avrcp_target_notify_position_p(void); +extern int utc_bluetooth_bt_avrcp_target_notify_track_p(void); +extern int utc_bluetooth_bt_avrcp_set_equalizer_state_changed_p(void); +extern int utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_p(void); +extern int utc_bluetooth_bt_avrcp_set_repeat_mode_changed_p(void); +extern int utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_p(void); +extern int utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_p(void); +extern int utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_p(void); +extern int utc_bluetooth_bt_avrcp_set_scan_mode_changed_p(void); +extern int utc_bluetooth_bt_avrcp_unset_scan_mode_changed_p(void); +extern int utc_bluetooth_bt_avrcp_set_position_changed_cb_p(void); +extern int utc_bluetooth_bt_avrcp_unset_position_changed_cb_p(void); +extern int utc_bluetooth_bt_avrcp_set_play_status_changed_cb_p(void); +extern int utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_p(void); +extern int utc_bluetooth_bt_avrcp_set_track_info_changed_cb_p(void); +extern int utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_p(void); +extern int utc_bluetooth_bt_initialize_p(void); +extern int utc_bluetooth_bt_deinitialize_p(void); +extern int utc_bluetooth_bt_adapter_stop_device_discovery_n1(void); +extern int utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_n1(void); +extern int utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n(void); +extern int utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n1(void); +extern int utc_bluetooth_bt_adapter_start_device_discovery_n1(void); +extern int utc_bluetooth_bt_adapter_is_discovering_n1(void); +extern int utc_bluetooth_bt_adapter_is_discovering_n2(void); +extern int utc_bluetooth_bt_adapter_is_discovering_p(void); +extern int utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_start_device_discovery_p(void); +extern int utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_p(void); +extern int utc_bluetooth_bt_adapter_stop_device_discovery_p(void); +extern int utc_bluetooth_bt_device_set_bond_created_cb_n(void); +extern int utc_bluetooth_bt_device_set_bond_created_cb_n1(void); +extern int utc_bluetooth_bt_device_set_bond_destroyed_cb_n(void); +extern int utc_bluetooth_bt_device_set_authorization_changed_cb_n(void); +extern int utc_bluetooth_bt_device_set_authorization_changed_cb_n1(void); +extern int utc_bluetooth_bt_device_unset_bond_created_cb_n(void); +extern int utc_bluetooth_bt_device_unset_bond_destroyed_cb_n(void); +extern int utc_bluetooth_bt_device_unset_authorization_changed_cb_n(void); +extern int utc_bluetooth_bt_device_create_bond_n(void); +extern int utc_bluetooth_bt_device_create_bond_n1(void); +extern int utc_bluetooth_bt_device_cancel_bonding_n(void); +extern int utc_bluetooth_bt_device_destroy_bond_n(void); +extern int utc_bluetooth_bt_adapter_foreach_bonded_device_n1(void); +extern int utc_bluetooth_bt_adapter_foreach_bonded_device_n2(void); +extern int utc_bluetooth_bt_device_set_alias_n(void); +extern int utc_bluetooth_bt_device_set_alias_n2(void); +extern int utc_bluetooth_bt_device_set_authorization_n(void); +extern int utc_bluetooth_bt_device_set_authorization_n2(void); +extern int utc_bluetooth_bt_device_get_service_mask_from_uuid_list_n(void); +extern int utc_bluetooth_bt_device_is_profile_connected_n(void); +extern int utc_bluetooth_bt_device_set_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_device_unset_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_device_foreach_connected_profiles_n(void); +extern int utc_bluetooth_bt_device_update_le_connection_mode_n(void); +extern int utc_bluetooth_bt_device_set_bond_created_cb_p(void); +extern int utc_bluetooth_bt_device_set_bond_destroyed_cb_p(void); +extern int utc_bluetooth_bt_device_set_authorization_changed_cb_p(void); +extern int utc_bluetooth_bt_device_get_service_mask_from_uuid_list_p(void); +extern int utc_bluetooth_bt_device_is_profile_connected_p(void); +extern int utc_bluetooth_bt_device_unset_bond_created_cb_p(void); +extern int utc_bluetooth_bt_adapter_foreach_bonded_device_p(void); +extern int utc_bluetooth_bt_device_unset_bond_destroyed_cb_p(void); +extern int utc_bluetooth_bt_device_unset_authorization_changed_cb_p(void); +extern int utc_bluetooth_bt_device_set_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_device_unset_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_gatt_connect_n(void); +extern int utc_bluetooth_bt_gatt_disconnect_n(void); +extern int utc_bluetooth_bt_gatt_connect_n1(void); +extern int utc_bluetooth_bt_gatt_disconnect_n1(void); +extern int utc_bluetooth_bt_gatt_set_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_get_value_n(void); +extern int utc_bluetooth_bt_gatt_get_int_value_n(void); +extern int utc_bluetooth_bt_gatt_get_float_value_n(void); +extern int utc_bluetooth_bt_gatt_set_value_n(void); +extern int utc_bluetooth_bt_gatt_set_int_value_n(void); +extern int utc_bluetooth_bt_gatt_set_float_value_n(void); +extern int utc_bluetooth_bt_gatt_get_uuid_n(void); +extern int utc_bluetooth_bt_gatt_get_type_n(void); +extern int utc_bluetooth_bt_gatt_service_get_client_n(void); +extern int utc_bluetooth_bt_gatt_service_get_characteristic_n(void); +extern int utc_bluetooth_bt_gatt_service_foreach_characteristics_n(void); +extern int utc_bluetooth_bt_gatt_service_get_included_service_n(void); +extern int utc_bluetooth_bt_gatt_service_foreach_included_services_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_get_service_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_get_properties_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_get_write_type_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_set_write_type_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_get_descriptor_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_foreach_descriptors_n(void); +extern int utc_bluetooth_bt_gatt_descriptor_get_characteristic_n(void); +extern int utc_bluetooth_bt_gatt_client_create_n(void); +extern int utc_bluetooth_bt_gatt_client_destroy_n(void); +extern int utc_bluetooth_bt_gatt_client_get_remote_address_n(void); +extern int utc_bluetooth_bt_gatt_client_read_value_n(void); +extern int utc_bluetooth_bt_gatt_client_write_value_n(void); +extern int utc_bluetooth_bt_gatt_client_set_characteristic_value_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_client_unset_characteristic_value_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_client_get_service_n(void); +extern int utc_bluetooth_bt_gatt_client_foreach_services_n(void); +extern int utc_bluetooth_bt_gatt_service_destroy_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_destroy_n(void); +extern int utc_bluetooth_bt_gatt_descriptor_destroy_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_get_permissions_n(void); +extern int utc_bluetooth_bt_gatt_descriptor_get_permissions_n(void); +extern int utc_bluetooth_bt_gatt_service_create_n(void); +extern int utc_bluetooth_bt_gatt_service_add_characteristic_n(void); +extern int utc_bluetooth_bt_gatt_service_add_included_service_n(void); +extern int utc_bluetooth_bt_gatt_service_get_server_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_create_n(void); +extern int utc_bluetooth_bt_gatt_characteristic_add_descriptor_n(void); +extern int utc_bluetooth_bt_gatt_descriptor_create_n(void); +extern int utc_bluetooth_bt_gatt_server_initialize_n(void); +extern int utc_bluetooth_bt_gatt_server_deinitialize_n(void); +extern int utc_bluetooth_bt_gatt_server_create_n(void); +extern int utc_bluetooth_bt_gatt_server_destroy_n(void); +extern int utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_n(void); +extern int utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_n(void); +extern int utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_n(void); +extern int utc_bluetooth_bt_gatt_server_notify_characteristic_changed_value_n(void); +extern int utc_bluetooth_bt_gatt_server_get_service_n(void); +extern int utc_bluetooth_bt_gatt_server_get_device_mtu_n(void); +extern int utc_bluetooth_bt_gatt_server_foreach_services_n(void); +extern int utc_bluetooth_bt_gatt_server_register_service_n(void); +extern int utc_bluetooth_bt_gatt_server_unregister_service_n(void); +extern int utc_bluetooth_bt_gatt_server_unregister_all_services_n(void); +extern int utc_bluetooth_bt_gatt_server_start_n(void); +extern int utc_bluetooth_bt_gatt_server_send_response_n(void); +extern int utc_bluetooth_bt_gatt_client_set_service_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_client_unset_service_changed_cb_n(void); +extern int utc_bluetooth_bt_ipsp_initialize_n(void); +extern int utc_bluetooth_bt_ipsp_deinitialize_n(void); +extern int utc_bluetooth_bt_ipsp_connect_n(void); +extern int utc_bluetooth_bt_ipsp_disconnect_n(void); +extern int utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_client_request_att_mtu_change_n(void); +extern int utc_bluetooth_bt_gatt_client_get_att_mtu_n(void); +extern int utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_n(void); +extern int utc_bluetooth_bt_gatt_set_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_gatt_service_destroy_p(void); +extern int utc_bluetooth_bt_gatt_characteristic_destroy_p(void); +extern int utc_bluetooth_bt_gatt_descriptor_destroy_p(void); +extern int utc_bluetooth_bt_gatt_characteristic_get_permissions_p(void); +extern int utc_bluetooth_bt_gatt_descriptor_get_permissions_p(void); +extern int utc_bluetooth_bt_gatt_service_create_p(void); +extern int utc_bluetooth_bt_gatt_service_add_characteristic_p(void); +extern int utc_bluetooth_bt_gatt_service_add_included_service_p(void); +extern int utc_bluetooth_bt_gatt_service_get_server_p(void); +extern int utc_bluetooth_bt_gatt_characteristic_create_p(void); +extern int utc_bluetooth_bt_gatt_characteristic_add_descriptor_p(void); +extern int utc_bluetooth_bt_gatt_descriptor_create_p(void); +extern int utc_bluetooth_bt_gatt_server_initialize_p(void); +extern int utc_bluetooth_bt_gatt_server_deinitialize_p(void); +extern int utc_bluetooth_bt_gatt_server_create_p(void); +extern int utc_bluetooth_bt_gatt_server_destroy_p(void); +extern int utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_p(void); +extern int utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_p(void); +extern int utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_p(void); +extern int utc_bluetooth_bt_gatt_server_get_service_p(void); +extern int utc_bluetooth_bt_gatt_server_foreach_services_p(void); +extern int utc_bluetooth_bt_gatt_server_register_service_p(void); +extern int utc_bluetooth_bt_gatt_server_unregister_service_p(void); +extern int utc_bluetooth_bt_gatt_server_unregister_all_services_p(void); +extern int utc_bluetooth_bt_gatt_server_start_p(void); +extern int utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_p(void); +extern int utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_p(void); +extern int utc_bluetooth_bt_hdp_set_data_received_cb_n(void); +extern int utc_bluetooth_bt_hdp_set_data_received_cb_n1(void); +extern int utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n1(void); +extern int utc_bluetooth_bt_hdp_disconnect_n(void); +extern int utc_bluetooth_bt_hdp_connect_to_source_n(void); +extern int utc_bluetooth_bt_hdp_connect_to_source_n2(void); +extern int utc_bluetooth_bt_hdp_register_sink_app_n(void); +extern int utc_bluetooth_bt_hdp_unregister_sink_app_n(void); +extern int utc_bluetooth_bt_hdp_unregister_sink_app_n1(void); +extern int utc_bluetooth_bt_hdp_send_data_n(void); +extern int utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_hdp_unset_data_received_cb_n(void); +extern int utc_bluetooth_bt_hdp_set_data_received_cb_p(void); +extern int utc_bluetooth_bt_hdp_unset_data_received_cb_p(void); +extern int utc_bluetooth_bt_hdp_set_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_hdp_unregister_sink_app_p(void); +extern int utc_bluetooth_bt_hdp_register_sink_app_p(void); +extern int utc_bluetooth_bt_hid_host_initialize_n(void); +extern int utc_bluetooth_bt_hid_host_initialize_n1(void); +extern int utc_bluetooth_bt_hid_host_connect_n(void); +extern int utc_bluetooth_bt_hid_host_disconnect_n(void); +extern int utc_bluetooth_bt_hid_host_deinitialize_n(void); +extern int utc_bluetooth_bt_hid_host_initialize_p(void); +extern int utc_bluetooth_bt_hid_host_deinitialize_p(void); +extern int utc_bluetooth_bt_opp_client_initialize_n(void); +extern int utc_bluetooth_bt_opp_client_deinitialize_n(void); +extern int utc_bluetooth_bt_opp_client_add_file_n(void); +extern int utc_bluetooth_bt_opp_client_add_file_n1(void); +extern int utc_bluetooth_bt_opp_client_clear_files_n(void); +extern int utc_bluetooth_bt_opp_client_push_files_n(void); +extern int utc_bluetooth_bt_opp_client_cancel_push_n(void); +extern int utc_bluetooth_bt_opp_client_initialize_p(void); +extern int utc_bluetooth_bt_opp_client_deinitialize_p(void); +extern int utc_bluetooth_bt_opp_client_clear_files_p(void); +extern int utc_bluetooth_bt_opp_server_accept_n(void); +extern int utc_bluetooth_bt_opp_server_accept_n1(void); +extern int utc_bluetooth_bt_opp_server_accept_n2(void); +extern int utc_bluetooth_bt_opp_server_reject_n(void); +extern int utc_bluetooth_bt_opp_server_reject_n1(void); +extern int utc_bluetooth_bt_opp_server_set_destination_n(void); +extern int utc_bluetooth_bt_opp_server_set_destination_n1(void); +extern int utc_bluetooth_bt_opp_server_set_destination_n2(void); +extern int utc_bluetooth_bt_opp_server_initialize_by_connection_request_n(void); +extern int utc_bluetooth_bt_opp_server_initialize_by_connection_request_n1(void); +extern int utc_bluetooth_bt_opp_server_deinitialize_n(void); +extern int utc_bluetooth_bt_opp_server_deinitialize_n1(void); +extern int utc_bluetooth_bt_opp_server_cancel_transfer_n(void); +extern int utc_bluetooth_bt_opp_server_cancel_transfer_n1(void); +extern int utc_bluetooth_bt_opp_server_initialize_by_connection_request_p(void); +extern int utc_bluetooth_bt_opp_server_deinitialize_p(void); +extern int utc_bluetooth_bt_opp_server_set_destination_p(void); +extern int utc_bluetooth_bt_device_set_service_searched_cb_n(void); +extern int utc_bluetooth_bt_device_set_service_searched_cb_n1(void); +extern int utc_bluetooth_bt_device_unset_service_searched_cb_n(void); +extern int utc_bluetooth_bt_device_start_service_search_n(void); +extern int utc_bluetooth_bt_device_set_service_searched_cb_p(void); +extern int utc_bluetooth_bt_device_unset_service_searched_cb_p(void); +extern int utc_bluetooth_bt_socket_set_data_received_cb_n(void); +extern int utc_bluetooth_bt_socket_set_data_received_cb_n1(void); +extern int utc_bluetooth_bt_socket_set_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_socket_set_connection_state_changed_cb_n1(void); +extern int utc_bluetooth_bt_socket_unset_data_received_cb_n(void); +extern int utc_bluetooth_bt_socket_unset_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_socket_create_rfcomm_n(void); +extern int utc_bluetooth_bt_socket_create_rfcomm_n1(void); +extern int utc_bluetooth_bt_socket_destroy_rfcomm_n(void); +extern int utc_bluetooth_bt_socket_listen_and_accept_rfcomm_n(void); +extern int utc_bluetooth_bt_socket_connect_rfcomm_n(void); +extern int utc_bluetooth_bt_socket_disconnect_rfcomm_n(void); +extern int utc_bluetooth_bt_socket_send_data_n(void); +extern int utc_bluetooth_bt_socket_set_connection_requested_cb_n(void); +extern int utc_bluetooth_bt_socket_unset_connection_requested_cb_n(void); +extern int utc_bluetooth_bt_socket_set_data_received_cb_p(void); +extern int utc_bluetooth_bt_socket_set_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_socket_create_rfcomm_p(void); +extern int utc_bluetooth_bt_socket_listen_and_accept_rfcomm_p(void); +extern int utc_bluetooth_bt_socket_destroy_rfcomm_p(void); +extern int utc_bluetooth_bt_socket_unset_data_received_cb_p(void); +extern int utc_bluetooth_bt_socket_unset_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_socket_set_connection_requested_cb_p(void); +extern int utc_bluetooth_bt_socket_unset_connection_requested_cb_p(void); +extern int utc_bluetooth_bt_avrcp_control_initialize_p(void); +extern int utc_bluetooth_bt_avrcp_control_deinitialize_p(void); +extern int utc_bluetooth_bt_avrcp_control_connect_n(void); +extern int utc_bluetooth_bt_avrcp_control_disconnect_n(void); +extern int utc_bluetooth_bt_avrcp_control_send_player_command_n(void); +extern int utc_bluetooth_bt_avrcp_control_set_equalizer_state_n(void); +extern int utc_bluetooth_bt_avrcp_control_get_equalizer_state_n(void); +extern int utc_bluetooth_bt_avrcp_control_set_repeat_mode_n(void); +extern int utc_bluetooth_bt_avrcp_control_get_repeat_mode_n(void); +extern int utc_bluetooth_bt_avrcp_control_set_shuffle_mode_n(void); +extern int utc_bluetooth_bt_avrcp_control_get_shuffle_mode_n(void); +extern int utc_bluetooth_bt_avrcp_control_set_scan_mode_n(void); +extern int utc_bluetooth_bt_avrcp_control_get_scan_mode_n(void); +extern int utc_bluetooth_bt_avrcp_control_get_position_n(void); +extern int utc_bluetooth_bt_avrcp_control_get_play_status_n(void); +extern int utc_bluetooth_bt_avrcp_control_get_track_info_n(void); +extern int utc_bluetooth_bt_avrcp_control_free_track_info_n(void); +extern int utc_bluetooth_bt_device_create_bond_p(void); +extern int utc_bluetooth_bt_device_destroy_bond_p(void); + +testcase tc_array[] = { + {"utc_bluetooth_bt_deinitialize_n",utc_bluetooth_bt_deinitialize_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_is_discovering_n",utc_bluetooth_bt_adapter_le_is_discovering_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_state_changed_cb_n",utc_bluetooth_bt_adapter_set_state_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_state_changed_cb_n1",utc_bluetooth_bt_adapter_set_state_changed_cb_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_name_changed_cb_n",utc_bluetooth_bt_adapter_set_name_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_name_changed_cb_n1",utc_bluetooth_bt_adapter_set_name_changed_cb_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n",utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n1",utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_state_n",utc_bluetooth_bt_adapter_get_state_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_state_n1",utc_bluetooth_bt_adapter_get_state_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_address_n",utc_bluetooth_bt_adapter_get_address_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_address_n1",utc_bluetooth_bt_adapter_get_address_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_name_n",utc_bluetooth_bt_adapter_get_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_name_n1",utc_bluetooth_bt_adapter_get_name_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_visibility_n",utc_bluetooth_bt_adapter_get_visibility_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_visibility_n1",utc_bluetooth_bt_adapter_get_visibility_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_name_n",utc_bluetooth_bt_adapter_set_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_name_n1",utc_bluetooth_bt_adapter_set_name_n1,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_unset_state_changed_cb_n",utc_bluetooth_bt_adapter_unset_state_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_unset_name_changed_cb_n",utc_bluetooth_bt_adapter_unset_name_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_n",utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_local_oob_data_n",utc_bluetooth_bt_adapter_get_local_oob_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_is_service_used_n",utc_bluetooth_bt_adapter_is_service_used_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_n",utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_create_advertiser_n",utc_bluetooth_bt_adapter_le_create_advertiser_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_destroy_advertiser_n",utc_bluetooth_bt_adapter_le_destroy_advertiser_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_stop_advertising_n",utc_bluetooth_bt_adapter_le_stop_advertising_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_clear_advertising_data_n",utc_bluetooth_bt_adapter_le_clear_advertising_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_n",utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_bonded_device_info_n",utc_bluetooth_bt_adapter_get_bonded_device_info_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_free_device_info_n",utc_bluetooth_bt_adapter_free_device_info_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_remote_oob_data_n",utc_bluetooth_bt_adapter_set_remote_oob_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_remove_remote_oob_data_n",utc_bluetooth_bt_adapter_remove_remote_oob_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_start_scan_n",utc_bluetooth_bt_adapter_le_start_scan_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_stop_scan_n",utc_bluetooth_bt_adapter_le_stop_scan_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_service_uuids_n",utc_bluetooth_bt_adapter_le_get_scan_result_service_uuids_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_device_name_n",utc_bluetooth_bt_adapter_le_get_scan_result_device_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_tx_power_level_n",utc_bluetooth_bt_adapter_le_get_scan_result_tx_power_level_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_service_solicitation_uuids_n",utc_bluetooth_bt_adapter_le_get_scan_result_service_solicitation_uuids_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_service_data_list_n",utc_bluetooth_bt_adapter_le_get_scan_result_service_data_list_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_free_service_data_list_n",utc_bluetooth_bt_adapter_le_free_service_data_list_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_appearance_n",utc_bluetooth_bt_adapter_le_get_scan_result_appearance_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_manufacturer_data_n",utc_bluetooth_bt_adapter_le_get_scan_result_manufacturer_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_n",utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_n",utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_service_data_n",utc_bluetooth_bt_adapter_le_add_advertising_service_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_appearance_n",utc_bluetooth_bt_adapter_le_set_advertising_appearance_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_n",utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_device_name_n",utc_bluetooth_bt_adapter_le_set_advertising_device_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_n",utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_start_advertising_new_n",utc_bluetooth_bt_adapter_le_start_advertising_new_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_mode_n",utc_bluetooth_bt_adapter_le_set_advertising_mode_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_connectable_n",utc_bluetooth_bt_adapter_le_set_advertising_connectable_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_get_uuid_name_n",utc_bluetooth_bt_get_uuid_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_scan_mode_n",utc_bluetooth_bt_adapter_le_set_scan_mode_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_get_local_oob_ext_data_n",utc_bluetooth_bt_adapter_get_local_oob_ext_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_remote_oob_ext_data_n",utc_bluetooth_bt_adapter_set_remote_oob_ext_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_create_n",utc_bluetooth_bt_adapter_le_scan_filter_create_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_destroy_n",utc_bluetooth_bt_adapter_le_scan_filter_destroy_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_device_address_n",utc_bluetooth_bt_adapter_le_scan_filter_set_device_address_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_device_name_n",utc_bluetooth_bt_adapter_le_scan_filter_set_device_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_n",utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_with_mask_n",utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_with_mask_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_n",utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_with_mask_n",utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_with_mask_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_n",utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_with_mask_n",utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_with_mask_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_n",utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_with_mask_n",utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_with_mask_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_register_n",utc_bluetooth_bt_adapter_le_scan_filter_register_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_unregister_n",utc_bluetooth_bt_adapter_le_scan_filter_unregister_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_unregister_all_n",utc_bluetooth_bt_adapter_le_scan_filter_unregister_all_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_type_n",utc_bluetooth_bt_adapter_le_scan_filter_set_type_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_n",utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_free_ibeacon_report_n",utc_bluetooth_bt_adapter_le_free_ibeacon_report_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_is_2m_phy_supported_n",utc_bluetooth_bt_adapter_le_is_2m_phy_supported_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_is_coded_phy_supported_n",utc_bluetooth_bt_adapter_le_is_coded_phy_supported_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup}, + {"utc_bluetooth_bt_adapter_le_is_discovering_p",utc_bluetooth_bt_adapter_le_is_discovering_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_state_changed_cb_p",utc_bluetooth_bt_adapter_set_state_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_name_changed_cb_p",utc_bluetooth_bt_adapter_set_name_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_name_changed_cb_p1",utc_bluetooth_bt_adapter_set_name_changed_cb_p1,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p",utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p1",utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p1,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_get_state_p",utc_bluetooth_bt_adapter_get_state_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_get_address_p",utc_bluetooth_bt_adapter_get_address_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_get_name_p",utc_bluetooth_bt_adapter_get_name_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_get_visibility_p",utc_bluetooth_bt_adapter_get_visibility_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_name_p",utc_bluetooth_bt_adapter_set_name_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_unset_state_changed_cb_p",utc_bluetooth_bt_adapter_unset_state_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_unset_name_changed_cb_p",utc_bluetooth_bt_adapter_unset_name_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_p",utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_get_local_oob_data_p",utc_bluetooth_bt_adapter_get_local_oob_data_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_is_service_used_p",utc_bluetooth_bt_adapter_is_service_used_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_clear_advertising_data_p",utc_bluetooth_bt_adapter_le_clear_advertising_data_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_p",utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_create_advertiser_p",utc_bluetooth_bt_adapter_le_create_advertiser_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_destroy_advertiser_p",utc_bluetooth_bt_adapter_le_destroy_advertiser_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_stop_advertising_p",utc_bluetooth_bt_adapter_le_stop_advertising_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_p",utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_start_scan_p",utc_bluetooth_bt_adapter_le_start_scan_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_stop_scan_p",utc_bluetooth_bt_adapter_le_stop_scan_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_p",utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_p",utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_service_data_p",utc_bluetooth_bt_adapter_le_add_advertising_service_data_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_appearance_p",utc_bluetooth_bt_adapter_le_set_advertising_appearance_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_p",utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_device_name_p",utc_bluetooth_bt_adapter_le_set_advertising_device_name_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_p",utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_start_advertising_new_p",utc_bluetooth_bt_adapter_le_start_advertising_new_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_mode_p",utc_bluetooth_bt_adapter_le_set_advertising_mode_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_advertising_connectable_p",utc_bluetooth_bt_adapter_le_set_advertising_connectable_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_is_2m_phy_supported_p",utc_bluetooth_bt_adapter_le_is_2m_phy_supported_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_is_coded_phy_supported_p",utc_bluetooth_bt_adapter_le_is_coded_phy_supported_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_get_uuid_name_p",utc_bluetooth_bt_get_uuid_name_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_set_scan_mode_p",utc_bluetooth_bt_adapter_le_set_scan_mode_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_get_local_oob_ext_data_p",utc_bluetooth_bt_adapter_get_local_oob_ext_data_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_scan_filter_set_type_p",utc_bluetooth_bt_adapter_le_scan_filter_set_type_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_p",utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_adapter_le_free_ibeacon_report_p",utc_bluetooth_bt_adapter_le_free_ibeacon_report_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup}, + {"utc_bluetooth_bt_audio_connect_n",utc_bluetooth_bt_audio_connect_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_audio_disconnect_n",utc_bluetooth_bt_audio_disconnect_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_audio_set_connection_state_changed_cb_n",utc_bluetooth_bt_audio_set_connection_state_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_audio_set_connection_state_changed_cb_n1",utc_bluetooth_bt_audio_set_connection_state_changed_cb_n1,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_audio_deinitialize_n",utc_bluetooth_bt_audio_deinitialize_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_audio_initialize_n",utc_bluetooth_bt_audio_initialize_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_audio_unset_connection_state_changed_cb_n",utc_bluetooth_bt_audio_unset_connection_state_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_set_equalizer_state_changed_cb_n",utc_bluetooth_bt_avrcp_set_equalizer_state_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_set_repeat_mode_changed_cb_n",utc_bluetooth_bt_avrcp_set_repeat_mode_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_set_scan_mode_changed_cb_n",utc_bluetooth_bt_avrcp_set_scan_mode_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_cb_n",utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_set_position_changed_cb_n",utc_bluetooth_bt_avrcp_set_position_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_set_play_status_changed_cb_n",utc_bluetooth_bt_avrcp_set_play_status_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_set_track_info_changed_cb_n",utc_bluetooth_bt_avrcp_set_track_info_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_deinitialize_n",utc_bluetooth_bt_avrcp_target_deinitialize_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_initialize_n",utc_bluetooth_bt_avrcp_target_initialize_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_equalizer_state_n",utc_bluetooth_bt_avrcp_target_notify_equalizer_state_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_player_state_n",utc_bluetooth_bt_avrcp_target_notify_player_state_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_position_n",utc_bluetooth_bt_avrcp_target_notify_position_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_repeat_mode_n",utc_bluetooth_bt_avrcp_target_notify_repeat_mode_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_scan_mode_n",utc_bluetooth_bt_avrcp_target_notify_scan_mode_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_n",utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_track_n",utc_bluetooth_bt_avrcp_target_notify_track_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_cb_n",utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_cb_n",utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_scan_mode_changed_cb_n",utc_bluetooth_bt_avrcp_unset_scan_mode_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_cb_n",utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_position_changed_cb_n",utc_bluetooth_bt_avrcp_unset_position_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_n",utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_n",utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_n,utc_bluetooth_bt_audio_negative_startup,utc_bluetooth_bt_audio_negative_cleanup}, + {"utc_bluetooth_bt_audio_initialize_p",utc_bluetooth_bt_audio_initialize_p,utc_bluetooth_audio_positive_startup,utc_bluetooth_audio_positive_cleanup}, + {"utc_bluetooth_bt_audio_set_connection_state_changed_cb_p",utc_bluetooth_bt_audio_set_connection_state_changed_cb_p,utc_bluetooth_audio_positive_startup,utc_bluetooth_audio_positive_cleanup}, + {"utc_bluetooth_bt_audio_unset_connection_state_changed_cb_p",utc_bluetooth_bt_audio_unset_connection_state_changed_cb_p,utc_bluetooth_audio_positive_startup,utc_bluetooth_audio_positive_cleanup}, + {"utc_bluetooth_bt_audio_deinitialize_p",utc_bluetooth_bt_audio_deinitialize_p,utc_bluetooth_audio_positive_startup,utc_bluetooth_audio_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_initialize_p",utc_bluetooth_bt_avrcp_target_initialize_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_deinitialize_p",utc_bluetooth_bt_avrcp_target_deinitialize_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_equalizer_state_p",utc_bluetooth_bt_avrcp_target_notify_equalizer_state_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_repeat_mode_p",utc_bluetooth_bt_avrcp_target_notify_repeat_mode_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_p",utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_scan_mode_p",utc_bluetooth_bt_avrcp_target_notify_scan_mode_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_player_state_p",utc_bluetooth_bt_avrcp_target_notify_player_state_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_position_p",utc_bluetooth_bt_avrcp_target_notify_position_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_target_notify_track_p",utc_bluetooth_bt_avrcp_target_notify_track_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_set_equalizer_state_changed_p",utc_bluetooth_bt_avrcp_set_equalizer_state_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_p",utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_set_repeat_mode_changed_p",utc_bluetooth_bt_avrcp_set_repeat_mode_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_p",utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_p",utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_p",utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_set_scan_mode_changed_p",utc_bluetooth_bt_avrcp_set_scan_mode_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_scan_mode_changed_p",utc_bluetooth_bt_avrcp_unset_scan_mode_changed_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_set_position_changed_cb_p",utc_bluetooth_bt_avrcp_set_position_changed_cb_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_position_changed_cb_p",utc_bluetooth_bt_avrcp_unset_position_changed_cb_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_set_play_status_changed_cb_p",utc_bluetooth_bt_avrcp_set_play_status_changed_cb_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_p",utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_set_track_info_changed_cb_p",utc_bluetooth_bt_avrcp_set_track_info_changed_cb_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_p",utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_p,utc_bluetooth_avrcp_callback_positive_startup,utc_bluetooth_avrcp_callback_positive_cleanup}, + {"utc_bluetooth_bt_initialize_p",utc_bluetooth_bt_initialize_p,utc_bluetooth_common_startup,utc_bluetooth_common_cleanup}, + {"utc_bluetooth_bt_deinitialize_p",utc_bluetooth_bt_deinitialize_p,utc_bluetooth_common_startup,utc_bluetooth_common_cleanup}, + {"utc_bluetooth_bt_adapter_stop_device_discovery_n1",utc_bluetooth_bt_adapter_stop_device_discovery_n1,utc_bluetooth_device_discovery_negative_startup,utc_bluetooth_device_discovery_negative_cleanup}, + {"utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_n1",utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_n1,utc_bluetooth_device_discovery_negative_startup,utc_bluetooth_device_discovery_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n",utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n,utc_bluetooth_device_discovery_negative_startup,utc_bluetooth_device_discovery_negative_cleanup}, + {"utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n1",utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n1,utc_bluetooth_device_discovery_negative_startup,utc_bluetooth_device_discovery_negative_cleanup}, + {"utc_bluetooth_bt_adapter_start_device_discovery_n1",utc_bluetooth_bt_adapter_start_device_discovery_n1,utc_bluetooth_device_discovery_negative_startup,utc_bluetooth_device_discovery_negative_cleanup}, + {"utc_bluetooth_bt_adapter_is_discovering_n1",utc_bluetooth_bt_adapter_is_discovering_n1,utc_bluetooth_device_discovery_negative_startup,utc_bluetooth_device_discovery_negative_cleanup}, + {"utc_bluetooth_bt_adapter_is_discovering_n2",utc_bluetooth_bt_adapter_is_discovering_n2,utc_bluetooth_device_discovery_negative_startup,utc_bluetooth_device_discovery_negative_cleanup}, + {"utc_bluetooth_bt_adapter_is_discovering_p",utc_bluetooth_bt_adapter_is_discovering_p,utc_bluetooth_device_discovery_positive_startup,utc_bluetooth_device_discovery_positive_cleanup}, + {"utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_p",utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_p,utc_bluetooth_device_discovery_positive_startup,utc_bluetooth_device_discovery_positive_cleanup}, + {"utc_bluetooth_bt_adapter_start_device_discovery_p",utc_bluetooth_bt_adapter_start_device_discovery_p,utc_bluetooth_device_discovery_positive_startup,utc_bluetooth_device_discovery_positive_cleanup}, + {"utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_p",utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_p,utc_bluetooth_device_discovery_positive_startup,utc_bluetooth_device_discovery_positive_cleanup}, + {"utc_bluetooth_bt_adapter_stop_device_discovery_p",utc_bluetooth_bt_adapter_stop_device_discovery_p,utc_bluetooth_device_discovery_positive_startup,utc_bluetooth_device_discovery_positive_cleanup}, + {"utc_bluetooth_bt_device_set_bond_created_cb_n",utc_bluetooth_bt_device_set_bond_created_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_bond_created_cb_n1",utc_bluetooth_bt_device_set_bond_created_cb_n1,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_bond_destroyed_cb_n",utc_bluetooth_bt_device_set_bond_destroyed_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_authorization_changed_cb_n",utc_bluetooth_bt_device_set_authorization_changed_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_authorization_changed_cb_n1",utc_bluetooth_bt_device_set_authorization_changed_cb_n1,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_unset_bond_created_cb_n",utc_bluetooth_bt_device_unset_bond_created_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_unset_bond_destroyed_cb_n",utc_bluetooth_bt_device_unset_bond_destroyed_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_unset_authorization_changed_cb_n",utc_bluetooth_bt_device_unset_authorization_changed_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_create_bond_n",utc_bluetooth_bt_device_create_bond_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_create_bond_n1",utc_bluetooth_bt_device_create_bond_n1,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_cancel_bonding_n",utc_bluetooth_bt_device_cancel_bonding_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_destroy_bond_n",utc_bluetooth_bt_device_destroy_bond_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_adapter_foreach_bonded_device_n1",utc_bluetooth_bt_adapter_foreach_bonded_device_n1,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_adapter_foreach_bonded_device_n2",utc_bluetooth_bt_adapter_foreach_bonded_device_n2,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_alias_n",utc_bluetooth_bt_device_set_alias_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_alias_n2",utc_bluetooth_bt_device_set_alias_n2,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_authorization_n",utc_bluetooth_bt_device_set_authorization_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_authorization_n2",utc_bluetooth_bt_device_set_authorization_n2,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_get_service_mask_from_uuid_list_n",utc_bluetooth_bt_device_get_service_mask_from_uuid_list_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_is_profile_connected_n",utc_bluetooth_bt_device_is_profile_connected_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_connection_state_changed_cb_n",utc_bluetooth_bt_device_set_connection_state_changed_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_unset_connection_state_changed_cb_n",utc_bluetooth_bt_device_unset_connection_state_changed_cb_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_foreach_connected_profiles_n",utc_bluetooth_bt_device_foreach_connected_profiles_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_update_le_connection_mode_n",utc_bluetooth_bt_device_update_le_connection_mode_n,utc_bluetooth_device_negative_startup,utc_bluetooth_device_negative_cleanup}, + {"utc_bluetooth_bt_device_set_bond_created_cb_p",utc_bluetooth_bt_device_set_bond_created_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_set_bond_destroyed_cb_p",utc_bluetooth_bt_device_set_bond_destroyed_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_set_authorization_changed_cb_p",utc_bluetooth_bt_device_set_authorization_changed_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_get_service_mask_from_uuid_list_p",utc_bluetooth_bt_device_get_service_mask_from_uuid_list_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_is_profile_connected_p",utc_bluetooth_bt_device_is_profile_connected_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_unset_bond_created_cb_p",utc_bluetooth_bt_device_unset_bond_created_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_adapter_foreach_bonded_device_p",utc_bluetooth_bt_adapter_foreach_bonded_device_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_unset_bond_destroyed_cb_p",utc_bluetooth_bt_device_unset_bond_destroyed_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_unset_authorization_changed_cb_p",utc_bluetooth_bt_device_unset_authorization_changed_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_set_connection_state_changed_cb_p",utc_bluetooth_bt_device_set_connection_state_changed_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_unset_connection_state_changed_cb_p",utc_bluetooth_bt_device_unset_connection_state_changed_cb_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_gatt_connect_n",utc_bluetooth_bt_gatt_connect_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_disconnect_n",utc_bluetooth_bt_gatt_disconnect_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_connect_n1",utc_bluetooth_bt_gatt_connect_n1,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_disconnect_n1",utc_bluetooth_bt_gatt_disconnect_n1,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_set_connection_state_changed_cb_n",utc_bluetooth_bt_gatt_set_connection_state_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_n",utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_get_value_n",utc_bluetooth_bt_gatt_get_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_get_int_value_n",utc_bluetooth_bt_gatt_get_int_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_get_float_value_n",utc_bluetooth_bt_gatt_get_float_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_set_value_n",utc_bluetooth_bt_gatt_set_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_set_int_value_n",utc_bluetooth_bt_gatt_set_int_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_set_float_value_n",utc_bluetooth_bt_gatt_set_float_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_get_uuid_n",utc_bluetooth_bt_gatt_get_uuid_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_get_type_n",utc_bluetooth_bt_gatt_get_type_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_get_client_n",utc_bluetooth_bt_gatt_service_get_client_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_get_characteristic_n",utc_bluetooth_bt_gatt_service_get_characteristic_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_foreach_characteristics_n",utc_bluetooth_bt_gatt_service_foreach_characteristics_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_get_included_service_n",utc_bluetooth_bt_gatt_service_get_included_service_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_foreach_included_services_n",utc_bluetooth_bt_gatt_service_foreach_included_services_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_get_service_n",utc_bluetooth_bt_gatt_characteristic_get_service_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_get_properties_n",utc_bluetooth_bt_gatt_characteristic_get_properties_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_get_write_type_n",utc_bluetooth_bt_gatt_characteristic_get_write_type_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_set_write_type_n",utc_bluetooth_bt_gatt_characteristic_set_write_type_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_get_descriptor_n",utc_bluetooth_bt_gatt_characteristic_get_descriptor_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_foreach_descriptors_n",utc_bluetooth_bt_gatt_characteristic_foreach_descriptors_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_descriptor_get_characteristic_n",utc_bluetooth_bt_gatt_descriptor_get_characteristic_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_create_n",utc_bluetooth_bt_gatt_client_create_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_destroy_n",utc_bluetooth_bt_gatt_client_destroy_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_get_remote_address_n",utc_bluetooth_bt_gatt_client_get_remote_address_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_read_value_n",utc_bluetooth_bt_gatt_client_read_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_write_value_n",utc_bluetooth_bt_gatt_client_write_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_set_characteristic_value_changed_cb_n",utc_bluetooth_bt_gatt_client_set_characteristic_value_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_unset_characteristic_value_changed_cb_n",utc_bluetooth_bt_gatt_client_unset_characteristic_value_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_get_service_n",utc_bluetooth_bt_gatt_client_get_service_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_foreach_services_n",utc_bluetooth_bt_gatt_client_foreach_services_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_destroy_n",utc_bluetooth_bt_gatt_service_destroy_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_destroy_n",utc_bluetooth_bt_gatt_characteristic_destroy_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_descriptor_destroy_n",utc_bluetooth_bt_gatt_descriptor_destroy_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_get_permissions_n",utc_bluetooth_bt_gatt_characteristic_get_permissions_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_descriptor_get_permissions_n",utc_bluetooth_bt_gatt_descriptor_get_permissions_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_create_n",utc_bluetooth_bt_gatt_service_create_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_add_characteristic_n",utc_bluetooth_bt_gatt_service_add_characteristic_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_add_included_service_n",utc_bluetooth_bt_gatt_service_add_included_service_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_service_get_server_n",utc_bluetooth_bt_gatt_service_get_server_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_create_n",utc_bluetooth_bt_gatt_characteristic_create_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_add_descriptor_n",utc_bluetooth_bt_gatt_characteristic_add_descriptor_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_descriptor_create_n",utc_bluetooth_bt_gatt_descriptor_create_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_initialize_n",utc_bluetooth_bt_gatt_server_initialize_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_deinitialize_n",utc_bluetooth_bt_gatt_server_deinitialize_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_create_n",utc_bluetooth_bt_gatt_server_create_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_destroy_n",utc_bluetooth_bt_gatt_server_destroy_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_n",utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_n",utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_n",utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_notify_characteristic_changed_value_n",utc_bluetooth_bt_gatt_server_notify_characteristic_changed_value_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_get_service_n",utc_bluetooth_bt_gatt_server_get_service_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_get_device_mtu_n",utc_bluetooth_bt_gatt_server_get_device_mtu_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_foreach_services_n",utc_bluetooth_bt_gatt_server_foreach_services_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_register_service_n",utc_bluetooth_bt_gatt_server_register_service_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_unregister_service_n",utc_bluetooth_bt_gatt_server_unregister_service_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_unregister_all_services_n",utc_bluetooth_bt_gatt_server_unregister_all_services_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_start_n",utc_bluetooth_bt_gatt_server_start_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_server_send_response_n",utc_bluetooth_bt_gatt_server_send_response_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_set_service_changed_cb_n",utc_bluetooth_bt_gatt_client_set_service_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_unset_service_changed_cb_n",utc_bluetooth_bt_gatt_client_unset_service_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_ipsp_initialize_n",utc_bluetooth_bt_ipsp_initialize_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_ipsp_deinitialize_n",utc_bluetooth_bt_ipsp_deinitialize_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_ipsp_connect_n",utc_bluetooth_bt_ipsp_connect_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_ipsp_disconnect_n",utc_bluetooth_bt_ipsp_disconnect_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_n",utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_n",utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_request_att_mtu_change_n",utc_bluetooth_bt_gatt_client_request_att_mtu_change_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_get_att_mtu_n",utc_bluetooth_bt_gatt_client_get_att_mtu_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_n",utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_n",utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_n,utc_bluetooth_gatt_negative_startup,utc_bluetooth_gatt_negative_cleanup}, + {"utc_bluetooth_bt_gatt_set_connection_state_changed_cb_p",utc_bluetooth_bt_gatt_set_connection_state_changed_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_p",utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_service_destroy_p",utc_bluetooth_bt_gatt_service_destroy_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_destroy_p",utc_bluetooth_bt_gatt_characteristic_destroy_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_descriptor_destroy_p",utc_bluetooth_bt_gatt_descriptor_destroy_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_get_permissions_p",utc_bluetooth_bt_gatt_characteristic_get_permissions_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_descriptor_get_permissions_p",utc_bluetooth_bt_gatt_descriptor_get_permissions_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_service_create_p",utc_bluetooth_bt_gatt_service_create_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_service_add_characteristic_p",utc_bluetooth_bt_gatt_service_add_characteristic_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_service_add_included_service_p",utc_bluetooth_bt_gatt_service_add_included_service_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_service_get_server_p",utc_bluetooth_bt_gatt_service_get_server_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_create_p",utc_bluetooth_bt_gatt_characteristic_create_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_characteristic_add_descriptor_p",utc_bluetooth_bt_gatt_characteristic_add_descriptor_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_descriptor_create_p",utc_bluetooth_bt_gatt_descriptor_create_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_initialize_p",utc_bluetooth_bt_gatt_server_initialize_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_deinitialize_p",utc_bluetooth_bt_gatt_server_deinitialize_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_create_p",utc_bluetooth_bt_gatt_server_create_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_destroy_p",utc_bluetooth_bt_gatt_server_destroy_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_p",utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_p",utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_p",utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_get_service_p",utc_bluetooth_bt_gatt_server_get_service_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_foreach_services_p",utc_bluetooth_bt_gatt_server_foreach_services_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_register_service_p",utc_bluetooth_bt_gatt_server_register_service_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_unregister_service_p",utc_bluetooth_bt_gatt_server_unregister_service_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_unregister_all_services_p",utc_bluetooth_bt_gatt_server_unregister_all_services_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_server_start_p",utc_bluetooth_bt_gatt_server_start_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_p",utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_p",utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_p",utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_p",utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_p,utc_bluetooth_gatt_positive_startup,utc_bluetooth_gatt_positive_cleanup}, + {"utc_bluetooth_bt_hdp_set_data_received_cb_n",utc_bluetooth_bt_hdp_set_data_received_cb_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_set_data_received_cb_n1",utc_bluetooth_bt_hdp_set_data_received_cb_n1,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n",utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n1",utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n1,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_disconnect_n",utc_bluetooth_bt_hdp_disconnect_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_connect_to_source_n",utc_bluetooth_bt_hdp_connect_to_source_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_connect_to_source_n2",utc_bluetooth_bt_hdp_connect_to_source_n2,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_register_sink_app_n",utc_bluetooth_bt_hdp_register_sink_app_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_unregister_sink_app_n",utc_bluetooth_bt_hdp_unregister_sink_app_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_unregister_sink_app_n1",utc_bluetooth_bt_hdp_unregister_sink_app_n1,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_send_data_n",utc_bluetooth_bt_hdp_send_data_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_n",utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_unset_data_received_cb_n",utc_bluetooth_bt_hdp_unset_data_received_cb_n,utc_bluetooth_hdp_negative_startup,utc_bluetooth_hdp_negative_cleanup}, + {"utc_bluetooth_bt_hdp_set_data_received_cb_p",utc_bluetooth_bt_hdp_set_data_received_cb_p,utc_bluetooth_hdp_positive_startup,utc_bluetooth_hdp_positive_cleanup}, + {"utc_bluetooth_bt_hdp_unset_data_received_cb_p",utc_bluetooth_bt_hdp_unset_data_received_cb_p,utc_bluetooth_hdp_positive_startup,utc_bluetooth_hdp_positive_cleanup}, + {"utc_bluetooth_bt_hdp_set_connection_state_changed_cb_p",utc_bluetooth_bt_hdp_set_connection_state_changed_cb_p,utc_bluetooth_hdp_positive_startup,utc_bluetooth_hdp_positive_cleanup}, + {"utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_p",utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_p,utc_bluetooth_hdp_positive_startup,utc_bluetooth_hdp_positive_cleanup}, + {"utc_bluetooth_bt_hdp_unregister_sink_app_p",utc_bluetooth_bt_hdp_unregister_sink_app_p,utc_bluetooth_hdp_positive_startup,utc_bluetooth_hdp_positive_cleanup}, + {"utc_bluetooth_bt_hdp_register_sink_app_p",utc_bluetooth_bt_hdp_register_sink_app_p,utc_bluetooth_hdp_positive_startup,utc_bluetooth_hdp_positive_cleanup}, + {"utc_bluetooth_bt_hid_host_initialize_n",utc_bluetooth_bt_hid_host_initialize_n,utc_bluetooth_hid_negative_startup,utc_bluetooth_hid_negative_cleanup}, + {"utc_bluetooth_bt_hid_host_initialize_n1",utc_bluetooth_bt_hid_host_initialize_n1,utc_bluetooth_hid_negative_startup,utc_bluetooth_hid_negative_cleanup}, + {"utc_bluetooth_bt_hid_host_connect_n",utc_bluetooth_bt_hid_host_connect_n,utc_bluetooth_hid_negative_startup,utc_bluetooth_hid_negative_cleanup}, + {"utc_bluetooth_bt_hid_host_disconnect_n",utc_bluetooth_bt_hid_host_disconnect_n,utc_bluetooth_hid_negative_startup,utc_bluetooth_hid_negative_cleanup}, + {"utc_bluetooth_bt_hid_host_deinitialize_n",utc_bluetooth_bt_hid_host_deinitialize_n,utc_bluetooth_hid_negative_startup,utc_bluetooth_hid_negative_cleanup}, + {"utc_bluetooth_bt_hid_host_initialize_p",utc_bluetooth_bt_hid_host_initialize_p,utc_bluetooth_hid_positive_startup,utc_bluetooth_hid_positive_cleanup}, + {"utc_bluetooth_bt_hid_host_deinitialize_p",utc_bluetooth_bt_hid_host_deinitialize_p,utc_bluetooth_hid_positive_startup,utc_bluetooth_hid_positive_cleanup}, + {"utc_bluetooth_bt_opp_client_initialize_n",utc_bluetooth_bt_opp_client_initialize_n,utc_bluetooth_opp_client_negative_startup,utc_bluetooth_opp_client_negative_cleanup}, + {"utc_bluetooth_bt_opp_client_deinitialize_n",utc_bluetooth_bt_opp_client_deinitialize_n,utc_bluetooth_opp_client_negative_startup,utc_bluetooth_opp_client_negative_cleanup}, + {"utc_bluetooth_bt_opp_client_add_file_n",utc_bluetooth_bt_opp_client_add_file_n,utc_bluetooth_opp_client_negative_startup,utc_bluetooth_opp_client_negative_cleanup}, + {"utc_bluetooth_bt_opp_client_add_file_n1",utc_bluetooth_bt_opp_client_add_file_n1,utc_bluetooth_opp_client_negative_startup,utc_bluetooth_opp_client_negative_cleanup}, + {"utc_bluetooth_bt_opp_client_clear_files_n",utc_bluetooth_bt_opp_client_clear_files_n,utc_bluetooth_opp_client_negative_startup,utc_bluetooth_opp_client_negative_cleanup}, + {"utc_bluetooth_bt_opp_client_push_files_n",utc_bluetooth_bt_opp_client_push_files_n,utc_bluetooth_opp_client_negative_startup,utc_bluetooth_opp_client_negative_cleanup}, + {"utc_bluetooth_bt_opp_client_cancel_push_n",utc_bluetooth_bt_opp_client_cancel_push_n,utc_bluetooth_opp_client_negative_startup,utc_bluetooth_opp_client_negative_cleanup}, + {"utc_bluetooth_bt_opp_client_initialize_p",utc_bluetooth_bt_opp_client_initialize_p,utc_bluetooth_opp_client_positive_startup,utc_bluetooth_opp_client_positive_cleanup}, + {"utc_bluetooth_bt_opp_client_deinitialize_p",utc_bluetooth_bt_opp_client_deinitialize_p,utc_bluetooth_opp_client_positive_startup,utc_bluetooth_opp_client_positive_cleanup}, + {"utc_bluetooth_bt_opp_client_clear_files_p",utc_bluetooth_bt_opp_client_clear_files_p,utc_bluetooth_opp_client_positive_startup,utc_bluetooth_opp_client_positive_cleanup}, + {"utc_bluetooth_bt_opp_server_accept_n",utc_bluetooth_bt_opp_server_accept_n,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_accept_n1",utc_bluetooth_bt_opp_server_accept_n1,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_accept_n2",utc_bluetooth_bt_opp_server_accept_n2,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_reject_n",utc_bluetooth_bt_opp_server_reject_n,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_reject_n1",utc_bluetooth_bt_opp_server_reject_n1,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_set_destination_n",utc_bluetooth_bt_opp_server_set_destination_n,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_set_destination_n1",utc_bluetooth_bt_opp_server_set_destination_n1,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_set_destination_n2",utc_bluetooth_bt_opp_server_set_destination_n2,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_initialize_by_connection_request_n",utc_bluetooth_bt_opp_server_initialize_by_connection_request_n,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_initialize_by_connection_request_n1",utc_bluetooth_bt_opp_server_initialize_by_connection_request_n1,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_deinitialize_n",utc_bluetooth_bt_opp_server_deinitialize_n,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_deinitialize_n1",utc_bluetooth_bt_opp_server_deinitialize_n1,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_cancel_transfer_n",utc_bluetooth_bt_opp_server_cancel_transfer_n,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_cancel_transfer_n1",utc_bluetooth_bt_opp_server_cancel_transfer_n1,utc_bluetooth_bt_opp_server_negative_startup,utc_bluetooth_bt_opp_server_negative_cleanup}, + {"utc_bluetooth_bt_opp_server_initialize_by_connection_request_p",utc_bluetooth_bt_opp_server_initialize_by_connection_request_p,utc_bluetooth_opp_server_positive_startup,utc_bluetooth_opp_server_positive_cleanup}, + {"utc_bluetooth_bt_opp_server_deinitialize_p",utc_bluetooth_bt_opp_server_deinitialize_p,utc_bluetooth_opp_server_positive_startup,utc_bluetooth_opp_server_positive_cleanup}, + {"utc_bluetooth_bt_opp_server_set_destination_p",utc_bluetooth_bt_opp_server_set_destination_p,utc_bluetooth_opp_server_positive_startup,utc_bluetooth_opp_server_positive_cleanup}, + {"utc_bluetooth_bt_device_set_service_searched_cb_n",utc_bluetooth_bt_device_set_service_searched_cb_n,utc_bluetooth_service_search_negative_startup,utc_bluetooth_service_search_negative_cleanup}, + {"utc_bluetooth_bt_device_set_service_searched_cb_n1",utc_bluetooth_bt_device_set_service_searched_cb_n1,utc_bluetooth_service_search_negative_startup,utc_bluetooth_service_search_negative_cleanup}, + {"utc_bluetooth_bt_device_unset_service_searched_cb_n",utc_bluetooth_bt_device_unset_service_searched_cb_n,utc_bluetooth_service_search_negative_startup,utc_bluetooth_service_search_negative_cleanup}, + {"utc_bluetooth_bt_device_start_service_search_n",utc_bluetooth_bt_device_start_service_search_n,utc_bluetooth_service_search_negative_startup,utc_bluetooth_service_search_negative_cleanup}, + {"utc_bluetooth_bt_device_set_service_searched_cb_p",utc_bluetooth_bt_device_set_service_searched_cb_p,utc_bluetooth_service_search_positive_startup,utc_bluetooth_service_search_positive_cleanup}, + {"utc_bluetooth_bt_device_unset_service_searched_cb_p",utc_bluetooth_bt_device_unset_service_searched_cb_p,utc_bluetooth_service_search_positive_startup,utc_bluetooth_service_search_positive_cleanup}, + {"utc_bluetooth_bt_socket_set_data_received_cb_n",utc_bluetooth_bt_socket_set_data_received_cb_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_set_data_received_cb_n1",utc_bluetooth_bt_socket_set_data_received_cb_n1,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_set_connection_state_changed_cb_n",utc_bluetooth_bt_socket_set_connection_state_changed_cb_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_set_connection_state_changed_cb_n1",utc_bluetooth_bt_socket_set_connection_state_changed_cb_n1,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_unset_data_received_cb_n",utc_bluetooth_bt_socket_unset_data_received_cb_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_unset_connection_state_changed_cb_n",utc_bluetooth_bt_socket_unset_connection_state_changed_cb_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_create_rfcomm_n",utc_bluetooth_bt_socket_create_rfcomm_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_create_rfcomm_n1",utc_bluetooth_bt_socket_create_rfcomm_n1,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_destroy_rfcomm_n",utc_bluetooth_bt_socket_destroy_rfcomm_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_listen_and_accept_rfcomm_n",utc_bluetooth_bt_socket_listen_and_accept_rfcomm_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_connect_rfcomm_n",utc_bluetooth_bt_socket_connect_rfcomm_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_disconnect_rfcomm_n",utc_bluetooth_bt_socket_disconnect_rfcomm_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_send_data_n",utc_bluetooth_bt_socket_send_data_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_set_connection_requested_cb_n",utc_bluetooth_bt_socket_set_connection_requested_cb_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_unset_connection_requested_cb_n",utc_bluetooth_bt_socket_unset_connection_requested_cb_n,utc_bluetooth_socket_negative_startup,utc_bluetooth_socket_negative_cleanup}, + {"utc_bluetooth_bt_socket_set_data_received_cb_p",utc_bluetooth_bt_socket_set_data_received_cb_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_set_connection_state_changed_cb_p",utc_bluetooth_bt_socket_set_connection_state_changed_cb_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_create_rfcomm_p",utc_bluetooth_bt_socket_create_rfcomm_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_listen_and_accept_rfcomm_p",utc_bluetooth_bt_socket_listen_and_accept_rfcomm_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_destroy_rfcomm_p",utc_bluetooth_bt_socket_destroy_rfcomm_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_unset_data_received_cb_p",utc_bluetooth_bt_socket_unset_data_received_cb_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_unset_connection_state_changed_cb_p",utc_bluetooth_bt_socket_unset_connection_state_changed_cb_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_set_connection_requested_cb_p",utc_bluetooth_bt_socket_set_connection_requested_cb_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_socket_unset_connection_requested_cb_p",utc_bluetooth_bt_socket_unset_connection_requested_cb_p,utc_bluetooth_bt_socket_positive_startup,utc_bluetooth_bt_socket_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_control_initialize_p",utc_bluetooth_bt_avrcp_control_initialize_p,utc_bluetooth_avrcp_control_positive_startup,utc_bluetooth_avrcp_control_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_control_deinitialize_p",utc_bluetooth_bt_avrcp_control_deinitialize_p,utc_bluetooth_avrcp_control_positive_startup,utc_bluetooth_avrcp_control_positive_cleanup}, + {"utc_bluetooth_bt_avrcp_control_connect_n",utc_bluetooth_bt_avrcp_control_connect_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_disconnect_n",utc_bluetooth_bt_avrcp_control_disconnect_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_send_player_command_n",utc_bluetooth_bt_avrcp_control_send_player_command_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_set_equalizer_state_n",utc_bluetooth_bt_avrcp_control_set_equalizer_state_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_get_equalizer_state_n",utc_bluetooth_bt_avrcp_control_get_equalizer_state_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_set_repeat_mode_n",utc_bluetooth_bt_avrcp_control_set_repeat_mode_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_get_repeat_mode_n",utc_bluetooth_bt_avrcp_control_get_repeat_mode_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_set_shuffle_mode_n",utc_bluetooth_bt_avrcp_control_set_shuffle_mode_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_get_shuffle_mode_n",utc_bluetooth_bt_avrcp_control_get_shuffle_mode_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_set_scan_mode_n",utc_bluetooth_bt_avrcp_control_set_scan_mode_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_get_scan_mode_n",utc_bluetooth_bt_avrcp_control_get_scan_mode_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_get_position_n",utc_bluetooth_bt_avrcp_control_get_position_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_get_play_status_n",utc_bluetooth_bt_avrcp_control_get_play_status_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_get_track_info_n",utc_bluetooth_bt_avrcp_control_get_track_info_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_avrcp_control_free_track_info_n",utc_bluetooth_bt_avrcp_control_free_track_info_n,utc_bluetooth_avrcp_control_negative_startup,utc_bluetooth_avrcp_control_negative_cleanup}, + {"utc_bluetooth_bt_device_create_bond_p",utc_bluetooth_bt_device_create_bond_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {"utc_bluetooth_bt_device_destroy_bond_p",utc_bluetooth_bt_device_destroy_bond_p,utc_bluetooth_device_positive_startup,utc_bluetooth_device_positive_cleanup}, + {NULL, NULL} +}; + +#endif // __TCT_BLUETOOTH_NATIVE_H__ diff --git a/tests/unittest/utc_bluetooth_adapter_negative.c b/tests/unittest/utc_bluetooth_adapter_negative.c new file mode 100644 index 0000000..a1b18d3 --- /dev/null +++ b/tests/unittest/utc_bluetooth_adapter_negative.c @@ -0,0 +1,1792 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include +#include + +//& set: BluetoothAdapterNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool le_supported = false; +static bool bt_supported = false; +static bool oob_supported = false; +static bool le_50_supported = false; + +/** + * @function utc_bluetooth_adapter_negative_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_adapter_negative_startup(void) +{ + startup_flag = BT_ERROR_NONE; + +#ifdef TV + bt_supported = true; + le_supported = true; +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + le_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le", &le_supported); + + oob_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.oob", &oob_supported); + + le_50_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le.5_0", &le_50_supported); +#endif + if (bt_supported) { + + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_adapter_negative_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_adapter_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** +* @testcase utc_bluetooth_bt_deinitialize_n +* @since_tizen 2.3 +* @description Call to de-initialize Bluetooth and related resources twice if BT is supported +* otherwise just call to de-initialize Bluetooth once. check the "ret" flag with BT_ERROR_NOT_INITIALIZED +* if BT is already supported otherwise check with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to de-Initialize Bluetooth and to release related resources. +*/ +int utc_bluetooth_bt_deinitialize_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +#if defined(MOBILE) || defined(TV) || defined(TIZENIOT) +/** +* @testcase utc_bluetooth_bt_adapter_le_is_discovering_n +* @since_tizen 2.3 +* @description Call to check whether LE device discovery is in progress or not. check the "ret" flag with +* BT_ERROR_INVALID_PARAMETER if LE is supported otherwise check with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to check whether LE device discovery is in progress. +*/ +int utc_bluetooth_bt_adapter_le_is_discovering_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_is_discovering(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_is_discovering(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} +#endif + +/** +* @testcase utc_bluetooth_bt_adapter_set_state_changed_cb_n +* @since_tizen 2.3 +* @description Call to register callback as "NULL"; to be invoked when bluetooth adapter's state changes and check the "ret" +* flag with BT_ERROR_INVALID_PARAMETER if LE is supported otherwise just call to register the adapter's state +* change callback as "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set bluetooth adapter's state change callback with "NULL". +*/ +int utc_bluetooth_bt_adapter_set_state_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_state_changed_cb_n1 +* @since_tizen 2.3 +* @description Call to register callback as "NULL"; to be invoked when bluetooth adapter's state +* changes after de-initializing Bluetooth and check the "ret" flag with BT_ERROR_NOT_INITIALIZED +* if LE is supported otherwise just call to register the callback with "NULL" and check the "ret" flag +* with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set bluetooth adapter's state change callback with "NULL" after deinitializng Bluetooth. +*/ +int utc_bluetooth_bt_adapter_set_state_changed_cb_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_set_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_name_changed_cb_n +* @since_tizen 2.3 +* @description Call to set local bluetooth adapter's friendly name changed callback as "NULL" +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise +* just set the callback with "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set bluetooth adapter's friendly name with "NULL". +*/ +int utc_bluetooth_bt_adapter_set_name_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_name_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_name_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_name_changed_cb_n1 +* @since_tizen 2.3 +* @description Call to set local bluetooth adapter's friendly name changed callback as "NULL" after de-initializing +* Bluetooth and check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise +* just set the callback with "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set bluetooth adapter's friendly name with "NULL" after de-initializing BT(if supported). +*/ +int utc_bluetooth_bt_adapter_set_name_changed_cb_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_name_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_set_name_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n +* @since_tizen 2.3 +* @description Call to set local bluetooth adapter's visibility mode changed callback as "NULL" and +* check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise +* just set the callback with "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set bluetooth adapter's visibility mode changed callback with "NULL". +*/ +int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_mode_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_visibility_mode_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n1 +* @since_tizen 2.3 +* @description Call to set local bluetooth adapter's visibility mode changed callback as "NULL" after de-initializing +* bluetooth and check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise +* just set the callback with "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set bluetooth adapter's visibility mode changed callback with "NULL" after de-initializing BT. +*/ +int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_mode_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_set_visibility_mode_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_state_n +* @since_tizen 2.3 +* @description Call to get local bluetooth adapter's current state and check the "ret" flag +* with BT_ERROR_INVALID_PARAMETER if le is supported otherwise call to get +* local bluetooth adapter's current state and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get current state of local Bluetooth adapter. +*/ +int utc_bluetooth_bt_adapter_get_state_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_state(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_get_state(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_state_n1 +* @since_tizen 2.3 +* @description Call to get local bluetooth adapter's current state after de-initializing Bluetooth and check the "ret" flag +* with BT_ERROR_NOT_INITIALIZED if le is supported otherwise call to get +* local bluetooth adapter's current state and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get current state of local Bluetooth adapter after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_get_state_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_get_state(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_get_state(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_address_n +* @since_tizen 2.3 +* @description Call to get local bluetooth adapter's address and check the "ret" flag with +* BT_ERROR_INVALID_PARAMETER if le is supported otherwise call to get the adapter's address +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get local Bluetooth adapter's address. +*/ +int utc_bluetooth_bt_adapter_get_address_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_address(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_get_address(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_address_n1 +* @since_tizen 2.3 +* @description Call to get local bluetooth adapter's address after de-initializing Bluetooth and check the "ret" flag with +* BT_ERROR_NOT_INITIALIZED if le is supported otherwise just call to get the adapter's address +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get local Bluetooth adapter's address after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_get_address_n1(void) +{ + char *address = NULL; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_get_address(&address); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_get_address(&address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_name_n +* @since_tizen 2.3 +* @description Call to get local bluetooth adapter's friendly name associated with and check the "ret" flag with +* BT_ERROR_INVALID_PARAMETER if le is supported otherwise just call to get the adapter's friendly name +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get local Bluetooth adapter's friendly name. +*/ +int utc_bluetooth_bt_adapter_get_name_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_name(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_get_name(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_name_n1 +* @since_tizen 2.3 +* @description Call to get local bluetooth adapter's friendly name associated with after de-initializing Bluetooth +* and check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just call +* to get the adapter's friendly name and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get local Bluetooth adapter's friendly name after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_get_name_n1(void) +{ + char *name = NULL; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_get_name(&name); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_get_name(&name); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_visibility_n +* @since_tizen 2.3 +* @description Call to get local Bluetooth adapter's current visibility mode and check the "ret" flag +* with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just call to get the +* adapter's current visibility mode and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get local Bluetooth adapter's current visibility mode. +*/ +int utc_bluetooth_bt_adapter_get_visibility_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_visibility(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_get_visibility(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_visibility_n1 +* @since_tizen 2.3 +* @description Call to get local Bluetooth adapter's current visibility mode after de-initializing Bluetooth and +* check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just call to get the +* adapter's current visibility mode and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get local Bluetooth adapter's current visibility mode after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_get_visibility_n1(void) +{ + int dur = 10; + bt_adapter_visibility_mode_e mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_get_visibility(&mode, &dur); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_get_visibility(&mode, &dur); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_name_n +* @since_tizen 2.3 +* @description Call to set local bluetooth adapter's friendly name with "NULL" and check the "ret" flag with +* BT_ERROR_INVALID_PARAMETER if le is supported otherwise just call to set local bluetooth adapter's +* friendly name with "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set local bluetooth adapter's friendly name with "NULL". +*/ +int utc_bluetooth_bt_adapter_set_name_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_name(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_name(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_name_n1 +* @since_tizen 2.3 +* @description Call to set local bluetooth adapter's friendly name with "NULL" after de-initializing bluetooth and check +* the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just call to set local +* bluetooth adapter's friendly name with "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set local bluetooth adapter's friendly name with "NULL" after de-initializing bluetooth. +*/ +int utc_bluetooth_bt_adapter_set_name_n1(void) +{ + char *name = "Test name"; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_name(name); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_set_name(name); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_unset_state_changed_cb_n +* @since_tizen 2.3 +* @description Call to unset local bluetooth adapter's state changed callback and check the "ret" flag with +* BT_ERROR_NOT_INITIALIZED if le is supported otherwise just unset local bluetooth adapter's +* state changed callback and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to unset local bluetooth adapter's state change callback. +*/ +int utc_bluetooth_bt_adapter_unset_state_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_unset_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_unset_name_changed_cb_n +* @since_tizen 2.3 +* @description Call to unset local bluetooth adapter's name changed callback after de-initializing Bluetooth and +* check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just call to unset local +* bluetooth adapter's name changed callback and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to unset local bluetooth adapter's name change callback after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_unset_name_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_name_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_unset_name_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_n +* @since_tizen 2.3 +* @description Call to unset local bluetooth adapter's visibility mode changed callback after de-initializing Bluetooth and +* check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just call to unset local +* bluetooth adapter's visibility mode changed callback and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to unset local bluetooth adapter's visibility changed callback after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_visibility_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_unset_visibility_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_local_oob_data_n +* @since_tizen 2.3 +* @description Call to get the Hash and Randmoizer value, synchronously by setting out param as "NULL" and +* check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just call to +* get the Hash and Randmoizer value, synchronously by setting out param as "NULL" and check the +* "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the Hash and Randmoizer value, synchronously by setting out param as "NULL". +*/ +int utc_bluetooth_bt_adapter_get_local_oob_data_n(void) +{ + if (bt_supported && oob_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_local_oob_data(NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_get_local_oob_data(NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; + +} + +/** +* @testcase utc_bluetooth_bt_adapter_is_service_used_n +* @since_tizen 2.3 +* @description Call to check whether the UUID of service is used or not setting service_uuid as "NULL" and check the "ret" +* flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just call to check whether the +* UUID of service is used by setting service_uuid as "NULL" check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to check whether the UUID of service is used by setting the service_uuid as "NULL". +*/ +int utc_bluetooth_bt_adapter_is_service_used_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_is_service_used(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_is_service_used(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_n +* @since_tizen 2.3 +* @description Call to set visibility duration changed callback as "NULL" and check the "ret" flag with +* BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to set visibility duration +* changed callback as "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set visibility duration changed callback as "NULL". +*/ +int utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_duration_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_visibility_duration_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_create_advertiser_n +* @since_tizen 2.3 +* @description Call to create advertiser to advertise device's existence after de-initializing Bluetooth and +* check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just try +* to create advertiser to advertise device's existence and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to create advertiser to advertise device's existence or respond to LE scanning reqeust. +*/ +int utc_bluetooth_bt_adapter_le_create_advertiser_n(void) +{ + bt_advertiser_h advertiser = NULL; + + if (le_supported) { + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_destroy_advertiser_n +* @since_tizen 2.3 +* @description Call to destroy advertiser after de-initializing Bluetooth after de-initializing bluetooth and +* check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just try +* to destroy advertiser and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to destroy advertiser. +*/ +int utc_bluetooth_bt_adapter_le_destroy_advertiser_n(void) +{ + bt_advertiser_h advertiser = NULL; + + if (le_supported) { + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_destroy_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_le_destroy_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_stop_advertising_n +* @since_tizen 2.3 +* @description Call to to stop advertising after de-initializing bluetooth and check the "ret" flag with +* BT_ERROR_NOT_INITIALIZED if le is supported otherwise just try to stop advertising +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to stop advertising after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_le_stop_advertising_n(void) +{ + bt_advertiser_h advertiser = NULL; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_stop_advertising(advertiser); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_le_stop_advertising(advertiser); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_clear_advertising_data_n +* @since_tizen 2.3 +* @description Call to clear all data to be advertised or responded to scan request from LE scanning device after +* de-initializing bluetooth and check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported +* otherwise just try clear the advertising data and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to clear all advertising data after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_le_clear_advertising_data_n(void) +{ + bt_advertiser_h advertiser = NULL; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_clear_advertising_data(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_le_clear_advertising_data(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void bt_adapter_vd_changed_cb(int duration, void *user_data) +{ + +} + +/** +* @testcase utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_n +* @since_tizen 2.3 +* @description Call to unset visibility duration changed callback after setting the callback and de-initializing bluetooth +* and then check the "ret" flag with BT_ERROR_NOT_INITIALIZED if le is supported +* otherwise just try to unsetthe callback and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to unset the visibility duration changed callback after de-initializing Bluetooth. +*/ +int utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_duration_changed_cb(bt_adapter_vd_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_visibility_duration_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_unset_visibility_duration_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_bonded_device_info_n +* @since_tizen 2.3 +* @description Call to get device information of a bonded device with "NULL" params and check the "ret" flag +* with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to get the device info with "NULL" +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get device information of a bonded device by setting the input device info param as "NULL". +*/ +int utc_bluetooth_bt_adapter_get_bonded_device_info_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_bonded_device_info(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_get_bonded_device_info(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_free_device_info_n +* @since_tizen 2.3 +* @description Call to free device information by setting the device info param as "NULL" and check the "ret" flag +* with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to free device information +* by setting the device info param as "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to free device information with "NULL" parameter. +*/ +int utc_bluetooth_bt_adapter_free_device_info_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_free_device_info(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_free_device_info(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_remote_oob_data_n +* @since_tizen 2.3 +* @description Call to set the Hash and Randmoizer value, synchronously by setting the input parameters "NULL" +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try +* set the value with "NULL" parameters and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set the Hash and Randmoizer value, synchronously with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_set_remote_oob_data_n(void) +{ + if (bt_supported && oob_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_remote_oob_data(NULL, NULL, NULL, 0, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_remote_oob_data(NULL, NULL, NULL, 0, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_remove_remote_oob_data_n +* @since_tizen 2.3 +* @description Call to delete the Hash and Randmoizer value, synchronously by setting the input parameter "NULL" +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try +* to delete the value with "NULL" parameter and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to delete the Hash and Randmoizer value, synchronously with "NULL" parameter. +*/ +int utc_bluetooth_bt_adapter_remove_remote_oob_data_n(void) +{ + if (bt_supported && oob_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_remove_remote_oob_data(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_remove_remote_oob_data(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_start_scan_n +* @since_tizen 2.3 +* @description Call to start scanning to find LE advertisement with "NULL" parameters and check the "ret" flag +* with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to start scanning with +* "NULL" parameters and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to start scanning with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_start_scan_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_start_scan(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_start_scan(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_stop_scan_n +* @since_tizen 2.3 +* @description Call to stop scanning after de-initializing Bluetooth and check the "ret" flag +* with BT_ERROR_NOT_INITIALIZED if le is supported otherwise just try to stop scanning +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to stop scanning. +*/ +int utc_bluetooth_bt_adapter_le_stop_scan_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_stop_scan(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_le_stop_scan(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_get_scan_result_service_uuids_n +* @since_tizen 2.3 +* @description Call to get the service UUID list from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise +* just try to get the service UUID list from the scan result with "NULL" parameters and check the +* "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the service UUID list from the scan result information with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_get_scan_result_service_uuids_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_service_uuids(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_get_scan_result_service_uuids(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_get_scan_result_device_name_n +* @since_tizen 2.3 +* @description Call to get the device name from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise +* just try to get the device name from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the device name from the scan result information with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_get_scan_result_device_name_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_device_name(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_get_scan_result_device_name(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_get_scan_result_tx_power_level_n +* @since_tizen 2.3 +* @description Call to get the transmission power level from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise +* just try to get the transmission power level from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the transmission power level from the scan result information with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_get_scan_result_tx_power_level_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_tx_power_level(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + } else { + ret = bt_adapter_le_get_scan_result_tx_power_level(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_get_scan_result_service_solicitation_uuids_n +* @since_tizen 2.3 +* @description Call to get the service solicitation UUID list from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise +* just try to get the service solicitation UUID list from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the service solicitation UUID list from the scan result information with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_get_scan_result_service_solicitation_uuids_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_service_solicitation_uuids(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_get_scan_result_service_solicitation_uuids(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_get_scan_result_service_data_list_n +* @since_tizen 2.3 +* @description Call to get the service data list from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise +* just try to get the service data list from the scan result information with "NULL" parameters +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the service data list from the scan result information with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_get_scan_result_service_data_list_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_service_data_list(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_get_scan_result_service_data_list(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_free_service_data_list_n +* @since_tizen 2.3 +* @description Call to free service data list with "NULL" data_list parameter and check the "ret" flag with +* BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to free service data list +* with "NULL" data_list parameter and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to free service data list with "NULL" data_list parameter. +*/ +int utc_bluetooth_bt_adapter_le_free_service_data_list_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_free_service_data_list(NULL, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_free_service_data_list(NULL, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_get_scan_result_appearance_n +* @since_tizen 2.3 +* @description Call to get the appearance from the scan result information with "NULL" parameters and check +* the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to get +* the appearance from the scan result information with "NULL" parameters and check the "ret" flag +* with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the appearance from the scan result information with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_get_scan_result_appearance_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_appearance(NULL, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_get_scan_result_appearance(NULL, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_get_scan_result_manufacturer_data_n +* @since_tizen 2.3 +* @description Call to get the manufacturer data from the scan result information with "NULL" parameters and check +* the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to get +* the manufacturer data from the scan result information with "NULL" parameters and check the "ret" flag +* with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get the manufacturer data from the scan result information with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_get_scan_result_manufacturer_data_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_manufacturer_data(NULL, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_get_scan_result_manufacturer_data(NULL, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_n +* @since_tizen 2.3 +* @description Call to add a service UUID to advertise or scan response data with "NULL" parameters and check +* the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to +* add a service UUID to advertise or scan response data with "NULL" parameters and check the "ret" flag +* with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to add a service UUID to advertise or scan response data with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_uuid(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_add_advertising_service_uuid(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_n +* @since_tizen 2.3 +* @description Call to add a service solicitation UUID to advertise or scan response data with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to +* add a service solicitation UUID to advertise or scan response data with "NULL" parameters and check +* the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to add a service solicitation UUID to advertise or scan response data with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_service_data_n +* @since_tizen 2.3 +* @description Call to add service data to advertise or scan response data with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to +* add service data to advertise or scan response data with "NULL" parameters and check +* the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to add service data to advertise or scan response data with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_service_data_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_data(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_add_advertising_service_data(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL, NULL, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_appearance_n +* @since_tizen 2.3 +* @description Call to set the external appearance of local device to advertise or scan response data with +* "NULL" advertiser parameter and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is +* supported otherwise just try to set the external appearance of this device to advertise or scan response +* data with "NULL"advertiser parameter and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set the external appearance of local device to advertise with "NULL" parameter. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_appearance_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_appearance(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_set_advertising_appearance(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_n +* @since_tizen 2.3 +* @description Call to add manufacturer specific data to advertise or scan response data with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to +* add manufacturer specific data to advertise or scan response data with "NULL" parameters and check +* the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to add manufacturer specific data to advertise or scan response data with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_manufacturer_data(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, 0, NULL, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_add_advertising_manufacturer_data(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, 0, NULL, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_device_name_n +* @since_tizen 2.3 +* @description Call to set the device name in advertising data or scan response data with "NULL" and "FALSE" +* parameters and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported +* otherwise just try to set the device name in advertising data or scan response data with +* "NULL" and "FALSE" parameters and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set the device name in advertising data or scan response data with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_device_name_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_device_name(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, false); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_set_advertising_device_name(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, false); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_n +* @since_tizen 2.3 +* @description Call to set whether the transmission power level should be included in advertise or scan response data +* with "NULL" parameters and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported +* otherwise just try to set transmission power level data in advertise or scan response data with "NULL" +* parameters and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set whether the transmission power level should be included in advertise data with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_tx_power_level(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, false); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_set_advertising_tx_power_level(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, false); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_start_advertising_new_n +* @since_tizen 2.3 +* @description Call to start advertising with "NULL" parameters and check the "ret" flag with BT_ERROR_INVALID_PARAMETER +* if le is supported otherwise just try to start advertising with "NULL" parameters with "NULL" parameters +* and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to start advertising with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_start_advertising_new_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_start_advertising_new(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_start_advertising_new(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_mode_n +* @since_tizen 2.3 +* @description Call to set advertising mode to control the advertising power and latency with "NULL" advertiser parameter +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to +* set advertising mode to control the advertising power and latency with "NULL" parameter and check +* the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set advertising mode to control the advertising power and latency with "NULL" parameter. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_mode_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_mode(NULL, BT_ADAPTER_LE_ADVERTISING_MODE_BALANCED); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_set_advertising_mode(NULL, BT_ADAPTER_LE_ADVERTISING_MODE_BALANCED); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_connectable_n +* @since_tizen 2.3 +* @description Call to set whether the advertising type should be connectable or non-connectable with "NULL" parameters +* and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to +* set whether the advertising type should be connectable or non-connectable with "NULL" parameters and check +* the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set whether the advertising type should be connectable or +* non-connectable with "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_connectable_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_connectable(NULL, false); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_set_advertising_connectable(NULL, false); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_get_uuid_name_n +* @since_tizen 3.0 +* @description Call to get uuid name with "NULL" parameters and check the "ret" flag with BT_ERROR_INVALID_PARAMETER +* if le is supported otherwise just try to get uuid name with "NULL" parameters and check the "ret" flag +* with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get uuid name "NULL" parameters. +*/ +int utc_bluetooth_bt_get_uuid_name_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_get_uuid_name(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_get_uuid_name(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_scan_mode_n +* @since_tizen 3.0 +* @description Call to set LE scan mode after deinitializing Bluetooth and check the "ret" +* flag with BT_ERROR_NOT_INITIALIZED if LE is supported otherwise just try to set LE scan mode +* check the "ret" flag with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set LE scan mode. + +*/ +int utc_bluetooth_bt_adapter_le_set_scan_mode_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_scan_mode(BT_ADAPTER_LE_SCAN_MODE_BALANCED); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_le_set_scan_mode(BT_ADAPTER_LE_SCAN_MODE_BALANCED); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_local_oob_ext_data_n +* @since_tizen 3.0 +* @description Call to get local oob ext data with "NULL" parameters and check the "ret" flag with BT_ERROR_INVALID_PARAMETER +* if le is supported otherwise just try to get uuid name with "NULL" parameters and check the "ret" flag +* with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to get local oob ext data "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_get_local_oob_ext_data_n(void) +{ + if (bt_supported && oob_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_get_local_oob_ext_data(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_get_local_oob_ext_data(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_remote_oob_ext_data_n +* @since_tizen 3.0 +* @description Call to set remotel oob ext data with "NULL" parameters and check the "ret" flag with BT_ERROR_INVALID_PARAMETER +* if le is supported otherwise just try to get uuid name with "NULL" parameters and check the "ret" flag +* with BT_ERROR_NOT_SUPPORTED. +* @scenario Negative scenario to set remote oob ext data "NULL" parameters. +*/ +int utc_bluetooth_bt_adapter_set_remote_oob_ext_data_n(void) +{ + if (bt_supported && oob_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_set_remote_oob_ext_data(NULL, NULL, NULL, 0, 0, NULL, NULL, 0, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_remote_oob_ext_data(NULL, NULL, NULL, 0, 0, NULL, NULL, 0, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_create_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_create(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_create(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_destroy_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_destroy(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_destroy(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_device_address_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_device_address(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_device_address(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_device_name_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_device_name(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_device_name(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_service_uuid(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_service_uuid(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_service_uuid_with_mask_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_service_uuid_with_mask(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_service_uuid_with_mask(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_service_solicitation_uuid(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_service_solicitation_uuid(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_service_solicitation_uuid_with_mask_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_service_solicitation_uuid_with_mask(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_service_solicitation_uuid_with_mask(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_service_data(NULL, NULL, NULL, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_service_data(NULL, NULL, NULL, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_service_data_with_mask_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_service_data_with_mask(NULL, NULL, NULL, 8, NULL, 8); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_service_data_with_mask(NULL, NULL, NULL, 8, NULL, 8); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_manufacturer_data(NULL, 0, NULL, 8); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_manufacturer_data(NULL, 0, NULL, 8); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_manufacturer_data_with_mask_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_manufacturer_data_with_mask(NULL, 0, NULL, 8, NULL, 8); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_manufacturer_data_with_mask(NULL, 0, NULL, 8, NULL, 8); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_register_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_register(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_register(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_unregister_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_unregister(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_unregister(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_unregister_all_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_unregister_all(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_le_scan_filter_unregister_all(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_type_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_scan_filter_set_type(NULL, BT_ADAPTER_LE_SCAN_FILTER_TYPE_IBEACON); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_scan_filter_set_type(NULL, BT_ADAPTER_LE_SCAN_FILTER_TYPE_IBEACON); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_get_scan_result_ibeacon_report(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_get_scan_result_ibeacon_report(NULL, BT_ADAPTER_LE_PACKET_ADVERTISING, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_free_ibeacon_report_n(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_free_ibeacon_report(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_free_ibeacon_report(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_is_2m_phy_supported_n(void) +{ + if (le_50_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_is_2m_phy_supported(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_is_2m_phy_supported(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_is_coded_phy_supported_n(void) +{ + if (le_50_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_is_coded_phy_supported(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_le_is_coded_phy_supported(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_adapter_positive.c b/tests/unittest/utc_bluetooth_adapter_positive.c new file mode 100644 index 0000000..23b41f4 --- /dev/null +++ b/tests/unittest/utc_bluetooth_adapter_positive.c @@ -0,0 +1,1484 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include +#include + +//& set: BluetoothAdapterPositive + +static int startup_flag = BT_ERROR_NONE; +static GMainLoop *mainloop = NULL; +static int ret = BT_ERROR_NONE; +static bool callback_result = false; +static char adapter_name[128] = "dts_test"; +static bool le_supported = false; +static bool bt_supported = false; +static bool oob_supported = false; +static bool le_50_supported = false; + +static int manufacturer_id = 117; +static char *manufacture = NULL; +static char manufacture_0[] = { 0x0, 0x0, 0x0, 0x0 }; +static char manufacture_3[] = { 0x03, 0x03, 0x03, 0x03 }; +static char service_data[] = { 0x01, 0x02, 0x03 }; + +static const char *time_svc_uuid_16 = "1805"; +static const char *battery_svc_uuid_16 = "180f"; +static const char *heart_rate_svc_uuid_16 = "180d"; + +static void adapter_state_changed_cb_for_adapter_p(int result, bt_adapter_state_e adapter_state, void *user_data) +{ + if (user_data != NULL) { + if (!strcmp((char *)user_data, "enable")) { + if (BT_ADAPTER_ENABLED == adapter_state) { + callback_result = true; + } + } else if (!strcmp((char *)user_data, "disable")) { + if (BT_ADAPTER_DISABLED == adapter_state) { + callback_result = true; + } + } + } + + if (mainloop) { + g_main_loop_quit(mainloop); + } +} + +static void adapter_name_changed_cb_for_adapter_p(char *device_name, void *user_data) +{ + if (user_data != NULL && !strcmp((char *)user_data, "set_name")) { + if (!strcmp(device_name, adapter_name)) { + callback_result = true; + } else { + fprintf(stderr, "device_name: %s \n", device_name); + fprintf(stderr, "adapter_name: %s \n", adapter_name); + } + } + + if (mainloop) { + g_main_loop_quit(mainloop); + } +} + +static void adapter_visibility_mode_changed_cb_for_adpater_p(int result, bt_adapter_visibility_mode_e visibility_mode, void *user_data) +{ + fprintf(stderr, "adapter_visibility_mode_changed_cb_for_adpater_p was called.\n"); + + callback_result = true; + + if (mainloop) { + g_main_loop_quit(mainloop); + } +} + +static void wait_for_async() +{ + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); +} + +/** + * @function utc_bluetooth_adapter_positive_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_adapter_positive_startup(void) +{ + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + startup_flag = BT_ERROR_NONE; + +#ifdef TV + bt_supported = true; + le_supported = true; +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + le_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le", &le_supported); + + oob_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.oob", &oob_supported); + + le_50_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le.5_0", &le_50_supported); +#endif + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + callback_result = false; + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_adapter_positive_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_adapter_positive_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +#if defined(MOBILE) || defined(TV) || defined(TIZENIOT) +/** +* @testcase utc_bluetooth_bt_adapter_le_is_discovering_p +* @since_tizen 2.3 +* @description Does assert check for startup_flag before checking LE device discovery +* (is in progress or not) when le is supported otherwise just check for the +* LE device discovery status. +* @scenario Checks for the LE device discovery status; is in progress or not. +*/ +int utc_bluetooth_bt_adapter_le_is_discovering_p(void) +{ + bool is_discovery = FALSE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_is_discovering(&is_discovery); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_is_discovering(&is_discovery); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} +#endif + +/** +* @testcase utc_bluetooth_bt_adapter_set_state_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then set the callback function to be invoked +* when Bluetooth adapter state changes if le is supported otherwise just set the +* callback. +* @scenario Registers a callback function to be invoked when the Bluetooth adapter state changes. +*/ +int utc_bluetooth_bt_adapter_set_state_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_adapter_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_adapter_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_name_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then Registers a callback function to be +* invoked when the name of Bluetooth adapter changes; then unset the callback +* if le is supported otherwise just registers the callback function. +* @scenario Set a callback function to be invoked when the name of Bluetooth adapter changes. +*/ +int utc_bluetooth_bt_adapter_set_name_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_set_name_changed_cb(adapter_name_changed_cb_for_adapter_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_name_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_set_name_changed_cb(adapter_name_changed_cb_for_adapter_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_name_changed_cb_p1 +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then Registers a callback function to be +* invoked when the name of Bluetooth adapter changes if le is supported otherwise +* just registers the callback function. +* @scenario Set a callback function to be invoked when the name of Bluetooth adapter changes. +*/ +int utc_bluetooth_bt_adapter_set_name_changed_cb_p1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + +#if defined(MOBILE) || defined(TIZENIOT) + char name[128] = "test"; + snprintf(name, 128, "%s", adapter_name); + strncpy(adapter_name, name, 128); +#endif + ret = bt_adapter_set_name_changed_cb(adapter_name_changed_cb_for_adapter_p, "set_name"); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_set_name_changed_cb(adapter_name_changed_cb_for_adapter_p, "set_name"); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then Registers a callback function to be +* invoked when the visibility mode of Bluetooth adapter changes and unset the +* callback if le is supported otherwise just registers the callback function. +* @scenario Set a callback function to be invoked when visibility mode of Bluetooth adapter changes. +*/ +int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_mode_changed_cb(adapter_visibility_mode_changed_cb_for_adpater_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_visibility_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_set_visibility_mode_changed_cb(adapter_visibility_mode_changed_cb_for_adpater_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p1 +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then Registers a callback function to be +* invoked when the visibility mode of Bluetooth adapter changes if le is supported +* otherwise just registers the callback function. +* @scenario Set a callback function to be invoked when visibility mode of Bluetooth adapter changes. +*/ +int utc_bluetooth_bt_adapter_set_visibility_mode_changed_cb_p1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_set_visibility_mode_changed_cb(adapter_visibility_mode_changed_cb_for_adpater_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_set_visibility_mode_changed_cb(adapter_visibility_mode_changed_cb_for_adpater_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_state_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then get the current state of Adapter +* if le is supported otherwise just get the current state of Adapter. +* @scenario Call to get the current state of adapter. +*/ +int utc_bluetooth_bt_adapter_get_state_p(void) +{ + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_state(&adapter_state); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_get_state(&adapter_state); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_address_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then gets the address of local Bluetooth adapter +* if le is supported otherwise just gets the address of local Bluetooth adapter. +* @scenario Call to get the bluetooth address of local adapter. +*/ +int utc_bluetooth_bt_adapter_get_address_p(void) +{ + char *address = NULL; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_address(&address); + assert_eq(ret, BT_ERROR_NONE); + + free(address); + address = NULL; + } else { + ret = bt_adapter_get_address(&address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_name_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then gets the friendly name +* of local Bluetooth Adapter if le is supported otherwise just gets the +* name of local Bluetooth adapter. +* @scenario Call to get the friendly name associated with local adapter. +*/ +int utc_bluetooth_bt_adapter_get_name_p(void) +{ + char *name = NULL; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_name(&name); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_get_name(&name); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_visibility_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then gets the visibility mode +* of local Bluetooth Adapter if le is supported otherwise just gets the +* the visibility mode of local Bluetooth adapter. +* @scenario Call to get the visibility mode of local bluetooth adapter. +*/ +int utc_bluetooth_bt_adapter_get_visibility_p(void) +{ + int dur = 1; + bt_adapter_visibility_mode_e mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_get_visibility(&mode, &dur); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_get_visibility(&mode, &dur); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_name_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then sets the name of local Bluetooth adapter +* if le is supported otherwise just sets the name of local Bluetooth adapter. +* @scenario Call to set the friendly name for local bluetooth adapter. +*/ +int utc_bluetooth_bt_adapter_set_name_p(void) +{ + if (bt_supported) { + ret = bt_adapter_set_name_changed_cb(adapter_name_changed_cb_for_adapter_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_name("Test name"); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + } else { + ret = bt_adapter_set_name(adapter_name); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; + +} + +/** +* @testcase utc_bluetooth_bt_adapter_unset_state_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then register the adapter state change callback +* and unregister it if le is supported otherwise just unregister the callback. +* @scenario Call to unset the adapter's state changed callback. +*/ +int utc_bluetooth_bt_adapter_unset_state_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_adapter_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_unset_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_unset_name_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then register the name changed callback +* and unregister it if le is supported otherwise just unregister the callback. +* @scenario Call to unset the adapter's name changed callback. +*/ +int utc_bluetooth_bt_adapter_unset_name_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_name_changed_cb(adapter_name_changed_cb_for_adapter_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_name_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_unset_name_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag" then register the visibility mode changed callback +* and unregister it if le is supported otherwise just unregister the callback. +* @scenario Call to unset the adapter's visibility mode changed callback. +*/ +int utc_bluetooth_bt_adapter_unset_visibility_mode_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_mode_changed_cb(adapter_visibility_mode_changed_cb_for_adpater_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_visibility_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_unset_visibility_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_local_oob_data_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag". Gets the Hash and Randmoizer value, +* synchronously when le is supported or not supported. +* @scenario Call to get the Hash and Randmoizer value, synchronously. +*/ +int utc_bluetooth_bt_adapter_get_local_oob_data_p(void) +{ + assert_eq(startup_flag, BT_ERROR_NONE); + + unsigned char *hash = NULL; + unsigned char *randomizer = NULL; + int hash_len = 0; + int randomizer_len = 0; + + if (bt_supported && oob_supported) { + ret = bt_adapter_get_local_oob_data(&hash, &randomizer, &hash_len, &randomizer_len); + + free(hash); + hash = NULL; + + free(randomizer); + randomizer = NULL; + + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_get_local_oob_data(&hash, &randomizer, &hash_len, &randomizer_len); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_is_service_used_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag". Checks whether the UUID of service is +* used or not when le is supported or not supported. +* @scenario Call to check whether the UUID of service is used or not. +*/ +int utc_bluetooth_bt_adapter_is_service_used_p(void) +{ + assert_eq(startup_flag, BT_ERROR_NONE); + + bool used = false; + const char *service_uuid = "00001105-0000-1000-8000-00805f9b34fb"; + + if (bt_supported) { + ret = bt_adapter_is_service_used(service_uuid, &used); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_is_service_used(service_uuid, &used); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_clear_advertising_data_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence or respond to LE scanning reqeust then clear all data to be advertised +* or responded to scan request from LE scanning device and then destroy the advertiser +* if le is supported otherwise just create advertiser to advertise device's +* existence or respond to LE scanning reqeust. +* @scenario Call to clear all data to be advertised or responded to scan request from LE scanning device. +*/ +int utc_bluetooth_bt_adapter_le_clear_advertising_data_p(void) +{ + bt_advertiser_h advertiser = NULL; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_clear_advertising_data(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING); + + bt_adapter_le_destroy_advertiser(advertiser); + + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void bt_adapter_vd_changed_cb(int duration, void *user_data) +{ + +} + +/** +* @testcase utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", registers a callback function to be invoked +* every second untill the visibility mode is changed and then unregister the callback +* if le is supported otherwise just registers the callback function. +* @scenario Call to set visibility duration changed callback for local adapter. +*/ +int utc_bluetooth_bt_adapter_set_visibility_duration_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_duration_changed_cb(bt_adapter_vd_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_adapter_unset_visibility_duration_changed_cb(); + } else { + ret = bt_adapter_set_visibility_duration_changed_cb(bt_adapter_vd_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_create_advertiser_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence or respond to LE scanning reqeust then destroy the advertiser +* if le is supported otherwise just create the advertiser. +* @scenario Call to create advertiser to advertise device's existence for local adapter. +*/ +int utc_bluetooth_bt_adapter_le_create_advertiser_p(void) +{ + bt_advertiser_h advertiser = NULL; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + bt_adapter_le_destroy_advertiser(advertiser); + } else { + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_destroy_advertiser_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence or respond to LE scanning reqeust then destroy the advertiser +* if le is supported otherwise just destroy the advertiser. +* @scenario Call to destroy advertiser for local adapter. +*/ +int utc_bluetooth_bt_adapter_le_destroy_advertiser_p(void) +{ + bt_advertiser_h second_advertiser = NULL; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_create_advertiser(&second_advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_destroy_advertiser(second_advertiser); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_destroy_advertiser(second_advertiser); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_adapter_le_advertising_state_changed_cb(int result, bt_advertiser_h advertiser, bt_adapter_le_advertising_state_e adv_state, void *user_data) +{ + if (mainloop) + g_main_loop_quit(mainloop); +} + +#if defined(MOBILE) || defined(TIZENIOT) +/** +* @testcase utc_bluetooth_bt_adapter_le_stop_advertising_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence or respond to LE scanning reqeust then start advertising then +* stop advertsing and then destroy the advertiser if le is supported otherwise +* just stop advertising. +* @scenario Call to stop advertising for the remote BLE scanning devices. +*/ +int utc_bluetooth_bt_adapter_le_stop_advertising_p(void) +{ + bt_advertiser_h advertiser = NULL; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + /* add advertising data start */ + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, time_svc_uuid_16, service_data, sizeof(service_data)); + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_device_name(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); + + assert_eq(ret, BT_ERROR_NONE); + + manufacture = manufacture_0; + ret = bt_adapter_le_add_advertising_manufacturer_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, manufacturer_id, manufacture, sizeof(manufacture_0)); + + assert_eq(ret, BT_ERROR_NONE); + /* add advertising data end */ + + ret = bt_adapter_le_start_advertising_new(advertiser, __bt_adapter_le_advertising_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) { + bt_adapter_le_destroy_advertiser(advertiser); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_stop_advertising(advertiser); + if (ret != BT_ERROR_NONE) { + bt_adapter_le_destroy_advertiser(advertiser); + } + + assert_eq(ret, BT_ERROR_NONE); + + bt_adapter_le_destroy_advertiser(advertiser); + } else { + ret = bt_adapter_le_stop_advertising(advertiser); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} +#endif + +/** +* @testcase utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", set the visibility duration changed +* callback then unset the callback if le is supported otherwise +* just unset the visibility duration changed callback. +* @scenario Call to unregister visibility duration changed callback for local adapter. +*/ +int utc_bluetooth_bt_adapter_unset_visibility_duration_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_visibility_duration_changed_cb(bt_adapter_vd_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_visibility_duration_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_unset_visibility_duration_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_adapter_le_scan_result_cb(int result, bt_adapter_le_device_scan_result_info_s *info, void *user_data) +{ + if (mainloop) + g_main_loop_quit(mainloop); +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_start_scan_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", start scanning the advertising devices +* if le is supported otherwise just start scanning the advertising devices. +* Stop the scanning process. +* @scenario Call to start LE scan to find LE advertisement of remote advertising devices. +*/ +int utc_bluetooth_bt_adapter_le_start_scan_p(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_start_scan(__bt_adapter_le_scan_result_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + + ret = bt_adapter_le_stop_scan(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_start_scan(__bt_adapter_le_scan_result_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_stop_scan_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", start scanning the advertising devices +* then stop scanning if le is supported otherwise just stop scanning. +* @scenario Call to stop LE scan. +*/ +int utc_bluetooth_bt_adapter_le_stop_scan_p(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_start_scan(__bt_adapter_le_scan_result_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + + ret = bt_adapter_le_stop_scan(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_stop_scan(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then add a service UUID to advertise or scan response data (The maximum +* advertised or responded data size is 31 bytes including data type and system wide data) +* then clear the advertsing data and destroy the advertiser if le is supported otherwise +* just add a service UUID to advertise or scan response data and clear the adv data. +* @scenario Call to add a service UUID to advertise. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, pkt_type, time_svc_uuid_16); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, pkt_type, time_svc_uuid_16); + + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then add a service solicitation UUID to advertise data (The maximum +* advertised or responded data size is 31 bytes including data type and system wide data) +* then clear the advertsing data and destroy the advertiser if le is supported otherwise +* add a service solicitation UUID to advertise data and clear the adv data. +* @scenario Call to add a service solicitation UUID to advertise. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, pkt_type, heart_rate_svc_uuid_16); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_add_advertising_service_solicitation_uuid(advertiser, pkt_type, heart_rate_svc_uuid_16); + + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_service_data_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then add service data to advertise (The maximum +* advertised or responded data size is 31 bytes including data type and system wide data) +* then clear the advertsing data and destroy the advertiser if le is supported otherwise +* add service data to advertise and clear the advertising data. +* @scenario Call to add the service data to advertise. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_service_data_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_SCAN_RESPONSE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_data(advertiser, pkt_type, time_svc_uuid_16, service_data, sizeof(service_data)); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_add_advertising_service_data(advertiser, pkt_type, time_svc_uuid_16, service_data, sizeof(service_data)); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_appearance_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then sets the external appearance of local device to advertise +* then clear the advertsing data and destroy the advertiser if le is supported otherwise +* sets the external appearance of local device to advertise and clear the advertising data. +* @scenario Call to add the external appearance of local device to advertise. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_appearance_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_SCAN_RESPONSE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_appearance(advertiser, pkt_type, 4); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_set_advertising_appearance(advertiser, pkt_type, 4); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then add manufacturer specific data to advertise +* then clear the advertsing data and destroy the advertiser if le is supported otherwise +* just add manufacturer specific data to advertise and clear the advertising data. +* @scenario Call to add manufacturer specific data to advertise. +*/ +int utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_SCAN_RESPONSE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + bt_adapter_le_create_advertiser(&advertiser); + manufacture = manufacture_3; + ret = bt_adapter_le_add_advertising_manufacturer_data(advertiser, pkt_type, manufacturer_id, manufacture, sizeof(manufacture_0)); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + bt_adapter_le_destroy_advertiser(advertiser); + } + manufacture = NULL; + } else { + ret = bt_adapter_le_add_advertising_manufacturer_data(advertiser, pkt_type, manufacturer_id, manufacture, sizeof(manufacture_0)); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_clear_advertising_data(advertiser, pkt_type); + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_device_name_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then add local device name to advertise (The maximum advertised +* or responded data size is 31 bytes including data type and system wide data) +* and then destroy the advertiser if le is supported otherwise +* just add add device name to advertising data. +* @scenario Call to add device advertise name to advertise. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_device_name_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_SCAN_RESPONSE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_device_name(advertiser, pkt_type, true); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_set_advertising_device_name(advertiser, pkt_type, true); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then add transmission power level to advertise then destroy the advertiser +* if le is supported otherwise just add transmission power level to advertsing data. +* @scenario Call to add transmission power level to advertise. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_tx_power_level(advertiser, pkt_type, true); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_set_advertising_tx_power_level(advertiser, pkt_type, true); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_start_advertising_new_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then start advertising with passed advertiser and advertising parameters +* then destroy the advertiser if le is supported otherwise just Start and stop advertising. +* @scenario Call to start advertising with passed advertiser and advertising parameters. +*/ +int utc_bluetooth_bt_adapter_le_start_advertising_new_p(void) +{ + bt_advertiser_h advertiser = NULL; + bt_adapter_le_advertising_state_changed_cb cb; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + bt_adapter_le_create_advertiser(&advertiser); + + cb = __bt_adapter_le_advertising_state_changed_cb; + + /* add advertising data start */ + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING, time_svc_uuid_16); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_uuid(advertiser, BT_ADAPTER_LE_PACKET_ADVERTISING, battery_svc_uuid_16); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_add_advertising_service_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, time_svc_uuid_16, service_data, sizeof(service_data)); + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_device_name(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); + + assert_eq(ret, BT_ERROR_NONE); + + manufacture = manufacture_0; + ret = bt_adapter_le_add_advertising_manufacturer_data(advertiser, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, manufacturer_id, manufacture, sizeof(manufacture_0)); + + assert_eq(ret, BT_ERROR_NONE); + /* add advertising data end */ + + ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + + if (ret == BT_ERROR_NONE) { + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + cb = __bt_adapter_le_advertising_state_changed_cb; + ret = bt_adapter_le_start_advertising_new(advertiser, cb, NULL); + + if (ret == BT_ERROR_NONE) { + bt_adapter_le_stop_advertising(advertiser); + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_mode_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then set advertising mode to control the advertising power and latency +* then destroy the advertiser if le is supported otherwise just Set advertising mode +* to control the advertising power and latency. +* @scenario Call to set advertising mode to control the advertising power and latency. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_mode_p(void) +{ + bt_advertiser_h advertiser = NULL; + int mode = BT_ADAPTER_LE_ADVERTISING_MODE_BALANCED; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_mode(advertiser, mode); + assert_eq(ret, BT_ERROR_NONE); + + if (ret == BT_ERROR_NONE) { + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_set_advertising_mode(advertiser, mode); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_advertising_connectable_p +* @since_tizen 2.3 +* @description Does assert check for "startup_flag", create advertiser to advertise device's +* existence then set whether the advertising type should be connectable or non-connectable +* then destroy the advertiser if le is supported otherwise just set whether the advertising +* type should be connectable or non-connectable. +* @scenario Call to set whether the advertising type should be connectable or non-connectable. +*/ +int utc_bluetooth_bt_adapter_le_set_advertising_connectable_p(void) +{ + bt_advertiser_h advertiser = NULL; + int type = 0x00; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_create_advertiser(&advertiser); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_le_set_advertising_connectable(advertiser, type); + assert_eq(ret, BT_ERROR_NONE); + if (ret == BT_ERROR_NONE) { + bt_adapter_le_destroy_advertiser(advertiser); + } + } else { + ret = bt_adapter_le_set_advertising_connectable(advertiser, type); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_get_uuid_name_p +* @since_tizen 3.0 +* @description Does assert check for "startup_flag" then gets the uuid name if bt is supported +* otherwise just gets the uuid name. +* @scenario Call to get the uuid name. +*/ +int utc_bluetooth_bt_get_uuid_name_p(void) +{ + char *uuid = NULL; + char *name = NULL; + + uuid = g_strdup("00001101-0000-1000-8000-00805F9B7777"); + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_get_uuid_name(uuid, &name); + g_free(uuid); + g_free(name); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_get_uuid_name(uuid, &name); + g_free(uuid); + g_free(name); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_le_set_scan_mode_p +* @since_tizen 3.0 +* @description Does assert check for "startup_flag" then set the scan mode if bt is supported +* otherwise just sets the scan mode. +* @scenario Call to set the scan mode. +*/ +int utc_bluetooth_bt_adapter_le_set_scan_mode_p(void) +{ + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_le_set_scan_mode(BT_ADAPTER_LE_SCAN_MODE_BALANCED); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_set_scan_mode(BT_ADAPTER_LE_SCAN_MODE_BALANCED); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** +* @testcase utc_bluetooth_bt_adapter_get_local_oob_ext_data_p +* @since_tizen 3.0 +* @description Does assert check for "startup_flag" then gets the uuid name if bt is supported +* otherwise just gets the uuid name. +* @scenario Call to get the uuid name. +*/ +int utc_bluetooth_bt_adapter_get_local_oob_ext_data_p(void) +{ + unsigned char *data[4]; + int len[4]; + int i; + + if (bt_supported && oob_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_adapter_get_local_oob_ext_data(&data[0], &data[1], &len[0], &len[1], &data[2], &data[3], &len[2], &len[3]); + + for (i = 0; i < 4; i++) { + g_free(data[i]); + } + + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_get_local_oob_ext_data(&data[0], &data[1], &len[0], &len[1], &data[2], &data[3], &len[2], &len[3]); + + if (ret == BT_ERROR_NONE) { + for (i = 0; i < 4; i++) { + g_free(data[i]); + } + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_scan_filter_set_type_p(void) +{ + bt_scan_filter_h scan_filter = NULL; + int result = BT_ERROR_NONE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + result = bt_adapter_le_scan_filter_create(&scan_filter); + + result = bt_adapter_le_scan_filter_set_type(scan_filter, BT_ADAPTER_LE_SCAN_FILTER_TYPE_IBEACON); + + result = bt_adapter_le_scan_filter_destroy(scan_filter); + assert_eq(ret, BT_ERROR_NONE); + } else { + result = bt_adapter_le_scan_filter_set_type(scan_filter, BT_ADAPTER_LE_SCAN_FILTER_TYPE_IBEACON); + assert_eq(result, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static bt_adapter_le_device_scan_result_info_s *__bt_create_le_device_scan_info_s(void) +{ + bt_adapter_le_device_scan_result_info_s *scan_info = NULL; + + scan_info = (bt_adapter_le_device_scan_result_info_s *)malloc(sizeof(bt_adapter_le_device_scan_result_info_s)); + if (scan_info == NULL) { + return NULL; + } + + memset(scan_info, 0x00, sizeof(bt_adapter_le_device_scan_result_info_s)); + + scan_info->remote_address = g_strdup("00:1B:66:01:23:1C"); + scan_info->address_type = BT_DEVICE_PUBLIC_ADDRESS; + scan_info->rssi = -31; + scan_info->adv_data_len = 31; + scan_info->adv_data = malloc(scan_info->adv_data_len); + if (scan_info->adv_data) { + + scan_info->adv_data[0] = 28; + scan_info->adv_data[1] = 0xff; + + /* Company ID 0x004C */ + scan_info->adv_data[2] = 0x4c; + scan_info->adv_data[3] = 0x00; + + /* UUID */ + scan_info->adv_data[4] = 0x01; + scan_info->adv_data[5] = 0x01; + scan_info->adv_data[6] = 0x01; + scan_info->adv_data[7] = 0x01; + scan_info->adv_data[8] = 0x01; + scan_info->adv_data[9] = 0x01; + scan_info->adv_data[10] = 0x01; + scan_info->adv_data[11] = 0x01; + scan_info->adv_data[12] = 0x01; + scan_info->adv_data[13] = 0x01; + scan_info->adv_data[14] = 0x01; + scan_info->adv_data[15] = 0x01; + scan_info->adv_data[16] = 0x01; + scan_info->adv_data[17] = 0x01; + scan_info->adv_data[18] = 0x01; + scan_info->adv_data[19] = 0x01; + + /* Major ID */ + scan_info->adv_data[20] = 0x02; + scan_info->adv_data[21] = 0x01; + + /* Minor ID */ + scan_info->adv_data[22] = 0x02; + scan_info->adv_data[23] = 0x01; + + /* Power */ + scan_info->adv_data[24] = -31; + } + + return scan_info; +} + +static void __bt_free_le_device_scan_info_s(bt_adapter_le_device_scan_result_info_s *scan_info) +{ + if (scan_info == NULL) { + return; + } + + if (scan_info->remote_address != NULL) { + free(scan_info->remote_address); + } + + if (scan_info->adv_data != NULL) { + free(scan_info->adv_data); + } + + free(scan_info); + scan_info = NULL; +} + +int utc_bluetooth_bt_adapter_le_get_scan_result_ibeacon_report_p(void) +{ + bt_adapter_le_device_scan_result_info_s *info = NULL; + bt_adapter_le_ibeacon_scan_result_info_s *ibeacon_info = NULL; + int result = BT_ERROR_NONE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + info = __bt_create_le_device_scan_info_s(); + + result = bt_adapter_le_get_scan_result_ibeacon_report(info, BT_ADAPTER_LE_PACKET_ADVERTISING, &ibeacon_info); + + __bt_free_le_device_scan_info_s(info); + result = bt_adapter_le_free_ibeacon_report(ibeacon_info); + assert_eq(result, BT_ERROR_NONE); + } else { + result = bt_adapter_le_get_scan_result_ibeacon_report(info, BT_ADAPTER_LE_PACKET_ADVERTISING, &ibeacon_info); + assert_eq(result, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_free_ibeacon_report_p(void) +{ + bt_adapter_le_device_scan_result_info_s *info = NULL; + bt_adapter_le_ibeacon_scan_result_info_s *ibeacon_info = NULL; + int result = BT_ERROR_NONE; + + if (le_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + info = __bt_create_le_device_scan_info_s(); + + result = bt_adapter_le_get_scan_result_ibeacon_report(info, BT_ADAPTER_LE_PACKET_ADVERTISING, &ibeacon_info); + + __bt_free_le_device_scan_info_s(info); + result = bt_adapter_le_free_ibeacon_report(ibeacon_info); + assert_eq(result, BT_ERROR_NONE); + } else { + result = bt_adapter_le_free_ibeacon_report(ibeacon_info); + assert_eq(result, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_is_2m_phy_supported_p(void) +{ + bool is_supported = false; + + if (le_50_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_is_2m_phy_supported(&is_supported); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_is_2m_phy_supported(&is_supported); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_adapter_le_is_coded_phy_supported_p(void) +{ + bool is_supported = false; + + if (le_50_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_le_is_coded_phy_supported(&is_supported); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_le_is_coded_phy_supported(&is_supported); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_audio_negative.c b/tests/unittest/utc_bluetooth_audio_negative.c new file mode 100644 index 0000000..5784dec --- /dev/null +++ b/tests/unittest/utc_bluetooth_audio_negative.c @@ -0,0 +1,872 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include + +//& set: BluetoothAudioNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool bt_supported = false; +static bool media_supported = false; +static bool call_supported = false; +static bool control_supported = false; + +/** + * @function utc_bluetooth_bt_audio_negative_startup + * @description check if bluetooth is supported, initialize bluetooth. + * check if media or call feature is supported, then initialize the audio profiles. + * @scenario initializes the bluetooth API and audio profiles, this needs to be called before each test. + * @parameter NA + * @return NA + */ +void utc_bluetooth_bt_audio_negative_startup(void) +{ +#ifdef TV + bt_supported = true; + media_supported = true; + call_supported = false; + control_supported = false; +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + media_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.media", &media_supported); + + call_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.call", &call_supported); + + control_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.controller", &control_supported); +#endif + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + if (media_supported || call_supported) { + ret = bt_audio_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_audio_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } + } +} + +/** + * @function utc_bluetooth_bt_audio_negative_cleanup + * @description check if media or call feature is supported, then de-initialize the audio profiles + * check if bluetooth is supported, de-initialize bluetooth. + * @scenario de-initializes the audio profiles and Rrelease all resources of bluetooth, this needs to be called after each test. + + * @parameter NA + * @return NA + */ +void utc_bluetooth_bt_audio_negative_cleanup(void) +{ + if (media_supported || call_supported) { + bt_audio_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_audio_connect_n + * @since_tizen 2.3 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * connect to the remote device with given audio profile and check for errors. + * @scenario Try to connect the remote device with the given audio profile, asynchronously, + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_audio_connect_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_audio_connect("DummyAddress", BT_AUDIO_PROFILE_TYPE_A2DP); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_audio_connect("DummyAddress", BT_AUDIO_PROFILE_TYPE_A2DP); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_disconnect_n + * @since_tizen 2.3 + * @description check if audio profile are supported and startup_flag is asserted, then deinitialize the bluetooth and + * disconnect to the remote device with given audio profile and check for errors. + * @scenario Try to disconnect the remote device with the given audio profile, asynchronously, + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_audio_disconnect_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_audio_disconnect(NULL, BT_AUDIO_PROFILE_TYPE_A2DP); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_audio_disconnect(NULL, BT_AUDIO_PROFILE_TYPE_A2DP); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_set_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description check if audio profile or call profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for change in connection state and check for errors. + * scenario Try to register a callback function to be invoked when the connection state is changed after bluetooth de-initialization. + */ +int utc_bluetooth_bt_audio_set_connection_state_changed_cb_n(void) +{ + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_audio_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_audio_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_set_connection_state_changed_cb_n1 + * @since_tizen 2.3 + * @description check if audio profile or call profile is supported and startup_flag is asserted, then register a callback for change + * in connection state by using invalid parameters and check for errors. + * scenario Try to register a callback function to be invoked when the connection state is changed by using invalid parameters. + */ +int utc_bluetooth_bt_audio_set_connection_state_changed_cb_n1(void) +{ + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_audio_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_audio_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_deinitialize_n + * @since_tizen 2.3 + * @description check if audio profile or call profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * de-initialize the audio profiles and check for errors. + * scenario Try to deinitialize the Bluetooth profiles related with audio. after bluetooth de-initialization. + */ +int utc_bluetooth_bt_audio_deinitialize_n(void) +{ + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_audio_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_audio_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_initialize_n + * @since_tizen 2.3 + * @description check if audio profile or call profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * initialize the audio profiles and check for errors. + * scenario Try to initialize the Bluetooth profiles related with audio. after bluetooth de-initialization. + */ +int utc_bluetooth_bt_audio_initialize_n(void) +{ + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_audio_initialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_audio_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_unset_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description check if audio profile or call profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback set for connection state changes and check for errors. + * scenario Try to unregister a callback function to be invoked when the connection state is changed after bluetooth de-initialization. + */ +int utc_bluetooth_bt_audio_unset_connection_state_changed_cb_n(void) +{ + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_audio_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_audio_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_equalizer_state_changed_cb(bt_avrcp_equalizer_state_e equalizer, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_equalizer_state_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register the callback function that will be invoked when the equalizer state is changed by the remote control device + * and check for errors. + * scenario Try to register a callback function that will be invoked when the equalizer state is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_set_equalizer_state_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_set_equalizer_state_changed_cb(__bt_avrcp_equalizer_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_set_equalizer_state_changed_cb(__bt_avrcp_equalizer_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_repeat_mode_changed_cb(bt_avrcp_repeat_mode_e repeat, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_repeat_mode_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register the callback function that will be invoked when the repeat mode is changed by the remote control device and check for errors. + * scenario Try to register a callback function that will be invoked when repeat mode is changed by the remote control device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_set_repeat_mode_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_set_repeat_mode_changed_cb(__bt_avrcp_repeat_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_set_repeat_mode_changed_cb(__bt_avrcp_repeat_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_scan_mode_changed_cb(bt_avrcp_scan_mode_e scan, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_scan_mode_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register the callback function that will be invoked when the scan mode is changed by the remote control device and check for errors. + * scenario Try to register a callback function that will be invoked when scan mode is changed by the remote control device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_set_scan_mode_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_set_scan_mode_changed_cb(__bt_avrcp_scan_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_set_scan_mode_changed_cb(__bt_avrcp_scan_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_set_shuffle_mode_changed_cb(bt_avrcp_shuffle_mode_e shuffle, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register the callback function that will be invoked when the shuffle mode is changed by the remote control device and check for errors. + * scenario Try to register a callback function that will be invoked when shuffle mode is changed by the remote control device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_set_shuffle_mode_changed_cb(__bt_avrcp_set_shuffle_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_set_shuffle_mode_changed_cb(__bt_avrcp_set_shuffle_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +#ifndef TV +static void __bt_avrcp_song_position_changed_cb(unsigned int postion, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_position_changed_cb_n + * @since_tizen 3.0 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register the callback function that will be invoked when the position is changed by the remote control device and check for errors. + * scenario Try to register a callback function that will be invoked when position is changed by the remote control device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_set_position_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_set_position_changed_cb(__bt_avrcp_song_position_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_set_position_changed_cb(__bt_avrcp_song_position_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_player_state_changed_cb(bt_avrcp_player_state_e state, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_play_status_changed_cb_n + * @since_tizen 3.0 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register the callback function that will be invoked when the play status is changed by the remote control device and check for errors. + * scenario Try to register a callback function that will be invoked when play status is changed by the remote control device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_set_play_status_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_set_play_status_changed_cb(__bt_avrcp_player_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_set_play_status_changed_cb(__bt_avrcp_player_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_track_info_changed_cb(bt_avrcp_metadata_attributes_info_s *metadata, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_track_info_changed_cb_n + * @since_tizen 3.0 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register the callback function that will be invoked when the track info is changed by the remote control device and check for errors. + * scenario Try to register a callback function that will be invoked when track info is changed by the remote control device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_set_track_info_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_set_track_info_changed_cb(__bt_avrcp_track_info_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_set_track_info_changed_cb(__bt_avrcp_track_info_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +#endif + +/** + * @testcase utc_bluetooth_bt_avrcp_target_deinitialize_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * de-initialize the AVRCP(Audio/Video Remote Control Profile) service and check for errors. + * scenario Try to deinitialize the Bluetooth AVRCP(Audio/Video Remote Control Profile) service after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_deinitialize_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_target_connection_state_changed_cb(bool connected, const char *remote_address, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_initialize_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * initialize the AVRCP(Audio/Video Remote Control Profile) service and check for errors. + * scenario Try to initialize the Bluetooth AVRCP(Audio/Video Remote Control Profile) service after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_initialize_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_equalizer_state_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send equalizer notification to the remote device and check for errors. + * @scenario Try to notify the equalize state to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_notify_equalizer_state_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_notify_equalizer_state(0x01); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_notify_equalizer_state(0x01); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_player_state_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send player state notification to the remote device and check for errors. + * @scenario Try to notify the player state to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_notify_player_state_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_notify_player_state(0x01); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_notify_player_state(0x01); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_position_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send song's current position notification to the remote device and check for errors. + * @scenario Try to notify the current position of song to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_notify_position_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_notify_position(0x01); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_notify_position(0x01); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_repeat_mode_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send repeat mode notification to the remote device and check for errors. + * @scenario Try to notify the repeat mode to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_notify_repeat_mode_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_notify_repeat_mode(0x01); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_notify_repeat_mode(0x01); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_scan_mode_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send scan mode notification to the remote device and check for errors. + * @scenario Try to notify the scan mode to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_notify_scan_mode_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_notify_scan_mode(0x01); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_notify_scan_mode(0x01); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send shuffle mode notification to the remote device and check for errors. + * @scenario Try to notify the shuffle mode to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_notify_shuffle_mode(0x01); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_notify_shuffle_mode(0x01); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_track_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send track notification to the remote device and check for errors. + * @scenario Try to notify the track details to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_target_notify_track_n(void) +{ + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_target_notify_track("title", "artist", "album", "genre", 5, 20, 2); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_target_notify_track("title", "artist", "album", "genre", 5, 20, 2); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback function set for equalizer state changes and check for errors. + * scenario Try to unregister a callback function that will be invoked when the equalizer state is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_unset_equalizer_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_unset_equalizer_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback function set for repeat mode changes and check for errors. + * scenario Try to unregister a callback function that will be invoked when the repeat mode is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_unset_repeat_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_unset_repeat_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_scan_mode_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback function set for scan mode changes and check for errors. + * scenario Try to unregister a callback function that will be invoked when the scan mode is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_unset_scan_mode_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_unset_scan_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_unset_scan_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_cb_n + * @since_tizen 2.4 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback function set for shuffle mode changes and check for errors. + * scenario Try to unregister a callback function that will be invoked when the shuffle mode is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_unset_shuffle_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_unset_shuffle_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +#ifndef TV +/** + * @testcase utc_bluetooth_bt_avrcp_unset_position_changed_cb_n + * @since_tizen 3.0 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback function set for position changes and check for errors. + * scenario Try to unregister a callback function that will be invoked when the position is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_unset_position_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_unset_position_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_unset_position_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_n + * @since_tizen 3.0 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback function set for play status changes and check for errors. + * scenario Try to unregister a callback function that will be invoked when the play status is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_unset_play_status_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_unset_play_status_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_n + * @since_tizen 3.0 + * @description check if audio profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback function set for track info changes and check for errors. + * scenario Try to unregister a callback function that will be invoked when the track info is changed by the remote control device + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_n(void) +{ + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_avrcp_unset_track_info_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_unset_track_info_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} +#endif diff --git a/tests/unittest/utc_bluetooth_audio_positive.c b/tests/unittest/utc_bluetooth_audio_positive.c new file mode 100644 index 0000000..bff233b --- /dev/null +++ b/tests/unittest/utc_bluetooth_audio_positive.c @@ -0,0 +1,960 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include + +//& set: BluetoothAudioPositive + +static int startup_flag = BT_ERROR_NONE; +static bool bt_supported = false; +static bool media_supported = false; +static bool call_supported = false; +static bool control_supported = false; + +static void __bt_avrcp_target_connection_state_changed_cb(bool connected, const char *remote_address, void *user_data) +{ + +} + +static void __bt_avrcp_control_connection_state_changed_cb(bool connected, const char *remote_address, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_audio_positive_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_audio_positive_startup(void) +{ + int ret = BT_ERROR_NONE; + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + +#ifndef TV + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + media_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.media", &media_supported); + + call_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.call", &call_supported); +#else + bt_supported = true; + media_supported = true; + call_supported = false; +#endif + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + if (media_supported || call_supported) { + ret = bt_audio_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_audio_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_audio_positive_cleanup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_audio_positive_cleanup(void) +{ + if (media_supported || call_supported) { + bt_audio_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @function utc_bluetooth_avrcp_callback_positive_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_avrcp_callback_positive_startup(void) +{ + int ret = BT_ERROR_NONE; + +#ifndef TV + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + media_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.media", &media_supported); + + call_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.call", &call_supported); + + control_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.controller", &control_supported); +#else + bt_supported = true; + media_supported = true; + call_supported = false; + control_supported = false; +#endif + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + if (media_supported) { + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_avrcp_target_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +#ifndef TV + if (control_supported) { + ret = bt_avrcp_control_initialize(__bt_avrcp_control_connection_state_changed_cb, NULL); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_avrcp_control_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +#endif + } +} + +/** + * @function utc_bluetooth_avrcp_callback_positive_cleanup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_avrcp_callback_positive_cleanup(void) +{ + if (media_supported) { + bt_avrcp_target_deinitialize(); + } + +#ifndef TV + if (control_supported) { + bt_avrcp_control_deinitialize(); + } +#endif + + if (bt_supported) { + bt_deinitialize(); + } +} + +static void connection_state_changed_cb_for_audio_p(int result, bool connected, const char *remote_address, bt_audio_profile_type_e type, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_audio_initialize_p + * @since_tizen 2.3 + * @description Check if bt, media or call features are supported. If yes, deinitialize audio and initialize audio and ensure there is no error. + * Else, initialize bt audio and verify result as BT_ERROR_NOT_SUPPORTED. + * @senario Check if BT and media/call is supported and then call bt_audio_initialize on the device and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_audio_initialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_audio_deinitialize(); + + ret = bt_audio_initialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_audio_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_set_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description Check if bt, media or call features are supported. If yes, set audio connection state change callback and ensure there is no error. + * Else, set audio connection state change callback and verify result as BT_ERROR_NOT_SUPPORTED. + * @senario Check if BT and media/call is supported and then call bt_audio_set_connection_state_changed_cb and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_audio_set_connection_state_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_audio_set_connection_state_changed_cb(connection_state_changed_cb_for_audio_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_audio_set_connection_state_changed_cb(connection_state_changed_cb_for_audio_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_unset_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description Check if bt, media or call features are supported. If yes, set and unset audio connection state change callback and ensure there is no error. + * Else, unset audio connection state change callback and verify result as BT_ERROR_NOT_SUPPORTED. + * @senario Check if BT and media/call is supported and then set and unset audio connection state changed cb. Check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_audio_unset_connection_state_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_audio_set_connection_state_changed_cb(connection_state_changed_cb_for_audio_p, NULL); + + ret = bt_audio_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_audio_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_audio_deinitialize_p + * @since_tizen 2.3 + * @description Check if bt, media or call features are supported. If yes, deinitialize audio and ensure there is no error. + * Else, deinitialize audio and verify result as BT_ERROR_NOT_SUPPORTED. + * @senario Positive case to check for audio deinitialize. Check if BT and media/call is supported and then deinitialize audio. + * Check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_audio_deinitialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || call_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_audio_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_audio_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_initialize_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Then deinitialize avrcp target. + * @senario Positive case to check for audio initialize. Check if BT and media/call is supported and then initialize audio. + * Check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_initialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_deinitialize_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Then deinitialize avrcp target. + * @senario Positive case to check for audio deinitialize. Check if BT and media/call is supported and then deinitialize audio. + * Check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_deinitialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_target_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_equalizer_state_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call bt_avrcp_target_notify_equalizer_state + * with BT_AVRCP_EQUALIZER_STATE_ON as parameter and check there is no error. Then deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_target_notify_equalizer_state(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_notify_equalizer_state_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_notify_equalizer_state(BT_AVRCP_EQUALIZER_STATE_ON); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_notify_equalizer_state(BT_AVRCP_EQUALIZER_STATE_ON); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_repeat_mode_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call bt_avrcp_target_notify_repeat_mode + * with BT_AVRCP_REPEAT_MODE_SINGLE_TRACK as parameter and check there is no error. Then deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_target_notify_repeat_mode(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_notify_repeat_mode_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_notify_repeat_mode(BT_AVRCP_REPEAT_MODE_SINGLE_TRACK); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_notify_repeat_mode(BT_AVRCP_REPEAT_MODE_SINGLE_TRACK); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call bt_avrcp_target_notify_shuffle_mode + * with BT_AVRCP_SHUFFLE_MODE_ALL_TRACK as parameter and check there is no error. Then deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_target_notify_shuffle_mode(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_notify_shuffle_mode_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_notify_shuffle_mode(BT_AVRCP_SHUFFLE_MODE_ALL_TRACK); + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_notify_shuffle_mode(BT_AVRCP_SHUFFLE_MODE_ALL_TRACK); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_scan_mode_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call bt_avrcp_target_notify_scan_mode + * with BT_AVRCP_SCAN_MODE_ALL_TRACK as parameter and check there is no error. Then deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_target_notify_scan_mode(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_notify_scan_mode_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_notify_scan_mode(BT_AVRCP_SCAN_MODE_ALL_TRACK); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_notify_scan_mode(BT_AVRCP_SCAN_MODE_ALL_TRACK); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_player_state_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call bt_avrcp_target_notify_player_state + * with BT_AVRCP_PLAYER_STATE_STOPPED as parameter and check there is no error. Then deinitialize avrcp target + * @senario Positive case to check for bt_avrcp_target_notify_player_state(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_notify_player_state_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_notify_player_state(BT_AVRCP_PLAYER_STATE_STOPPED); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_notify_player_state(BT_AVRCP_PLAYER_STATE_STOPPED); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_position_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call bt_avrcp_target_notify_position + * and check there is no error. Then deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_target_notify_position(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_notify_position_p(void) +{ + int ret = BT_ERROR_NONE; + unsigned int position = 0; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_notify_position(position); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_notify_position(position); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_target_notify_track_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call bt_avrcp_target_notify_track + * with valid input details and check there is no error. Then deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_target_notify_track(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_target_notify_track_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_avrcp_target_initialize(__bt_avrcp_target_connection_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_target_notify_track("title", "artist", "album", "genre", 5, 20, 2); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_avrcp_target_deinitialize(); + } else { + ret = bt_avrcp_target_notify_track("title", "artist", "album", "genre", 5, 20, 2); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_set_equalizer_state_changed_cb(bt_avrcp_equalizer_state_e equalizer, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_equalizer_state_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp equalizer state changed callback + * with valid input details and check there is no error. Then unset the avrcp equalizer state changed callback. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_set_equalizer_state_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_set_equalizer_state_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_equalizer_state_changed_cb(__bt_avrcp_set_equalizer_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_unset_equalizer_state_changed_cb(); + } else { + ret = bt_avrcp_set_equalizer_state_changed_cb(__bt_avrcp_set_equalizer_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp equalizer state changed callback + * with valid input details and check there is no error. Then unset the avrcp equalizer state changed callback and verify there is no error. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_unset_equalizer_state_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_unset_equalizer_state_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_equalizer_state_changed_cb(__bt_avrcp_set_equalizer_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_unset_equalizer_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_unset_equalizer_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_set_repeat_mode_changed_cb(bt_avrcp_repeat_mode_e repeat, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_repeat_mode_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp repeat mode changed callback + * with valid input details and check there is no error. Then unset the avrcp repeat mode changed callback. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_set_repeat_mode_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_set_repeat_mode_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_repeat_mode_changed_cb(__bt_avrcp_set_repeat_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_unset_repeat_mode_changed_cb(); + } else { + ret = bt_avrcp_set_repeat_mode_changed_cb(__bt_avrcp_set_repeat_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp repeat mode changed callback + * with valid input details and check there is no error. Then unset the avrcp repeat mode changed callback and verify there is no error. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_unset_repeat_mode_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_unset_repeat_mode_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_repeat_mode_changed_cb(__bt_avrcp_set_repeat_mode_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_unset_repeat_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_unset_repeat_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_set_shuffle_mode_changed_cb(bt_avrcp_shuffle_mode_e shuffle, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp shuffle mode changed callback + * with valid input details and check there is no error. Then unset the avrcp shuffle mode changed callback. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_set_shuffle_mode_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_set_shuffle_mode_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_shuffle_mode_changed_cb(__bt_avrcp_set_shuffle_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_unset_shuffle_mode_changed_cb(); + } else { + ret = bt_avrcp_set_shuffle_mode_changed_cb(__bt_avrcp_set_shuffle_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp shuffle mode changed callback + * with valid input details and check there is no error. Then unset the avrcp shuffle mode changed callback and verify there is no error. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_unset_shuffle_mode_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_unset_shuffle_mode_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_shuffle_mode_changed_cb(__bt_avrcp_set_shuffle_mode_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_unset_shuffle_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_unset_shuffle_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_set_scan_mode_changed_cb(bt_avrcp_scan_mode_e scan, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_scan_mode_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp scan mode changed callback + * with valid input details and check there is no error. Then unset the avrcp scan mode changed callback. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_set_scan_mode_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_set_scan_mode_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_scan_mode_changed_cb(__bt_avrcp_set_scan_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_unset_scan_mode_changed_cb(); + } else { + ret = bt_avrcp_set_scan_mode_changed_cb(__bt_avrcp_set_scan_mode_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_scan_mode_changed_p + * @since_tizen 2.3 + * @description Assert bt is initialized. Initialize avrcp target and check for BT_ERROR_NONE. Call set avrcp scan mode changed callback + * with valid input details and check there is no error. Then unset the avrcp scan mode changed callback and verify there is no error. + * Deinitialize avrcp target. + * @senario Positive case to check for bt_avrcp_unset_scan_mode_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_unset_scan_mode_changed_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_scan_mode_changed_cb(__bt_avrcp_set_scan_mode_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_unset_scan_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_unset_scan_mode_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +#ifndef TV +static void __bt_avrcp_song_position_changed_cb(unsigned int postion, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_position_changed_cb_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Call set avrcp position changed callback + * with valid input details and check there is no error. Then unset the avrcp position changed callback. + * @senario Positive case to check for bt_avrcp_set_position_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_set_position_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_position_changed_cb(__bt_avrcp_song_position_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_unset_position_changed_cb(); + } else { + ret = bt_avrcp_set_position_changed_cb(__bt_avrcp_song_position_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_position_changed_cb_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Call set avrcp position changed callback + * with valid input details and check there is no error. Then unset the avrcp position changed callback and verify there is no error. + * @senario Positive case to check for bt_avrcp_unset_position_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_unset_position_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_position_changed_cb(__bt_avrcp_song_position_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_unset_position_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_unset_position_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_player_state_changed_cb(bt_avrcp_player_state_e state, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_play_status_changed_cb_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Call set avrcp play status changed callback + * with valid input details and check there is no error. Then unset the avrcp play status changed callback. + * @senario Positive case to check for bt_avrcp_set_play_status_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_set_play_status_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_play_status_changed_cb(__bt_avrcp_player_state_changed_cb, NULL); + + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_unset_play_status_changed_cb(); + } else { + ret = bt_avrcp_set_play_status_changed_cb(__bt_avrcp_player_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Call set avrcp play status changed callback + * with valid input details and check there is no error. Then unset the avrcp play status changed callback and verify there is no error. + * @senario Positive case to check for bt_avrcp_unset_play_status_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_unset_play_status_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_play_status_changed_cb(__bt_avrcp_player_state_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_unset_play_status_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_unset_play_status_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_avrcp_track_info_changed_cb(bt_avrcp_metadata_attributes_info_s *metadata, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_avrcp_set_track_info_changed_cb_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Call set avrcp track info changed callback + * with valid input details and check there is no error. Then unset the avrcp track info changed callback. + * @senario Positive case to check for bt_avrcp_set_track_info_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_set_track_info_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_track_info_changed_cb(__bt_avrcp_track_info_changed_cb, NULL); + + assert_eq(ret, BT_ERROR_NONE); + ret = bt_avrcp_unset_track_info_changed_cb(); + } else { + ret = bt_avrcp_set_track_info_changed_cb(__bt_avrcp_track_info_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Call set avrcp play status changed callback + * with valid input details and check there is no error. Then unset the avrcp play status changed callback and verify there is no error. + * @senario Positive case to check for bt_avrcp_unset_track_info_changed_cb(). Verify result is BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_unset_track_info_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (media_supported || control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_set_track_info_changed_cb(__bt_avrcp_track_info_changed_cb, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_unset_track_info_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_unset_track_info_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +#endif diff --git a/tests/unittest/utc_bluetooth_avrcp_control_negative.c b/tests/unittest/utc_bluetooth_avrcp_control_negative.c new file mode 100644 index 0000000..0f9b5df --- /dev/null +++ b/tests/unittest/utc_bluetooth_avrcp_control_negative.c @@ -0,0 +1,508 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include + +//& set: BluetoothAVRCPControlNegative + +static int startup_flag = BT_ERROR_NONE; +static bool bt_supported = false; +static bool control_supported = false; + +#ifndef TV +static void __bt_avrcp_control_connection_state_changed_cb(bool connected, const char *remote_address, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_avrcp_control_negative_startup + * @description check if bluetooth is supported, initialize bluetooth. + * check if media or call feature is supported, then initialize the avrcp control profiles. + * @parameter NA + * @return NA + */ +void utc_bluetooth_avrcp_control_negative_startup(void) +{ + int ret = BT_ERROR_NONE; + startup_flag = BT_ERROR_NONE; + + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + control_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.controller", &control_supported); + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + if (control_supported) { + ret = bt_avrcp_control_initialize(__bt_avrcp_control_connection_state_changed_cb, NULL); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_avrcp_control_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } + } +} + +/** + * @function utc_bluetooth_avrcp_control_negative_cleanup + * @description check if audio controller feature is supported, then de-initialize the avrcp control profiles + * check if bluetooth is supported, de-initialize bluetooth. + * @parameter NA + * @return NA + */ +void utc_bluetooth_avrcp_control_negative_cleanup(void) +{ + if (control_supported) { + bt_avrcp_control_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_connect_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * connect to the remote device with given avrcp control profile and check for errors. + * @scenario Try to connect the remote device with the given avrcp control profile, asynchronously, + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_connect_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_connect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_connect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_disconnect_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * connect to the remote device with given avrcp control profile and check for errors. + * @scenario Try to disconnect the remote device with the given avrcp control profile, asynchronously, + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_disconnect_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_disconnect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_disconnect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_send_player_command_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_send_player_command_n(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PLAY); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_send_player_command(BT_AVRCP_CONTROL_PLAY); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_set_equalizer_state_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_set_equalizer_state_n(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_set_equalizer_state(BT_AVRCP_EQUALIZER_STATE_ON); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_set_equalizer_state(BT_AVRCP_EQUALIZER_STATE_ON); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_get_equalizer_state_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_get_equalizer_state_n(void) +{ + int ret = BT_ERROR_NONE; + bt_avrcp_equalizer_state_e state = BT_AVRCP_EQUALIZER_STATE_ON; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_get_equalizer_state(&state); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_get_equalizer_state(&state); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_set_repeat_mode_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_set_repeat_mode_n(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_set_repeat_mode(BT_AVRCP_REPEAT_MODE_SINGLE_TRACK); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_set_repeat_mode(BT_AVRCP_REPEAT_MODE_SINGLE_TRACK); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_get_repeat_mode_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_get_repeat_mode_n(void) +{ + int ret = BT_ERROR_NONE; + bt_avrcp_repeat_mode_e mode = BT_AVRCP_REPEAT_MODE_SINGLE_TRACK; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_get_repeat_mode(&mode); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_get_repeat_mode(&mode); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_set_shuffle_mode_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_set_shuffle_mode_n(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_set_shuffle_mode(BT_AVRCP_SHUFFLE_MODE_ALL_TRACK); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_set_shuffle_mode(BT_AVRCP_SHUFFLE_MODE_ALL_TRACK); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_get_shuffle_mode_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_get_shuffle_mode_n(void) +{ + int ret = BT_ERROR_NONE; + bt_avrcp_shuffle_mode_e mode = BT_AVRCP_SHUFFLE_MODE_ALL_TRACK; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_get_shuffle_mode(&mode); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_get_shuffle_mode(&mode); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_set_scan_mode_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_set_scan_mode_n(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_set_scan_mode(BT_AVRCP_SCAN_MODE_GROUP); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_set_scan_mode(BT_AVRCP_SCAN_MODE_GROUP); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_get_scan_mode_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_get_scan_mode_n(void) +{ + int ret = BT_ERROR_NONE; + bt_avrcp_scan_mode_e mode = BT_AVRCP_SCAN_MODE_GROUP; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_get_scan_mode(&mode); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_get_scan_mode(&mode); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_get_position_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_get_position_n(void) +{ + int ret = BT_ERROR_NONE; + unsigned int position = 0; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_get_position(&position); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_get_position(&position); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_get_play_status_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_get_play_status_n(void) +{ + int ret = BT_ERROR_NONE; + bt_avrcp_player_state_e status = BT_AVRCP_PLAYER_STATE_STOPPED; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_get_play_status(&status); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_get_play_status(&status); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_get_track_info_n + * @since_tizen 3.0 + * @description check if avrcp control profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given avrcp control profile API and check for errors. + * @scenario Try to call the given avrcp control API, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_avrcp_control_get_track_info_n(void) +{ + int ret = BT_ERROR_NONE; + bt_avrcp_metadata_attributes_info_s *track_info = NULL; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_get_track_info(&track_info); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_avrcp_control_get_track_info(&track_info); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + if (track_info) { + ret = bt_avrcp_control_free_track_info(track_info); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_free_track_info_n + * @since_tizen 3.0 + * @description Call to free track information by setting the track info param as "NULL" and check the "ret" flag + * with BT_ERROR_INVALID_PARAMETER if le is supported otherwise just try to free device information + * by setting the device info param as "NULL" and check the "ret" flag with BT_ERROR_NOT_SUPPORTED. + * @scenario Negative scenario to free device information with "NULL" parameter. + */ +int utc_bluetooth_bt_avrcp_control_free_track_info_n(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_control_free_track_info(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_avrcp_control_free_track_info(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} +#endif diff --git a/tests/unittest/utc_bluetooth_avrcp_control_positive.c b/tests/unittest/utc_bluetooth_avrcp_control_positive.c new file mode 100644 index 0000000..8773c19 --- /dev/null +++ b/tests/unittest/utc_bluetooth_avrcp_control_positive.c @@ -0,0 +1,140 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include + +//& set: BluetoothAVRCPControlPositive + +static int startup_flag = BT_ERROR_NONE; +static bool bt_supported = false; +static bool control_supported = false; + +#ifndef TV +static void __bt_avrcp_control_connection_state_changed_cb(bool connected, const char *remote_address, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_avrcp_control_positive_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_avrcp_control_positive_startup(void) +{ + int ret = BT_ERROR_NONE; + startup_flag = BT_ERROR_NONE; + + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + control_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.audio.controller", &control_supported); + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + if (control_supported) { + ret = bt_avrcp_control_initialize(__bt_avrcp_control_connection_state_changed_cb, NULL); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_avrcp_control_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } + } +} + +/** + * @function utc_bluetooth_avrcp_control_positive_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void utc_bluetooth_avrcp_control_positive_cleanup(void) +{ + if (control_supported) { + bt_avrcp_control_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_initialize_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Initialize avrcp control and check for BT_ERROR_NONE. Then deinitialize avrcp control. + * @senario Positive case to check for avrcp control initialize. Check if BT and controller is supported and then initialize avrcp control. + * Check for BT_ERROR_NONE. + */ + +int utc_bluetooth_bt_avrcp_control_initialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_control_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_avrcp_control_initialize(__bt_avrcp_control_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_control_initialize(__bt_avrcp_control_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_avrcp_control_deinitialize_p + * @since_tizen 3.0 + * @description Assert bt is initialized. Initialize avrcp control and check for BT_ERROR_NONE. Then deinitialize avrcp control. + * @senario Positive case to check for avrcp control deinitialize. Check if BT and controller is supported and then deinitialize avrcp control. + * Check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_avrcp_control_deinitialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (control_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_avrcp_control_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_avrcp_control_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} +#endif diff --git a/tests/unittest/utc_bluetooth_common_positive.c b/tests/unittest/utc_bluetooth_common_positive.c new file mode 100644 index 0000000..bd50538 --- /dev/null +++ b/tests/unittest/utc_bluetooth_common_positive.c @@ -0,0 +1,96 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "bluetooth.h" +#include "assert_local.h" +#include +#include + +//& set: BluetoothCommonPositive + +static int ret = BT_ERROR_NONE; +static bool supported = false; + +/** + * @function utc_bluetooth_common_startup + * @description initialize bluetooth and check the adapter state and store adapter state for further use. + * @parameter NA + * @return NA + */ +void utc_bluetooth_common_startup(void) +{ + ret = bt_initialize(); + supported = false; + +#ifdef TV +#ifndef TV_PRODUCT + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &supported); +#else + supported = true; +#endif +#else + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &supported); +#endif +} + +/** + * @function utc_bluetooth_common_cleanup + * @description release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_common_cleanup(void) +{ + bt_deinitialize(); +} + +/** + * @testcase utc_bluetooth_bt_initialize_p + * @since_tizen 2.3 + * @description check if bluetooth is supported or not and check for errors. + * @scenario Check if bluetooth is supported or not. + */ +int utc_bluetooth_bt_initialize_p(void) +{ + ret = bt_initialize(); + + if (!supported) { + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_deinitialize_p + * @since_tizen 2.3 + * @description de-initialize the bluetooth and check if bluetooth is supported or not and check for errors. + * @scenario Releases all resources of the Bluetooth API, after bluetooth de-initialization. + + */ +int utc_bluetooth_bt_deinitialize_p(void) +{ + ret = bt_deinitialize(); + + if (!supported) { + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_device_discovery_negative.c b/tests/unittest/utc_bluetooth_device_discovery_negative.c new file mode 100644 index 0000000..2f08fb3 --- /dev/null +++ b/tests/unittest/utc_bluetooth_device_discovery_negative.c @@ -0,0 +1,251 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothDeviceDiscoveryNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool bt_supported = false; + +/** + * @function utc_bluetooth_device_discovery_negative_startup + * @description check if bluetooth is supported, Initialialize bluetooth. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_discovery_negative_startup(void) +{ + startup_flag = BT_ERROR_NONE; + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#endif + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_device_discovery_negative_cleanup + * @description check if bluetooth is supported release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_discovery_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_adapter_stop_device_discovery_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then de-initialize the bluetooth and + * stop the device discovery and check for errors. + * @scenario Try to stop the device discovery, asynchronously, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_adapter_stop_device_discovery_n1(void) +{ + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_stop_device_discovery(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_stop_device_discovery(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then de-initialize the bluetooth and + * unregister the callback set for device discovery state changes and check for errors. + * @scenario Try to unregister a callback function to be invoked when the device discovery state changes, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_unset_device_discovery_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_unset_device_discovery_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void device_discovery_state_changed_cb_for_discovery_p(int result, bt_adapter_device_discovery_state_e discovery_state, bt_adapter_device_discovery_info_s *discovery_info, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then de-initialize the bluetooth and + * register a callback that will be invoked when device discovery state changes and check for errors. + * @scenario Try to register a callback function, to be invoked when the device discovery state changes, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_discovery_p, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_discovery_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then register a callback that will be + * invoked when device discovery state changes, by using invalid parameters and check for errors. + * @scenario Try to register a callback function, to be invoked when the device discovery state changes, by using invalid parameters. + */ +int utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_device_discovery_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_set_device_discovery_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_start_device_discovery_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then de-initialize the bluetooth and + * start the device discovery and check for errors. + * @scenario Try to start the device discovery, asynchronously, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_adapter_start_device_discovery_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_start_device_discovery(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_start_device_discovery(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_is_discovering_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then de-initialize the bluetooth and + * check the satuts of device discovery and check for errors. + * @scenario Try to check for the device discovery is in progress or not after bluetooth de-initialization. + */ +int utc_bluetooth_bt_adapter_is_discovering_n1(void) +{ + bool status = false; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_is_discovering(&status); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_is_discovering(&status); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_is_discovering_n2 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then check the satuts of + * device discovery by using invalid parameters and check for errors. + * @scenario Try to check for the device discovery is in progress or not after bluetooth de-initialization, by using invalid parameters. + */ +int utc_bluetooth_bt_adapter_is_discovering_n2(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_is_discovering(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_is_discovering(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_device_discovery_positive.c b/tests/unittest/utc_bluetooth_device_discovery_positive.c new file mode 100644 index 0000000..68ec835 --- /dev/null +++ b/tests/unittest/utc_bluetooth_device_discovery_positive.c @@ -0,0 +1,229 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothDeviceDiscoveryPositive + +static int startup_flag = BT_ERROR_NONE; +static GMainLoop *mainloop = NULL; +static int ret = BT_ERROR_NONE; +static bool callback_result = false; +static bool bt_supported = false; + +static void device_discovery_state_changed_cb_for_discovery_p(int result, bt_adapter_device_discovery_state_e discovery_state, bt_adapter_device_discovery_info_s *discovery_info, void *user_data) +{ + if (mainloop) + g_main_loop_quit(mainloop); +} + +static void wait_for_async() +{ + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); +} + +/** + * @function utc_bluetooth_device_discovery_positive_startup + * @description check if bluetooth is supported, initialize bluetooth and check the adapter state and + * store adapter state for further use. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_discovery_positive_startup(void) +{ + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + startup_flag = BT_ERROR_NONE; + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#endif + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + callback_result = false; + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_device_discovery_positive_cleanup + * @description check if bluetooth is supported and release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_discovery_positive_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_adapter_is_discovering_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then check the satuts of device discovery, + * and check for errors. + * @scenario Checks for the device discovery is in progress or not. + */ +int utc_bluetooth_bt_adapter_is_discovering_p(void) +{ + bool status = false; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_is_discovering(&status); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_is_discovering(&status); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback that + * will be invoked when device discovery state changes and check for errors. + * @scenario Registers a callback function to be invoked when the device discovery state changes. + */ +int utc_bluetooth_bt_adapter_set_device_discovery_state_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_discovery_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_discovery_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_start_device_discovery_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, start the device discovery + * and check for errors. + * @scenario Starts the device discovery, asynchronously. + */ +int utc_bluetooth_bt_adapter_start_device_discovery_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_stop_device_discovery(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_discovery_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_start_device_discovery(); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + + ret = bt_adapter_stop_device_discovery(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_start_device_discovery(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then unregister the callback set + * for device discovery state changes and check for errors. + * @scenario Unregisters a callback function to be invoked when the device discovery state changes. + */ +int utc_bluetooth_bt_adapter_unset_device_discovery_state_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_unset_device_discovery_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_unset_device_discovery_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_stop_device_discovery_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted, then stop the device discovery + * and check for errors. + * @scenario Stops the device discovery, asynchronously. + */ +int utc_bluetooth_bt_adapter_stop_device_discovery_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_stop_device_discovery(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_discovery_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_start_device_discovery(); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + + ret = bt_adapter_stop_device_discovery(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_stop_device_discovery(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_device_negative.c b/tests/unittest/utc_bluetooth_device_negative.c new file mode 100644 index 0000000..b2206cb --- /dev/null +++ b/tests/unittest/utc_bluetooth_device_negative.c @@ -0,0 +1,685 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothDeviceNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static const char *remote_address = "B8:5E:7B:E7:92:7D"; +static bool bt_supported = false; + +static void bt_connection_state_changed_cb(bool connected, bt_device_connection_info_s *conn_info, void *user_data) +{ + +} + +static bool bonded_device_cb_for_device_p(bt_device_info_s *dev_info, void *user_data) +{ + return false; +} + +/** + * @function utc_bluetooth_device_negative_startup + * @description check if bluetooth is supported, Initialialize bluetooth. Here adapter state is not checked. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_negative_startup(void) +{ + startup_flag = BT_ERROR_NONE; + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + +#endif + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_device_negative_cleanup + * @description check if bluetooth is supported release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_device_set_bond_created_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for bond creation with invalid paramters else check for errors. + * @scenario Try to register a callback function with invalid paramters for bond creation after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_set_bond_created_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_set_bond_created_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_set_bond_created_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_bond_created_cb_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback + * for bond creation with invalid paramters and check for errors. + * @scenario Registers a callback function with invalid paramters for bond creation. + */ +int utc_bluetooth_bt_device_set_bond_created_cb_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_bond_created_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_device_set_bond_created_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_bond_destroyed_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for bond destroy with invalid paramters and check for errors. + * @scenario Try to register a callback function with invalid paramters for bond destroy after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_set_bond_destroyed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_set_bond_destroyed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_set_bond_destroyed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_authorization_changed_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for change in device authorization with invalid paramters and check for errors. + * @scenario Try to register a callback function with invalid paramters for change in device authorizationafter bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_set_authorization_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_set_authorization_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_set_authorization_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_authorization_changed_cb_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback for change + * in device authorization with invalid paramters and check for errors. + * @scenario Registers a callback function with invalid paramters for change in device authorization. + */ +int utc_bluetooth_bt_device_set_authorization_changed_cb_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_authorization_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_device_set_authorization_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_bond_created_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * the callback is unregistered for bond creation and check for errors. + * @scenario Try to unregister the callback function for bond creation after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_unset_bond_created_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_bond_created_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_unset_bond_created_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_bond_destroyed_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * the callback is unregistered for bond destroy and check for errors. + * @scenario Try to unregister the callback function for bond destroyafter bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_unset_bond_destroyed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_bond_destroyed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_unset_bond_destroyed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_authorization_changed_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * the callback is unregistered for change in device authorization and check for errors. + * @scenario Try to unregisters the callback function for change in device authorization, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_unset_authorization_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_authorization_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_unset_authorization_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_create_bond_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * initiate bond creation to remote device and check for errors. + * @scenario Try to create a bond with a remote Bluetooth device, asynchronously after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_create_bond_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_create_bond(remote_address); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_create_bond(remote_address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_create_bond_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then initiate bond creation + * with invalid paramters and check for errors. + * @scenario Creates a bond with invalid parameters. + */ +int utc_bluetooth_bt_device_create_bond_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_create_bond(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_device_create_bond(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_cancel_bonding_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * cancel the bond creation to remote device and check for errors. + * @scenario Try to cancel the bonding process after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_cancel_bonding_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_cancel_bonding(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_cancel_bonding(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_destroy_bond_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * initiate bond destroy procedure to remote device and check for errors. + * @scenario Try to destroy the bond, asynchronously after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_destroy_bond_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_destroy_bond(remote_address); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_destroy_bond(remote_address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_foreach_bonded_device_n1 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and all bonded + * device information is listed from the device list else all bonded device information is listed from the device list and checked for errors. + * scenario Try to retriev the device information of all bonded devices after bluetooth de-initialization. + */ +int utc_bluetooth_bt_adapter_foreach_bonded_device_n1(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_adapter_foreach_bonded_device(bonded_device_cb_for_device_p, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_adapter_foreach_bonded_device(bonded_device_cb_for_device_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_foreach_bonded_device_n2 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then all bonded device information + * is listed from the device list with invalid parameters and checked for errors. + * scenario Try to retriev the device information of all bonded devices with invalid parameters. + */ +int utc_bluetooth_bt_adapter_foreach_bonded_device_n2(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_foreach_bonded_device(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_adapter_foreach_bonded_device(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_alias_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * set device alias name and check for errors. + * scenario Try to sets an alias for the bonded device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_set_alias_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_set_alias(remote_address, "dts_alias"); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_set_alias(remote_address, "dts_alias"); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_alias_n2 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then set device alias name + * with invalid parameters and check for errors. + * scenario Try to sets an alias for the bonded device with invalid parameter. + */ +int utc_bluetooth_bt_device_set_alias_n2(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_alias(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_device_set_alias(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_authorization_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * set device authoriazation and check for errors. + * scenario Try to set the authorization of a bonded device, asynchronously after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_set_authorization_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_set_authorization(remote_address, BT_DEVICE_AUTHORIZED); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_set_authorization(remote_address, BT_DEVICE_AUTHORIZED); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_authorization_n2 + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then set device authoriazation + * with invalid parameters and check for errors. + * scenario Try to set authoriazation of a bonded device, asynchronously with invalid parameter. + */ +int utc_bluetooth_bt_device_set_authorization_n2(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_authorization(NULL, BT_DEVICE_AUTHORIZED); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_device_set_authorization(NULL, BT_DEVICE_AUTHORIZED); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_get_service_mask_from_uuid_list_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * retrive the service class of the uuid from uuid list a and check for errors. + * @scenario Try to get the service mask from the uuid list after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_get_service_mask_from_uuid_list_n(void) +{ +#if defined(MOBILE) || defined(TIZENIOT) + char *uuid = "00001101-0000-1000-8000-00805f9b34fb"; + int no_of_service = 1; + bt_service_class_t service_mask_list; +#endif + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + +#if defined(MOBILE) || defined(TIZENIOT) + ret = bt_device_get_service_mask_from_uuid_list(&uuid, no_of_service, &service_mask_list); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#else + ret = bt_device_get_service_mask_from_uuid_list(NULL, 1, NULL); + + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#endif + } else { +#if defined(MOBILE) || defined(TIZENIOT) + ret = bt_device_get_service_mask_from_uuid_list(&uuid, no_of_service, &service_mask_list); +#else + ret = bt_device_get_service_mask_from_uuid_list(NULL, 1, NULL); +#endif + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_is_profile_connected_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * retrive the profile connection state with respect to remote address and profile and check for errors + * @scenario Try to gets the profile connected status after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_is_profile_connected_n(void) +{ + bt_profile_e bt_profile = BT_PROFILE_RFCOMM; + bool is_connected; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_is_profile_connected(remote_address, bt_profile, &is_connected); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_is_profile_connected(remote_address, bt_profile, &is_connected); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for change in connection state and check for errors. + * scenario Try to register a callback function to be invoked when the connection state is changed after bluetooth de-initialization. + */ +int utc_bluetooth_bt_device_set_connection_state_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_set_connection_state_changed_cb(bt_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_set_connection_state_changed_cb(bt_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then deinitialize the bluetooth and + * the callback is unregistered for change in connection state and check for errors. + * scenario Try to unregister a callback function to be invoked when the connection state is changed after bluetooth de-initialization. + + */ +int utc_bluetooth_bt_device_unset_connection_state_changed_cb_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_connection_state_changed_cb(bt_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_device_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static bool bt_device_connected_profiles_cb(bt_profile_e profile, void *user_data) +{ + return false; +} + +/** + * @testcase utc_bluetooth_bt_device_foreach_connected_profiles_n + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then retrive the profile connection state + * with respect to remote address and profile for all devices with invalid parameters and check for errors + * @scenario Try to gets the profile connected status with invalid parameters. + */ +int utc_bluetooth_bt_device_foreach_connected_profiles_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_foreach_connected_profiles(NULL, bt_device_connected_profiles_cb, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_device_foreach_connected_profiles(NULL, bt_device_connected_profiles_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_update_le_connection_mode_n + * @since_tizen 3.0 + * @description check if bluetooth is supported and startup_flag is asserted then update device le connection mode + * with invalid parameters and check for errors. + * scenario Try to update device le connection mode with invalid parameter. + */ +int utc_bluetooth_bt_device_update_le_connection_mode_n(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_update_le_connection_mode(NULL, BT_DEVICE_LE_CONNECTION_MODE_BALANCED); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_device_update_le_connection_mode(NULL, BT_DEVICE_LE_CONNECTION_MODE_BALANCED); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_device_positive.c b/tests/unittest/utc_bluetooth_device_positive.c new file mode 100644 index 0000000..89c1ef8 --- /dev/null +++ b/tests/unittest/utc_bluetooth_device_positive.c @@ -0,0 +1,434 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothDevicePositive + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool callback_result = false; +static bt_device_info_s *device_info = NULL; +static const char *remote_address = "B8:5E:7B:E7:92:7D"; +static bool bt_supported = false; +static GMainLoop *mainloop = NULL; + +static void wait_for_async() +{ + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); +} + +static void device_bonded_cb(int result, bt_device_info_s *device_info, void *user_data) +{ + if (mainloop) + g_main_loop_quit(mainloop); +} + +static void device_unbonded_cb(int result, char *remote_address, void *user_data) +{ + if (mainloop) + g_main_loop_quit(mainloop); +} + +static void device_authorization_state_changed_cb(bt_device_authorization_e authorization_state, char *address, void *user_data) +{ + +} + +static bool bonded_device_cb_for_device_p(bt_device_info_s *dev_info, void *user_data) +{ + return false; +} + +static void bt_connection_state_changed_cb(bool connected, bt_device_connection_info_s *conn_info, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_device_positive_startup + * @description check if bluetooth is supported, initialize bluetooth and check the adapter state and + * store adapter state for further use. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_positive_startup(void) +{ + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#endif + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + callback_result = false; + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_device_positive_cleanup + * @description check if bluetooth is supported, clear the device information resources and release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_device_positive_cleanup(void) +{ + if (bt_supported) { + free(device_info); + device_info = NULL; + + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_device_set_bond_created_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback for bond creation + * and check for errors. + * @scenario Registers a callback function to be invoked when the bond creates. + */ +int utc_bluetooth_bt_device_set_bond_created_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_bond_created_cb(device_bonded_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_device_unset_bond_created_cb(); + } else { + ret = bt_device_set_bond_created_cb(device_bonded_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_bond_destroyed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback for bond destroy + * and check for errors. + * @scenario Registers a callback function to be invoked when the bond destroys. + */ +int utc_bluetooth_bt_device_set_bond_destroyed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_bond_destroyed_cb(device_unbonded_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_device_unset_bond_destroyed_cb(); + } else { + ret = bt_device_set_bond_destroyed_cb(device_unbonded_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_authorization_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback for change in device authorization + * and check for errors. + * @scenario Registers a callback function to be invoked when the authorization of device changes. + */ +int utc_bluetooth_bt_device_set_authorization_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_authorization_changed_cb(device_authorization_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_device_unset_authorization_changed_cb(); + } else { + ret = bt_device_set_authorization_changed_cb(device_authorization_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_get_service_mask_from_uuid_list_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then retrive the service class of the uuid from uuid list + * and check for errors. + * @scenario Get the service mask from the uuid list. + */ +int utc_bluetooth_bt_device_get_service_mask_from_uuid_list_p(void) +{ + char *uuid = "00001101-0000-1000-8000-00805f9b34fb"; + int no_of_service = 1; + bt_service_class_t service_mask_list; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_get_service_mask_from_uuid_list(&uuid, no_of_service, &service_mask_list); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_device_get_service_mask_from_uuid_list(&uuid, no_of_service, &service_mask_list); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_is_profile_connected_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then retrive the profile connection state with + * respect to remote address and profile and check for errors. + * @scenario Gets the profile connected status if bluetooth is supported else throws an error. + + */ +int utc_bluetooth_bt_device_is_profile_connected_p(void) +{ + bt_profile_e bt_profile = BT_PROFILE_RFCOMM; + bool is_connected = FALSE; + + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_is_profile_connected(remote_address, bt_profile, &is_connected); + + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_device_is_profile_connected(remote_address, bt_profile, &is_connected); + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_bond_created_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then unregister a callback for bond creation + * and check for errors. + * @scenario Unregisters the callback function for bond creation. + */ +int utc_bluetooth_bt_device_unset_bond_created_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_bond_created_cb(device_bonded_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_bond_created_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_device_unset_bond_created_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_adapter_foreach_bonded_device_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then all bonded device information is listed from the device list + * and check for errors. + * scenario Retrieves the device information of all bonded devices. + */ +int utc_bluetooth_bt_adapter_foreach_bonded_device_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_adapter_foreach_bonded_device(bonded_device_cb_for_device_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_adapter_foreach_bonded_device(bonded_device_cb_for_device_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_bond_destroyed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then unregister a callback for bond destroy + * and check for errors. + * @scenario Unregisters the callback function for bond destroy. + */ +int utc_bluetooth_bt_device_unset_bond_destroyed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_bond_destroyed_cb(device_unbonded_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_bond_destroyed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_device_unset_bond_destroyed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_authorization_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback for change in device authorization + * and check for errors. + * @scenraio Unregisters the callback function for device authorization changes. + */ +int utc_bluetooth_bt_device_unset_authorization_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_authorization_changed_cb(device_authorization_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_authorization_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_device_unset_authorization_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then register a callback for change in connection state + * and check for errors. + * scenario Registers a callback function to be invoked when the connection state is changed. + */ +int utc_bluetooth_bt_device_set_connection_state_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_connection_state_changed_cb(bt_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_device_unset_connection_state_changed_cb(); + } else { + ret = bt_device_set_connection_state_changed_cb(bt_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth is supported and startup_flag is asserted then unregister a callback for change in connection state + * and check for errors. + * @scenario Unregisters the callback function to be invoked when the connection state is changed. + */ +int utc_bluetooth_bt_device_unset_connection_state_changed_cb_p(void) +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_connection_state_changed_cb(bt_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_device_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/* Platform TCs */ +int utc_bluetooth_bt_device_create_bond_p() +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_bond_created_cb(device_bonded_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_create_bond(remote_address); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + } else { + ret = bt_device_create_bond(remote_address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_device_destroy_bond_p() +{ + if (bt_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_bond_destroyed_cb(device_unbonded_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_destroy_bond(remote_address); + assert_eq(ret, BT_ERROR_NONE); + wait_for_async(); + } else { + ret = bt_device_destroy_bond(remote_address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_gatt_negative.c b/tests/unittest/utc_bluetooth_gatt_negative.c new file mode 100644 index 0000000..e2892ae --- /dev/null +++ b/tests/unittest/utc_bluetooth_gatt_negative.c @@ -0,0 +1,1970 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothGattNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static const char *remote_addr = "E4:32:CB:41:1F:A6"; +static bool le_supported = false; +static bool bt_supported = false; +static bool gatt_client_supported = false; +static bool gatt_server_supported = false; +static bool ipsp_supported = false; + +static void gatt_connection_state_changed_cb_p(int result, bool connected, const char *remote_address, void *user_data) +{ + if (connected) { + fprintf(stderr, "Device is connected with remote address."); + } else { + fprintf(stderr, "Device is disconnected from remote address."); + } +} + +/** + * @function utc_bluetooth_gatt_negative_startup + * @description if bluetooth is supported and LE is supported, initialize bluetooth. + * @parameter NA + * @return NA + */ +void utc_bluetooth_gatt_negative_startup(void) +{ + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + le_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le", &le_supported); + + gatt_client_supported = false; + system_info_get_platform_bool("tizen.org/feature/network.bluetooth.le.gatt.client", &gatt_client_supported); + + gatt_server_supported = false; + system_info_get_platform_bool("tizen.org/feature/network.bluetooth.le.gatt.server", &gatt_server_supported); + + ipsp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le.ipsp", &ipsp_supported); + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_gatt_negative_cleanup + * @description If bluetooth is supported and LE is supported, release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_gatt_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_gatt_connect_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * connect to the remote device and check for errors. + * @scenario Try to connect to a specific LE based service on a remote bluetooth dievice address, + * asynchronously after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_connect_n(void) +{ + bool auto_connect = FALSE; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_connect(remote_addr, auto_connect); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_connect(remote_addr, auto_connect); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/* + * @brief Negative test case of bt_gatt_disconnect() + */ +/** + * @testcase utc_bluetooth_bt_gatt_disconnect_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * disconnect connection to the remote device and check for errors. + * @scenario Try to disconnect to a specific LE based service on a remote bluetooth dievice address, + * asynchronously after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_disconnect_n(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_disconnect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_disconnect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/* + * @brief Negative test case of bt_gatt_connect() + */ +/** + * @testcase utc_bluetooth_bt_gatt_connect_n1 + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then connect to the remote device + * with invalid parameters and check for errors. + * @scenario Try to connect to a specific LE based service on a remote bluetooth dievice address, + * asynchronously with invalid parameters. + */ +int utc_bluetooth_bt_gatt_connect_n1(void) +{ + bool auto_connect = FALSE; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_connect(NULL, auto_connect); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_connect(NULL, auto_connect); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/* + * @brief Negative test case of bt_gatt_disconnect() + */ +/** + * @testcase utc_bluetooth_bt_gatt_disconnect_n1 + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then disconnect the connection to the remote device + * with invalid parameters and check for errors. + * @scenario Try to disconnect to a specific LE based service on a remote bluetooth dievice address, + * asynchronously with invalid parameters. + */ +int utc_bluetooth_bt_gatt_disconnect_n1(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_disconnect(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_disconnect(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_set_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for LE connection change and check for errors. + * @scenario Registers a callback function that will be invoked when a LE connection state is changed + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_set_connection_state_changed_cb_n(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_set_connection_state_changed_cb(gatt_connection_state_changed_cb_p, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_set_connection_state_changed_cb(gatt_connection_state_changed_cb_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback for LE connection change and check for errors. + * @scenario Try to unregister the callback function that will be invoked when a LE connection state is changed + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_n(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_get_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the value of a + * characteristic or descriptor's GATT handle by using the invalid parameters and check for errors. + * @scenario Try to get the value of a characteristic or descriptor's GATT handle by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_get_value_n(void) +{ + bt_gatt_h gatt_handle = NULL; + char *value = NULL; + int len = 0; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_get_value(gatt_handle, &value, &len); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_get_value(gatt_handle, &value, &len); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_get_int_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the value of a + * characteristic or descriptor's GATT handle of interger type by using the invalid parameters and check for errors. + * @scenario Try to get the value of a characteristic or descriptor's GATT handle as an integer type by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_get_int_value_n(void) +{ + bt_gatt_h gatt_handle = NULL; + int *value = NULL; + int offset = 0; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_get_int_value(gatt_handle, BT_DATA_TYPE_SINT16, offset, value); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_get_int_value(gatt_handle, BT_DATA_TYPE_SINT16, offset, value); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_get_float_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the value of a + * characteristic or descriptor's GATT handle of float type by using the invalid parameters and check for errors. + * @scenario Try to get the value of a characteristic or descriptor's GATT handle as an float type by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_get_float_value_n(void) +{ + bt_gatt_h gatt_handle = NULL; + float *value = NULL; + int offset = 0; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_get_float_value(gatt_handle, BT_DATA_TYPE_FLOAT, offset, value); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_get_float_value(gatt_handle, BT_DATA_TYPE_FLOAT, offset, value); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_set_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then set the value of a + * characteristic or descriptor's GATT handle by using the invalid parameters and check for errors. + * @scenario Try to set the value of a characteristic or descriptor's GATT handle by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_set_value_n(void) +{ + bt_gatt_h gatt_handle = NULL; + const char *value = NULL; + int value_length = 0; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_set_value(gatt_handle, value, value_length); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_set_value(gatt_handle, value, value_length); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_set_int_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then update the value of a + * characteristic or descriptor's GATT handle of interger type by using the invalid parameters and check for errors. + * @scenario Try to update the value of a characteristic or descriptor's GATT handle as an integer type by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_set_int_value_n(void) +{ + bt_gatt_h gatt_handle = NULL; + int value = 0; + int value_length = 0; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_set_int_value(gatt_handle, 0x02, value, value_length); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_set_int_value(gatt_handle, 0x02, value, value_length); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_set_float_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then update the value of a + * characteristic or descriptor's GATT handle of float type by using the invalid parameters and check for errors. + * @scenario Try to update the value of a characteristic or descriptor's GATT handle as an float type by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_set_float_value_n(void) +{ + bt_gatt_h gatt_handle = NULL; + int mantissa = 0; + int exponent = 0; + int offset = 0; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_set_float_value(gatt_handle, BT_DATA_TYPE_FLOAT, mantissa, exponent, offset); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_set_float_value(gatt_handle, BT_DATA_TYPE_FLOAT, mantissa, exponent, offset); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_get_uuid_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the uuid of given + * GATT attribute handle by using the invalid parameters and check for errors. + * @scenario Try to get the UUID of a service, characteristic or descriptor's GATT handle by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_get_uuid_n(void) +{ + bt_gatt_h gatt_handle = NULL; + char *uuid = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_get_uuid(gatt_handle, &uuid); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_get_uuid(gatt_handle, &uuid); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_get_type_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the attribute type + * of given GATT attribute handle by using the invalid parameters and check for errors. + * @scenario Try to get the type of GATT handle by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_get_type_n(void) +{ + bt_gatt_h gatt_handle = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_get_type(gatt_handle, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_get_type(gatt_handle, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_get_client_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the client handle + * of given GATT attribute handle by using the invalid parameters and check for errors. + * @scenario Try to get the GATT client handle which the specified service belongs to, using invalid paramters. + */ +int utc_bluetooth_bt_gatt_service_get_client_n(void) +{ + bt_gatt_h gatt_handle = NULL; + bt_gatt_client_h *client = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_get_client(gatt_handle, client); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_get_client(gatt_handle, client); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_get_characteristic_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the characteristic's GATT handle + * of the given UUID by using invalid paramters and check for errors. + * @scenario Try to get a characteristic's GATT handle which has specific UUID by using invalid paramters. + */ +int utc_bluetooth_bt_gatt_service_get_characteristic_n(void) +{ + bt_gatt_h service = NULL; + const char *uuid = NULL; + bt_gatt_h *characteristic = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_get_characteristic(service, uuid, characteristic); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_get_characteristic(service, uuid, characteristic); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static bool __bt_gatt_client_foreach_chr_cb(int total, int index, bt_gatt_h chr_handle, void *data) +{ + return true; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_foreach_characteristics_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get all of the characterisitcs those + * belong to a specific service by using the invalid parameters and check for errors. + * @scenario Try to invoke callback function on each characteristic that belongs to the specified service + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_foreach_characteristics_n(void) +{ + int test_id = 0; + bt_gatt_h service = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_foreach_characteristics(service, __bt_gatt_client_foreach_chr_cb, (void *)test_id); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_foreach_characteristics(service, __bt_gatt_client_foreach_chr_cb, (void *)test_id); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_get_included_service_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the included service's GATT handle + * of the given specific UUID by using the invalid parameters. and check for errors. + * @scenario Try to get a included service's GATT handle which has specific UUID, where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_get_included_service_n(void) +{ + bt_gatt_h service = NULL; + const char *uuid = NULL; + bt_gatt_h *included_service = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_get_included_service(service, uuid, included_service); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_get_included_service(service, uuid, included_service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_foreach_included_services_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get all of the included services those + * belong to a specific service by using the invalid parameters and check for errors. + * @scenario Try to invoke callback function on each included services that belongs to the specified service + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_foreach_included_services_n(void) +{ + bt_gatt_h service = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_foreach_included_services(service, __bt_gatt_client_foreach_chr_cb, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_foreach_included_services(service, __bt_gatt_client_foreach_chr_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_get_service_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the service handle + * of the given characteristics handle using invalid paramters and check for errors. + * @scenario Try to get the service's GATT handle which the specified characteristic belongs to using invalid paramters. + */ +int utc_bluetooth_bt_gatt_characteristic_get_service_n(void) +{ + bt_gatt_h characteristic = NULL; + bt_gatt_h *service = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_get_service(characteristic, service); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_get_service(characteristic, service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_get_properties_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the properties of the given + * characteristics handle by using the invalid parameters. and check for errors. + * @scenario Try to get the properties which a characteristic's GATT handle has, where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_get_properties_n(void) +{ + bt_gatt_h characteristic = NULL; + int *properties = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_get_properties(characteristic, properties); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_get_properties(characteristic, properties); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_get_write_type_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the attribute write type of the given + * characteristics handle by using the invalid parameters. and check for errors. + * @scenario Try to get the write type of the specified characteristic, where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_get_write_type_n(void) +{ + bt_gatt_h characteristic = NULL; + bt_gatt_write_type_e *write_type = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_get_write_type(characteristic, write_type); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + } else { + ret = bt_gatt_characteristic_get_write_type(characteristic, write_type); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_set_write_type_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then set the attribute write type of the given + * characteristics handle by using the invalid parameters. and check for errors. + * @scenario Try to set the write type of the specified characteristic, where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_set_write_type_n(void) +{ + bt_gatt_h characteristic = NULL; + bt_gatt_write_type_e write_type = BT_GATT_WRITE_TYPE_WRITE_NO_RESPONSE; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_set_write_type(characteristic, write_type); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_set_write_type(characteristic, write_type); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_get_descriptor_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the descriptor's GATT handle + * of the given specific UUID by using the invalid parameters. and check for errors. + * @scenario Try to get a descriptor's GATT handle which has specific UUID, where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_get_descriptor_n(void) +{ + bt_gatt_h characteristic = NULL; + const char *uuid = NULL; + bt_gatt_h *descriptor = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_get_descriptor(characteristic, uuid, descriptor); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_get_descriptor(characteristic, uuid, descriptor); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_foreach_descriptors_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get all of the descriptors those + * belong to a specific characteristic by using the invalid parameters and check for errors. + * @scenario Try to invoke callback function on each characteristic that belongs to the specified characteristic + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_foreach_descriptors_n(void) +{ + bt_gatt_h characteristic = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_foreach_descriptors(characteristic, __bt_gatt_client_foreach_chr_cb, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_foreach_descriptors(characteristic, __bt_gatt_client_foreach_chr_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_descriptor_get_characteristic_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the characteristic's handle + * of the given descriptor handle by using the invalid parameters and check for errors. + * @scenario Try to get the characteristic's GATT handle which the specified descriptor belongs to by using the invalid parameters. + */ +int utc_bluetooth_bt_gatt_descriptor_get_characteristic_n(void) +{ + bt_gatt_h descriptor = NULL; + bt_gatt_h *characteristic = NULL; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_get_characteristic(descriptor, characteristic); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_descriptor_get_characteristic(descriptor, characteristic); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_create_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * create the client for given remote device and check for errors. + * scenario Try to create the GATT client handle after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_client_create_n(void) +{ + const char *remote_address = "00:19:0E:01:61:17"; + bt_gatt_client_h client = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_client_create(remote_address, &client); + if (ret == BT_ERROR_NONE) { + bt_gatt_client_destroy(client); + } + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_client_create(remote_address, client); + if (ret == BT_ERROR_NONE) { + bt_gatt_client_destroy(client); + } + + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_destroy_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * destroy the client for given remote device and check for errors. + * scenario Try to destroy the GATT client handle after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_client_destroy_n(void) +{ + const char *remote_address = "00:19:0E:01:61:17"; + bt_gatt_client_h client = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_client_create(remote_address, &client); + ret = bt_gatt_client_destroy(client); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_client_destroy(client); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_get_remote_address_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * get the device address for given remote device for which client is create and check for errors. + * scenario Try to get the address of remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_client_get_remote_address_n(void) +{ + bt_gatt_client_h client = NULL; + char *remote_address = "00:19:0E:01:61:17"; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_client_create(remote_address, &client); + + ret = bt_gatt_client_get_remote_address(client, &remote_address); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + if (ret == BT_ERROR_NONE) { + bt_gatt_client_destroy(client); + } + } else { + ret = bt_gatt_client_get_remote_address(client, &remote_address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_gatt_client_read_complete_cb(int result, bt_gatt_h gatt_handle, void *data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_read_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then read the value of a + * characteristic or descriptor's GATT handle by using the invalid parameters and check for errors. + * @scenario Try to read the value of a characteristic or descriptor from the remote device asynchronously, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_client_read_value_n(void) +{ + bt_gatt_h gatt_handle = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_read_value(gatt_handle, __bt_gatt_client_read_complete_cb, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_read_value(gatt_handle, __bt_gatt_client_read_complete_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_gatt_client_request_completed_cb(int result, bt_gatt_h request_handle, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_write_value_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then update the value of a + * characteristic or descriptor's GATT handle by using the invalid parameters and check for errors. + * @scenario Try to write the value of a characteristic or descriptor from the remote device asynchronously, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_client_write_value_n(void) +{ + bt_gatt_h client = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_write_value(client, __bt_gatt_client_request_completed_cb, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_write_value(client, __bt_gatt_client_read_complete_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static void __bt_gatt_client_value_changed_cb(bt_gatt_h chr, char *value, int len, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_set_characteristic_value_changed_cb_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then register a callback for characterisitc value is changed + * on the remote device by using the invalid parameters and check for errors. + * @scenario Try to unregister a callback function to be invoked when the characteristic value is changed on the remote device, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_client_set_characteristic_value_changed_cb_n(void) +{ + bt_gatt_h characteristic = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_set_characteristic_value_changed_cb(characteristic, __bt_gatt_client_value_changed_cb, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_set_characteristic_value_changed_cb(characteristic, __bt_gatt_client_value_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_unset_characteristic_value_changed_cb_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then unregister a callback for characterisitc value is changed + * on the remote device by using the invalid parameters and check for errors. + * @scenario Try to unregister a callback function to be invoked when the characteristic value is changed on the remote device, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_client_unset_characteristic_value_changed_cb_n(void) +{ + bt_gatt_h characteristic = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_unset_characteristic_value_changed_cb(characteristic); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_unset_characteristic_value_changed_cb(characteristic); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_get_service_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get the service's handle + * of the given specific UUId from the client created by using the invalid parameters and check for errors. + * @scenario Try to get a service's GATT handle which has specific UUID, where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_client_get_service_n(void) +{ + bt_gatt_client_h client = NULL; + const char *uuid = NULL; + bt_gatt_h *service = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_get_service(client, uuid, service); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_get_service(client, uuid, service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +static bool __bt_gatt_foreach_cb(int total, int index, bt_gatt_h gatt_handle, void *user_data) +{ + return true; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_foreach_services_n + * @since_tizen 2.3 + * @description if bluetooth LE is supported and startup_flag is asserted then get all of the service those + * belong to a specific GATT client device by using the invalid parameters and check for errors. + * @scenario Try to invoke callback function on each service that belongs to the specified GATT client + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_client_foreach_services_n(void) +{ + bt_gatt_client_h client = NULL; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_foreach_services(client, __bt_gatt_foreach_cb, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_foreach_services(client, __bt_gatt_foreach_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_destroy_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then destroy the service handle, + * by using the invalid parameters and check for errors. + * @scenario Try to destroy the service handle, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_destroy_n(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_destroy(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_destroy(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_destroy_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then destroy the characteristic handle, + * by using the invalid parameters and check for errors. + * @scenario Try to destroy the characteristic handle, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_destroy_n(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_destroy(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_destroy(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_descriptor_destroy_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then destroy the descriptor handle, + * by using the invalid parameters and check for errors. + * @scenario Try to destroy the descriptor handle, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_descriptor_destroy_n(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_destroy(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_descriptor_destroy(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_get_permissions_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then get the characteristic's permission, + * by using the invalid parameters and check for errors. + * @scenario Try to get the characteristic's permission, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_get_permissions_n(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_get_permissions(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_get_permissions(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_descriptor_get_permissions_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then get the descriptor's permission, + * by using the invalid parameters and check for errors. + * @scenario Try to get the descriptor's permission, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_descriptor_get_permissions_n(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_get_permissions(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_descriptor_get_permissions(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_create_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then create the GATT service, + * by using the invalid parameters and check for errors. + * @scenario Try to create the GATT service, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_create_n(void) +{ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_create(NULL, service_type, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_create(NULL, service_type, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_add_characteristic_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then add the characteristic to the service, + * by using the invalid parameters and check for errors. + * @scenario Try to add the characteristic to the service, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_add_characteristic_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_add_characteristic(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_add_characteristic(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_add_included_service_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then add the service to the specified service as included service, + * by using the invalid parameters and check for errors. + * @scenario Try to add the service to the specified service, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_add_included_service_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_add_included_service(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_add_included_service(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_get_server_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then get the GATT server handle from the specified service, + * by using the invalid parameters and check for errors. + * @scenario Try to get the GATT server handle from the specified service, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_service_get_server_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_get_server(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_service_get_server(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_create_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then create the GATT characteristic, + * by using the invalid parameters and check for errors. + * @scenario Try to create the GATT characteristic, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_create_n(void) +{ + int permissions = BT_GATT_PERMISSION_READ; + int properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + char char_value[1] = { 80 }; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(NULL, permissions, properties, char_value, sizeof(char_value), NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_create(NULL, permissions, properties, char_value, sizeof(char_value), NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_add_descriptor_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then add the descriptor to the characteristic, + * by using the invalid parameters and check for errors. + * @scenario Try to add the descriptor to the characteristic, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_characteristic_add_descriptor_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_add_descriptor(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_characteristic_add_descriptor(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_descriptor_create_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then create the GATT descriptor, + * by using the invalid parameters and check for errors. + * @scenario Try to create the GATT descriptor, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_descriptor_create_n(void) +{ + char desc_value[2] = { 0, 0 }; + int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_create(NULL, permissions, desc_value, sizeof(desc_value), NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_descriptor_create(NULL, permissions, desc_value, sizeof(desc_value), NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_initialize_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * initialize the GATT server and check for errors. + * @scenario Try to initialize the GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_initialize_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_deinitialize_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * deinitialize the GATT server and check for errors. + * @scenario Try to deinitialize the GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_deinitialize_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_create_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * create the GATT server and check for errors. + * @scenario Try to create the GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_create_n(void) +{ + bt_gatt_server_h server = NULL; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_destroy_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * destroy the GATT server and check for errors. + * @scenario Try to destroy the GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_destroy_n(void) +{ + bt_gatt_server_h server = NULL; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_destroy(server); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_destroy(server); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * register a callback function to be invoked when a read request is issued and check for errors. + * @scenario Try to register a callback function to be invoked when a read request is issued after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_n(void) +{ + bt_gatt_h characteristic = NULL; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_set_read_value_requested_cb(characteristic, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_set_read_value_requested_cb(characteristic, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, i + * then deinitialize the bluetooth and register a callback function to be invoked + * when the remote device enables or disables the Notification/Indication for particular characteristics and check for errors. + * @scenario Try to register a callback function to be invoked + * when the remote device enables or disables the Notification/Indication for particular characteristics and check for errors + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_n(void) +{ + bt_gatt_h characteristic = NULL; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * register a callback function to be invoked when a write request is issued and check for errors. + * @scenario Try to register a callback function to be invoked when a write request is issued after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_n(void) +{ + bt_gatt_h characteristic = NULL; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_set_write_value_requested_cb(characteristic, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_set_write_value_requested_cb(characteristic, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_notify_characteristic_changed_value_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * notify value change of the characteristic to the remote device and check for errors. + * @scenario Try to notify value change of the characteristic to the remote device after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_notify_characteristic_changed_value_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_notify_characteristic_changed_value(NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_notify_characteristic_changed_value(NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_get_service_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * get a service's GATT handle which has a specific UUID and check for errors. + * @scenario Try to get a service's GATT handle which has a specific UUID after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_get_service_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_get_service(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_get_service(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_get_device_mtu_n + * @since_tizen 5.5 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * get the remote deivce's MTU value and check for errors. + * @scenario Try to get the remote deivce's MTU value after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_get_device_mtu_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_get_device_mtu(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_get_device_mtu(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_foreach_services_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * invoke a callback function on each service that belongs to be specified GATT server and check for errors. + * @scenario Try to invoke a callback function on each service that belongs to be specified GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_foreach_services_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_foreach_services(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_foreach_services(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_register_service_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * register a GATT service handle to GATT server and check for errors. + * @scenario Try to register a GATT service handle to GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_register_service_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_register_service(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_unregister_service_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * unregister a GATT service handle from the GATT server and check for errors. + * @scenario Try to unregister a GATT service handle from the GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_unregister_service_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_unregister_service(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_unregister_service(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_unregister_all_services_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * unregister the all GATT services handle from the GATT server and check for errors. + * @scenario Try to unregister the all GATT services handle from the GATT server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_unregister_all_services_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_unregister_all_services(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_unregister_all_services(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_start_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * start a server and check for errors. + * @scenario Try to start a server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_start_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_start(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_start(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_send_response_n + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * send response and check for errors. + * @scenario Try to send response after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_server_send_response_n(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_send_response(0, 0, 0, 0, NULL, -1); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_server_send_response(0, 0, 0, 0, NULL, -1); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_set_service_changed_cb_n + * @since_tizen 3.0 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for service change and check for errors. + * @scenario Registers a callback function that will be invoked when a service is changed after bluetooth de-initialization. + */ +int utc_bluetooth_bt_gatt_client_set_service_changed_cb_n(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_client_set_service_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_gatt_client_set_service_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_client_unset_service_changed_cb_n + * @since_tizen 3.0 + * @description if bluetooth LE is supported and startup_flag is asserted then unregister a callback for service is changed + * on the remote device by using the invalid parameters and check for errors. + * @scenario Try to unregister a callback function to be invoked when the service is changed on the remote device, + * where the parameters passed are invalid. + */ +int utc_bluetooth_bt_gatt_client_unset_service_changed_cb_n(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_unset_service_changed_cb(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_unset_service_changed_cb(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_initialize_n + * @since_tizen 4.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * initialize the IPSP server and check for errors. + * @scenario Try to initialize the IPSP server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_ipsp_initialize_n(void) +{ + if (ipsp_supported) { + ret = bt_ipsp_initialize(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_ipsp_initialize(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_deinitialize_n + * @since_tizen 4.0 + * @description check if bluetooth LE is supported and startup_flag is asserted, then deinitialize the bluetooth and + * deinitialize the IPSP server and check for errors. + * @scenario Try to deinitialize the IPSP server after bluetooth de-initialization. + */ +int utc_bluetooth_bt_ipsp_deinitialize_n(void) +{ + if (ipsp_supported) { + ret = bt_deinitialize(); + + ret = bt_ipsp_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_ipsp_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_connect_n + * @since_tizen 4.0 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * connect to the remote device and check for errors. + * @scenario Try to connect to the IPSP service on a remote bluetooth dievice address, + * asynchronously after bluetooth de-initialization. + */ +int utc_bluetooth_bt_ipsp_connect_n(void) +{ + if (ipsp_supported) { + ret = bt_ipsp_connect(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_ipsp_connect(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_disconnect_n + * @since_tizen 4.0 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * disconnect connection to the remote device and check for errors. + * @scenario Try to disconnect to the IPSP service on a remote bluetooth dievice address, + * asynchronously after bluetooth de-initialization. + */ +int utc_bluetooth_bt_ipsp_disconnect_n(void) +{ + if (ipsp_supported) { + ret = bt_ipsp_disconnect(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_ipsp_disconnect(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_n + * @since_tizen 4.0 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for IPSP connection change and check for errors. + * @scenario Registers a callback function that will be invoked when a IPSP connection state is changed + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_n(void) +{ + if (ipsp_supported) { + ret = bt_ipsp_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_ipsp_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_n + * @since_tizen 4.0 + * @description if bluetooth LE is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback for IPSP connection change and check for errors. + * @scenario Try to unregister the callback function that will be invoked when a IPSP connection state is changed + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_n(void) +{ + if (ipsp_supported) { + ret = bt_deinitialize(); + + ret = bt_ipsp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_ipsp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_gatt_client_request_att_mtu_change_n(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_request_att_mtu_change(NULL, 0); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_request_att_mtu_change(NULL, 0); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_gatt_client_get_att_mtu_n(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_get_att_mtu(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_get_att_mtu(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_n(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_set_att_mtu_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_set_att_mtu_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_n(void) +{ + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_unset_att_mtu_changed_cb(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } else { + ret = bt_gatt_client_unset_att_mtu_changed_cb(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_gatt_positive.c b/tests/unittest/utc_bluetooth_gatt_positive.c new file mode 100644 index 0000000..e8d6cb4 --- /dev/null +++ b/tests/unittest/utc_bluetooth_gatt_positive.c @@ -0,0 +1,1276 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothGattPositive + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool le_supported = false; +static bool gatt_client_supported = false; +static bool gatt_server_supported = false; +static bool bt_supported = false; +static bool ipsp_supported = false; + +static void gatt_connection_state_changed_cb_p(int result, bool connected, const char *remote_address, void *user_data) +{ + if (connected) { + fprintf(stderr, "Device is connected with remote address."); + } else { + fprintf(stderr, "Device is disconnected from remote address."); + } +} + +void __bt_ipsp_connection_state_changed_cb(int result, bool connected, const char *remote_address, const char *iface_name, void *user_data) +{ + +} + +static void __bt_gatt_client_att_mtu_changed_cb(bt_gatt_client_h client, const bt_gatt_client_att_mtu_info_s *mtu_info, void *user_data) +{ + +} + +static void __bt_gatt_server_read_value_requested_cb_p(const char *remote_address, int request_id, bt_gatt_server_h server, bt_gatt_h gatt_handle, int offset, void *user_data) +{ + fprintf(stderr, "__bt_gatt_server_read_value_requested_cb"); +} + +static void __bt_gatt_server_notification_state_change_cb_p(bool notify, bt_gatt_server_h server, bt_gatt_h gatt_handle, void *user_data) +{ + fprintf(stderr, "__bt_gatt_server_notification_state_change_cb"); +} + +static void __bt_gatt_server_write_value_requested_cb_p(const char *remote_address, int request_id, bt_gatt_server_h server, bt_gatt_h gatt_handle, bool response_needed, int offset, const char *value, int len, void *user_data) +{ + fprintf(stderr, "__bt_gatt_server_write_value_requested_cb"); +} + +static bool __bt_gatt_server_foreach_svc_cb_p(int total, int index, bt_gatt_h svc_handle, void *data) +{ + fprintf(stderr, "__bt_gatt_server_foreach_svc_cb"); + return true; +} + +/** + * @function utc_bluetooth_gatt_positive_startup + * @description check if bluetooth is supported and LE is supported, Initialize bluetooth and check the adapter state and + * store adapter state for further use. + * @parameter NA + * @return NA + */ +void utc_bluetooth_gatt_positive_startup(void) +{ + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + le_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le", &le_supported); + + gatt_client_supported = false; + system_info_get_platform_bool("tizen.org/feature/network.bluetooth.le.gatt.client", &gatt_client_supported); + + gatt_server_supported = false; + system_info_get_platform_bool("tizen.org/feature/network.bluetooth.le.gatt.server", &gatt_server_supported); + + ipsp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.le.ipsp", &ipsp_supported); + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_gatt_positive_cleanup + * @description check If bluetooth is supported and LE is supported, release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_gatt_positive_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_gatt_set_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth LE is supported and startup_flag is asserted then register a callback for change + * in LE connection state and checked for errors. + * scenario Registers a callback function that will be invoked when the LE connection state is changed. + */ +int utc_bluetooth_bt_gatt_set_connection_state_changed_cb_p(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_set_connection_state_changed_cb(gatt_connection_state_changed_cb_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_set_connection_state_changed_cb(gatt_connection_state_changed_cb_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description check if bluetooth LE is supported and startup_flag is asserted then the callback is unregistered for change + * in LE connection state and checked for errors. + * scenario Unregisters a callback function that will be invoked when the connection state is changed. + */ +int utc_bluetooth_bt_gatt_unset_connection_state_changed_cb_p(void) +{ + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_destroy_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then the GATT service handle is destroyed + * and checked for errors. + * scenario Call to destroy GATT service handle. + */ +int utc_bluetooth_bt_gatt_service_destroy_p(void) +{ + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_destroy(service); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_service_destroy(service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_destroy_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then the GATT characteristic handle is destroyed + * and checked for errors. + * scenario Call to destroy GATT characteristic handle. + */ +int utc_bluetooth_bt_gatt_characteristic_destroy_p(void) +{ + bt_gatt_h characteristic = NULL; + char *char_uuid = "2a19"; /* Battery Level */ + char char_value[1] = { 80 }; /* 80% */ + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_destroy(characteristic); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_characteristic_destroy(characteristic); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_descriptor_destroy_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then the GATT descriptor handle is destroyed + * and checked for errors. + * scenario Call to destroy GATT descriptor handle. + */ +int utc_bluetooth_bt_gatt_descriptor_destroy_p(void) +{ + bt_gatt_h descriptor = NULL; + char *desc_uuid = "2902"; + char desc_value[2] = { 0, 0 }; /* Notification & Indication */ + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_create(desc_uuid, permissions, desc_value, sizeof(desc_value), &descriptor); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_destroy(descriptor); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_descriptor_destroy(descriptor); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_get_permissions_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, create characteristic's handle and get characteristic's permission then ensure there is no error. + * And then, destroy the characteristic's handle. + * Else, get characteristic's permission and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_characteristic_get_permissions and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_characteristic_get_permissions_p(void) +{ + bt_gatt_h characteristic = NULL; + char *char_uuid = "2a19"; /* Battery Level */ + char char_value[1] = { 80 }; /* 80% */ + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_get_permissions(characteristic, (int *)&permissions); + if (ret != BT_ERROR_NONE) { + bt_gatt_characteristic_destroy(characteristic); + } + + assert_eq(ret, BT_ERROR_NONE); + bt_gatt_characteristic_destroy(characteristic); + } else { + ret = bt_gatt_characteristic_get_permissions(characteristic, (int *)&permissions); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_descriptor_get_permissions_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, create descriptor's handle and get descriptor's permission then ensure there is no error. + * And then, destroy the descriptor's handle. + * Else, get descriptor's permission and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_descriptor_get_permissions and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_descriptor_get_permissions_p(void) +{ + bt_gatt_h descriptor = NULL; + char *desc_uuid = "2902"; + char desc_value[2] = { 0, 0 }; /* Notification & Indication */ + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_create(desc_uuid, permissions, desc_value, sizeof(desc_value), &descriptor); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_get_permissions(descriptor, (int *)&permissions); + if (ret != BT_ERROR_NONE) { + bt_gatt_descriptor_destroy(descriptor); + } + + assert_eq(ret, BT_ERROR_NONE); + bt_gatt_descriptor_destroy(descriptor); + } else { + ret = bt_gatt_descriptor_get_permissions(descriptor, (int *)&permissions); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_create_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then the GATT service is created + * for specific UUID/type and checked for errors. + * scenario Create the GATT service for specific UUID and service type. + */ +int utc_bluetooth_bt_gatt_service_create_p(void) +{ + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + } else { + ret = bt_gatt_service_create(service_uuid, service_type, &service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_add_characteristic_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, create GATT service handle and characteristic handle. + * Then, add the characteristic's handle to serivce's handle and ensure there is no error. + * Else, add the characteristic's handle to serivce's handle and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_service_add_characteristic and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_service_add_characteristic_p(void) +{ + bt_gatt_h service = NULL; + bt_gatt_h characteristic = NULL; + char *service_uuid = "180f"; /* Battery Service */ + char *char_uuid = "2a19"; /* Battery Level */ + char char_value[1] = { 80 }; /* 80% */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_add_characteristic(service, characteristic); + if (ret != BT_ERROR_NONE) { + bt_gatt_characteristic_destroy(characteristic); + bt_gatt_service_destroy(service); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_characteristic_destroy(characteristic); + bt_gatt_service_destroy(service); + } else { + ret = bt_gatt_service_add_characteristic(service, characteristic); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_add_included_service_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, create GATT service handle and included service handle. + * Then, add the included service handle to service handle and ensure there is no error. + * Else, add the included service handle to service handle and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_service_add_included_service and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_service_add_included_service_p(void) +{ + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + bt_gatt_h included_service = NULL; + char *included_service_uuid = "180d"; /* Heart Rate Service */ + bt_gatt_service_type_e included_service_type = BT_GATT_SERVICE_TYPE_SECONDARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(included_service_uuid, included_service_type, &included_service); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_add_included_service(service, included_service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_service_destroy(included_service); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_service_destroy(included_service); + } else { + ret = bt_gatt_service_add_included_service(service, included_service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_service_get_server_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT server's handle and GATT service. Then, register service to server and get server from service and ensure there is no error. + * Else, get GATT server handle from service and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_service_get_server on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_service_get_server_p(void) +{ + bt_gatt_server_h server = NULL; + bt_gatt_server_h get_server = NULL; + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_destroy(server); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_get_server(service, &get_server); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_service_get_server(service, &get_server); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_create_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then the GATT characteristic is created + * for specific UUID/property and checked for errors. + * scenario Create the GATT characteristic for specific UUID and property. + */ +int utc_bluetooth_bt_gatt_characteristic_create_p(void) +{ + bt_gatt_h characteristic = NULL; + char *char_uuid = "2a19"; /* Battery Level */ + char char_value[1] = { 80 }; /* 80% */ + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_characteristic_destroy(characteristic); + } else { + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_characteristic_add_descriptor_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, create GATT characteristic's handle and descriptor's handle. + * Then, add the descriptor's handle to characteristic's handle and ensure there is no error. + * Else, add the descriptor's handle to characteristic's handle and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_characteristic_add_descriptor and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_characteristic_add_descriptor_p(void) +{ + bt_gatt_h characteristic = NULL; + bt_gatt_h descriptor = NULL; + char *char_uuid = "2a19"; /* Battery Level */ + char *desc_uuid = "2902"; + char char_value[1] = { 80 }; /* 80% */ + char desc_value[2] = { 0, 0 }; /* Notification & Indication */ + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + ret = bt_gatt_descriptor_create(desc_uuid, permissions, desc_value, sizeof(desc_value), &descriptor); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor); + if (ret != BT_ERROR_NONE) { + bt_gatt_descriptor_destroy(descriptor); + bt_gatt_characteristic_destroy(characteristic); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_descriptor_destroy(descriptor); + bt_gatt_characteristic_destroy(characteristic); + } else { + ret = bt_gatt_characteristic_add_descriptor(characteristic, descriptor); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_descriptor_create_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then the GATT descriptor is created + * for specific UUID/permissions and checked for errors. + * scenario Create the GATT descriptor for specific UUID and permissions. + */ +int utc_bluetooth_bt_gatt_descriptor_create_p(void) +{ + bt_gatt_h descriptor = NULL; + char *desc_uuid = "2902"; + char desc_value[2] = { 0, 0 }; /* Notification & Indication */ + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; + + if (gatt_client_supported || gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_descriptor_create(desc_uuid, permissions, desc_value, sizeof(desc_value), &descriptor); + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_descriptor_destroy(descriptor); + } else { + ret = bt_gatt_descriptor_create(desc_uuid, permissions, desc_value, sizeof(desc_value), &descriptor); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_initialize_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, deinitialize the GATT server and initialize the GATT server and ensure there is no error. + * Else, initialize the GATT server and verify the result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_initialize on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_initialize_p(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_deinitialize_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, deinitialize the GATT server and ensure there is no error. + * Else, deinitialize the GATT server and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_deinitialize on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_deinitialize_p(void) +{ + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_create_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, create GATT server's handle and ensure there is no error. + * Else, create GATT server's handle and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_create on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_create_p(void) +{ + bt_gatt_server_h server = NULL; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_server_destroy(server); + } else { + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_destroy_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. If yes, create GATT server's handle and destroy GATT server's handle then ensure there is no error. + * Else, destroy GATT server's handle and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_destroy on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_destroy_p(void) +{ + bt_gatt_server_h server = NULL; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_destroy(server); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_server_destroy(server); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT characteristic handle. Then, register a callback function to invoked when a read request + * for a specified characteristic is issued and ensure there is no error. + * Else, register a callback function and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_set_read_value_requested_cb on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_set_read_value_requested_cb_p(void) +{ + bt_gatt_h characteristic = NULL; + char *char_uuid = "2a19"; /* Battery Level */ + char char_value[1] = { 80 }; /* 80% */ + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb_p, NULL); + if (ret != BT_ERROR_NONE) { + bt_gatt_characteristic_destroy(characteristic); + } + + assert_eq(ret, BT_ERROR_NONE); + bt_gatt_characteristic_destroy(characteristic); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_set_read_value_requested_cb(characteristic, __bt_gatt_server_read_value_requested_cb_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT characteristic handle. Then, register a callback function to invoked when the remote device + * enables or disables the Notification/Indication for particular characteristics and ensure there is no error. + * Else, register a callback function and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_set_characteristic_notification_state_change_cb on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_set_characteristic_notification_state_change_cb_p(void) +{ + bt_gatt_h characteristic = NULL; + char *char_uuid = "2a19"; /* Battery Level */ + char char_value[1] = { 80 }; /* 80% */ + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, __bt_gatt_server_notification_state_change_cb_p, NULL); + if (ret != BT_ERROR_NONE) { + bt_gatt_characteristic_destroy(characteristic); + } + + assert_eq(ret, BT_ERROR_NONE); + bt_gatt_characteristic_destroy(characteristic); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_set_characteristic_notification_state_change_cb(characteristic, __bt_gatt_server_notification_state_change_cb_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT characteristic handle. Then, register a callback function to invoked when a value of + * characteristic has been changed cnd ensure there is no error. + * Else, register a callback function and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_set_write_value_requested_cb on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_set_write_value_requested_cb_p(void) +{ + bt_gatt_h characteristic = NULL; + char *char_uuid = "2a19"; /* Battery Level */ + char char_value[1] = { 80 }; /* 80% */ + bt_gatt_property_e properties = BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_NOTIFY; + bt_gatt_permission_e permissions = BT_GATT_PERMISSION_READ; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_characteristic_create(char_uuid, permissions, properties, char_value, sizeof(char_value), &characteristic); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_set_write_value_requested_cb(characteristic, __bt_gatt_server_write_value_requested_cb_p, NULL); + if (ret != BT_ERROR_NONE) { + bt_gatt_characteristic_destroy(characteristic); + } + + assert_eq(ret, BT_ERROR_NONE); + bt_gatt_characteristic_destroy(characteristic); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_set_write_value_requested_cb(characteristic, __bt_gatt_server_write_value_requested_cb_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_get_service_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT server's handle and GATT service. Then, register service to server and get service from servere and ensure there is no error. + * Else, get GATT service handle from server and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_get_service on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_get_service_p(void) +{ + bt_gatt_server_h server = NULL; + bt_gatt_h service = NULL; + bt_gatt_h get_service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_destroy(server); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_get_service(server, service_uuid, &get_service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_get_service(server, service_uuid, &get_service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_foreach_services_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT server's handle and GATT service. + * Then, register service to server and invokes a callback function on each service that belongs to the GATT server and ensure there is no error. + * Else, invokes a callback function on each service and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_foreach_services on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_foreach_services_p(void) +{ + bt_gatt_server_h server = NULL; + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_destroy(server); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_foreach_services(server, __bt_gatt_server_foreach_svc_cb_p, NULL); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_foreach_services(server, __bt_gatt_server_foreach_svc_cb_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_register_service_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT server's handle and GATT service. Then, register service to server and ensure there is no error. + * Else, register service to server and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_register_service on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_register_service_p(void) +{ + bt_gatt_server_h server = NULL; + + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_destroy(server); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_register_service(server, service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_unregister_service_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT server's handle and GATT service. Then, register service to server and unregister service and ensure there is no error. + * Else, unregister service from server and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_unregister_service on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_unregister_service_p(void) +{ + bt_gatt_server_h server = NULL; + + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_destroy(server); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_unregister_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_unregister_service(server, service); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_unregister_all_services_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT server's handle and GATT service. Then, register service to server and unregister all services and ensure there is no error. + * Else, unregister services from server and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_unregister_all_services on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_unregister_all_services_p(void) +{ + bt_gatt_server_h server = NULL; + + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_destroy(server); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_unregister_all_services(server); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + } + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_unregister_all_services(server); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_gatt_server_start_p + * @since_tizen 3.0 + * @description check if bluetooth LE is supported and startup_flag is asserted. + * If yes, create GATT server's handle and GATT service. Then, register service to server and start server and ensure there is no error. + * Else, start server and verify result as BT_ERROR_NOT_SUPPORTED. + * scenario Check if bluetooth LE is supported and startup_flag is asserted. Then, call bt_gatt_server_start on the device and check for BT_ERROR_NOE. + */ +int utc_bluetooth_bt_gatt_server_start_p(void) +{ + bt_gatt_server_h server = NULL; + + bt_gatt_h service = NULL; + char *service_uuid = "180f"; /* Battery Service */ + bt_gatt_service_type_e service_type = BT_GATT_SERVICE_TYPE_PRIMARY; + + if (gatt_server_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_server_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_create(&server); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_deinitialize(); + } + + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_service_create(service_uuid, service_type, &service); + if (ret != BT_ERROR_NONE) { + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_register_service(server, service); + if (ret != BT_ERROR_NONE) { + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_server_start(); + assert_eq(ret, BT_ERROR_NONE); + + bt_gatt_service_destroy(service); + bt_gatt_server_destroy(server); + bt_gatt_server_deinitialize(); + } else { + ret = bt_gatt_server_start(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_p + * @since_tizen 4.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then register a callback for change + * in IPSP connection state and checked for errors. + * scenario Registers a callback function that will be invoked when the IPSP connection state is changed. + */ +int utc_bluetooth_bt_ipsp_set_connection_state_changed_cb_p(void) +{ + if (ipsp_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_ipsp_set_connection_state_changed_cb(__bt_ipsp_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_ipsp_unset_connection_state_changed_cb(); + } else { + ret = bt_ipsp_set_connection_state_changed_cb(__bt_ipsp_connection_state_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_p + * @since_tizen 4.0 + * @description check if bluetooth LE is supported and startup_flag is asserted then the callback is unregistered for change + * in IPSP connection state and checked for errors. + * scenario Unregisters a callback function that will be invoked when the IPSP connection state is changed. + */ +int utc_bluetooth_bt_ipsp_unset_connection_state_changed_cb_p(void) +{ + if (ipsp_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_ipsp_set_connection_state_changed_cb(__bt_ipsp_connection_state_changed_cb, NULL); + + ret = bt_ipsp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_ipsp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_gatt_client_set_att_mtu_changed_cb_p(void) +{ + bt_gatt_client_h client = NULL; + static const char *remote_addr = "E4:32:CB:41:1F:A6"; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_create(remote_addr, &client); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_client_set_att_mtu_changed_cb(client, __bt_gatt_client_att_mtu_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_client_unset_att_mtu_changed_cb(client); + + bt_gatt_client_destroy(client); + } else { + ret = bt_gatt_client_set_att_mtu_changed_cb(client, __bt_gatt_client_att_mtu_changed_cb, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +int utc_bluetooth_bt_gatt_client_unset_att_mtu_changed_cb_p(void) +{ + bt_gatt_client_h client = NULL; + static const char *remote_addr = "E4:32:CB:41:1F:A6"; + + if (gatt_client_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_gatt_client_create(remote_addr, &client); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_gatt_client_set_att_mtu_changed_cb(client, __bt_gatt_client_att_mtu_changed_cb, NULL); + + ret = bt_gatt_client_unset_att_mtu_changed_cb(client); + bt_gatt_client_destroy(client); + + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_gatt_client_unset_att_mtu_changed_cb(client); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_hdp_negative.c b/tests/unittest/utc_bluetooth_hdp_negative.c new file mode 100644 index 0000000..a810953 --- /dev/null +++ b/tests/unittest/utc_bluetooth_hdp_negative.c @@ -0,0 +1,413 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothHDPNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool hdp_supported = false; +static bool bt_supported = false; + +/** + * @function utc_bluetooth_hdp_negative_startup + * @description check if bluetooth is supported and HDP is supported, initialize bluetooth + * @parameter NA + * @return NA + */ +void utc_bluetooth_hdp_negative_startup(void) +{ + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + hdp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.health", &hdp_supported); + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_hdp_negative_cleanup + * @description If bluetooth is supported and release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_hdp_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_hdp_set_data_received_cb_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then de-initialize the bluetooth and register a callback + * that will be invoked when you receive the data and check for errors. + * @scenario Try to register a callback function that will be invoked when you receive the data, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hdp_set_data_received_cb_n(void) +{ + if (hdp_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_hdp_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_set_data_received_cb_n1 + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then register a callback, + * that will be invoked when you receive the data, by using invalid parameters and check for errors. + * @scenario Try to register a callback function that will be invoked when you receive the data by using invalid parameters. + */ +int utc_bluetooth_bt_hdp_set_data_received_cb_n1(void) +{ + if (!hdp_supported) { + ret = bt_hdp_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then de-initialize the bluetooth and register a callback + * that will be invoked when HDP connection state is changed and check for errors. + * @scenario Try to register a callback function that will be invoked when the HDP connection state is changed, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n(void) +{ + if (!hdp_supported) { + ret = bt_hdp_set_connection_state_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_set_connection_state_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n1 + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then register a callback, + * that will be invoked when HDP connection state is changed, by using invalid parameters and check for errors. + * @scenario Try to register a callback function that will be invoked when the HDP connection state is changed, by using invalid parameters. + */ +int utc_bluetooth_bt_hdp_set_connection_state_changed_cb_n1(void) +{ + if (!hdp_supported) { + ret = bt_hdp_set_connection_state_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_connection_state_changed_cb(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_disconnect_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then de-initialize the bluetooth and disconnect + * HDP connection and check for errors. + * @scenario Try to disconnect the remote device, asynchronously. after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hdp_disconnect_n(void) +{ + if (!hdp_supported) { + ret = bt_hdp_disconnect(NULL, 1); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_disconnect(NULL, 1); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_connect_to_source_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then disconnect HDP connection + * by using invalid parameters. and check for errors. + * @scenario Try to disconnect the remote device, asynchronously by using invalid parameters. + */ +int utc_bluetooth_bt_hdp_connect_to_source_n(void) +{ + if (!hdp_supported) { + ret = bt_hdp_connect_to_source(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef WEARABLE + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); +#endif + ret = bt_hdp_connect_to_source(NULL, NULL); +#ifdef WEARABLE + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#else + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#endif + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_connect_to_source_n2 + * @since_tizen 2.3 + * @description + */ +int utc_bluetooth_bt_hdp_connect_to_source_n2(void) +{ + if (!hdp_supported) { + ret = bt_hdp_connect_to_source(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_connect_to_source(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_register_sink_app_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then de-initialize the bluetooth and register + * HDP app with sink role and check for errors. + * @scenario Try to register an application that acts as the @a Sink role of HDP(Health Device Profile), after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hdp_register_sink_app_n(void) +{ + if (!hdp_supported) { + ret = bt_hdp_register_sink_app(1, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_register_sink_app(1, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_unregister_sink_app_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then de-initialize the bluetooth and unregister + * HDP app with sink role and check for errors. + * @scenario Try to unregister an application that acts as the @a Sink role of HDP(Health Device Profile), after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hdp_unregister_sink_app_n(void) +{ + if (!hdp_supported) { + ret = bt_hdp_unregister_sink_app(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_unregister_sink_app(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_unregister_sink_app_n1 + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, unregister HDP app with sink role + * by using invalid parameters and check for errors. + * @scenario Try to unregister an application that acts as the @a Sink role of HDP(Health Device Profile) by using invalid parameters. + */ +int utc_bluetooth_bt_hdp_unregister_sink_app_n1(void) +{ + if (!hdp_supported) { + ret = bt_hdp_unregister_sink_app(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_unregister_sink_app(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_send_data_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then send HDP data to remote device + * by using invalid parameters and check for errors. + * @scenario Try to send the data to the remote device by using invalid parameters. + */ +int utc_bluetooth_bt_hdp_send_data_n(void) +{ +#ifdef WEARABLE + const char *data = "dts_test"; +#else + char *data = "dts_test"; +#endif + if (!hdp_supported) { +#ifdef WEARABLE + ret = bt_hdp_send_data(1, data, strlen(data)); +#else + ret = bt_hdp_send_data(1, data, sizeof(data)); +#endif + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + +#ifdef WEARABLE + ret = bt_hdp_send_data(1, data, strlen(data)); +#else + ret = bt_hdp_send_data(1, data, sizeof(data)); +#endif + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; + +} + +static void connected_cb_for_hdp_p(int result, const char *remote_address, const char *app_id, bt_hdp_channel_type_e type, unsigned int channel, void *user_data) +{ + +} + +static void disconnected_cb_for_hdp_p(int result, const char *remote_address, unsigned int channel, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then de-initialize the bluetooth and unregister the callback set + * for HDP connection state change and check for errors. + * @scenario Try to unregister a callback function that will be invoked when the HDP connection state is changed, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_n(void) +{ + if (!hdp_supported) { + ret = bt_hdp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_connection_state_changed_cb(connected_cb_for_hdp_p, disconnected_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + bt_deinitialize(); + bt_hdp_unset_connection_state_changed_cb(); + } + + return 0; +} + +static void data_received_cb_for_hdp_p(unsigned int channel, const char *data, unsigned int size, void *user_data) +{ + +} + +/** + * @testcase utc_bluetooth_bt_hdp_unset_data_received_cb_n + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted, then de-initialize the bluetooth and unregister the callback + * set for receiving the data and check for errors. + * @scenario Try to unregister a callback function that will be invoked when you receive the data, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hdp_unset_data_received_cb_n(void) +{ + if (!hdp_supported) { + ret = bt_hdp_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_data_received_cb(data_received_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + bt_deinitialize(); + bt_hdp_unset_data_received_cb(); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_hdp_positive.c b/tests/unittest/utc_bluetooth_hdp_positive.c new file mode 100644 index 0000000..19b77cb --- /dev/null +++ b/tests/unittest/utc_bluetooth_hdp_positive.c @@ -0,0 +1,254 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothHDPPositive + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool hdp_supported = false; +static bool bt_supported = false; + +static void data_received_cb_for_hdp_p(unsigned int channel, const char *data, unsigned int size, void *user_data) +{ + +} + +static void connected_cb_for_hdp_p(int result, const char *remote_address, const char *app_id, bt_hdp_channel_type_e type, unsigned int channel, void *user_data) +{ + +} + +static void disconnected_cb_for_hdp_p(int result, const char *remote_address, unsigned int channel, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_hdp_positive_startup + * @description check if bluetooth is supported and HDP is supported, Initialize bluetooth and check the adapter state and + * store adapter state for further use. + * @parameter NA + * @return NA + */ +void utc_bluetooth_hdp_positive_startup(void) +{ + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + startup_flag = BT_ERROR_NONE; + + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + hdp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.health", &hdp_supported); + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_hdp_positive_cleanup + * @description check If bluetooth is supported release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_hdp_positive_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_hdp_set_data_received_cb_p + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted then register a callback + * that will be invoked when you receive the data and check for errors. + * @scenario Registers a callback function that will be invoked when you receive the data. + */ +int utc_bluetooth_bt_hdp_set_data_received_cb_p(void) +{ + if (!hdp_supported) { + ret = bt_hdp_set_data_received_cb(data_received_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_data_received_cb(data_received_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_unset_data_received_cb_p + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted then unregister a callback + * that will be invoked when you receive the data and check for errors. + * @scenario unregisters a callback function that will be invoked when you receive the data. + */ +int utc_bluetooth_bt_hdp_unset_data_received_cb_p(void) +{ + if (!hdp_supported) { + ret = bt_hdp_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_data_received_cb(data_received_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_set_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted then register a callback that will be + * called when HDP connection state is changed and check for errors. + * scenario Registers a callback function that will be invoked when the HDP connection state is changed. + */ +int utc_bluetooth_bt_hdp_set_connection_state_changed_cb_p(void) +{ + if (!hdp_supported) { + ret = bt_hdp_set_connection_state_changed_cb(connected_cb_for_hdp_p, disconnected_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_connection_state_changed_cb(connected_cb_for_hdp_p, disconnected_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted then unregister the callback set for + * HDP connection state change and check for errors. + * scenario Unregisters a callback function that will be invoked when the HDP connection state is changed. + */ +int utc_bluetooth_bt_hdp_unset_connection_state_changed_cb_p(void) +{ + if (!hdp_supported) { + ret = bt_hdp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_set_connection_state_changed_cb(connected_cb_for_hdp_p, disconnected_cb_for_hdp_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hdp_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_unregister_sink_app_p + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted then unregister the app + * that acts as sink role for HDP and checked for errors. + * scenario Unregisters the given application that acts as the @a Sink role of HDP(Health Device Profile). + */ +int utc_bluetooth_bt_hdp_unregister_sink_app_p(void) +{ + char *app_id = NULL; + + if (!hdp_supported) { + ret = bt_hdp_unregister_sink_app(app_id); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); +#ifdef WEARABLE + ret = bt_hdp_register_sink_app(1, &app_id); + assert_eq(ret, BT_ERROR_NONE); +#else + bt_hdp_register_sink_app(1, &app_id); +#endif + + ret = bt_hdp_unregister_sink_app(app_id); + assert_eq(ret, BT_ERROR_NONE); + + free(app_id); + app_id = NULL; + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hdp_register_sink_app_p + * @since_tizen 2.3 + * @description check if HDP is supported and startup_flag is asserted then register the app + * that acts as sink role for HDP and checked for errors. + * scenario Registers the given application that acts as the @a Sink role of HDP(Health Device Profile). + */ +int utc_bluetooth_bt_hdp_register_sink_app_p(void) +{ + char *app_id = NULL; + + if (!hdp_supported) { + ret = bt_hdp_register_sink_app(1, &app_id); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hdp_register_sink_app(1, &app_id); + assert_eq(ret, BT_ERROR_NONE); + +#ifdef WEARABLE + ret = bt_hdp_unregister_sink_app(app_id); + assert_eq(ret, BT_ERROR_NONE); +#else + bt_hdp_unregister_sink_app(app_id); +#endif + + free(app_id); + app_id = NULL; + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_hid_negative.c b/tests/unittest/utc_bluetooth_hid_negative.c new file mode 100644 index 0000000..f94eca8 --- /dev/null +++ b/tests/unittest/utc_bluetooth_hid_negative.c @@ -0,0 +1,441 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothHIDNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool hid_supported = false; +static bool hid_device_supported = false; +static bool bt_supported = false; +static char *remote_address = "D8:90:E8:EE:2B:3A"; + +static void host_connection_state_changed_cb_for_hid_p(int result, bool connected, const char *remote_address, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_hid_negative_startup + * @description Check for the support of BT and HID features on the device and initialize the Bluetooth + * and HID(Human Interface Device) Host on the device. + * @parameter NA + * @return NA + */ +void utc_bluetooth_hid_negative_startup(void) +{ + startup_flag = BT_ERROR_NONE; + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + hid_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.hid", &hid_supported); +#else + bt_supported = true; + hid_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + hid_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.hid", &hid_supported); +#ifdef WEARABLE + hid_device_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.hid_device", &hid_device_supported); +#endif +#endif + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } + + if (hid_supported) { + ret = bt_hid_host_initialize(host_connection_state_changed_cb_for_hid_p, NULL); + } +} + +/** + * @function utc_bluetooth_hid_negative_cleanup + * @description Check for the support of BT and HID features on the device and deinitialize the HID(Human Interface Device) Host. + * @parameter NA + * @return NA + */ +void utc_bluetooth_hid_negative_cleanup(void) +{ + if (hid_supported) { + bt_hid_host_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_hid_host_initialize_n + * @since_tizen 2.3 + * @description Check for the support of HID feature and initialize the Bluetooth HID(Human Interface Device) Host with NULL parameters. + * Check bt is initialized and deinitialize the bluetooth and initialize the HID host on the device. Check for expected error. + * @senario Initialize the HID host when HID feature is not supported. Denitialize the bt adapter and re-initialize hid host and check status. + */ +int utc_bluetooth_bt_hid_host_initialize_n(void) +{ + if (!hid_supported) { + ret = bt_hid_host_initialize(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_host_initialize(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_host_initialize_n1 + * @since_tizen 2.3 + * @description Check for the support of HID feature and initialize the Bluetooth HID(Human Interface Device) Host with NULL parameters. + * Confirm the bluetooth is initialzed and then initialize the HID host on the device. Check for expected error. + * @senario Initialize the HID host when HID feature is not supported. Ensure bt is initlaized and initialize HID host and check status. + */ +int utc_bluetooth_bt_hid_host_initialize_n1(void) +{ + if (!hid_supported) { + ret = bt_hid_host_initialize(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hid_host_initialize(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_host_connect_n + * @since_tizen 2.3 + * @description Check for the support of HID feature and perform connect operation from HID(Human Interface Device) Host with NULL parameter. + * Confirm the bluetooth is initialized and perform connect operation from HID host with NULL parameter. Check for expected error. + * @senario Perform the connect operation from HID Host when HID feature is not supported. Ensure bt is initialized and perform HID host connect and check status. + */ +int utc_bluetooth_bt_hid_host_connect_n(void) +{ + if (!hid_supported) { + ret = bt_hid_host_connect(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef TV + ret = bt_hid_host_connect(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#else + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_host_connect(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#endif + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_host_disconnect_n + * @since_tizen 2.3 + * @description Check for the support of HID feature and perform disconnect operation from HID(Human Interface Device) Host with NULL parameter. + * Confirm the bluetooth is initialized and perform disconnect operation from HID host with NULL parameter. Check for expected error. + * @senario Perform the disconnect operation from HID Host when HID feature is not supported. Ensure bt is initialized and perform HID host disconnect and check status. + */ +int utc_bluetooth_bt_hid_host_disconnect_n(void) +{ + if (!hid_supported) { + ret = bt_hid_host_disconnect(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef TV + ret = bt_hid_host_disconnect(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#else + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_host_disconnect(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#endif + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_host_deinitialize_n + * @since_tizen 2.3 + * @description Check for the support of HID feature and perform HID host deinitialize. + * Confirm the bluetooth is initialized and perform HID host initialize and deinitialize and then deinitialize again. Check for expected error. + * @senario Perform the HID Host initialize and deinitialize operations mutiple times and for check for expected result. + */ +int utc_bluetooth_bt_hid_host_deinitialize_n(void) +{ + if (!hid_supported) { + ret = bt_hid_host_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hid_host_initialize(host_connection_state_changed_cb_for_hid_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_host_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_host_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_hid_device_activate_n + * @since_tizen 3.0 + * @description Check for the support of HID DEVICE feature and initialize the Bluetooth HID(Human Interface Device) DEVICE with NULL parameters. + * Check bt is initialized and deinitialize the bluetooth and initialize the HID device on the device. Check for expected error. + * @senario Activate the HID Device when HID DEVICE feature is not supported. Denitialize the bt adapter and re-activate hid device and check status. + */ +int utc_bluetooth_bt_hid_device_activate_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_activate(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_activate(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_deactivate_n + * @since_tizen 3.0 + * @description Check for the support of HID DEVICE feature and perform HID device deactivate. + * Confirm the bluetooth is initialized and perform HID device activate and deactivate and then deactivate again. Check for expected error. + * @senario Perform the HID Device activate and deactivate operations mutiple times and for check for expected result. + */ +int utc_bluetooth_bt_hid_device_deactivate_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_deactivate(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_device_deactivate(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_connect_n + * @since_tizen 3.0 + * @description Check for the support of HID DEVICE feature and perform connect operation from HID(Human Interface Device) Device with NULL parameter. + * Confirm the bluetooth is initialized and perform connect operation from HID device with NULL parameter. Check for expected error. + * @senario Perform the connect operation from HID Device when HID DEVICE feature is not supported. Ensure bt is initialized and perform HID Device connect and check status. + */ +int utc_bluetooth_bt_hid_device_connect_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_connect(remote_address); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_connect(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_disconnect_n + * @since_tizen 3.0 + * @description Check for the support of HID DEVICE feature and perform disconnect operation from HID(Human Interface Device) Device with NULL parameter. + * Confirm the bluetooth is initialized and perform disconnect operation from HID Device with NULL parameter. Check for expected error. + * @senario Perform the disconnect operation from HID Device when HID Device feature is not supported. Ensure bt is initialized and perform HID Device disconnect and check status. + */ +int utc_bluetooth_bt_hid_device_disconnect_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_disconnect(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_disconnect(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_bt_hid_device_send_mouse_event_n + * @since_tizen 3.0 + * @description check if HID is supported and startup_flag is asserted, then send the mouse event's data to remote device + * by using invalid parameters and check for errors. + * @scenario Try to send the data to the remote device by using invalid parameters. + */ +int utc_bluetooth_bt_hid_device_send_mouse_event_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_send_mouse_event(remote_address, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_send_mouse_event(remote_address, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_bt_hid_device_send_key_event_n + * @since_tizen 3.0 + * @description check if HID is supported and startup_flag is asserted, then send the key event's data to remote device + * by using invalid parameters and check for errors. + * @scenario Try to send the data to the remote device by using invalid parameters. + */ +int utc_bluetooth_bt_hid_device_send_key_event_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_send_key_event(remote_address, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_send_key_event(remote_address, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_reply_to_report_n + * @since_tizen 3.0 + * @description check if HID is supported and startup_flag is asserted, then de-initialize the bluetooth and register a callback + * that will be invoked when you respose reports and check for errors. + * @scenario Try to respose to reports from HID host, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hid_device_reply_to_report_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_reply_to_report(remote_address, 0x01, 0x01, "reply", 8); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_hid_device_reply_to_report(remote_address, 0x01, 0x01, "reply", 8); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_set_data_received_cb_n + * @since_tizen 3.0 + * @description check if HID is supported and startup_flag is asserted, then de-initialize the bluetooth and register a callback + * that will be invoked when you receive the data and check for errors. + * @scenario Try to register a callback function that will be invoked when you receive the data, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hid_device_set_data_received_cb_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_hid_device_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_unset_data_received_cb_n + * @since_tizen 3.0 + * @description check if HID is supported and startup_flag is asserted, then de-initialize the bluetooth and unregister the callback + * set for receiving the data and check for errors. + * @scenario Try to unregister a callback function that will be invoked when you receive the data, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hid_device_unset_data_received_cb_n(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + + ret = bt_hid_device_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_hid_positive.c b/tests/unittest/utc_bluetooth_hid_positive.c new file mode 100644 index 0000000..eb8aa24 --- /dev/null +++ b/tests/unittest/utc_bluetooth_hid_positive.c @@ -0,0 +1,255 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothHIDPositive + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool hid_supported = false; +static bool hid_device_supported = false; +static bool bt_supported = false; + +static void host_connection_state_changed_cb_for_hid_p(int result, bool connected, const char *remote_address, void *user_data) +{ +} + +static void device_connection_state_changed_cb_for_hid_p(int result, bool connected, const char *remote_address, void *user_data) +{ + +} + +static void device_data_received_cb_for_hid_p(const bt_hid_device_received_data_s *data, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_hid_positive_startup + * @description Get system information to check for the support of Bluetooth and HID feature. If BT is supported on the device, + * then intialize the bluetooth on the device successfully and retrieve the adapter state. + * @parameter NA + * @return NA + */ +void utc_bluetooth_hid_positive_startup(void) +{ + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + hid_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.hid", &hid_supported); +#else + bt_supported = true; + hid_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + hid_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.hid", &hid_supported); +#ifdef WEARABLE + hid_device_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.hid_device", &hid_device_supported); +#endif +#endif + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_hid_positive_cleanup + * @description Check the system if HID feature is supported and if so deinitialize the hid support on the device. + * Check if BT is supported on the system and then deinitliaze the bluetooth. All resources should be cleaned up. + * @parameter NA + * @return NA + */ +void utc_bluetooth_hid_positive_cleanup(void) +{ + if (hid_supported) { + bt_hid_host_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_hid_host_initialize_p + * @since_tizen 2.3 + * @description Check the system if HID feature is supported and if so initialize the HID host on the device. Check for expected result. + * Check if BT is supported on the system and then initliaze the HID host. Check for expected result. + * @senario Check for the support of BT and HID features and then initialze the HID host. + */ +int utc_bluetooth_bt_hid_host_initialize_p(void) +{ + if (!hid_supported) { + ret = bt_hid_host_initialize(host_connection_state_changed_cb_for_hid_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hid_host_initialize(host_connection_state_changed_cb_for_hid_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_host_deinitialize_p + * @since_tizen 2.3 + * @description Check if HID feature is supported and if so deinitialize the HID host on the device. Check for expected result. + * Check if BT is supported on the system and then initliaze and deinitalize the HID host. Check for expected result. + * @senario Check for the support of BT and HID features then initialze and deinitlaize the HID host. + */ +int utc_bluetooth_bt_hid_host_deinitialize_p(void) +{ + if (!hid_supported) { + ret = bt_hid_host_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_hid_host_initialize(host_connection_state_changed_cb_for_hid_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_host_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_hid_device_activate_p + * @since_tizen 3.0 + * @description Check for the support of HID DEVICE feature and activate the Bluetooth HID(Human Interface Device) DEVICE with registering call back. + * Check to activate the HID device. Check for expected error. + * @senario Activate the HID Device when HID DEVICE feature is supported. After finish to activate hid device successfully and deactivate hid device. + */ +int utc_bluetooth_bt_hid_device_activate_p(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_activate(device_connection_state_changed_cb_for_hid_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_activate(device_connection_state_changed_cb_for_hid_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_device_deactivate(); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_deactivate_p + * @since_tizen 3.0 + * @description Check for the support of HID DEVICE feature and perform HID device deactivate. + * Confirm the bluetooth is initialized and perform HID device activate and deactivate. Check for expected error. + * @senario Perform the HID Device activate and deactivate operations and for check for expected result. + */ +int utc_bluetooth_bt_hid_device_deactivate_p(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_deactivate(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_activate(device_connection_state_changed_cb_for_hid_p, NULL); + + ret = bt_hid_device_deactivate(); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_set_data_received_cb_p + * @since_tizen 3.0 + * @description check if HID Device is supported and startup_flag is asserted then register a callback + * that will be invoked when you receive the data and check for errors. + * @scenario Try to register a callback function that will be invoked when you receive the data, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_hid_device_set_data_received_cb_p(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_set_data_received_cb(device_data_received_cb_for_hid_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_hid_device_unset_data_received_cb(); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_hid_device_unset_data_received_cb_p + * @since_tizen 3.0 + * @description check if HID Device is supported and startup_flag is asserted then unregister a callback + * that will be invoked when you receive the data and check for errors. + * @scenario Registers a callback function that will be invoked when you receive the data. + */ +int utc_bluetooth_bt_hid_device_unset_data_received_cb_p(void) +{ + if (!hid_device_supported) { + ret = bt_hid_device_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } else { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_hid_device_set_data_received_cb(device_data_received_cb_for_hid_p, NULL); + + ret = bt_hid_device_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NONE); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_opp_client_negative.c b/tests/unittest/utc_bluetooth_opp_client_negative.c new file mode 100644 index 0000000..6f6f43f --- /dev/null +++ b/tests/unittest/utc_bluetooth_opp_client_negative.c @@ -0,0 +1,268 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothOpp-clientNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool opp_supported = false; +static bool bt_supported = false; + +/** + * @function utc_bluetooth_opp_client_negative_startup + * @description Get system information to check for the support of Bluetooth and OPP feature. If BT is supported on the device, + * then intialize the bluetooth on the device successfully. If OPP is supported, initialize opp client. + * @parameter NA + * @return NA + */ +void utc_bluetooth_opp_client_negative_startup(void) +{ + startup_flag = BT_ERROR_NONE; + + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + opp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.opp", &opp_supported); + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } + + if (opp_supported) { + ret = bt_opp_client_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_opp_client_initialize failed (code: %d)\n", ret); + startup_flag = ret; + } + } +} + +/** + * @function utc_bluetooth_opp_client_negative_cleanup + * @description Check if bluetooth and OPP featurse are supported. If OPP is supported then deinitialize opp client. + * If BT is supported then deinitialize bluetooth. Check for expected result. + * @parameter NA + * @return NA + */ +void utc_bluetooth_opp_client_negative_cleanup(void) +{ + if (opp_supported) { + bt_opp_client_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_opp_client_initialize_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP featurse are supported. If OPP is supported then try to initialize opp client. + * If BT is supported then deinitialize bluetooth. Now try to initialize the opp client. Check for expected result. + * @senario Check if BT and OPP features are supported and then deinitialize bluetooth and initialize opp on the device. + * Should get error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_client_initialize_n(void) +{ + if (!opp_supported) { + ret = bt_opp_client_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_client_initialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_deinitialize_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then try to deinitialize opp client. + * If BT is supported then deinitialize bluetooth. Now try to deinitialize the opp client. Check for expected result. + * @senario Check if BT and OPP features are supported and then deinitialize opp client and bluetooth on the device. + * Should get error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_client_deinitialize_n(void) +{ + if (!opp_supported) { + ret = bt_opp_client_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_client_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_add_file_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then do bt_opp_client_add_file(). + * If BT is supported then deinitialize bluetooth. Now try to call bt_opp_client_add_file(). Check for expected result. + * @senario Check if BT and OPP features are supported and deinitialize bluetooth on the device and call bt_opp_client_add_file (). + * Should get error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_client_add_file_n(void) +{ + const char *file = "/tmp/image16.jpg"; + + if (!opp_supported) { + ret = bt_opp_client_add_file(file); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_client_add_file(file); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_add_file_n1 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then do bt_opp_client_add_file(). + * If BT is initialzed then try to call bt_opp_client_add_file() with NULL parameter. Check for result BT_ERROR_INVALID_PARAMETER. + * @senario Check if BT is initalized and OPP features is supported and call bt_opp_client_add_file () with NULL parameters. + */ +int utc_bluetooth_bt_opp_client_add_file_n1(void) +{ + if (!opp_supported) { + ret = bt_opp_client_add_file(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_client_add_file(NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_clear_files_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP feature are supported. If OPP is not supported then do bt_opp_client_clear_files(). + * If BT is initialized, then deinitalize bluetooth and call bt_opp_client_clear_files(). Check for result BT_ERROR_NOT_INITIALIZED. + * @senario Check if BT and OPP features are supported and call bt_opp_client_clear_files () after deinitializing the bluetooth. + */ +int utc_bluetooth_bt_opp_client_clear_files_n(void) +{ + if (!opp_supported) { + ret = bt_opp_client_clear_files(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_client_clear_files(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_push_files_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP feature are supported. If OPP is not supported then call bt_opp_client_push_files(). + * If BT is initialized, then deinitalize bluetooth and call bt_opp_client_push_files(). Check for result BT_ERROR_NOT_INITIALIZED. + * @senario Check if BT and OPP features are supported and call bt_opp_client_push_files () after deinitializing the bluetooth. + */ +int utc_bluetooth_bt_opp_client_push_files_n(void) +{ + if (!opp_supported) { + ret = bt_opp_client_push_files(NULL, NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_client_push_files(NULL, NULL, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_cancel_push_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP feature are supported. If OPP is not supported then call bt_opp_client_cancel_push(). + * If BT is initialized, then deinitalize bluetooth and call bt_opp_client_cancel_push(). Check for result BT_ERROR_NOT_INITIALIZED. + * @senario Check if BT and OPP features are supported and call bt_opp_client_cancel_push () after deinitializing the bluetooth. + */ +int utc_bluetooth_bt_opp_client_cancel_push_n(void) +{ + if (!opp_supported) { + ret = bt_opp_client_cancel_push(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_client_cancel_push(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_opp_client_positive.c b/tests/unittest/utc_bluetooth_opp_client_positive.c new file mode 100644 index 0000000..0203bde --- /dev/null +++ b/tests/unittest/utc_bluetooth_opp_client_positive.c @@ -0,0 +1,161 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothOpp-client_Positive + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool opp_supported = false; +static bool bt_supported = false; + +/** + * @function utc_bluetooth_opp_client_positive_startup + * @description Get system information to check for the support of Bluetooth and OPP feature. If BT is supported on the device, + * then intialize the bluetooth on the device successfully and retrieve the adapter state. If OPP is supported, initialize opp client. + * @parameter NA + * @return NA + */ +void utc_bluetooth_opp_client_positive_startup(void) +{ + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + opp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.opp", &opp_supported); + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } + + if (opp_supported) { + ret = bt_opp_client_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_opp_client_initialize failed (code: %d)\n", ret); + startup_flag = ret; + } + } +} + +/** + * @function utc_bluetooth_opp_client_positive_cleanup + * @description Check if bluetooth and OPP feature is supported. If OPP is supported then deinitialize opp client. + * If BT is supported then deinitialize bluetooth. Check for expected result. + * @parameter NA + * @return NA + */ +void utc_bluetooth_opp_client_positive_cleanup(void) +{ + if (opp_supported) { + bt_opp_client_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_opp_client_initialize_p + * @since_tizen 2.3 + * @description Check if OPP feature is supported. If OPP is non-supported then initialize OPP client. If bluetooth is initialized, + * deinitialize the opp client and then re-initialize the opp client. Check for expected result. + * @senario Check if BT and OPP features are supported and then initialize and deinitialize the OPP client + */ +int utc_bluetooth_bt_opp_client_initialize_p(void) +{ + if (!opp_supported) { + ret = bt_opp_client_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_client_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_client_initialize(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_deinitialize_p + * @since_tizen 2.3 + * @description Check if OPP feature is supported. If OPP is not supported then de-initialize the OPP client. If bluetooth is initialized, + * then deinitialize the opp client. Check for expected result. + * @senario Check if BT and OPP features are supported and then deinitialize the OPP client + */ +int utc_bluetooth_bt_opp_client_deinitialize_p(void) +{ + if (!opp_supported) { + ret = bt_opp_client_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_client_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_client_clear_files_p + * @since_tizen 2.3 + * @description Check for support of OPP feature and then clear all files received by the OPP client. If bluetooth is initialized, + * then clear all files received by the opp client. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_client_clear_files() from OPP client + */ +int utc_bluetooth_bt_opp_client_clear_files_p(void) +{ + if (!opp_supported) { + ret = bt_opp_client_clear_files(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_client_clear_files(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_opp_server_negative.c b/tests/unittest/utc_bluetooth_opp_server_negative.c new file mode 100644 index 0000000..c973773 --- /dev/null +++ b/tests/unittest/utc_bluetooth_opp_server_negative.c @@ -0,0 +1,454 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothOpp-serverNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static const char *dest = "/tmp"; +static bool opp_supported = false; +static bool bt_supported = false; + +static void transfer_finished_cb_for_opp_server_p(int result, const char *file, long long size, void *user_data) +{ + +} + +static void transfer_progress_cb_for_opp_server(const char *file, long long size, int percent, void *user_data) +{ + +} + +static void transfer_finished_cb_for_opp_server(int result, const char *file, long long size, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_bt_opp_server_negative_startup + * @description Get system information to check for the support of Bluetooth and OPP feature. If BT is supported on the device, + * then intialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_bt_opp_server_negative_startup(void) +{ + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + opp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.opp", &opp_supported); + + startup_flag = BT_ERROR_NONE; + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_bt_opp_server_negative_cleanup + * @description Check if bluetooth and OPP features are supported. If OPP is supported then deinitialize opp server. + * If BT is supported then deinitialize bluetooth. Check for expected result. + * @parameter NA + * @return NA + */ +void utc_bluetooth_bt_opp_server_negative_cleanup(void) +{ +#ifndef TV + if (opp_supported) { + bt_opp_server_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +#endif +} + +/** + * @testcase utc_bluetooth_bt_opp_server_accept_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call opp server accept api. + * If BT is initialized then deinitialize bluetooth and call bt_opp_server_accept. Check for expected result. + * @senario Check if BT and OPP features are supported and then deinitialize the bluetooth and call bt_opp_server_accept. + * Verify the result as BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_accept_n(void) +{ + if (!opp_supported) { + ret = bt_opp_server_accept(transfer_progress_cb_for_opp_server, transfer_finished_cb_for_opp_server, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_server_accept(transfer_progress_cb_for_opp_server, transfer_finished_cb_for_opp_server, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_accept_n1 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call opp server accept api. + * If BT is initialized then call bt_opp_server_accept. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_accept. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_accept_n1(void) +{ + if (!opp_supported) { + ret = bt_opp_server_accept(transfer_progress_cb_for_opp_server, transfer_finished_cb_for_opp_server, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_accept(transfer_progress_cb_for_opp_server, transfer_finished_cb_for_opp_server, NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_accept_n2 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call opp server accept api. + * If BT is initialized then call bt_opp_server_accept. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_accept. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_accept_n2(void) +{ + int tid = 0; + const char *name = "abc"; + + if (!opp_supported) { + ret = bt_opp_server_accept(transfer_progress_cb_for_opp_server, transfer_finished_cb_for_opp_server_p, name, NULL, &tid); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_accept(transfer_progress_cb_for_opp_server, transfer_finished_cb_for_opp_server_p, name, NULL, &tid); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_reject_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_reject(). + * If BT is initialized then deinitialize bluetooth and call bt_opp_server_reject. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_reject. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_reject_n(void) +{ + if (!opp_supported) { + ret = bt_opp_server_reject(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_server_reject(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_reject_n1 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_reject(). + * If BT is initialized then call bt_opp_server_reject. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_reject. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_reject_n1(void) +{ + if (!opp_supported) { + ret = bt_opp_server_reject(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_reject(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_set_destination_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_set_destination(). + * If BT is initialized then deinitialize bluetooth and set the destination for opp server with NULL parameters. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_set_destination. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_set_destination_n(void) +{ + if (!opp_supported) { + ret = bt_opp_server_set_destination(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_server_set_destination(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_set_destination_n1 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_set_destination(). + * If BT is initialized then set the destination for opp server with NULL parameters. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_set_destination. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_set_destination_n1(void) +{ + if (!opp_supported) { + ret = bt_opp_server_set_destination(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_set_destination(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_set_destination_n2 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_set_destination(). + * If BT is initialized then set the destination for opp server with valid parameters. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_set_destination. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_set_destination_n2(void) +{ + if (!opp_supported) { + ret = bt_opp_server_set_destination(dest); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_set_destination(dest); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_initialize_by_connection_request_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_initialize_by_connection_request(). + * If BT is initialized then deinitialize bluetooth and initialize opp server by connect request. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_initialize_by_connection_request. + * verify for error BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_initialize_by_connection_request_n(void) +{ + if (!opp_supported) { + ret = bt_opp_server_initialize_by_connection_request(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_server_initialize_by_connection_request(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_initialize_by_connection_request_n1 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_initialize_by_connection_request(). + * If BT is initialized then initialize opp server by connect request with NULL parameters. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_initialize_by_connection_request with NULL params. + * Verify for error BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_opp_server_initialize_by_connection_request_n1(void) +{ + if (!opp_supported) { + ret = bt_opp_server_initialize_by_connection_request(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_initialize_by_connection_request(NULL, NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_deinitialize_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then deinitialize opp server. + * If BT is initialized then deinitialize bluetooth and deinitialize opp server. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_deinitialize. + * Verify result as BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_deinitialize_n(void) +{ + if (!opp_supported) { + ret = bt_opp_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_deinitialize_n1 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then deinitialize opp server. + * If BT is initialized then deinitialize opp server. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_deinitialize. + * Verify result as BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_deinitialize_n1(void) +{ + if (!opp_supported) { + ret = bt_opp_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_cancel_transfer_n + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_cancel_transfer(). + * If BT is initialized then deinitialize bluetooth and cancel the transfer of data from opp server. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_cancel_transfer. + * Verify result as BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_cancel_transfer_n(void) +{ + int tid = 0; + + if (!opp_supported) { + ret = bt_opp_server_cancel_transfer(tid); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_opp_server_cancel_transfer(tid); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_cancel_transfer_n1 + * @since_tizen 2.3 + * @description Check if bluetooth and OPP features are supported. If OPP is not supported then call bt_opp_server_cancel_transfer(). + * If BT is initialized then cancel the transfer of data from opp server. Check for expected result. + * @senario Check if BT and OPP features are supported and then call bt_opp_server_cancel_transfer. + * Verify result as BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_opp_server_cancel_transfer_n1(void) +{ + int tid = 0; + + if (!opp_supported) { + ret = bt_opp_server_cancel_transfer(tid); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_cancel_transfer(tid); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_opp_server_positive.c b/tests/unittest/utc_bluetooth_opp_server_positive.c new file mode 100644 index 0000000..fe7bb61 --- /dev/null +++ b/tests/unittest/utc_bluetooth_opp_server_positive.c @@ -0,0 +1,160 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothOpp-serverPositive + +static bool startup_flag = true; +static int ret = BT_ERROR_NONE; +static const char *dest = "/tmp"; +static bool opp_supported = false; +static bool bt_supported = false; + +static void push_requested_cb_for_opp_server_p(const char *remote_address, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_opp_server_positive_startup + * @description Get system information to check for the support of Bluetooth and OPP feature. If BT is supported on the device, + * then intialize the bluetooth on the device successfully and retrieve the adapter state. + * @parameter NA + * @return NA + */ +void utc_bluetooth_opp_server_positive_startup(void) +{ + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + opp_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.opp", &opp_supported); + + startup_flag = BT_ERROR_NONE; + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_opp_server_positive_cleanup + * @description If BT is supported on the device, then deintialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_opp_server_positive_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_opp_server_initialize_by_connection_request_p + * @since_tizen 2.3 + * @description Check if OPP feature is supported. If OPP is non-supported then try to initialize the opp server. + * @senario Check if BT is initialized and then call bt_opp_server_initialize_by_connection_request(). + * @senario check if BT and OPP support is available on the device. Then call bt_opp_server_initialize_by_connection_request() + * and check for expected result. + */ +int utc_bluetooth_bt_opp_server_initialize_by_connection_request_p(void) +{ + if (!opp_supported) { + ret = bt_opp_server_initialize_by_connection_request(dest, push_requested_cb_for_opp_server_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_initialize_by_connection_request(dest, push_requested_cb_for_opp_server_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_deinitialize_p + * @since_tizen 2.3 + * @description Check if OPP feature is supported. If OPP is non-supported then try to deinitialize the opp server (bt_opp_server_deinitialize). + * @senario Check if BT is initialized and then call bt_opp_server_initialize_by_connection_request(). Then deinitialize opp server. + * @senario Check if BT and OPP support is available on the device. Then call bt_opp_server_initialize_by_connection_request() + * and bt_opp_server_deinitialize() and check for expected result. + */ +int utc_bluetooth_bt_opp_server_deinitialize_p(void) +{ + if (!opp_supported) { + ret = bt_opp_server_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_initialize_by_connection_request(dest, push_requested_cb_for_opp_server_p, NULL); + + ret = bt_opp_server_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_opp_server_set_destination_p + * @since_tizen 2.3 + * @description Check if OPP feature is supported. If OPP is non-supported then try to intialize the opp server. + * @senario Check if BT is initialized and then call bt_opp_server_initialize_by_connection_request(). Then set destination for opp server. + * @senario Check if BT and OPP support is available on the device. Then call bt_opp_server_initialize_by_connection_request() and + * then set destination(bt_opp_server_set_destination) and check for expected result. + */ +int utc_bluetooth_bt_opp_server_set_destination_p(void) +{ + if (!opp_supported) { + ret = bt_opp_server_initialize_by_connection_request(dest, push_requested_cb_for_opp_server_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_opp_server_initialize_by_connection_request(dest, push_requested_cb_for_opp_server_p, NULL); + + ret = bt_opp_server_set_destination(dest); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_pbap_negative.c b/tests/unittest/utc_bluetooth_pbap_negative.c new file mode 100644 index 0000000..e6b54b7 --- /dev/null +++ b/tests/unittest/utc_bluetooth_pbap_negative.c @@ -0,0 +1,389 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include + +//& set: BluetoothPBAPNegative + +static int startup_flag = BT_ERROR_NONE; +static bool pbap_supported = false; +static bool bt_supported = false; + +void get_phonebook_size_cb_for_pbap_n(int result, const char *remote_address, int size, void *user_data) +{ + +} + +void get_phonebook_pull_cb_pbap_n(int result, const char *remote_address, const char *vcf_file, void *user_data) +{ + +} + +void get_phonebook_list_cb_pbap_n(int result, const char *remote_address, const bt_pbap_vcard_info_s *vcard_info, int count, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_pbap_negative_startup + * @description check if bluetooth is supported and PBAP is supported, initialize bluetooth + * @parameter NA + * @return NA + */ +void utc_bluetooth_pbap_negative_startup(void) +{ + int ret = BT_ERROR_NONE; + + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + pbap_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.phonebook.client", &pbap_supported); + + if (bt_supported) { + startup_flag = BT_ERROR_NONE; + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_pbap_negative_cleanup + * @description If bluetooth is supported and release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_pbap_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_initialize_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * initialize the pbap client profiles and check for errors. + * scenario Try to initialize the Bluetooth profiles related with pbap client. after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_initialize_n(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_initialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_deinitialize_n + * @since_tizen 3.0 + * @description check if pbap client is supported and startup_flag is asserted then deinitialize the bluetooth and + * de-initialize the pbap client profiles and check for errors. + * scenario Try to deinitialize the Bluetooth profiles related with pbap client. after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_deinitialize_n(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_set_connection_state_changed_cb_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * register a callback for change in connection state and check for errors. + * scenario Try to register a callback function to be invoked when the connection state is changed after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_set_connection_state_changed_cb_n(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_unset_connection_state_changed_cb_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted then deinitialize the bluetooth and + * unregister the callback set for connection state changes and check for errors. + * scenario Try to unregister a callback function to be invoked when the connection state is changed after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_unset_connection_state_changed_cb_n(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_connect_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * connect to the remote device with given pbap client profile and check for errors. + * @scenario Try to connect the remote device with the given pbap client profile, asynchronously, + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_connect_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_connect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_connect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_disconnect_n + * @since_tizen 2.3 + * @description check if pbap client profile are supported and startup_flag is asserted, then deinitialize the bluetooth and + * disconnect to the remote device with given pbap client profile and check for errors. + * @scenario Try to disconnect the remote device with the given pbap client profile, asynchronously, + * after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_disconnect_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_disconnect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_disconnect(remote_addr); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_get_phone_book_size_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given pbap client profile API and check for errors. + * @scenario Try to call the given pbap client API asynchronously, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_get_phone_book_size_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_get_phone_book_size(remote_addr, 0, 0, get_phonebook_size_cb_for_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_get_phone_book_size(remote_addr, 0, 0, get_phonebook_size_cb_for_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_get_phone_book_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given pbap client profile API and check for errors. + * @scenario Try to call the given pbap client API asynchronously, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_get_phone_book_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + unsigned int fields = BT_PBAP_FIELD_PHOTO | BT_PBAP_FIELD_EMAIL; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_get_phone_book(remote_addr, 0, 0, 0, 0, 0, 100, fields, get_phonebook_pull_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_get_phone_book(remote_addr, 0, 0, 0, 0, 0, 100, fields, get_phonebook_pull_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_get_list_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given pbap client profile API and check for errors. + * @scenario Try to call the given pbap client API asynchronously, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_get_list_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_get_list(remote_addr, 0, 0, 0, 0, 100, get_phonebook_list_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_get_list(remote_addr, 0, 0, 0, 0, 100, get_phonebook_list_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_pull_vcard_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given pbap client profile API and check for errors. + * @scenario Try to call the given pbap client API asynchronously, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_pull_vcard_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + unsigned int fields = BT_PBAP_FIELD_PHOTO | BT_PBAP_FIELD_EMAIL; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_pull_vcard(remote_addr, 0, 0, 0, 0, fields, get_phonebook_pull_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_pull_vcard(remote_addr, 0, 0, 0, 0, fields, get_phonebook_pull_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_search_phone_book_n + * @since_tizen 3.0 + * @description check if pbap client profile is supported and startup_flag is asserted, then deinitialize the bluetooth and + * call the given pbap client profile API and check for errors. + * @scenario Try to call the given pbap client API asynchronously, after bluetooth de-initialization. + */ +int utc_bluetooth_bt_pbap_client_search_phone_book_n(void) +{ + int ret = BT_ERROR_NONE; + char remote_addr[18] = "F6:FB:8F:D8:C8:7C"; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_search_phone_book(remote_addr, 0, 0, 0, "ff", 0, 0, 100, get_phonebook_list_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + } else { + ret = bt_pbap_client_search_phone_book(remote_addr, 0, 0, 0, "ff", 0, 0, 100, get_phonebook_list_cb_pbap_n, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_pbap_positive.c b/tests/unittest/utc_bluetooth_pbap_positive.c new file mode 100644 index 0000000..fac9fc2 --- /dev/null +++ b/tests/unittest/utc_bluetooth_pbap_positive.c @@ -0,0 +1,199 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include + +//& set: BluetoothPBAPPositive + +static int startup_flag = BT_ERROR_NONE; +static bool pbap_supported = false; +static bool bt_supported = false; + +void connection_state_changed_cb_for_pbap_p(int result, bool connected, const char *remote_address, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_pbap_positive_startup + * @description check if bluetooth is supported and PABP is supported, Initialize bluetooth and check the adapter state and + * store adapter state for further use. + * @parameter NA + * @return NA + */ +void utc_bluetooth_pbap_positive_startup(void) +{ + int ret = BT_ERROR_NONE; + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + startup_flag = BT_ERROR_NONE; + + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); + + pbap_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth.phonebook.client", &pbap_supported); + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } + + if (pbap_supported) { + ret = bt_pbap_client_initialize(); + if (BT_ERROR_NONE != ret && BT_ERROR_ALREADY_DONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_pbap_client_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_pbap_positive_cleanup + * @description check If bluetooth is supported release all the bluetooth resources. + * @parameter NA + * @return NA + */ +void utc_bluetooth_pbap_positive_cleanup(void) +{ + if (pbap_supported) { + bt_pbap_client_deinitialize(); + } + + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_initialize_p + * @since_tizen 3.0 + * @description Check if bt, pbap features are supported. If yes, deinitialize pbap and initialize pbap and ensure there is no error. + * Else, initialize pbap and verify result as BT_ERROR_NOT_SUPPORTED. + * @senario Check if BT and pbap is supported and then call bt_pbap_client_initialize on the device and check for BT_ERROR_NONE. + */ + +int utc_bluetooth_bt_pbap_client_initialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_pbap_client_deinitialize(); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_initialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_pbap_client_initialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_deinitialize_p + * @since_tizen 3.0 + * @description Check if bt, pbap features are supported. If yes, deinitialize audio and ensure there is no error. + * Else, deinitialize pbap and verify result as BT_ERROR_NOT_SUPPORTED. + * @senario Positive case to check for pbap deinitialize. Check if BT and pbap is supported and then deinitialize pbap. + * Check for BT_ERROR_NONE. + */ + +int utc_bluetooth_bt_pbap_client_deinitialize_p(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_pbap_client_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_pbap_client_deinitialize(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_set_connection_state_changed_cb_p + * @since_tizen 3.0 + * @description check if PBAP is supported and startup_flag is asserted then register a callback that will be + * called when PBAP connection state is changed and check for errors. + * scenario Registers a callback function that will be invoked when the PBAP connection state is changed. + */ +int utc_bluetooth_bt_pbap_client_set_connection_state_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_pbap_client_set_connection_state_changed_cb(connection_state_changed_cb_for_pbap_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_pbap_client_unset_connection_state_changed_cb(); + /* Don't check the error in this position */ + } else { + ret = bt_pbap_client_set_connection_state_changed_cb(connection_state_changed_cb_for_pbap_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_pbap_client_unset_connection_state_changed_cb_p + * @since_tizen 3.0 + * @description check if PBAP is supported and startup_flag is asserted then unregister the callback set for + * PBAP connection state change and check for errors. + * scenario Unregisters a callback function that will be invoked when the PBAP connection state is changed. + */ +int utc_bluetooth_bt_pbap_client_unset_connection_state_changed_cb_p(void) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) { + assert_eq(startup_flag, BT_ERROR_NONE); + ret = bt_pbap_client_set_connection_state_changed_cb(connection_state_changed_cb_for_pbap_p, NULL); + /* Don't check the error in this position, because this is the precondition to verify */ + + ret = bt_pbap_client_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + } else { + ret = bt_pbap_client_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + } + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_service_search_negative.c b/tests/unittest/utc_bluetooth_service_search_negative.c new file mode 100644 index 0000000..fab9f1c --- /dev/null +++ b/tests/unittest/utc_bluetooth_service_search_negative.c @@ -0,0 +1,182 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothServiceSearchNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool bt_supported = false; + +/** + * @function utc_bluetooth_service_search_negative_startup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then intialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_service_search_negative_startup(void) +{ + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#endif + + startup_flag = BT_ERROR_NONE; + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_service_search_negative_cleanup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then deintialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_service_search_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_device_set_service_searched_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the service + * searched callback and check for error. If bluetooth is initialized, deinitialize bluetooth and set the service searched callback. + * @senario Check if BT is supported and then deinitialize bluetooth and set bt_device_set_service_searched_cb on the device. + * Check result BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_device_set_service_searched_cb_n(void) +{ + if (!bt_supported) { + ret = bt_device_set_service_searched_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_set_service_searched_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_set_service_searched_cb_n1 + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the service + * searched callback and check for error. If bluetooth is initialized, set the service searched callback. + * @senario Check if BT is supported and then set bt_device_set_service_searched_cb with NULL parameters on the device. + * Check result BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_device_set_service_searched_cb_n1(void) +{ + if (!bt_supported) { + ret = bt_device_set_service_searched_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_service_searched_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_service_searched_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, unset the service + * searched callback and check for error. If bluetooth is initialized, deinitialize bluetooth and unset the service searched callback. + * @senario Check if BT is supported and then call bt_device_unset_service_searched_cb on the device. + * Check result BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_device_unset_service_searched_cb_n(void) +{ + if (!bt_supported) { + ret = bt_device_unset_service_searched_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_service_searched_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_start_service_search_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, start the service + * search on the device and check for error. If bluetooth is initialized, deinitialize bluetooth and call bt_device_start_service_search(). + * @senario Check if BT is supported and then call bt_device_unset_service_searched_cb on the device. + * Check result BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_device_start_service_search_n(void) +{ + if (!bt_supported) { + ret = bt_device_start_service_search(NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_start_service_search(NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_service_search_positive.c b/tests/unittest/utc_bluetooth_service_search_positive.c new file mode 100644 index 0000000..cb6cd29 --- /dev/null +++ b/tests/unittest/utc_bluetooth_service_search_positive.c @@ -0,0 +1,137 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothServiceSearchPositive + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static bool bt_supported = false; + +static void service_searched_cb_for_service_search_p(int result, bt_device_sdp_info_s *sdp_info, void *user_data) +{ + +} + +/** + * @function utc_bluetooth_service_search_positive_startup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then intialize the bluetooth on the device successfully and retrieve the adapter state. + * @parameter NA + * @return NA + */ +void utc_bluetooth_service_search_positive_startup(void) +{ + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#endif + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + startup_flag = ret; + return; + } + + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + } + } +} + +/** + * @function utc_bluetooth_service_search_positive_cleanup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then deintialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_service_search_positive_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_device_set_service_searched_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the service + * searched callback and check for error. If bluetooth is initialized, set and unset the service searched callback successfully. + * @senario Check if BT is supported and then set bt_device_set_service_searched_cb on the device and check for expected result. + */ +int utc_bluetooth_bt_device_set_service_searched_cb_p(void) +{ + if (!bt_supported) { + ret = bt_device_set_service_searched_cb(service_searched_cb_for_service_search_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_service_searched_cb(service_searched_cb_for_service_search_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_device_unset_service_searched_cb(); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_device_unset_service_searched_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, unset the service + * searched callback and check for error. If bluetooth is initialized, set and unset the service searched callback successfully. + * @senario Check if BT is supported and then set bt_device_unset_service_searched_cb on the device and check for expected result. + */ +int utc_bluetooth_bt_device_unset_service_searched_cb_p(void) +{ + if (!bt_supported) { + ret = bt_device_unset_service_searched_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_device_set_service_searched_cb(service_searched_cb_for_service_search_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_device_unset_service_searched_cb(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_socket_negative.c b/tests/unittest/utc_bluetooth_socket_negative.c new file mode 100644 index 0000000..ccdeb37 --- /dev/null +++ b/tests/unittest/utc_bluetooth_socket_negative.c @@ -0,0 +1,521 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothSocketNegative + +static int startup_flag = BT_ERROR_NONE; +static int ret = BT_ERROR_NONE; +static const char *data = "dts_test"; +static char *address = "D8:90:E8:EE:2B:3A"; +static bool bt_supported = false; + +/** + * @function utc_bluetooth_socket_negative_startup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then intialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_socket_negative_startup(void) +{ +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#endif + + startup_flag = BT_ERROR_NONE; + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + } +} + +/** + * @function utc_bluetooth_socket_negative_cleanup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then deintialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_socket_negative_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_socket_set_data_received_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the data + * received callback and check for error. If bluetooth is initialized, set the data received callback with NULL parameters. + * @senario Check if BT is supported and then set bt_socket_set_data_received_cb with NULL params. Check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_set_data_received_cb_n(void) +{ + if (!bt_supported) { + ret = bt_socket_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#else + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#endif + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_set_data_received_cb_n1 + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the data + * received callback and check for error. If bluetooth is initialized, set the data received callback with NULL parameters. + * @senario Check if BT is supported and then set bt_socket_set_data_received_cb with NULL params. Check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_set_data_received_cb_n1(void) +{ + if (!bt_supported) { + ret = bt_socket_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_data_received_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_set_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the connection + * state changed callback and check for error. If bluetooth is initialized, set connection state changed callback with NULL params. + * @senario Check if BT is supported and then set bt_socket_set_connection_state_changed_cb with NULL parameters. + * Check for error BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_set_connection_state_changed_cb_n(void) +{ + if (!bt_supported) { + ret = bt_socket_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#else + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#endif + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_set_connection_state_changed_cb_n1 + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the connection + * state changed callback and check for error. If bluetooth is initialized, set connection state changed callback with NULL params. + * @senario Check if BT is supported and then set bt_socket_set_connection_state_changed_cb with NULL parameters. + * Check for error BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_set_connection_state_changed_cb_n1(void) +{ + if (!bt_supported) { + ret = bt_socket_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_connection_state_changed_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_unset_data_received_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * unset the data received callback and check for error. If bluetooth is initialized, deinitialize bluetooth + * and unset data received callback. + * @senario Check if BT is supported and then set and unset data received callback on the device + * and check for BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_socket_unset_data_received_cb_n(void) +{ + if (!bt_supported) { + ret = bt_socket_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_unset_connection_state_changed_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * unset the connection state changed callback and check for error. If bluetooth is initialized, deinitialize + * bluetooth and unset connection state changed callback. + * @senario Check if BT is supported and then deinitialize bt and unset connection state changed callback on the device + * and check for BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_socket_unset_connection_state_changed_cb_n(void) +{ + if (!bt_supported) { + ret = bt_socket_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_create_rfcomm_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, create rfcomm socket + * and check for error. If bluetooth is initialized, deinitialize bt and create rfcomm socket with NULL parameters. + * @senario Check if BT is supported and then deinitialize bluetooth and create rfcomm socket on the device and check for BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_socket_create_rfcomm_n(void) +{ + if (!bt_supported) { + ret = bt_socket_create_rfcomm(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_create_rfcomm(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_create_rfcomm_n1 + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, create rfcomm socket + * and check for error. If bluetooth is initialized, create rfcomm socket with NULL parameters. + * @senario Check if BT is supported then create rfcomm socket on the device and check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_create_rfcomm_n1(void) +{ + if (!bt_supported) { + ret = bt_socket_create_rfcomm(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_create_rfcomm(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_destroy_rfcomm_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * destroy the rfcomm socket and check for error. If bluetooth is initialized, then destroy rfcomm socket + * with invalid parameter. + * @senario Check if BT is supported and then call bt_socket_destroy_rfcomm on the device with invalid parameter. + * Check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_destroy_rfcomm_n(void) +{ + if (!bt_supported) { + ret = bt_socket_destroy_rfcomm(-1); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_destroy_rfcomm(-1); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#else + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_destroy_rfcomm(-1); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#endif + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_listen_and_accept_rfcomm_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * call bt_socket_listen_and_accept_rfcomm and check for error. If bluetooth is initialized, then + * listen and accept for rfcomm connection with invalid paramters. + * @senario Check if BT is supported and then call bt_socket_listen_and_accept_rfcomm on the device with invalid parameters + * and check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_listen_and_accept_rfcomm_n(void) +{ + if (!bt_supported) { + ret = bt_socket_listen_and_accept_rfcomm(1, 1); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_listen_and_accept_rfcomm(-1, 1); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#else + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_listen_and_accept_rfcomm(1, 1); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#endif + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_connect_rfcomm_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * call bt_socket_connect_rfcomm and check for error. If bluetooth is initialized, then + * call rfcomm connect api with invalid paramters. + * @senario Check if BT is supported and then call bt_socket_connect_rfcomm on the device with invalid parameters + * and check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_connect_rfcomm_n(void) +{ + char *uuid = ""; + + if (!bt_supported) { +#ifdef TV + ret = bt_socket_connect_rfcomm(address, NULL); +#else + ret = bt_socket_connect_rfcomm(address, uuid); +#endif + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_connect_rfcomm(address, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); +#else + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_connect_rfcomm(address, uuid); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); +#endif + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_disconnect_rfcomm_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * call bt_socket_disconnect_rfcomm and check for error. If bluetooth is initialized, then call + * rfcomm disconnect api with invalid paramter. + * @senario Check if BT is supported and then call bt_socket_disconnect_rfcomm on the device with invalid parameters + * and check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_disconnect_rfcomm_n(void) +{ + if (!bt_supported) { + ret = bt_socket_disconnect_rfcomm(-1); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_disconnect_rfcomm(1); +#else + ret = bt_socket_disconnect_rfcomm(-1); +#endif + + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_send_data_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * call bt_socket_send_data and check for error. If bluetooth is initialized, then call send data over bt socket + * with invalid paramter. + * @senario Check if BT is supported and then call bt_socket_send_data on the device with invalid parameters + * and check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_send_data_n(void) +{ + if (!bt_supported) { + ret = bt_socket_send_data(1, data, strlen(data)); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_send_data(1, data, strlen(data)); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_set_connection_requested_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * set bt_socket_set_connection_requested_cb and check for error. If bluetooth is initialized, then + * set connected requested callback with invalid paramter. + * @senario Check if BT is supported and then call bt_socket_set_connection_requested_cb on the device with invalid parameters + * and check for BT_ERROR_INVALID_PARAMETER. + */ +int utc_bluetooth_bt_socket_set_connection_requested_cb_n(void) +{ + if (!bt_supported) { + ret = bt_socket_set_connection_requested_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_connection_requested_cb(NULL, NULL); + assert_eq(ret, BT_ERROR_INVALID_PARAMETER); + + return 0; +} + +static void bt_socket_connection_requested_cb_func(int socket_fd, const char *remote_address, void *user_data) +{ +} + +/** + * @testcase utc_bluetooth_bt_socket_unset_connection_requested_cb_n + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * call bt_socket_unset_connection_requested_cb and check for error. If bluetooth is initialized, then deinitlaize bluetooth and + * unset connected requested callbackr. + * @senario Check if BT is supported then deinitialize bluetooth and call bt_socket_unset_connection_requested_cb on the device + * and check for BT_ERROR_NOT_INITIALIZED. + */ +int utc_bluetooth_bt_socket_unset_connection_requested_cb_n(void) +{ + if (!bt_supported) { + ret = bt_socket_unset_connection_requested_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_connection_requested_cb(bt_socket_connection_requested_cb_func, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_deinitialize(); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_unset_connection_requested_cb(); + assert_eq(ret, BT_ERROR_NOT_INITIALIZED); + + bt_deinitialize(); + bt_socket_unset_connection_requested_cb(); + + return 0; +} diff --git a/tests/unittest/utc_bluetooth_socket_positive.c b/tests/unittest/utc_bluetooth_socket_positive.c new file mode 100644 index 0000000..5a68743 --- /dev/null +++ b/tests/unittest/utc_bluetooth_socket_positive.c @@ -0,0 +1,348 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert_local.h" +#include +#include +#include +#include +#include +#include + +//& set: BluetoothSocketPositive + +static int startup_flag = BT_ERROR_NONE; +static int socket_fd = 0; +static int ret = BT_ERROR_NONE; +static const char *rfcomm_test_uuid_spp = "00001101-0000-1000-8000-00805F9B34FB"; +static bool bt_supported = false; + +static void socket_data_received_cb_for_socket_p(bt_socket_received_data_s *data, void *user_data) +{ +} + +static void socket_connection_state_changed_cb_for_socket_p(int result, bt_socket_connection_state_e connection_state, bt_socket_connection_s *connection, void *user_data) +{ +} + +/** + * @function utc_bluetooth_bt_socket_positive_startup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then intialize the bluetooth on the device successfully and retrieve the adapter state. + * @parameter NA + * @return NA + */ +void utc_bluetooth_bt_socket_positive_startup(void) +{ + +#ifdef TV +#ifndef TV_PRODUCT + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#else + bt_supported = true; +#endif +#else + bt_supported = false; + system_info_get_platform_bool("http://tizen.org/feature/network.bluetooth", &bt_supported); +#endif + + startup_flag = BT_ERROR_NONE; + + if (bt_supported) { + ret = bt_initialize(); + if (BT_ERROR_NONE != ret) { + fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "bt_initialize failed (code: %d)\n", ret); + startup_flag = ret; + return; + } + + bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; + + ret = bt_adapter_get_state(&adapter_state); + if (adapter_state != BT_ADAPTER_ENABLED) { + fprintf(stdout, "BT is not enabled!!"); + startup_flag = BT_ERROR_NOT_ENABLED; + //disable_bluetooth_le_adapter(); + } + } +} + +/** + * @function utc_bluetooth_bt_socket_positive_cleanup + * @description Get system information to check for the support of Bluetooth. If BT is supported on the device, + * then deintialize the bluetooth on the device successfully. + * @parameter NA + * @return NA + */ +void utc_bluetooth_bt_socket_positive_cleanup(void) +{ + if (bt_supported) { + bt_deinitialize(); + } +} + +/** + * @testcase utc_bluetooth_bt_socket_set_data_received_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the data + * received callback and check for error. If bluetooth is initialized, set and unset the data received callback successfully. + * @senario Check if BT is supported and then set bt_socket_set_data_received_cb on the device and check for expected result. + */ +int utc_bluetooth_bt_socket_set_data_received_cb_p(void) +{ + if (!bt_supported) { + ret = bt_socket_set_data_received_cb(socket_data_received_cb_for_socket_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_data_received_cb(socket_data_received_cb_for_socket_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_socket_unset_data_received_cb(); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_set_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, set the connection + * state changed callback and check for error. If bluetooth is initialized, set and unset connection state changed callback successfully. + * @senario Check if BT is supported and then set bt_socket_set_connection_state_changed_cb on the device and check for expected result. + */ +int utc_bluetooth_bt_socket_set_connection_state_changed_cb_p(void) +{ + if (!bt_supported) { + ret = bt_socket_set_connection_state_changed_cb(socket_connection_state_changed_cb_for_socket_p, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_connection_state_changed_cb(socket_connection_state_changed_cb_for_socket_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_socket_unset_connection_state_changed_cb(); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_create_rfcomm_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, create rfcomm socket + * and check for error. If bluetooth is initialized, then create rfcomm socket successfully. + * @senario Check if BT is supported and then call bt_socket_create_rfcomm on the device and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_socket_create_rfcomm_p(void) +{ + if (!bt_supported) { + ret = bt_socket_create_rfcomm(rfcomm_test_uuid_spp, &socket_fd); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_create_rfcomm(rfcomm_test_uuid_spp, &socket_fd); + assert_eq(ret, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_destroy_rfcomm(socket_fd); +#endif + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_listen_and_accept_rfcomm_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * call bt_socket_listen_and_accept_rfcomm and check for error. If bluetooth is initialized, then create rfcomm socket + * and listen and accept for rfcomm connection successfully. + * @senario Check if BT is supported and then call bt_socket_create_rfcomm and bt_socket_listen_and_accept_rfcomm on the device + * and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_socket_listen_and_accept_rfcomm_p(void) +{ + if (!bt_supported) { + ret = bt_socket_listen_and_accept_rfcomm(socket_fd, 1); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_create_rfcomm(rfcomm_test_uuid_spp, &socket_fd); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_listen_and_accept_rfcomm(socket_fd, 1); + assert_eq(ret, BT_ERROR_NONE); + +#ifdef TV + ret = bt_socket_destroy_rfcomm(socket_fd); +#endif + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_destroy_rfcomm_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * destroy the rfcomm socket and check for error. If bluetooth is initialized, then create rfcomm socket + * and destroy rfcomm socket successfully. + * @senario Check if BT is supported and then call bt_socket_create_rfcomm and bt_socket_destroy_rfcomm on the device + * and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_socket_destroy_rfcomm_p(void) +{ + if (!bt_supported) { + ret = bt_socket_destroy_rfcomm(socket_fd); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_create_rfcomm(rfcomm_test_uuid_spp, &socket_fd); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_destroy_rfcomm(socket_fd); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_unset_data_received_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * unset the data received callback and check for error. If bluetooth is initialized, then set data received callback + * and unset data received callback successfully. + * @senario Check if BT is supported and then set and unset data received callback on the device + * and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_socket_unset_data_received_cb_p(void) +{ + if (!bt_supported) { + ret = bt_socket_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_data_received_cb(socket_data_received_cb_for_socket_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_unset_data_received_cb(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_unset_connection_state_changed_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * unset the connection state changed callback and check for error. If bluetooth is initialized, then set + * connection state changed callback and unset connection state changed successfully. + * @senario Check if BT is supported and then set and unset connection state changed callback on the device + * and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_socket_unset_connection_state_changed_cb_p(void) +{ + if (!bt_supported) { + ret = bt_socket_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_connection_state_changed_cb(socket_connection_state_changed_cb_for_socket_p, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_unset_connection_state_changed_cb(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} + +static void bt_socket_connection_requested_cb_func(int socket_fd, const char *remote_address, void *user_data) +{ +} + +/** + * @testcase utc_bluetooth_bt_socket_set_connection_requested_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * set the connection requested callback and check for error. If bluetooth is initialized, then set + * connection requested callback and unset connection requested callback successfully. + * @senario Check if BT is supported and then set and unset connection requested callback on the device + * and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_socket_set_connection_requested_cb_p(void) +{ + if (!bt_supported) { + ret = bt_socket_set_connection_requested_cb(bt_socket_connection_requested_cb_func, NULL); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_connection_requested_cb(bt_socket_connection_requested_cb_func, NULL); + assert_eq(ret, BT_ERROR_NONE); + + bt_socket_unset_connection_requested_cb(); + + return 0; +} + +/** + * @testcase utc_bluetooth_bt_socket_unset_connection_requested_cb_p + * @since_tizen 2.3 + * @description Get system information to check for the support of Bluetooth. If BT is not supported on the device, + * unset the connection requested callback and check for error. If bluetooth is initialized, then set + * connection requested callback and unset connection requested callback successfully and check for error. + * @senario Check if BT is supported and then set and unset connection requested callback on the device + * and check for BT_ERROR_NONE. + */ +int utc_bluetooth_bt_socket_unset_connection_requested_cb_p(void) +{ + if (!bt_supported) { + ret = bt_socket_unset_connection_requested_cb(); + assert_eq(ret, BT_ERROR_NOT_SUPPORTED); + return 0; + } + + assert_eq(startup_flag, BT_ERROR_NONE); + + ret = bt_socket_set_connection_requested_cb(bt_socket_connection_requested_cb_func, NULL); + assert_eq(ret, BT_ERROR_NONE); + + ret = bt_socket_unset_connection_requested_cb(); + assert_eq(ret, BT_ERROR_NONE); + + return 0; +} diff --git a/tests/unittest/utc_convert.sh b/tests/unittest/utc_convert.sh new file mode 100755 index 0000000..083b352 --- /dev/null +++ b/tests/unittest/utc_convert.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +for file in `find . -name "*.c"` +do + sed -i -e 's/\"assert.h\"/\"assert_local.h\"/g' $file +done +