From ccd60a493f4200496e511d9ee8991f4defa9a7b0 Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Tue, 7 Jun 2016 14:46:18 +0900 Subject: [PATCH] [UTC][Bluetooth][ACR-584][Add pbap client TCs] Change-Id: Iea6174e08747fea3be655ed76473288705c77aa0 Signed-off-by: DoHyun Pyun --- src/utc/bluetooth/CMakeLists.txt | 31 ++ src/utc/bluetooth/tct-bluetooth-core_wearable.h | 37 +++ src/utc/bluetooth/utc_bluetooth_pbap_negative.c | 393 ++++++++++++++++++++++++ src/utc/bluetooth/utc_bluetooth_pbap_positive.c | 201 ++++++++++++ 4 files changed, 662 insertions(+) create mode 100644 src/utc/bluetooth/utc_bluetooth_pbap_negative.c create mode 100644 src/utc/bluetooth/utc_bluetooth_pbap_positive.c diff --git a/src/utc/bluetooth/CMakeLists.txt b/src/utc/bluetooth/CMakeLists.txt index ec92566..f61a96d 100755 --- a/src/utc/bluetooth/CMakeLists.txt +++ b/src/utc/bluetooth/CMakeLists.txt @@ -4,6 +4,36 @@ SET(EXEC_NAME "tct-${PKG_NAME}-core") SET(RPM_NAME "core-${PKG_NAME}-tests") SET(CAPI_LIB "capi-network-bluetooth") + +IF( DEFINED WEARABLE ) +SET(TC_SOURCES +utc_bluetooth_adapter_negative.c +utc_bluetooth_adapter_positive.c +utc_bluetooth_audio_negative.c +utc_bluetooth_audio_positive.c +utc_bluetooth_common_positive.c +utc_bluetooth_device_discovery_negative.c +utc_bluetooth_device_discovery_positive.c +utc_bluetooth_device_negative.c +utc_bluetooth_device_positive.c +utc_bluetooth_gatt_negative.c +utc_bluetooth_gatt_positive.c +utc_bluetooth_hdp_negative.c +utc_bluetooth_hdp_positive.c +utc_bluetooth_hid_negative.c +utc_bluetooth_hid_positive.c +utc_bluetooth_opp_client_negative.c +utc_bluetooth_opp_client_positive.c +utc_bluetooth_opp_server_negative.c +utc_bluetooth_opp_server_positive.c +utc_bluetooth_service_search_negative.c +utc_bluetooth_service_search_positive.c +utc_bluetooth_socket_negative.c +utc_bluetooth_socket_positive.c +utc_bluetooth_pbap_negative.c +utc_bluetooth_pbap_positive.c +) +ELSE() SET(TC_SOURCES utc_bluetooth_adapter_negative.c utc_bluetooth_adapter_positive.c @@ -29,6 +59,7 @@ utc_bluetooth_service_search_positive.c utc_bluetooth_socket_negative.c utc_bluetooth_socket_positive.c ) +ENDIF() IF( DEFINED MOBILE ) PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED diff --git a/src/utc/bluetooth/tct-bluetooth-core_wearable.h b/src/utc/bluetooth/tct-bluetooth-core_wearable.h index 0574c1a..fd27ef0 100755 --- a/src/utc/bluetooth/tct-bluetooth-core_wearable.h +++ b/src/utc/bluetooth/tct-bluetooth-core_wearable.h @@ -65,6 +65,10 @@ 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_pbap_positive_startup(void); +extern void utc_bluetooth_pbap_positive_cleanup(void); +extern void utc_bluetooth_pbap_negative_startup(void); +extern void utc_bluetooth_pbap_negative_cleanup(void); extern int utc_bluetooth_bt_deinitialize_n(void); extern int utc_bluetooth_bt_adapter_set_state_changed_cb_n(void); @@ -368,6 +372,24 @@ 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_pbap_client_initialize_p(void); +extern int utc_bluetooth_bt_pbap_client_deinitialize_p(void); +extern int utc_bluetooth_bt_pbap_client_set_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_pbap_client_unset_connection_state_changed_cb_p(void); +extern int utc_bluetooth_bt_pbap_client_initialize_n(void); +extern int utc_bluetooth_bt_pbap_client_deinitialize_n(void); +extern int utc_bluetooth_bt_pbap_client_set_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_pbap_client_unset_connection_state_changed_cb_n(void); +extern int utc_bluetooth_bt_pbap_client_connect_n(void); +extern int utc_bluetooth_bt_pbap_client_disconnect_n(void); +extern int utc_bluetooth_bt_pbap_client_get_phone_book_size_n(void); +extern int utc_bluetooth_bt_pbap_client_get_phone_book_n(void); +extern int utc_bluetooth_bt_pbap_client_get_list_n(void); +extern int utc_bluetooth_bt_pbap_client_pull_vcard_n(void); +extern int utc_bluetooth_bt_pbap_client_search_phone_book_n(void); + + + testcase tc_array[] = { {"utc_bluetooth_bt_deinitialize_n", utc_bluetooth_bt_deinitialize_n, utc_bluetooth_adapter_negative_startup, utc_bluetooth_adapter_negative_cleanup}, @@ -672,6 +694,21 @@ testcase tc_array[] = { {"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_pbap_client_initialize_p", utc_bluetooth_bt_pbap_client_initialize_p, utc_bluetooth_pbap_positive_startup, utc_bluetooth_pbap_positive_cleanup}, + {"utc_bluetooth_bt_pbap_client_deinitialize_p", utc_bluetooth_bt_pbap_client_deinitialize_p, utc_bluetooth_pbap_positive_startup, utc_bluetooth_pbap_positive_cleanup}, + {"utc_bluetooth_bt_pbap_client_set_connection_state_changed_cb_p", utc_bluetooth_bt_pbap_client_set_connection_state_changed_cb_p, utc_bluetooth_pbap_positive_startup, utc_bluetooth_pbap_positive_cleanup}, + {"utc_bluetooth_bt_pbap_client_unset_connection_state_changed_cb_p", utc_bluetooth_bt_pbap_client_unset_connection_state_changed_cb_p, utc_bluetooth_pbap_positive_startup, utc_bluetooth_pbap_positive_cleanup}, + {"utc_bluetooth_bt_pbap_client_initialize_n", utc_bluetooth_bt_pbap_client_initialize_n, utc_bluetooth_pbap_negative_startup, utc_bluetooth_pbap_negative_cleanup}, + {"utc_bluetooth_bt_pbap_client_deinitialize_n", utc_bluetooth_bt_pbap_client_deinitialize_n, utc_bluetooth_pbap_negative_startup, utc_bluetooth_pbap_negative_cleanup}, + {"utc_bluetooth_bt_pbap_client_set_connection_state_changed_cb_n", utc_bluetooth_bt_pbap_client_set_connection_state_changed_cb_n, utc_bluetooth_pbap_negative_startup, utc_bluetooth_pbap_negative_cleanup}, + {"utc_bluetooth_bt_pbap_client_unset_connection_state_changed_cb_n", utc_bluetooth_bt_pbap_client_unset_connection_state_changed_cb_n, utc_bluetooth_pbap_negative_startup, utc_bluetooth_pbap_negative_cleanup}, + {"utc_bluetooth_bt_pbap_client_connect_n", utc_bluetooth_bt_pbap_client_connect_n, utc_bluetooth_pbap_negative_startup, utc_bluetooth_pbap_negative_cleanup}, + {"utc_bluetooth_bt_pbap_client_disconnect_n", utc_bluetooth_bt_pbap_client_disconnect_n, utc_bluetooth_pbap_negative_startup, utc_bluetooth_pbap_negative_cleanup}, + {"utc_bluetooth_bt_pbap_client_get_phone_book_size_n", utc_bluetooth_bt_pbap_client_get_phone_book_size_n, utc_bluetooth_pbap_negative_startup, utc_bluetooth_pbap_negative_cleanup}, + {"utc_bluetooth_bt_pbap_client_get_phone_book_n", utc_bluetooth_bt_pbap_client_get_phone_book_n, utc_bluetooth_pbap_negative_startup, utc_bluetooth_pbap_negative_cleanup}, + {"utc_bluetooth_bt_pbap_client_get_list_n", utc_bluetooth_bt_pbap_client_get_list_n, utc_bluetooth_pbap_negative_startup, utc_bluetooth_pbap_negative_cleanup}, + {"utc_bluetooth_bt_pbap_client_pull_vcard_n", utc_bluetooth_bt_pbap_client_pull_vcard_n, utc_bluetooth_pbap_negative_startup, utc_bluetooth_pbap_negative_cleanup}, + {"utc_bluetooth_bt_pbap_client_search_phone_book_n", utc_bluetooth_bt_pbap_client_search_phone_book_n, utc_bluetooth_pbap_negative_startup, utc_bluetooth_pbap_negative_cleanup}, {NULL, NULL} }; diff --git a/src/utc/bluetooth/utc_bluetooth_pbap_negative.c b/src/utc/bluetooth/utc_bluetooth_pbap_negative.c new file mode 100644 index 0000000..87a0507 --- /dev/null +++ b/src/utc/bluetooth/utc_bluetooth_pbap_negative.c @@ -0,0 +1,393 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert.h" +#include +#include +#include + +//& 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/src/utc/bluetooth/utc_bluetooth_pbap_positive.c b/src/utc/bluetooth/utc_bluetooth_pbap_positive.c new file mode 100644 index 0000000..5572a58 --- /dev/null +++ b/src/utc/bluetooth/utc_bluetooth_pbap_positive.c @@ -0,0 +1,201 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "assert.h" +#include +#include +#include + +//& 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) +{ + int ret = BT_ERROR_NONE; + + if (pbap_supported) + ret = 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; +} + -- 2.7.4