summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaejin Woo <tt.woo@samsung.com>2013-10-23 13:52:15 +0900
committerTaejin Woo <tt.woo@samsung.com>2013-10-23 16:17:20 +0900
commit8bae75a12879a9f3a86ddeaa0561fa53380043d0 (patch)
tree3d3324b1ed537ef661341cc04f3e54f00ed94912
parent1c303a6746cd73a7cc6f219d954851e1917b8c78 (diff)
downloadbluetooth-8bae75a12879a9f3a86ddeaa0561fa53380043d0.tar.gz
bluetooth-8bae75a12879a9f3a86ddeaa0561fa53380043d0.tar.bz2
bluetooth-8bae75a12879a9f3a86ddeaa0561fa53380043d0.zip
Merge the latest CAPI Private code in Tizen2.2 RSA
We do CAPI Code Sync in tizen2.2 RSA. Change-Id: I6b2eb95b365566b1e6a78744fb3f8dbe0b7281e6
-rw-r--r--TC/READAME.txt5
-rwxr-xr-xTC/_export_env.sh9
-rwxr-xr-xTC/_export_target_env.sh8
-rwxr-xr-xTC/build.sh16
-rwxr-xr-xTC/clean.sh11
-rw-r--r--TC/config2
-rwxr-xr-xTC/execute.sh15
-rw-r--r--TC/testcase/Makefile24
-rw-r--r--TC/testcase/tslist28
-rw-r--r--TC/testcase/utc_network_bluetooth_adapter_negative.c288
-rw-r--r--TC/testcase/utc_network_bluetooth_adapter_positive.c499
-rw-r--r--TC/testcase/utc_network_bluetooth_audio_negative.c362
-rw-r--r--TC/testcase/utc_network_bluetooth_audio_positive.c618
-rw-r--r--TC/testcase/utc_network_bluetooth_avrcp_negative.c171
-rw-r--r--TC/testcase/utc_network_bluetooth_avrcp_positive.c387
-rw-r--r--TC/testcase/utc_network_bluetooth_common_negative.c84
-rw-r--r--TC/testcase/utc_network_bluetooth_common_positive.c119
-rw-r--r--TC/testcase/utc_network_bluetooth_device_discovery_negative.c191
-rw-r--r--TC/testcase/utc_network_bluetooth_device_discovery_positive.c261
-rw-r--r--TC/testcase/utc_network_bluetooth_device_negative.c296
-rw-r--r--TC/testcase/utc_network_bluetooth_device_positive.c610
-rw-r--r--TC/testcase/utc_network_bluetooth_gatt_negative.c238
-rw-r--r--TC/testcase/utc_network_bluetooth_gatt_positive.c282
-rw-r--r--TC/testcase/utc_network_bluetooth_hdp_negative.c235
-rw-r--r--TC/testcase/utc_network_bluetooth_hdp_positive.c226
-rw-r--r--TC/testcase/utc_network_bluetooth_hid_negative.c149
-rw-r--r--TC/testcase/utc_network_bluetooth_hid_positive.c152
-rw-r--r--TC/testcase/utc_network_bluetooth_opp-client_negative.c172
-rw-r--r--TC/testcase/utc_network_bluetooth_opp-client_positive.c190
-rw-r--r--TC/testcase/utc_network_bluetooth_opp-server_negative.c174
-rw-r--r--TC/testcase/utc_network_bluetooth_opp-server_positive.c182
-rw-r--r--TC/testcase/utc_network_bluetooth_pan_negative.c148
-rw-r--r--TC/testcase/utc_network_bluetooth_pan_positive.c237
-rw-r--r--TC/testcase/utc_network_bluetooth_service_search_negative.c178
-rw-r--r--TC/testcase/utc_network_bluetooth_service_search_positive.c366
-rw-r--r--TC/testcase/utc_network_bluetooth_socket_negative.c266
-rw-r--r--TC/testcase/utc_network_bluetooth_socket_positive.c440
-rwxr-xr-xTC/tet_scen7
-rw-r--r--TC/tetbuild.cfg5
-rw-r--r--TC/tetclean.cfg5
-rw-r--r--TC/tetexec.cfg5
-rw-r--r--debian/changelog32
-rw-r--r--include/bluetooth.h42
-rw-r--r--include/bluetooth_private.h4
-rw-r--r--src/bluetooth-adapter.c14
-rw-r--r--src/bluetooth-common.c20
-rw-r--r--src/bluetooth-device.c17
-rw-r--r--src/bluetooth-gatt.c4
-rw-r--r--src/bluetooth-pan.c17
-rw-r--r--test/bt_unit_test.c83
50 files changed, 7854 insertions, 40 deletions
diff --git a/TC/READAME.txt b/TC/READAME.txt
new file mode 100644
index 0000000..f0edad5
--- /dev/null
+++ b/TC/READAME.txt
@@ -0,0 +1,5 @@
+Before run DTS of bluetooth, BT should be disabled.
+This DTS needs another target and it must be set as the following:
+ 1) BT is activated.
+ 2) BT is discoverable.
+ 3) BT name is set as "dts_test".
diff --git a/TC/_export_env.sh b/TC/_export_env.sh
new file mode 100755
index 0000000..ac8f4a1
--- /dev/null
+++ b/TC/_export_env.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+. ./config
+export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path
+#export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-simulator # tetware simulator path
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh
new file mode 100755
index 0000000..c693f83
--- /dev/null
+++ b/TC/_export_target_env.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+. ./config
+export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+#export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-simulator # tetware simulator path
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755
index 0000000..72aad6c
--- /dev/null
+++ b/TC/build.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+. ./_export_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./
+tcc -b -j $JOURNAL_RESULT -p ./
+grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/TC/clean.sh b/TC/clean.sh
new file mode 100755
index 0000000..29743e0
--- /dev/null
+++ b/TC/clean.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+. ./_export_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+RESULT_DIR=results
+
+tcc -c -p ./ # executing tcc, with clean option (-c)
+rm -r $RESULT_DIR
+rm -r tet_tmp_dir
+rm testcase/tet_captured
diff --git a/TC/config b/TC/config
new file mode 100644
index 0000000..f919537
--- /dev/null
+++ b/TC/config
@@ -0,0 +1,2 @@
+TET_INSTALL_HOST_PATH=/home/bwlee/tools/TETware
+TET_INSTALL_TARGET_PATH=/home/bwlee/tools/TETware
diff --git a/TC/execute.sh b/TC/execute.sh
new file mode 100755
index 0000000..0fe02e2
--- /dev/null
+++ b/TC/execute.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. ./_export_target_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./
+grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile
new file mode 100644
index 0000000..7d86802
--- /dev/null
+++ b/TC/testcase/Makefile
@@ -0,0 +1,24 @@
+CC ?= gcc
+
+C_FILES = $(shell ls *.c)
+
+PKGS = capi-network-bluetooth glib-2.0
+
+LDFLAGS = `pkg-config --libs $(PKGS)`
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+TCS := $(shell ls -1 *.c | cut -d. -f1)
+
+all: $(TCS)
+
+%: %.c
+ $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+ rm -f $(TCS)
diff --git a/TC/testcase/tslist b/TC/testcase/tslist
new file mode 100644
index 0000000..39a8464
--- /dev/null
+++ b/TC/testcase/tslist
@@ -0,0 +1,28 @@
+/testcase/utc_network_bluetooth_adapter_positive
+/testcase/utc_network_bluetooth_adapter_negative
+/testcase/utc_network_bluetooth_device_discovery_positive
+/testcase/utc_network_bluetooth_device_discovery_negative
+/testcase/utc_network_bluetooth_device_positive
+/testcase/utc_network_bluetooth_device_negative
+/testcase/utc_network_bluetooth_service_search_positive
+/testcase/utc_network_bluetooth_service_search_negative
+/testcase/utc_network_bluetooth_socket_positive
+/testcase/utc_network_bluetooth_socket_negative
+/testcase/utc_network_bluetooth_gatt_negative
+/testcase/utc_network_bluetooth_gatt_positive
+/testcase/utc_network_bluetooth_hid_negative
+/testcase/utc_network_bluetooth_hid_positive
+/testcase/utc_network_bluetooth_hdp_negative
+/testcase/utc_network_bluetooth_hdp_positive
+/testcase/utc_network_bluetooth_opp-server_negative
+/testcase/utc_network_bluetooth_opp-server_positive
+/testcase/utc_network_bluetooth_opp-client_negative
+/testcase/utc_network_bluetooth_opp-client_positive
+/testcase/utc_network_bluetooth_pan_negative
+/testcase/utc_network_bluetooth_pan_positive
+/testcase/utc_network_bluetooth_audio_negative
+/testcase/utc_network_bluetooth_audio_positive
+/testcase/utc_network_bluetooth_avrcp_negative
+/testcase/utc_network_bluetooth_avrcp_positive
+/testcase/utc_network_bluetooth_common_negative
+/testcase/utc_network_bluetooth_common_positive
diff --git a/TC/testcase/utc_network_bluetooth_adapter_negative.c b/TC/testcase/utc_network_bluetooth_adapter_negative.c
new file mode 100644
index 0000000..06fdea7
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_adapter_negative.c
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+#include <time.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+bt_adapter_visibility_mode_e adapter_visibility_mode = BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE;
+char adapter_name[128] = "dts_test";
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_deinitialize_n(void);
+static void utc_network_bluetooth_adapter_set_state_changed_cb_n(void);
+static void utc_network_bluetooth_adapter_set_name_changed_cb_n(void);
+static void utc_network_bluetooth_adapter_set_visibility_mode_changed_cb_n(void);
+static void utc_network_bluetooth_adapter_enable_n(void);
+static void utc_network_bluetooth_adapter_get_state_n(void);
+static void utc_network_bluetooth_adapter_get_address_n(void);
+static void utc_network_bluetooth_adapter_set_name_n(void);
+static void utc_network_bluetooth_adapter_get_name_n(void);
+static void utc_network_bluetooth_adapter_set_visibility_n(void);
+static void utc_network_bluetooth_adapter_get_visibility_n(void);
+static void utc_network_bluetooth_adapter_disable_n(void);
+static void utc_network_bluetooth_adapter_unset_state_changed_cb_n(void);
+static void utc_network_bluetooth_adapter_unset_name_changed_cb_n(void);
+static void utc_network_bluetooth_adapter_unset_visibility_mode_changed_cb_n(void);
+
+void adapter_state_changed_cb_for_adapter_n(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+void adapter_state_changed_cb_for_adapter_n(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+void adapter_name_changed_cb_for_adapter_n(char *device_name, void *user_data);
+void adapter_visibility_mode_changed_cb_for_adpater_n(int result,
+ bt_adapter_visibility_mode_e visibility_mode,
+ void *user_data);
+void device_discovery_state_changed_cb_for_adapter_n(int result,
+ bt_adapter_device_discovery_state_e discovery_state,
+ bt_device_info_s *device_info,
+ void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_adapter_disable_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_set_state_changed_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_set_name_changed_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_set_visibility_mode_changed_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_get_state_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_get_address_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_set_name_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_get_name_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_get_visibility_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_set_visibility_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_deinitialize_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_enable_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_unset_state_changed_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_unset_name_changed_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_unset_visibility_mode_changed_cb_n, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ /* start of TC */
+ tet_printf("TC start.");
+ bt_initialize();
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ tet_printf("TC end");
+}
+
+/**
+ * @brief Negative test case of bt_deinitialize()
+ */
+static void utc_network_bluetooth_deinitialize_n(void)
+{
+ int ret = bt_deinitialize();
+
+ if (ret == BT_ERROR_NONE) {
+ ret = bt_deinitialize();
+ dts_check_eq("bt_deinitialize", ret, BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned.");
+ } else {
+ dts_fail("bt_deinitialize", "bt_deinitialize() failed.");
+ }
+}
+
+/**
+ * @brief Negative test case of bt_adapter_disable()
+ */
+static void utc_network_bluetooth_adapter_disable_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_disable();
+ dts_check_eq("bt_adapter_disable", ret, BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is disabled");
+}
+
+/**
+ * @brief Negative test case of bt_adapter_set_state_changed_cb()
+ */
+static void utc_network_bluetooth_adapter_set_state_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_set_state_changed_cb(NULL, NULL);
+ dts_check_eq("bt_adapter_set_state_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when parameter is NULL.");
+}
+
+/**
+ * @brief Negative test case of bt_adapter_set_name_changed_cb()
+ */
+static void utc_network_bluetooth_adapter_set_name_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_set_name_changed_cb(NULL, NULL);
+ dts_check_eq("bt_adapter_set_name_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when parameter is NULL.");
+}
+
+/**
+ * @brief Negative test case of bt_adapter_set_visibility_mode_changed_cb()
+ */
+static void utc_network_bluetooth_adapter_set_visibility_mode_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_set_visibility_mode_changed_cb(NULL, NULL);
+ dts_check_eq("bt_adapter_set_visibility_mode_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when parameter is NULL.");
+}
+
+/**
+ * @brief Negative test case of bt_adapter_get_state()
+ */
+static void utc_network_bluetooth_adapter_get_state_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_get_state(NULL);
+ dts_check_eq("bt_adapter_get_state", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when parameter is NULL.");
+}
+
+/**
+ * @brief Negative test case of bt_adapter_get_address().
+ */
+static void utc_network_bluetooth_adapter_get_address_n(void)
+{
+ char *address = NULL;
+ int ret = bt_adapter_get_address(&address);
+
+ dts_check_eq("bt_adapter_get_address", ret, BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled.");
+}
+
+/**
+ * @brief Negative test case of bt_adapter_get_name().
+ */
+static void utc_network_bluetooth_adapter_get_name_n(void)
+{
+ char *name = NULL;
+ int ret = bt_adapter_get_name(&name);
+
+ dts_check_eq("bt_adapter_get_name", ret, BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled.");
+}
+
+/**
+ * @brief Negative test case of bt_adapter_get_visibility().
+ */
+static void utc_network_bluetooth_adapter_get_visibility_n(void)
+{
+ bt_adapter_visibility_mode_e mode =
+ BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE;
+ int dur = 10;
+ int ret = bt_adapter_get_visibility(&mode, &dur);
+
+ dts_check_eq("bt_adapter_get_visibility", ret, BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled.");
+}
+
+/**
+ * @brief Negative test case of bt_adapter_set_name().
+ */
+static void utc_network_bluetooth_adapter_set_name_n(void)
+{
+ int ret = bt_adapter_set_name(adapter_name);
+
+ dts_check_eq("bt_adapter_set_name", ret, BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled.");
+}
+
+/**
+ * @brief Negative test case of bt_adapter_set_visibility().
+ */
+static void utc_network_bluetooth_adapter_set_visibility_n(void)
+{
+ int ret = bt_adapter_set_visibility(adapter_visibility_mode, 180);
+
+ dts_check_eq("bt_adapter_set_visibility", ret, BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled.");
+}
+
+/**
+ * @brief Negative test case of bt_adapter_unset_state_changed_cb()
+ */
+static void utc_network_bluetooth_adapter_unset_state_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_unset_state_changed_cb();
+ dts_check_eq("bt_adapter_unset_state_changed_cb", ret,
+ BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned when BT service is not initialized.");
+}
+
+/**
+ * @brief Negative test case of bt_adapter_unset_name_changed_cb()
+ */
+static void utc_network_bluetooth_adapter_unset_name_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_unset_name_changed_cb();
+ dts_check_eq("bt_adapter_unset_name_changed_cb", ret,
+ BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned when BT service is not initialized.");
+}
+
+/**
+ * @brief Negative test case of bt_adapter_unset_visibility_mode_changed_cb()
+ */
+static void
+utc_network_bluetooth_adapter_unset_visibility_mode_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_unset_visibility_mode_changed_cb();
+ dts_check_eq("bt_adapter_unset_visibility_mode_changed_cb", ret,
+ BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned when BT service is not initialized.");
+}
+
+/**
+ * @brief Negative test case of bt_adapter_enable()
+ */
+static void utc_network_bluetooth_adapter_enable_n(void)
+{
+ bt_error_e ret = bt_adapter_enable();
+ dts_check_eq("bt_adapter_enable", ret, BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned.");
+}
diff --git a/TC/testcase/utc_network_bluetooth_adapter_positive.c b/TC/testcase/utc_network_bluetooth_adapter_positive.c
new file mode 100644
index 0000000..28168a3
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_adapter_positive.c
@@ -0,0 +1,499 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+#include <time.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+static GMainLoop *mainloop;
+static bool callback_result = false;
+bt_adapter_visibility_mode_e adapter_visibility_mode = BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE;
+char adapter_name[128] = "dts_test";
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_initialize_p(void);
+static void utc_network_bluetooth_deinitialize_p(void);
+static void utc_network_bluetooth_adapter_set_state_changed_cb_p(void);
+static void utc_network_bluetooth_adapter_set_name_changed_cb_p(void);
+static void utc_network_bluetooth_adapter_set_visibility_mode_changed_cb_p(void);
+static void utc_network_bluetooth_adapter_enable_p(void);
+static void utc_network_bluetooth_adapter_get_state_p(void);
+static void utc_network_bluetooth_adapter_get_address_p(void);
+static void utc_network_bluetooth_adapter_set_name_p(void);
+static void utc_network_bluetooth_adapter_get_name_p(void);
+static void utc_network_bluetooth_adapter_set_visibility_p(void);
+static void utc_network_bluetooth_adapter_get_visibility_p(void);
+static void utc_network_bluetooth_adapter_disable_p(void);
+static void utc_network_bluetooth_adapter_unset_state_changed_cb_p(void);
+static void utc_network_bluetooth_adapter_unset_name_changed_cb_p(void);
+static void utc_network_bluetooth_adapter_unset_visibility_mode_changed_cb_p(void);
+
+void adapter_state_changed_cb_for_adapter_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+void adapter_state_changed_cb_for_adapter_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+void adapter_name_changed_cb_for_adapter_p(char *device_name, void *user_data);
+void adapter_visibility_mode_changed_cb_for_adpater_p(int result,
+ bt_adapter_visibility_mode_e visibility_mode,
+ void *user_data);
+void device_discovery_state_changed_cb_for_adapter_p(int result,
+ bt_adapter_device_discovery_state_e discovery_state,
+ bt_device_info_s *device_info,
+ void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_initialize_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_enable_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_set_state_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_unset_state_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_get_state_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_get_address_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_get_name_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_set_name_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_unset_name_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_set_name_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_set_visibility_mode_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_unset_visibility_mode_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_get_visibility_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_set_visibility_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_adapter_disable_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_deinitialize_p, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ /* start of TC */
+ tet_printf("TC start.");
+ mainloop = g_main_loop_new(NULL, FALSE);
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ tet_printf("TC end");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Callback funtions
+ */
+void adapter_state_changed_cb_for_adapter_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+ if (user_data != NULL && !strcmp((char *)user_data, "enable")) {
+ if (adapter_state == BT_ADAPTER_ENABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was enabled.");
+ callback_result = true;
+ } else {
+ tet_printf("Callback: BT was not enabled.");
+ }
+
+ if (mainloop)
+ g_main_loop_quit(mainloop);
+ } else if (user_data != NULL && !strcmp((char *)user_data, "disable")) {
+ if (adapter_state == BT_ADAPTER_DISABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was disabled.");
+ callback_result = true;
+ } else {
+ tet_printf("Callback: BT was not disabled.");
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+}
+
+void device_discovery_state_changed_cb_for_adapter_p(int result,
+ bt_adapter_device_discovery_state_e discovery_state,
+ bt_device_info_s *device_info,
+ void *user_data)
+{
+ tet_printf("bt_adapter_device_discovery_state_changed_cb was called");
+
+ if (user_data != NULL && !strcmp((char *)user_data, "enable")) {
+ if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FINISHED) {
+ tet_printf("Callback: bt_adapter_device_discovery_state_changed_cb_for_adapter_p was called \
+ and device discovery ends.");
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+ }
+}
+
+void adapter_name_changed_cb_for_adapter_p(char *device_name, void *user_data)
+{
+ tet_printf("bt_adapter_name_changed_cb_for_adapter_p was called: %s",
+ (char *)device_name);
+
+ if (user_data != NULL && !strcmp((char *)user_data, "set_name")) {
+ if (!strcmp(device_name, adapter_name))
+ callback_result = true;
+ }
+
+ if (mainloop)
+ g_main_loop_quit(mainloop);
+
+}
+
+void adapter_visibility_mode_changed_cb_for_adpater_p(int result,
+ bt_adapter_visibility_mode_e visibility_mode,
+ void *user_data)
+{
+ tet_printf("bt_adapter_visibility_mode_changed_cb was called: %d", visibility_mode);
+
+ if (user_data != NULL && !strcmp((char *)user_data, "set_visibility")) {
+ if (result == BT_ERROR_NONE) {
+ if (visibility_mode == adapter_visibility_mode) {
+ callback_result = true;
+ } else {
+ tet_printf("Callback: adapter_visibility_mode_changed_cb_for_adpater_p() was called but visibility mode is not same.");
+ tet_printf("Callback: actual visibility mode : %d", visibility_mode);
+ callback_result = false;
+ }
+ } else {
+ tet_printf("\n Callback: adapter_visibility_mode_changed_cb_for_adpater_p() was called but failed.");
+ callback_result = false;
+ }
+ }
+
+ if (mainloop)
+ g_main_loop_quit(mainloop);
+}
+
+/**
+ * @brief Positive test case of bt_initialize()
+ */
+static void utc_network_bluetooth_initialize_p(void)
+{
+ int ret = bt_initialize();
+ dts_check_eq("bt_initialize", ret, BT_ERROR_NONE,
+ "bt_initialize() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_deinitialize()
+ */
+static void utc_network_bluetooth_deinitialize_p(void)
+{
+ int ret = bt_deinitialize();
+ dts_check_eq("bt_deinitialize", ret,
+ BT_ERROR_NONE, "bt_deinitialize() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_adapter_set_state_changed_cb()
+ */
+static void utc_network_bluetooth_adapter_set_state_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_adapter_p, NULL);
+ dts_check_eq("bt_adapter_set_state_changed_cb", ret, BT_ERROR_NONE,
+ "bt_adapter_set_state_changed_cb failed.");
+}
+
+/**
+ * @brief Positive test case of bt_adapter_set_name_changed_cb()
+ */
+static void utc_network_bluetooth_adapter_set_name_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ ret = bt_adapter_set_name_changed_cb(adapter_name_changed_cb_for_adapter_p, NULL);
+ if (ret == BT_ERROR_NONE) {
+ timeout_id = g_timeout_add(10000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ }
+ dts_check_eq("bt_adapter_set_name_changed_cb", ret, BT_ERROR_NONE,
+ "bt_adapter_set_name_changed_cb failed.");
+}
+
+/**
+ * @brief Positive test case of bt_adapter_set_visibility_mode_changed_cb()
+ */
+static void utc_network_bluetooth_adapter_set_visibility_mode_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ ret = bt_adapter_set_visibility_mode_changed_cb(adapter_visibility_mode_changed_cb_for_adpater_p, NULL);
+ if (ret == BT_ERROR_NONE) {
+ timeout_id = g_timeout_add(10000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ }
+ dts_check_eq("bt_adapter_set_visibility_mode_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_adapter_set_visibility_mode_changed_cb failed.");
+}
+
+/**
+ * @brief Positive test case of bt_adapter_enable()
+ */
+static void utc_network_bluetooth_adapter_enable_p(void)
+{
+ int timeout_id = 0;
+ callback_result = false;
+ bt_error_e ret = BT_ERROR_NONE;
+
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_adapter_p, "enable") != BT_ERROR_NONE) {
+ dts_fail("bt_adapter_enable",
+ "bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ ret = bt_adapter_enable();
+ if (ret == BT_ERROR_NONE) {
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_ALREADY_DONE) {
+ callback_result = true;
+ } else {
+ dts_fail("bt_adapter_enable", "bt_adapter_enable() failed.");
+ bt_adapter_unset_state_changed_cb();
+ return;
+ }
+
+ tet_printf("callback_result: %d", callback_result);
+ bt_adapter_unset_state_changed_cb();
+ dts_check_eq("bt_adapter_enable", callback_result, true,
+ "BT was not enabled.");
+}
+
+/**
+ * @brief Positive test case of bt_adapter_get_state()
+ */
+static void utc_network_bluetooth_adapter_get_state_p(void)
+{
+ bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED;
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_get_state(&adapter_state);
+ if (ret == BT_ERROR_NONE && adapter_state == BT_ADAPTER_ENABLED) {
+ dts_pass("bt_adapter_get_state",
+ "bt_adapter_get_state() succeeded.");
+ } else {
+ dts_fail("bt_adapter_get_state",
+ "bt_adapter_get_state() failed.");
+ }
+}
+
+/**
+ * @brief Positive test case of bt_adapter_get_address().
+ */
+static void utc_network_bluetooth_adapter_get_address_p(void)
+{
+ char *address = NULL;
+ int ret = bt_adapter_get_address(&address);
+
+ if (address != NULL)
+ tet_printf("device address: %s", address);
+
+ dts_check_eq("bt_adapter_get_address", ret, BT_ERROR_NONE,
+ "bt_adapter_get_address() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_adapter_get_name().
+ */
+static void utc_network_bluetooth_adapter_get_name_p(void)
+{
+ char *name = NULL;
+ int ret = bt_adapter_get_name(&name);
+
+ if (name != NULL)
+ tet_printf("device name : %s", name);
+
+ memset(adapter_name, 0x00, sizeof(adapter_name));
+ g_strlcpy(adapter_name, name, sizeof(adapter_name));
+
+ dts_check_eq("bt_adapter_get_name", ret, BT_ERROR_NONE,
+ "bt_adapter_get_name() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_adapter_get_visibility().
+ */
+static void utc_network_bluetooth_adapter_get_visibility_p(void)
+{
+ bt_adapter_visibility_mode_e mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE;
+ int dur = 1;
+ int ret = bt_adapter_get_visibility(&mode, &dur);
+
+ tet_printf("visibility mode : %d", mode);
+ if (mode == BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE) {
+ adapter_visibility_mode = BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE;
+ } else if (mode == BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE) {
+ adapter_visibility_mode = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE;
+ } else
+ adapter_visibility_mode = BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE;
+
+ dts_check_eq("bt_adapter_get_visibility", ret, BT_ERROR_NONE,
+ "bt_adapter_get_visibility() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_adapter_set_name().
+ */
+static void utc_network_bluetooth_adapter_set_name_p(void)
+{
+ int timeout_id = 0;
+ char name[128] = "";
+
+ snprintf(name, 128, "%s_1", adapter_name);
+ strncpy(adapter_name, name, 128);
+
+ if (bt_adapter_set_name_changed_cb(adapter_name_changed_cb_for_adapter_p, "set_name") != BT_ERROR_NONE) {
+ dts_fail("bt_adapter_set_name",
+ "bt_adapter_set_name_changed_cb() failed.");
+ }
+
+ if (bt_adapter_set_name(adapter_name) == BT_ERROR_NONE) {
+ tet_printf("adapter_name_changed_cb_for_adapter_p() will be called");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ bt_adapter_unset_name_changed_cb();
+ dts_check_eq("bt_adapter_set_name", callback_result, true,
+ "The local adapter name was not set.");
+ } else {
+ dts_fail("bt_adapter_set_name", "bt_adapter_set_name() failed");
+ }
+}
+
+/**
+ * @brief Positive test case of bt_adapter_set_visibility().
+ */
+static void utc_network_bluetooth_adapter_set_visibility_p(void)
+{
+ callback_result = false;
+ int timeout = 0;
+ int timeout_id = 0;
+
+ if (bt_adapter_set_visibility_mode_changed_cb(adapter_visibility_mode_changed_cb_for_adpater_p, "set_visibility") != BT_ERROR_NONE) {
+ dts_fail("bt_adapter_set_visibility",
+ "bt_adapter_set_visibility_mode_changed_cb() failed.");
+ }
+
+ tet_printf("set visibility mode: %d", adapter_visibility_mode);
+ if (adapter_visibility_mode == BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE) {
+ timeout = 90;
+ tet_printf("set timeout: %d", timeout);
+ }
+
+ if (bt_adapter_set_visibility(adapter_visibility_mode, timeout) == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_visibility_changed_cb() will be called");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ bt_adapter_unset_visibility_mode_changed_cb();
+ dts_check_eq("bt_adapter_set_visibility", callback_result, true,
+ "The visibility of BT was not set.");
+ } else {
+ dts_fail("bt_adapter_set_visibility",
+ "bt_adapter_set_visibility() failed");
+ }
+}
+
+/**
+ * @brief Positive test case of bt_adapter_disable()
+ */
+static void utc_network_bluetooth_adapter_disable_p(void)
+{
+ callback_result = false;
+ int timeout_id = 0;
+
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_adapter_p, "disable") != BT_ERROR_NONE) {
+ dts_fail("bt_adapter_disable",
+ "bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ if (bt_adapter_disable() == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_state_changed_cb() will be called");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ bt_adapter_unset_state_changed_cb();
+ dts_check_eq("bt_adapter_disable", callback_result, true,
+ "BT was not disabled");
+ } else {
+ dts_fail("bt_adapter_disable", "bt_adapter_disable() failed");
+ }
+}
+
+/**
+ * @brief Positive test case of bt_adapter_unset_state_changed_cb()
+ */
+static void utc_network_bluetooth_adapter_unset_state_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_unset_state_changed_cb();
+ dts_check_eq("bt_adapter_unset_state_changed_cb", ret, BT_ERROR_NONE,
+ "bt_adapter_unset_state_changed_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_adapter_unset_name_changed_cb()
+ */
+static void utc_network_bluetooth_adapter_unset_name_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_unset_name_changed_cb();
+ dts_check_eq("bt_adapter_unset_name_changed_cb", ret, BT_ERROR_NONE,
+ "bt_adapter_unset_name_changed_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_adapter_unset_visibility_mode_changed_cb()
+ */
+static void utc_network_bluetooth_adapter_unset_visibility_mode_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_unset_visibility_mode_changed_cb();
+ dts_check_eq("bt_adapter_unset_visibility_mode_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_adapter_unset_visibility_mode_changed_cb() failed.");
+}
diff --git a/TC/testcase/utc_network_bluetooth_audio_negative.c b/TC/testcase/utc_network_bluetooth_audio_negative.c
new file mode 100644
index 0000000..63c29d9
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_audio_negative.c
@@ -0,0 +1,362 @@
+/*
+ * utc_network_bluetooth_audio_negative.c
+ *
+ * Created on: 19-Sep-2013
+ * Author: mrinal.m
+ */
+
+#include <tet_api.h>
+#include <bluetooth.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_audio_connect_n(void);
+static void utc_network_bluetooth_audio_disconnect_n(void);
+static void utc_network_bluetooth_audio_set_connection_n(void);
+static void utc_network_bluetooth_ag_get_speaker_gain_n(void);
+static void utc_network_bluetooth_ag_is_nrec_enabled_n(void);
+static void utc_network_bluetooth_ag_set_microphone_gain_changed_n(void);
+static void utc_network_bluetooth_ag_set_speaker_gain_changed_n(void);
+static void utc_network_bluetooth_ag_is_sco_opened_n(void);
+static void utc_network_bluetooth_ag_set_sco_state_changed_n(void);
+static void utc_network_bluetooth_ag_notify_call_event_n(void);
+static void utc_network_bluetooth_ag_notify_call_list_n(void);
+static void utc_network_bluetooth_ag_set_call_handling_event_cb_n(void);
+static void utc_network_bluetooth_ag_set_multi_call_handling_event_cb_n(void);
+static void utc_network_bluetooth_ag_unset_multi_call_handling_event_cb_n(void);
+static void utc_network_bluetooth_ag_unset_dtmf_transmitted_cb_n(void);
+static void utc_network_bluetooth_ag_call_list_destroy_n(void);
+static void utc_network_bluetooth_ag_call_list_reset_n(void);
+static void utc_network_bluetooth_ag_call_list_add_n(void);
+
+void adapter_state_changed_cb_for_audio_negative(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_audio_connect_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_audio_disconnect_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_audio_set_connection_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_get_speaker_gain_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_is_nrec_enabled_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_set_microphone_gain_changed_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_set_speaker_gain_changed_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_is_sco_opened_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_set_sco_state_changed_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_notify_call_event_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_notify_call_list_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_set_call_handling_event_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_set_multi_call_handling_event_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_unset_multi_call_handling_event_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_unset_dtmf_transmitted_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_call_list_destroy_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_call_list_reset_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_ag_call_list_add_n, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+
+ if (bt_audio_initialize() != BT_ERROR_NONE)
+ tet_printf("bt_audio_initialize failed");
+
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_audio_negative, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Callback funtions
+ */
+void adapter_state_changed_cb_for_audio_negative(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+ tet_printf("Callback: bt_adapter_state_changed_cb was called.");
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_DISABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was disabled. DTS will be started.");
+ } else {
+ tet_printf("Callback: BT was not disabled. DTS will be started but DTS may fail.");
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+}
+
+/**
+ * @brief Negative test case of bt_audio_connect()
+ */
+static void utc_network_bluetooth_audio_connect_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_audio_connect(NULL, BT_AUDIO_PROFILE_TYPE_HSP_HFP);
+ dts_check_eq("bt_audio_connect", ret,
+ BT_ERROR_INVALID_PARAMETER, "bt_audio_connect() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_audio_disconnect()
+ */
+static void utc_network_bluetooth_audio_disconnect_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_audio_disconnect(NULL, BT_AUDIO_PROFILE_TYPE_A2DP);
+ dts_check_eq("bt_audio_disconnect", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_audio_disconnect() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_audio_set_connection_state_changed_cb()
+ */
+static void utc_network_bluetooth_audio_set_connection_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_audio_set_connection_state_changed_cb(NULL, NULL);
+ dts_check_eq("bt_audio_set_connection_state_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_audio_set_connection_state_changed_cb() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_ag_get_speaker_gain()
+ */
+static void utc_network_bluetooth_ag_get_speaker_gain_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_get_speaker_gain(NULL);
+ dts_check_eq("bt_ag_get_speaker_gain", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_ag_get_speaker_gain() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_ag_is_nrec_enabled()
+ */
+static void utc_network_bluetooth_ag_is_nrec_enabled_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_is_nrec_enabled(NULL);
+ dts_check_eq("bt_ag_is_nrec_enabled", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_ag_is_nrec_enabled() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_ag_set_microphone_gain_changed_cb()
+ */
+static void utc_network_bluetooth_ag_set_microphone_gain_changed_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_set_microphone_gain_changed_cb(NULL, NULL);
+ dts_check_eq("bt_ag_set_microphone_gain_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_ag_set_microphone_gain_changed_cb() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_ag_set_speaker_gain_changed_cb()
+ */
+static void utc_network_bluetooth_ag_set_speaker_gain_changed_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_set_speaker_gain_changed_cb(NULL, NULL);
+ dts_check_eq("bt_ag_set_speaker_gain_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_ag_set_speaker_gain_changed_cb() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_ag_is_sco_opened()
+ */
+static void utc_network_bluetooth_ag_is_sco_opened_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_is_sco_opened(NULL);
+ dts_check_eq("bt_ag_is_sco_opened", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_ag_is_sco_opened() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_ag_set_sco_state_changed_cb()
+ */
+static void utc_network_bluetooth_ag_set_sco_state_changed_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_set_sco_state_changed_cb(NULL, NULL);
+ dts_check_eq("bt_ag_set_sco_state_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_ag_set_sco_state_changed_cb() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_ag_notify_call_event()
+ */
+static void utc_network_bluetooth_ag_notify_call_event_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ unsigned int call_id = 0;
+ ret = bt_ag_notify_call_event(BT_AG_CALL_EVENT_INCOMING, call_id, NULL);
+ dts_check_eq("bt_ag_notify_call_event", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_ag_notify_call_event() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_ag_notify_call_list()
+ */
+static void utc_network_bluetooth_ag_notify_call_list_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_notify_call_list(NULL);
+ dts_check_eq("bt_ag_notify_call_list", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_ag_notify_call_list() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_ag_set_call_handling_event_cb()
+ */
+static void utc_network_bluetooth_ag_set_call_handling_event_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_set_call_handling_event_cb(NULL, NULL);
+ dts_check_eq("bt_ag_set_call_handling_event_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_ag_set_call_handling_event_cb() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_ag_set_multi_call_handling_event_cb()
+ */
+static void utc_network_bluetooth_ag_set_multi_call_handling_event_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_set_multi_call_handling_event_cb(NULL, NULL);
+ dts_check_eq("bt_ag_set_multi_call_handling_event_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_ag_set_multi_call_handling_event_cb() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_ag_set_dtmf_transmitted_cb()
+ */
+static void utc_network_bluetooth_ag_unset_multi_call_handling_event_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_set_dtmf_transmitted_cb(NULL, NULL);
+ dts_check_eq("bt_ag_set_dtmf_transmitted_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_ag_set_dtmf_transmitted_cb() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_call_list_create()
+ */
+static void utc_network_bluetooth_ag_unset_dtmf_transmitted_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_call_list_h handle;
+ handle = g_malloc0(sizeof(bt_call_list_h));
+ ret = bt_call_list_create(handle);
+ dts_check_eq("bt_call_list_create", ret, BT_ERROR_NONE,
+ "bt_call_list_create() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_call_list_destroy()
+ */
+static void utc_network_bluetooth_ag_call_list_destroy_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_call_list_destroy(NULL);
+ dts_check_eq("bt_call_list_destroy", ret, BT_ERROR_INVALID_PARAMETER,
+ "bt_call_list_destroy() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_call_list_reset()
+ */
+static void utc_network_bluetooth_ag_call_list_reset_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_call_list_reset(NULL);
+ dts_check_eq("bt_call_list_reset", ret, BT_ERROR_INVALID_PARAMETER,
+ "bt_call_list_reset() failed.");
+}
+
+/**
+ * @brief Negative test case of bt_call_list_add()
+ */
+static void utc_network_bluetooth_ag_call_list_add_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ unsigned int call_id = 0;
+
+ ret = bt_call_list_add(NULL, call_id, BT_AG_CALL_STATE_INCOMING);
+ dts_check_eq("bt_call_list_add", ret, BT_ERROR_INVALID_PARAMETER,
+ "bt_call_list_add() failed.");
+
+}
diff --git a/TC/testcase/utc_network_bluetooth_audio_positive.c b/TC/testcase/utc_network_bluetooth_audio_positive.c
new file mode 100644
index 0000000..1f7c6a5
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_audio_positive.c
@@ -0,0 +1,618 @@
+/*
+ * utc_network_bluetooth_audio_positive.c
+ *
+ * Created on: 19-Sep-2013
+ * Author: mrinal.m
+ */
+
+#include <tet_api.h>
+#include <bluetooth.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+char target_address[18] = "";
+static GMainLoop *mainloop;
+
+static void utc_network_bluetooth_audio_initialize_p(void);
+static void utc_network_bluetooth_audio_deinitialize_p(void);
+static void utc_network_bluetooth_audio_connect_p(void);
+static void utc_network_bluetooth_audio_disconnect_p(void);
+static void utc_network_bluetooth_audio_set_connection_p(void);
+static void utc_network_bluetooth_audio_unset_connection_p(void);
+static void utc_network_bluetooth_ag_notify_speaker_gain_p(void);
+static void utc_network_bluetooth_ag_get_speaker_gain_p(void);
+static void utc_network_bluetooth_ag_is_nrec_enabled_p(void);
+static void utc_network_bluetooth_ag_set_microphone_gain_changed_p(void);
+static void utc_network_bluetooth_ag_unset_microphone_gain_changed_p(void);
+static void utc_network_bluetooth_ag_set_speaker_gain_changed_p(void);
+static void utc_network_bluetooth_ag_unset_speaker_gain_changed_p(void);
+static void utc_network_bluetooth_ag_open_sco_p(void);
+static void utc_network_bluetooth_ag_close_sco_p(void);
+static void utc_network_bluetooth_ag_is_sco_opened_p(void);
+static void utc_network_bluetooth_ag_set_sco_state_changed_p(void);
+static void utc_network_bluetooth_ag_unset_sco_state_changed_p(void);
+static void utc_network_bluetooth_ag_notify_call_event_p(void);
+static void utc_network_bluetooth_ag_notify_call_list_p(void);
+static void utc_network_bluetooth_ag_notify_voice_recognition_state_p(void);
+static void utc_network_bluetooth_ag_set_call_handling_event_cb_p(void);
+static void utc_network_bluetooth_ag_unset_call_handling_event_cb_p(void);
+static void utc_network_bluetooth_ag_set_multi_call_handling_event_cb_p(void);
+static void utc_network_bluetooth_ag_unset_multi_call_handling_event_cb_p(void);
+static void utc_network_bluetooth_ag_set_dtmf_transmitted_cb_p(void);
+static void utc_network_bluetooth_ag_unset_dtmf_transmitted_cb_p(void);
+static void utc_network_bluetooth_ag_call_list_create_p(void);
+static void utc_network_bluetooth_ag_call_list_destroy_p(void);
+static void utc_network_bluetooth_ag_call_list_reset_p(void);
+static void utc_network_bluetooth_ag_call_list_add_p(void);
+static void utc_network_bluetooth_ag_ca2dp_set_content_protection_p(void);
+
+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);
+void dtmf_transmitted_cb_for_ag_p(const char *dtmf, void *user_data);
+void multi_call_handling_event_cb_for_ag_p(bt_ag_multi_call_handling_event_e event, void *user_data);
+void call_handling_event_cb_for_ag_p(bt_ag_call_handling_event_e event,
+ unsigned int call_id, void *user_data);
+void sco_state_changed_cb_for_ag_p(int result, bool opened, void *user_data);
+void speaker_gain_changed_cb_for_ag_p(int gain, void *user_data);
+void microphone_gain_changed_cb_for_ag_p(int gain, void *user_data);
+void adapter_state_changed_cb_for_audio_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_audio_initialize_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_audio_set_connection_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_audio_connect_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_open_sco_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_set_microphone_gain_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_set_speaker_gain_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_notify_speaker_gain_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_get_speaker_gain_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_is_nrec_enabled_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_unset_microphone_gain_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_unset_speaker_gain_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_set_sco_state_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_is_sco_opened_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_notify_call_event_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_notify_call_list_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_notify_voice_recognition_state_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_set_call_handling_event_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_unset_call_handling_event_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_set_multi_call_handling_event_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_unset_multi_call_handling_event_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_set_dtmf_transmitted_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_unset_dtmf_transmitted_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_close_sco_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_unset_sco_state_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_call_list_create_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_call_list_destroy_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_call_list_reset_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_call_list_add_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_ag_ca2dp_set_content_protection_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_audio_disconnect_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_audio_unset_connection_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_audio_deinitialize_p, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ bt_error_e ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ tet_printf("TC start.");
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_audio_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_enable() was called.");
+ ret = bt_adapter_enable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_enable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret != BT_ERROR_ALREADY_DONE) {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("[%s] Callback: Timeout.", __FUNCTION__);
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Callback funtions
+ */
+
+void adapter_state_changed_cb_for_audio_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+
+}
+
+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)
+{
+
+}
+
+void microphone_gain_changed_cb_for_ag_p(int gain, void *user_data)
+{
+
+}
+
+void speaker_gain_changed_cb_for_ag_p(int gain, void *user_data)
+{
+
+}
+
+void sco_state_changed_cb_for_ag_p(int result, bool opened, void *user_data)
+{
+
+}
+
+void call_handling_event_cb_for_ag_p(bt_ag_call_handling_event_e event,
+ unsigned int call_id, void *user_data)
+{
+
+}
+
+void multi_call_handling_event_cb_for_ag_p(bt_ag_multi_call_handling_event_e event, void *user_data)
+{
+
+}
+
+void dtmf_transmitted_cb_for_ag_p(const char *dtmf, void *user_data)
+{
+
+}
+
+/**
+ * @brief Positive test case of bt_audio_initialize()
+ */
+static void utc_network_bluetooth_audio_initialize_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_audio_initialize();
+ dts_check_eq("bt_audio_initialize", ret, BT_ERROR_NONE,
+ "bt_audio_initialize() failed. %x", ret);
+
+}
+
+/**
+ * @brief Positive test case of bt_audio_connect()
+ */
+static void utc_network_bluetooth_audio_connect_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ const char *remote_address = "00:23:78:AB:C4:20";
+ ret = bt_audio_connect(remote_address, BT_AUDIO_PROFILE_TYPE_HSP_HFP);
+ dts_check_eq("bt_audio_connect", ret, BT_ERROR_NONE,
+ "bt_audio_connect() failed. %x", ret);
+}
+
+/**
+ * @brief Positive test case of bt_audio_disconnect()
+ */
+static void utc_network_bluetooth_audio_disconnect_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ const char *remote_address = "00:23:78:AB:C4:20";
+ ret = bt_audio_disconnect(remote_address, BT_AUDIO_PROFILE_TYPE_A2DP);
+ dts_check_eq("bt_audio_disconnect", ret, BT_ERROR_NONE,
+ "bt_audio_disconnect() failed. %x", ret);
+}
+
+/**
+ * @brief Positive test case of bt_audio_set_connection_state_changed_cb()
+ */
+static void utc_network_bluetooth_audio_set_connection_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret =
+ bt_audio_set_connection_state_changed_cb
+ (connection_state_changed_cb_for_audio_p, NULL);
+ dts_check_eq("bt_audio_set_connection_state_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_audio_set_connection_state_changed_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_audio_unset_connection_state_changed_cb()
+ */
+static void utc_network_bluetooth_audio_unset_connection_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_audio_unset_connection_state_changed_cb();
+ dts_check_eq("bt_audio_set_connection_state_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_audio_set_connection_state_changed_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_ag_notify_speaker_gain()
+ */
+static void utc_network_bluetooth_ag_notify_speaker_gain_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ int gain = 10;
+ ret = bt_ag_notify_speaker_gain(gain);
+ dts_check_eq("bt_ag_notify_speaker_gain", ret, BT_ERROR_NONE,
+ "bt_ag_notify_speaker_gain() failed.%x", ret);
+}
+
+/**
+ * @brief Positive test case of bt_ag_get_speaker_gain()
+ */
+static void utc_network_bluetooth_ag_get_speaker_gain_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ int gain = 0;
+ ret = bt_ag_get_speaker_gain(&gain);
+ dts_check_eq("bt_ag_get_speaker_gain", ret, BT_ERROR_NONE,
+ "bt_ag_get_speaker_gain() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_is_nrec_enabled()
+ */
+static void utc_network_bluetooth_ag_is_nrec_enabled_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bool enabled = 1;
+ ret = bt_ag_is_nrec_enabled(&enabled);
+ dts_check_eq("bt_ag_is_nrec_enabled", ret, BT_ERROR_NONE,
+ "bt_ag_is_nrec_enabled() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_set_microphone_gain_changed_cb()
+ */
+static void utc_network_bluetooth_ag_set_microphone_gain_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_set_microphone_gain_changed_cb(microphone_gain_changed_cb_for_ag_p, NULL);
+ dts_check_eq("bt_ag_set_microphone_gain_changed_cb", ret, BT_ERROR_NONE,
+ "bt_ag_set_microphone_gain_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_unset_microphone_gain_changed_cb()
+ */
+static void utc_network_bluetooth_ag_unset_microphone_gain_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_unset_microphone_gain_changed_cb();
+ dts_check_eq("bt_ag_unset_microphone_gain_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_ag_unset_microphone_gain_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_set_speaker_gain_changed_cb()
+ */
+static void utc_network_bluetooth_ag_set_speaker_gain_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_set_speaker_gain_changed_cb(speaker_gain_changed_cb_for_ag_p, NULL);
+ dts_check_eq("bt_ag_set_speaker_gain_changed_cb", ret, BT_ERROR_NONE,
+ "bt_ag_set_speaker_gain_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_unset_speaker_gain_changed_cb()
+ */
+static void utc_network_bluetooth_ag_unset_speaker_gain_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_unset_speaker_gain_changed_cb();
+ dts_check_eq("bt_ag_unset_speaker_gain_changed_cb", ret, BT_ERROR_NONE,
+ "bt_ag_unset_speaker_gain_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_open_sco()
+ */
+static void utc_network_bluetooth_ag_open_sco_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_open_sco();
+ dts_check_eq("bt_ag_open_sco", ret, BT_ERROR_NONE,
+ "bt_ag_open_sco() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_close_sco()
+ */
+static void utc_network_bluetooth_ag_close_sco_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_close_sco();
+ dts_check_eq("bt_ag_close_sco", ret, BT_ERROR_NONE,
+ "bt_ag_close_sco() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_is_sco_opened()
+ */
+static void utc_network_bluetooth_ag_is_sco_opened_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bool opened = 1;
+ ret = bt_ag_is_sco_opened(&opened);
+ dts_check_eq("bt_ag_is_sco_opened", ret, BT_ERROR_NONE,
+ "bt_ag_is_sco_opened() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_set_sco_state_changed_cb()
+ */
+static void utc_network_bluetooth_ag_set_sco_state_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_set_sco_state_changed_cb(sco_state_changed_cb_for_ag_p, NULL);
+ dts_check_eq("bt_ag_set_sco_state_changed_cb", ret, BT_ERROR_NONE,
+ "bt_ag_set_sco_state_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_unset_sco_state_changed_cb()
+ */
+static void utc_network_bluetooth_ag_unset_sco_state_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_unset_sco_state_changed_cb();
+ dts_check_eq("bt_ag_unset_sco_state_changed_cb", ret, BT_ERROR_NONE,
+ "bt_ag_unset_sco_state_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_notify_call_event()
+ */
+static void utc_network_bluetooth_ag_notify_call_event_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ const char *phone_number = "9663868998";
+ unsigned int call_id = 0;
+ ret = bt_ag_notify_call_event(BT_AG_CALL_EVENT_INCOMING,
+ call_id, phone_number);
+ dts_check_eq("bt_ag_notify_call_event", ret, BT_ERROR_NONE,
+ "bt_ag_notify_call_event() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_notify_call_list()
+ */
+static void utc_network_bluetooth_ag_notify_call_list_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_call_list_h handle;
+ handle = g_malloc0(sizeof(bt_call_list_h));
+ bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE);
+ ret = bt_ag_notify_call_list(handle);
+ dts_check_eq("bt_ag_notify_call_list", ret, BT_ERROR_NONE,
+ "bt_ag_notify_call_list() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_notify_voice_recognition_state()
+ */
+static void utc_network_bluetooth_ag_notify_voice_recognition_state_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bool state = true;
+
+ ret = bt_ag_notify_voice_recognition_state(state);
+ dts_check_eq("bt_ag_notify_voice_recognition_state", ret, BT_ERROR_NONE,
+ "bt_ag_notify_voice_recognition_state() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_set_call_handling_event_cb()
+ */
+static void utc_network_bluetooth_ag_set_call_handling_event_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_set_call_handling_event_cb(call_handling_event_cb_for_ag_p,
+ NULL);
+ dts_check_eq("bt_ag_set_call_handling_event_cb", ret, BT_ERROR_NONE,
+ "bt_ag_set_call_handling_event_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_unset_call_handling_event_cb()
+ */
+static void utc_network_bluetooth_ag_unset_call_handling_event_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_unset_call_handling_event_cb();
+ dts_check_eq("bt_ag_unset_call_handling_event_cb", ret, BT_ERROR_NONE,
+ "bt_ag_unset_call_handling_event_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_set_multi_call_handling_event_cb()
+ */
+static void utc_network_bluetooth_ag_set_multi_call_handling_event_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_set_multi_call_handling_event_cb(multi_call_handling_event_cb_for_ag_p, NULL);
+ dts_check_eq("bt_ag_set_multi_call_handling_event_cb", ret,
+ BT_ERROR_NONE,
+ "bt_ag_set_multi_call_handling_event_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_unset_multi_call_handling_event_cb()
+ */
+static void utc_network_bluetooth_ag_unset_multi_call_handling_event_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_unset_multi_call_handling_event_cb();
+ dts_check_eq("bt_ag_unset_multi_call_handling_event_cb", ret,
+ BT_ERROR_NONE,
+ "bt_ag_unset_multi_call_handling_event_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_set_dtmf_transmitted_cb()
+ */
+static void utc_network_bluetooth_ag_set_dtmf_transmitted_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_set_dtmf_transmitted_cb(dtmf_transmitted_cb_for_ag_p, NULL);
+ dts_check_eq("bt_ag_set_dtmf_transmitted_cb", ret, BT_ERROR_NONE,
+ "bt_ag_set_dtmf_transmitted_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_ag_unset_dtmf_transmitted_cb()
+ */
+static void utc_network_bluetooth_ag_unset_dtmf_transmitted_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_ag_unset_dtmf_transmitted_cb();
+ dts_check_eq("bt_ag_unset_dtmf_transmitted_cb", ret, BT_ERROR_NONE,
+ "bt_ag_unset_dtmf_transmitted_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_call_list_create()
+ */
+static void utc_network_bluetooth_ag_call_list_create_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_call_list_h handle;
+ handle = g_malloc0(sizeof(bt_call_list_h));
+ bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE);
+ ret = bt_call_list_create(&handle);
+ dts_check_eq("bt_call_list_create", ret, BT_ERROR_NONE,
+ "bt_call_list_create() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_call_list_destroy()
+ */
+static void utc_network_bluetooth_ag_call_list_destroy_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_call_list_h handle;
+ handle = g_malloc0(sizeof(bt_call_list_h));
+ bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE);
+ ret = bt_call_list_destroy(handle);
+ dts_check_eq("bt_call_list_destroy", ret, BT_ERROR_NONE,
+ "bt_call_list_destroy() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_call_list_reset()
+ */
+static void utc_network_bluetooth_ag_call_list_reset_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_call_list_h handle;
+ handle = g_malloc0(sizeof(bt_call_list_h));
+ bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE);
+ ret = bt_call_list_reset(handle);
+ dts_check_eq("bt_call_list_reset", ret, BT_ERROR_NONE,
+ "bt_call_list_reset() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_call_list_add()
+ */
+static void utc_network_bluetooth_ag_call_list_add_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ unsigned int call_id = 0;
+ bt_call_list_h handle;
+ handle = g_malloc0(sizeof(bt_call_list_h));
+ bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE);
+ ret = bt_call_list_add(handle, call_id, BT_AG_CALL_STATE_INCOMING);
+ dts_check_eq("bt_call_list_add", ret, BT_ERROR_NONE,
+ "bt_call_list_add() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_a2dp_set_content_protection()
+ */
+static void utc_network_bluetooth_ag_ca2dp_set_content_protection_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bool status = true;
+ ret = bt_a2dp_set_content_protection(status);
+ dts_check_eq("bt_a2dp_set_content_protection", ret, BT_ERROR_NONE,
+ "bt_a2dp_set_content_protection() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_audio_deinitialize()
+ */
+static void utc_network_bluetooth_audio_deinitialize_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_audio_deinitialize();
+ dts_check_eq("bt_audio_deinitialize", ret, BT_ERROR_NONE,
+ "bt_audio_deinitialize() failed.");
+}
diff --git a/TC/testcase/utc_network_bluetooth_avrcp_negative.c b/TC/testcase/utc_network_bluetooth_avrcp_negative.c
new file mode 100644
index 0000000..d418475
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_avrcp_negative.c
@@ -0,0 +1,171 @@
+/*
+ * utc_network_bluetooth_avrcp_negative.c
+ *
+ * Created on: 20-Sep-2013
+ * Author: mrinal.m
+ */
+
+#include "bluetooth.h"
+#include <tet_api.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+const char target_name[128] = "dts_test";
+char target_address[18] = "";
+
+static GMainLoop *mainloop;
+
+static void utc_network_bluetooth_audio_initialize_n(void);
+static void utc_network_bluetooth_avrcp_set_equalizer_state_changed_n(void);
+static void utc_network_bluetooth_avrcp_set_repeat_mode_changed_n(void);
+static void utc_network_bluetooth_avrcp_set_shuffle_mode_changed_n(void);
+static void utc_network_bluetooth_avrcp_set_scan_mode_changed_n(void);
+
+void adapter_state_changed_cb_for_avrcp_n(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_audio_initialize_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_set_equalizer_state_changed_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_set_repeat_mode_changed_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_set_shuffle_mode_changed_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_set_scan_mode_changed_n, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_avrcp_n, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Negative test case of bt_avrcp_target_initialize()
+ */
+
+void adapter_state_changed_cb_for_avrcp_n(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+
+}
+
+static void utc_network_bluetooth_audio_initialize_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_target_initialize(NULL, NULL);
+ dts_check_eq("bt_avrcp_target_initialize", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_avrcp_target_initialize() failed.");
+
+}
+
+/**
+ * @brief Negative test case of bt_avrcp_set_equalizer_state_changed_cb()
+ */
+static void utc_network_bluetooth_avrcp_set_equalizer_state_changed_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_set_equalizer_state_changed_cb(NULL, NULL);
+ dts_check_eq("bt_avrcp_set_equalizer_state_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_avrcp_set_equalizer_state_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Negative test case of bt_avrcp_set_repeat_mode_changed_cb()
+ */
+static void utc_network_bluetooth_avrcp_set_repeat_mode_changed_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_set_repeat_mode_changed_cb(NULL, NULL);
+ dts_check_eq("bt_avrcp_set_repeat_mode_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_avrcp_set_repeat_mode_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Negative test case of bt_avrcp_set_shuffle_mode_changed_cb()
+ */
+static void utc_network_bluetooth_avrcp_set_shuffle_mode_changed_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_set_shuffle_mode_changed_cb(NULL, NULL);
+ dts_check_eq("bt_avrcp_set_shuffle_mode_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_avrcp_set_shuffle_mode_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Negative test case of bt_avrcp_set_scan_mode_changed_cb()
+ */
+static void utc_network_bluetooth_avrcp_set_scan_mode_changed_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_set_scan_mode_changed_cb(NULL, NULL);
+ dts_check_eq("bt_avrcp_set_scan_mode_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_avrcp_set_scan_mode_changed_cb() failed.");
+
+}
diff --git a/TC/testcase/utc_network_bluetooth_avrcp_positive.c b/TC/testcase/utc_network_bluetooth_avrcp_positive.c
new file mode 100644
index 0000000..dab7f7e
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_avrcp_positive.c
@@ -0,0 +1,387 @@
+/*
+ * utc_network_bluetooth_avrcp_positive.c
+ *
+ * Created on: 20-Sep-2013
+ * Author: mrinal.m
+ */
+
+#include "bluetooth.h"
+#include <tet_api.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+void target_connection_state_changed_cb_for_avrcp_p(bool connected,
+ const char *remote_address,
+ void *user_data);
+void equalizer_state_changed_cb_for_avrcp_p(bt_avrcp_equalizer_state_e equalizer, void *user_data);
+void repeat_mode_changed_cb_for_avrcp_p(bt_avrcp_repeat_mode_e repeat,
+ void *user_data);
+void shuffle_mode_changed_cb_for_avrcp_p(bt_avrcp_shuffle_mode_e shuffle,
+ void *user_data);
+void scan_mode_changed_cb_for_avrcp_p(bt_avrcp_scan_mode_e scan,
+ void *user_data);
+
+static void utc_network_bluetooth_avrcp_targe_initialize_p(void);
+static void utc_network_bluetooth_avrcp_target_deinitialize_p(void);
+static void utc_network_bluetooth_avrcp_target_notify_equalizer_state_p(void);
+static void utc_network_bluetooth_avrcp_target_notify_repeat_mode_p(void);
+static void utc_network_bluetooth_avrcp_target_notify_shuffle_mode_p(void);
+static void utc_network_bluetooth_avrcp_target_notify_scan_mode_p(void);
+static void utc_network_bluetooth_avrcp_target_notify_player_state_p(void);
+static void utc_network_bluetooth_avrcp_target_notify_position_p(void);
+static void utc_network_bluetooth_avrcp_target_notify_track_p(void);
+static void utc_network_bluetooth_avrcp_set_equalizer_state_changed_p(void);
+static void utc_network_bluetooth_avrcp_unset_equalizer_state_changed_p(void);
+static void utc_network_bluetooth_avrcp_set_repeat_mode_changed_p(void);
+static void utc_network_bluetooth_avrcp_unset_repeat_mode_changed_p(void);
+static void utc_network_bluetooth_avrcp_set_shuffle_mode_changed_p(void);
+static void utc_network_bluetooth_avrcp_unset_shuffle_mode_changed_p(void);
+static void utc_network_bluetooth_avrcp_set_scan_mode_changed_p(void);
+static void utc_network_bluetooth_avrcp_unset_scan_mode_changed_p(void);
+
+void adapter_state_changed_cb_for_avrcp_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_avrcp_targe_initialize_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_target_notify_equalizer_state_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_target_notify_repeat_mode_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_target_notify_shuffle_mode_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_target_notify_scan_mode_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_target_notify_player_state_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_target_notify_position_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_target_notify_track_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_set_equalizer_state_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_unset_equalizer_state_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_set_repeat_mode_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_unset_repeat_mode_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_set_shuffle_mode_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_unset_shuffle_mode_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_set_scan_mode_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_unset_scan_mode_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_avrcp_target_deinitialize_p, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_avrcp_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_enable() was called.");
+ ret = bt_adapter_enable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_enable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret != BT_ERROR_ALREADY_DONE) {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Callback funtions
+ */
+
+void adapter_state_changed_cb_for_avrcp_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+
+}
+
+void target_connection_state_changed_cb_for_avrcp_p(bool connected,
+ const char *remote_address,
+ void *user_data)
+{
+
+}
+
+void equalizer_state_changed_cb_for_avrcp_p(bt_avrcp_equalizer_state_e equalizer, void *user_data)
+{
+
+}
+
+void repeat_mode_changed_cb_for_avrcp_p(bt_avrcp_repeat_mode_e repeat,
+ void *user_data)
+{
+
+}
+
+void shuffle_mode_changed_cb_for_avrcp_p(bt_avrcp_shuffle_mode_e shuffle,
+ void *user_data)
+{
+
+}
+
+void scan_mode_changed_cb_for_avrcp_p(bt_avrcp_scan_mode_e scan,
+ void *user_data)
+{
+
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_target_initialize()
+ */
+static void utc_network_bluetooth_avrcp_targe_initialize_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_target_initialize(target_connection_state_changed_cb_for_avrcp_p, NULL);
+ dts_check_eq("bt_avrcp_target_initialize", ret, BT_ERROR_NONE,
+ "bt_avrcp_target_initialize() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_target_deinitialize()
+ */
+static void utc_network_bluetooth_avrcp_target_deinitialize_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_target_deinitialize();
+ dts_check_eq("bt_avrcp_target_deinitialize", ret, BT_ERROR_NONE,
+ "bt_avrcp_target_deinitialize() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_target_notify_equalizer_state()
+ */
+static void utc_network_bluetooth_avrcp_target_notify_equalizer_state_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_target_notify_equalizer_state(BT_AVRCP_EQUALIZER_STATE_ON);
+ dts_check_eq("bt_avrcp_target_notify_equalizer_state", ret,
+ BT_ERROR_NONE,
+ "bt_avrcp_target_notify_equalizer_state() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_target_notify_repeat_mode()
+ */
+static void utc_network_bluetooth_avrcp_target_notify_repeat_mode_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_target_notify_repeat_mode(BT_AVRCP_REPEAT_MODE_ALL_TRACK);
+ dts_check_eq("bt_avrcp_target_notify_repeat_mode", ret, BT_ERROR_NONE,
+ "bt_avrcp_target_notify_repeat_mode() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_target_notify_shuffle_mode()
+ */
+static void utc_network_bluetooth_avrcp_target_notify_shuffle_mode_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_target_notify_shuffle_mode(BT_AVRCP_SHUFFLE_MODE_ALL_TRACK);
+ dts_check_eq("bt_avrcp_target_notify_shuffle_mode", ret, BT_ERROR_NONE,
+ "bt_avrcp_target_notify_shuffle_mode() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_target_notify_scan_mode()
+ */
+static void utc_network_bluetooth_avrcp_target_notify_scan_mode_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_target_notify_scan_mode(BT_AVRCP_SCAN_MODE_ALL_TRACK);
+ dts_check_eq("bt_avrcp_target_notify_scan_mode", ret, BT_ERROR_NONE,
+ "bt_avrcp_target_notify_scan_mode() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_target_notify_player_state()
+ */
+static void utc_network_bluetooth_avrcp_target_notify_player_state_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_target_notify_player_state(BT_AVRCP_PLAYER_STATE_PLAYING);
+ dts_check_eq("bt_avrcp_target_notify_player_state", ret, BT_ERROR_NONE,
+ "bt_avrcp_target_notify_player_state() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_target_notify_position()
+ */
+static void utc_network_bluetooth_avrcp_target_notify_position_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ unsigned int position = 0;
+ ret = bt_avrcp_target_notify_position(position);
+ dts_check_eq("bt_avrcp_target_notify_position", ret, BT_ERROR_NONE,
+ "bt_avrcp_target_notify_position() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_target_notify_track()
+ */
+static void utc_network_bluetooth_avrcp_target_notify_track_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_target_notify_track("title", "artist", "album", "genre", 5, 20, 2);
+ dts_check_eq("bt_avrcp_target_notify_track", ret, BT_ERROR_NONE,
+ "bt_avrcp_target_notify_track() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_set_equalizer_state_changed_cb()
+ */
+static void utc_network_bluetooth_avrcp_set_equalizer_state_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_set_equalizer_state_changed_cb(equalizer_state_changed_cb_for_avrcp_p, NULL);
+ dts_check_eq("bt_avrcp_set_equalizer_state_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_avrcp_set_equalizer_state_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_unset_equalizer_state_changed_cb()
+ */
+static void utc_network_bluetooth_avrcp_unset_equalizer_state_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_unset_equalizer_state_changed_cb();
+ dts_check_eq("bt_avrcp_unset_equalizer_state_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_avrcp_unset_equalizer_state_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_set_repeat_mode_changed_cb()
+ */
+static void utc_network_bluetooth_avrcp_set_repeat_mode_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_set_repeat_mode_changed_cb(repeat_mode_changed_cb_for_avrcp_p, NULL);
+ dts_check_eq("bt_avrcp_set_repeat_mode_changed_cb", ret, BT_ERROR_NONE,
+ "bt_avrcp_set_repeat_mode_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_unset_repeat_mode_changed_cb()
+ */
+static void utc_network_bluetooth_avrcp_unset_repeat_mode_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_unset_repeat_mode_changed_cb();
+ dts_check_eq("bt_avrcp_unset_repeat_mode_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_avrcp_unset_repeat_mode_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_set_shuffle_mode_changed_cb()
+ */
+static void utc_network_bluetooth_avrcp_set_shuffle_mode_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_set_shuffle_mode_changed_cb(shuffle_mode_changed_cb_for_avrcp_p, NULL);
+ dts_check_eq("bt_avrcp_set_shuffle_mode_changed_cb", ret, BT_ERROR_NONE,
+ "bt_avrcp_set_shuffle_mode_changed_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_unset_shuffle_mode_changed_cb()
+ */
+static void utc_network_bluetooth_avrcp_unset_shuffle_mode_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_unset_shuffle_mode_changed_cb();
+ dts_check_eq("bt_avrcp_unset_shuffle_mode_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_avrcp_unset_shuffle_mode_changed_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_set_scan_mode_changed_cb()
+ */
+static void utc_network_bluetooth_avrcp_set_scan_mode_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_set_scan_mode_changed_cb(scan_mode_changed_cb_for_avrcp_p, NULL);
+ dts_check_eq("bt_avrcp_set_scan_mode_changed_cb", ret, BT_ERROR_NONE,
+ "bt_avrcp_set_scan_mode_changed_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_avrcp_unset_scan_mode_changed_cb()
+ */
+static void utc_network_bluetooth_avrcp_unset_scan_mode_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_avrcp_unset_scan_mode_changed_cb();
+ dts_check_eq("bt_avrcp_unset_scan_mode_changed_cb", ret, BT_ERROR_NONE,
+ "bt_avrcp_unset_scan_mode_changed_cb() failed.");
+
+}
diff --git a/TC/testcase/utc_network_bluetooth_common_negative.c b/TC/testcase/utc_network_bluetooth_common_negative.c
new file mode 100644
index 0000000..507d7f5
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_common_negative.c
@@ -0,0 +1,84 @@
+/*
+ * utc_network_bluetooth_common_negative.c
+ *
+ * Created on: 20-Sep-2013
+ * Author: mrinal.m
+ */
+
+#include "bluetooth.h"
+#include <tet_api.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+void adapter_state_changed_cb_for_common_n(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_common_n, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+void adapter_state_changed_cb_for_common_n(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+
+}
diff --git a/TC/testcase/utc_network_bluetooth_common_positive.c b/TC/testcase/utc_network_bluetooth_common_positive.c
new file mode 100644
index 0000000..c694655
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_common_positive.c
@@ -0,0 +1,119 @@
+/*
+ * utc_network_bluetooth_common_positive.c
+ *
+ * Created on: 20-Sep-2013
+ * Author: mrinal.m
+ */
+
+#include "bluetooth.h"
+#include <tet_api.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+void adapter_state_changed_cb_for_common_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+gboolean timeout_func(gpointer data);
+
+static void utc_network_bluetooth_bt_initialize_p(void);
+static void utc_network_bluetooth_bt_deinitialize_p(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_bt_initialize_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_bt_deinitialize_p, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_common_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_enable() was called.");
+ ret = bt_adapter_enable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_enable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret != BT_ERROR_ALREADY_DONE) {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+void adapter_state_changed_cb_for_common_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+
+}
+
+/**
+ * @brief Positive test case of bt_initialize()
+ */
+static void utc_network_bluetooth_bt_initialize_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_initialize();
+ dts_check_eq("bt_initialize", ret, BT_ERROR_NONE,
+ "bt_initialize() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_deinitialize()
+ */
+static void utc_network_bluetooth_bt_deinitialize_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_deinitialize();
+ dts_check_eq("bt_deinitialize", ret, BT_ERROR_NONE,
+ "bt_deinitialize() failed.");
+
+}
diff --git a/TC/testcase/utc_network_bluetooth_device_discovery_negative.c b/TC/testcase/utc_network_bluetooth_device_discovery_negative.c
new file mode 100644
index 0000000..b5b422f
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_device_discovery_negative.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static GMainLoop *mainloop;
+gboolean timeout_func(gpointer data);
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_device_discovery_cancel_n(void);
+static void utc_network_bluetooth_device_discovery_unset_state_changed_cb_n(void);
+static void utc_network_bluetooth_device_discovery_set_state_changed_cb_n(void);
+static void utc_network_bluetooth_device_discovery_start_n(void);
+static void utc_network_bluetooth_device_discovery_get_status_n(void);
+
+void adapter_state_changed_cb_for_discovery_n(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_device_discovery_cancel_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_discovery_set_state_changed_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_discovery_get_status_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_discovery_start_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_discovery_unset_state_changed_cb_n, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_discovery_n, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Callback funtions
+ */
+void adapter_state_changed_cb_for_discovery_n(int result,
+ state_e adapter_state,
+ void *user_data)
+{
+ tet_printf("Callback: bt_adapter_state_changed_cb was called.");
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_DISABLED &&
+ result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was disabled. DTS will be started.");
+ } else {
+ tet_printf("Callback: BT was not disabled. DTS will be started but DTS may fail.");
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+}
+
+/**
+ *@brief Negative test case of bt_adapter_stop_device_discovery()
+ */
+static void utc_network_bluetooth_device_discovery_cancel_n(void)
+{
+ int ret = bt_adapter_stop_device_discovery();
+
+ dts_check_eq("bt_adapter_stop_device_discovery", ret,
+ BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled");
+}
+
+/**
+ *@brief Negative test case of bt_adapter_unset_device_discovery_state_changed_cb()
+ */
+static void utc_network_bluetooth_device_discovery_unset_state_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ if (bt_deinitialize() != BT_ERROR_NONE) {
+ dts_fail("bt_adapter_unset_device_discovery_state_changed_cb",
+ "bt_deinitialize() failed.");
+ }
+ ret = bt_adapter_unset_device_discovery_state_changed_cb();
+ dts_check_eq("bt_adapter_unset_device_discovery_state_changed_cb", ret,
+ BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned when BT service is not initialized.");
+}
+
+/**
+ *@brief Negative test case of bt_adapter_set_device_discovery_state_changed_cb()
+ */
+static void utc_network_bluetooth_device_discovery_set_state_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_set_device_discovery_state_changed_cb(NULL, NULL);
+ dts_check_eq("bt_adapter_set_device_discovery_state_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when callback parameter is NULL");
+}
+
+/**
+ *@brief Negative test case of bt_adapter_start_device_discovery()
+ */
+static void utc_network_bluetooth_device_discovery_start_n(void)
+{
+ bt_error_e ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_start_device_discovery();;
+ dts_check_eq("bt_adapter_start_device_discovery", ret,
+ BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled");
+}
+
+/**
+ *@brief Negative test case of bt_adapter_is_discovering()
+ */
+static void utc_network_bluetooth_device_discovery_get_status_n(void)
+{
+ bt_error_e ret = BT_ERROR_NONE;
+ bool status = false;
+
+ ret = bt_adapter_is_discovering(&status);
+ dts_check_eq("bt_adapter_is_discovering", ret, BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled");
+}
diff --git a/TC/testcase/utc_network_bluetooth_device_discovery_positive.c b/TC/testcase/utc_network_bluetooth_device_discovery_positive.c
new file mode 100644
index 0000000..0cd0fe4
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_device_discovery_positive.c
@@ -0,0 +1,261 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static GMainLoop *mainloop;
+static bool callback_result = false;
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_device_discovery_get_status_p(void);
+static void utc_network_bluetooth_device_discovery_set_state_changed_cb_p(void);
+static void utc_network_bluetooth_device_discovery_start_p(void);
+static void utc_network_bluetooth_device_discovery_unset_state_changed_cb_p(void);
+static void utc_network_bluetooth_device_discovery_cancel_p(void);
+
+gboolean timeout_func(gpointer data);
+void adapter_state_changed_cb_for_discovery_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+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);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_device_discovery_get_status_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_discovery_set_state_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_discovery_start_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_discovery_unset_state_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_discovery_cancel_p, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ bt_error_e ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_discovery_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ ret = bt_adapter_enable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_enable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_ALREADY_DONE) {
+ tet_printf("BT was already enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_enable() failed.");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf
+ ("bt_adapter_unset_device_discovery_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ tet_printf("TC end");
+ bt_deinitialize();
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Callback funtions
+ */
+void adapter_state_changed_cb_for_discovery_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_ENABLED &&
+ result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was enabled.");
+ } else {
+ tet_printf("Callback: bt_adapter_state_changed_cb() was \
+ called but bt_adapter_enable() failed.");
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+}
+
+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)
+{
+ tet_printf("Callback: device_discovery_state_changed_cb_for_discovery_p is called");
+
+ if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FOUND) {
+ tet_printf("Callback: Devices were found");
+ tet_printf("Callback: Device name is %s", discovery_info->remote_name);
+ tet_printf("Callback: Service class: %x", discovery_info->bt_class.major_service_class_mask);
+ if (user_data != NULL && !strcmp((char *)user_data, "start")) {
+ callback_result = true;
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+ } else if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FINISHED) {
+ tet_printf("Callback: Device discovery finished");
+ if (user_data != NULL) {
+ if (!strcmp((char *)user_data, "start") && callback_result == false) {
+ tet_printf("You need a discoverable device");
+ tet_printf("utc_network_bluetooth_device_discovery_start_p and \
+ utc_network_bluetooth_device_discovery_cancel_p will fail");
+ } else if (!strcmp((char *)user_data, "cancel")) {
+ if (result == BT_ERROR_CANCELLED) {
+ callback_result = true;
+ }
+ }
+ }
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+}
+
+/**
+ * @brief Positive test case of bt_adapter_is_discovering()
+ */
+static void utc_network_bluetooth_device_discovery_get_status_p(void)
+{
+ bt_error_e ret = BT_ERROR_NONE;
+ bool status = false;
+
+ ret = bt_adapter_is_discovering(&status);
+ dts_check_eq("bt_adapter_is_discovering", ret, BT_ERROR_NONE,
+ "bt_adapter_is_discovering() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_adapter_set_device_discovery_state_changed_cb()
+ */
+static void utc_network_bluetooth_device_discovery_set_state_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_discovery_p, "start");
+ dts_check_eq("bt_adapter_set_device_discovery_state_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_adapter_set_device_discovery_state_changed_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_adapter_start_device_discovery()
+ */
+static void utc_network_bluetooth_device_discovery_start_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ callback_result = false;
+
+ ret = bt_adapter_start_device_discovery();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_device_discovery_state_changed_cb_for_discovery_p() will be called.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ dts_check_eq("bt_adapter_start_device_discovery",
+ callback_result, true,
+ "Callback was called but failed.");
+ } else {
+ dts_fail("bt_adapter_start_device_discovery",
+ "bt_adapter_start_device_discovery() failed.");
+ }
+}
+
+/**
+ * @brief Positive test case of bt_adapter_unset_device_discovery_state_changed_cb()
+ */
+static void utc_network_bluetooth_device_discovery_unset_state_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_unset_device_discovery_state_changed_cb();
+ dts_check_eq("bt_adapter_unset_device_discovery_state_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_device_discovery_uset_state_changed_cb() failed");
+}
+
+/**
+ * @brief Positive test case of bt_adapter_stop_device_discovery()
+ */
+static void utc_network_bluetooth_device_discovery_cancel_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ callback_result = false;
+
+ if (bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_discovery_p, "cancel") != BT_ERROR_NONE) {
+ dts_fail("bt_adapter_stop_device_discovery",
+ "bt_adapter_set_device_discovery_state_changed_cb() failed");
+ }
+
+ ret = bt_adapter_stop_device_discovery();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_device_discovery_state_changed_cb_for_discovery_p() will be called");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ bt_adapter_unset_device_discovery_state_changed_cb();
+ dts_check_eq("bt_adapter_stop_device_discovery",
+ callback_result, true,
+ "Callback was called but failed");
+ } else {
+ dts_fail("bt_adapter_stop_device_discovery",
+ "bt_adapter_stop_device_discovery() failed");
+ }
+
+}
diff --git a/TC/testcase/utc_network_bluetooth_device_negative.c b/TC/testcase/utc_network_bluetooth_device_negative.c
new file mode 100644
index 0000000..f1e7d42
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_device_negative.c
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+gboolean timeout_func(gpointer data);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_device_set_bonded_cb_n(void);
+static void utc_network_bluetooth_device_set_unbonded_cb_n(void);
+static void utc_network_bluetooth_device_set_authorization_state_changed_cb_n(void);
+static void utc_network_bluetooth_device_cancel_bonding_n(void);
+static void utc_network_bluetooth_device_bond_n(void);
+static void utc_network_bluetooth_device_foreach_bonded_device_n(void);
+static void utc_network_bluetooth_device_set_alias_n(void);
+static void utc_network_bluetooth_device_set_authorization_n(void);
+static void utc_network_bluetooth_device_unbond_n(void);
+static void utc_network_bluetooth_device_unset_bonded_cb_n(void);
+static void utc_network_bluetooth_device_unset_unbonded_cb_n(void);
+static void utc_network_bluetooth_device_unset_authorization_state_changed_cb_n(void);
+
+void adapter_state_changed_cb_for_device_negative(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_device_set_bonded_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_set_unbonded_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_set_authorization_state_changed_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_bond_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_cancel_bonding_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_unbond_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_foreach_bonded_device_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_set_alias_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_set_authorization_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_unset_bonded_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_unset_unbonded_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_device_unset_authorization_state_changed_cb_n, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_device_negative, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+/**
+ * @brief Callback funtions
+ */
+void adapter_state_changed_cb_for_device_negative(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+ tet_printf("Callback: bt_adapter_state_changed_cb was called.");
+ if ((user_data != NULL) && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_DISABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was disabled. DTS will be started.");
+ } else {
+ tet_printf("Callback: BT was not disabled. DTS will be started but DTS may fail.");
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+}
+
+/**
+ * @brief Negative test case of bt_device_set_bond_created_cb()
+ */
+static void utc_network_bluetooth_device_set_bonded_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_set_bond_created_cb(NULL, NULL);
+ dts_check_eq("bt_device_set_bond_created_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when callback parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_device_set_bond_destroyed_cb()
+ */
+static void utc_network_bluetooth_device_set_unbonded_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_set_bond_destroyed_cb(NULL, NULL);
+ dts_check_eq("bt_device_set_bond_destroyed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when callback parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_device_set_authorization_changed_cb()
+ */
+static void
+utc_network_bluetooth_device_set_authorization_state_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_set_authorization_changed_cb(NULL, NULL);
+ dts_check_eq("bt_device_set_authorization_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when callback parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_device_unset_bond_created_cb()
+ */
+static void utc_network_bluetooth_device_unset_bonded_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ if (bt_deinitialize() != BT_ERROR_NONE) {
+ dts_fail("bt_device_unset_bond_created_cb",
+ "bt_deinitialize() failed.");
+ }
+
+ ret = bt_device_unset_bond_created_cb();
+ dts_check_eq("bt_device_unset_bond_created_cb", ret,
+ BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned when BT service is not initialized.");
+}
+
+ /**
+ * @brief Negative test case of bt_device_unset_bond_destroyed_cb()
+ */
+static void utc_network_bluetooth_device_unset_unbonded_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_unset_bond_destroyed_cb();
+ dts_check_eq("bt_device_unset_bond_destroyed_cb", ret,
+ BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned when BT service is not initialized.");
+}
+
+/**
+ * @brief Negative test case of bt_device_unset_authorization_changed_cb()
+ */
+static void
+utc_network_bluetooth_device_unset_authorization_state_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_unset_authorization_changed_cb();
+ dts_check_eq("bt_device_unset_authorization_changed_cb", ret,
+ BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned when BT service is not initialized.");
+}
+
+ /**
+ * @brief Negative test case of bt_device_create_bond()
+ */
+static void utc_network_bluetooth_device_bond_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_create_bond(NULL);
+ dts_check_eq("bt_device_create_bond", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_NOT_INITIALIZED must be returned when BT service is not initialized.");
+}
+
+ /**
+ * @brief Negative test case of bt_device_cancel_bonding()
+ */
+static void utc_network_bluetooth_device_cancel_bonding_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_cancel_bonding();
+ dts_check_eq("bt_device_cancel_bonding", ret, BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled");
+}
+
+/**
+ * @brief Negative test case of bt_device_destroy_bond()
+ */
+static void utc_network_bluetooth_device_unbond_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_destroy_bond(NULL);
+ dts_check_eq("bt_device_destroy_bond", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_adapter_foreach_bonded_device()
+ */
+static void utc_network_bluetooth_device_foreach_bonded_device_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_foreach_bonded_device(NULL, NULL);
+ dts_check_eq("bt_adapter_foreach_bonded_device", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_device_set_alias()
+ */
+static void utc_network_bluetooth_device_set_alias_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_set_alias(NULL, "dts_alias");
+ dts_check_eq("bt_device_set_alias", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when address parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_device_set_authorization()
+ */
+static void utc_network_bluetooth_device_set_authorization_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_set_authorization(NULL, BT_DEVICE_AUTHORIZED);
+ dts_check_eq("bt_device_set_authorization", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when address parameter is NULL");
+}
diff --git a/TC/testcase/utc_network_bluetooth_device_positive.c b/TC/testcase/utc_network_bluetooth_device_positive.c
new file mode 100644
index 0000000..0a43e2d
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_device_positive.c
@@ -0,0 +1,610 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+static bool callback_result = false;
+char target_name[128] = "dts_test";
+char target_address[18] = "";
+bt_device_info_s *device_info = NULL;
+bool discovery_result = false;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_device_set_bonded_cb_p(void);
+static void utc_network_bluetooth_device_set_unbonded_cb_p(void);
+static void utc_network_bluetooth_device_set_authorization_state_changed_cb_p(void);
+static void utc_network_bluetooth_device_cancel_bonding_p(void);
+static void utc_network_bluetooth_device_bond_p(void);
+static void utc_network_bluetooth_device_foreach_bonded_device_p(void);
+static void utc_network_bluetooth_device_set_alias_p(void);
+static void utc_network_bluetooth_device_set_authorization_p(void);
+static void utc_network_bluetooth_device_unbond_p(void);
+static void utc_network_bluetooth_device_unset_bonded_cb_p(void);
+static void utc_network_bluetooth_device_unset_unbonded_cb_p(void);
+static void utc_network_bluetooth_device_unset_authorization_state_changed_cb_p(void);
+
+gboolean timeout_func(gpointer data);
+void adapter_state_changed_cb_for_device_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+void device_discovery_state_changed_cb_for_device_p(int result,
+ bt_adapter_device_discovery_state_e discovery_state,
+ bt_adapter_device_discovery_info_s *discovery_info,
+ void *user_data);
+void device_bonded_cb(int result, bt_device_info_s *device_info,
+ void *user_data);
+void device_unbonded_cb(int result, char *remote_address, void *user_data);
+void device_authorization_state_changed_cb(bt_device_authorization_e authorization_state,
+ char *remote_address,
+ void *user_data);
+bool bonded_device_cb_for_device_p(bt_device_info_s *dev_info,
+ void *user_data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_device_set_bonded_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_unset_bonded_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_cancel_bonding_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_bond_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_foreach_bonded_device_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_set_alias_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_set_authorization_state_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_set_authorization_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_unset_authorization_state_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_set_unbonded_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_unbond_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_device_unset_unbonded_cb_p, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ bt_error_e ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ callback_result = false;
+ discovery_result = false;
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_device_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ if (bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_device_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_device_discovery_state_changed_cb() failed.");
+ }
+
+ ret = bt_adapter_enable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_enable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+
+ tet_printf("BT was enabled. Device discovery will be started");
+ if (bt_adapter_start_device_discovery() == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_start_device_discovery() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else {
+ tet_printf("bt_adapter_start_device_discovery() failed.");
+ }
+ } else if (ret == BT_ERROR_ALREADY_DONE) {
+ tet_printf("BT was already enabled. Device discovery will be started");
+ if (bt_adapter_start_device_discovery() == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_start_device_discovery() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else {
+ tet_printf("bt_adapter_start_device_discovery() failed.");
+ }
+ } else {
+ tet_printf("DTS may fail because bt_adapter_enable() failed.");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_unset_state_changed_cb() failed.");
+ }
+
+ if (bt_adapter_unset_device_discovery_state_changed_cb() !=
+ BT_ERROR_NONE) {
+ tet_printf("bt_adapter_unset_device_discovery_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start.");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ if (device_info != NULL)
+ free(device_info);
+
+ bt_deinitialize();
+ tet_printf("TC end");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("[%s] Callback: Timeout.", __FUNCTION__);
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+void adapter_state_changed_cb_for_device_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+ tet_printf("Callback: bt_adapter_state_changed_cb() was called");
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_ENABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was enabled.");
+ } else {
+ tet_printf("Callback: BT was not enabled. DTS will be started but DTS may fail.");
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+}
+
+void device_discovery_state_changed_cb_for_device_p(int result,
+ bt_adapter_device_discovery_state_e discovery_state,
+ bt_adapter_device_discovery_info_s *discovery_info,
+ void *user_data)
+{
+ tet_printf("Callback: bt_adapter_device_discovery_state_changed_cb() was called");
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FINISHED) {
+ tet_printf("Callback: Device discovery finished. DTS will be started.");
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ } else if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FOUND) {
+ tet_printf("Callback: Devices were founded (%s)", discovery_info->remote_name);
+ if (discovery_info->remote_name != NULL && !strcmp(discovery_info->remote_name, target_name)) {
+ discovery_result = true;
+ tet_printf("Callback: dts_test device was found.");
+ strncpy(target_address, discovery_info->remote_address, 18);
+ tet_printf("Callback: device address: [%s]", discovery_info->remote_address);
+ if (bt_adapter_stop_device_discovery() == BT_ERROR_NONE) {
+ tet_printf("Callback: Device discovery will be stopped");
+ }
+ }
+ }
+ }
+}
+
+void device_bonded_cb(int result, bt_device_info_s * device_info,
+ void *user_data)
+{
+ int i = 0;
+
+ tet_printf("Callback: bt_device_bond_created_cb() was called.");
+ if (result == BT_ERROR_TIMED_OUT)
+ tet_printf("result is BT_ERROR_TIMEOUT");
+ else if (result == BT_ERROR_CANCELLED)
+ tet_printf("result is BT_ERROR_CANCELLED");
+ else if (result == BT_ERROR_AUTH_FAILED)
+ tet_printf("result is BT_ERROR_AUTH_FAILED");
+ else if (result == BT_ERROR_OPERATION_FAILED)
+ tet_printf("result is BT_ERROR_OPERATION_FAILED");
+ else if (result == BT_ERROR_AUTH_REJECTED)
+ tet_printf("result is BT_ERROR_AUTH_REJECTED");
+ else if (result == BT_ERROR_REMOTE_DEVICE_NOT_FOUND)
+ tet_printf("result is BT_ERROR_REMOTE_DEVICE_NOT_FOUND");
+ else if (result == BT_ERROR_NONE)
+ tet_printf("result is BT_ERROR_NONE");
+ else
+ tet_printf("result is unknown: %s",
+ _bt_convert_error_to_string(result));
+
+ /* in case of bt_device_cancel_bonding() */
+ if (user_data != NULL && !strcmp((char *)user_data, "cancel")) {
+ if (result == BT_ERROR_CANCELLED) {
+ tet_printf("Callback: Cancellation of bonding succeeded");
+ callback_result = true;
+ } else {
+ tet_printf("Callback: Cancellation of bonding failed");
+ }
+ } /* in case of bt_device_create_bond() */
+ else if (user_data != NULL && !strcmp((char *)user_data, "bond")) {
+ if (device_info == NULL) {
+ tet_printf("Callback data is NULL");
+
+ if (result == BT_ERROR_CANCELLED)
+ tet_printf("No user input in the peer device");
+
+ if (mainloop)
+ g_main_loop_quit(mainloop);
+
+ return;
+ }
+
+ if (device_info->remote_name != NULL && !strcmp(device_info->remote_name, target_name)) {
+ if (result == BT_ERROR_NONE) {
+ tet_printf("Callback: Bonding succeeded");
+ tet_printf("Callback: serivce count : %d", device_info->service_count);
+ callback_result = true;
+ for (i = 0; i < device_info->service_count; i++) {
+ tet_printf("Callback: service list[%d] - %s", i + 1, device_info->service_uuid[i]);
+ }
+ } else {
+ tet_printf("Callback: Bonding failed");
+ }
+ }
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+}
+
+void device_unbonded_cb(int result, char *remote_address, void *user_data)
+{
+ tet_printf("Callback: bt_device_bond_destroyed_cb() was called.");
+ tet_printf("Callback: target address");
+ if (target_address != NULL) {
+ tet_printf("device address: %s", target_address);
+ } else
+ tet_printf("Callback: target address is NULL!");
+
+ tet_printf("Callback: address of unbonded device");
+ if (remote_address != NULL) {
+ tet_printf("device address: %s", remote_address);
+ if (!strcmp(remote_address, target_address)) {
+ if (result == BT_ERROR_NONE) {
+ tet_printf("Callback: Unbonding succeeded");
+ callback_result = true;
+ } else {
+ tet_printf("Callback: Unbonding failed");
+ }
+ }
+ } else
+ tet_printf("Callback: address of unbonded device is NULL!");
+
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+
+}
+
+void device_authorization_state_changed_cb(bt_device_authorization_e
+ authorization_state, char *address,
+ void *user_data)
+{
+ if (authorization_state == BT_DEVICE_AUTHORIZED) {
+ if (address != NULL && !strcmp(address, target_address)) {
+ callback_result = true;
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+ } else {
+ if (address != NULL && !strcmp(address, target_address)) {
+ callback_result = true;
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+ }
+}
+
+/**
+ * @brief Positive test case of bt_device_set_bond_created_cb()
+ */
+static void utc_network_bluetooth_device_set_bonded_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ /* Normal operation test */
+ ret = bt_device_set_bond_created_cb(device_bonded_cb, "cancel");
+ dts_check_eq("bt_device_set_bond_created_cb", ret, BT_ERROR_NONE,
+ "bt_device_set_bond_created_cb() failed");
+}
+
+/**
+ * @brief Positive test case of bt_device_set_bond_destroyed_cb()
+ */
+static void utc_network_bluetooth_device_set_unbonded_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ /* Normal operation test */
+ ret = bt_device_set_bond_destroyed_cb(device_unbonded_cb, NULL);
+ dts_check_eq("bt_device_set_bond_destroyed_cb", ret, BT_ERROR_NONE,
+ "bt_device_set_bond_destroyed_cb() failed");
+}
+
+/**
+ * @brief Positive test case of bt_device_set_authorization_changed_cb()
+ */
+static void
+utc_network_bluetooth_device_set_authorization_state_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ /* Normal operation test */
+ ret = bt_device_set_authorization_changed_cb(device_authorization_state_changed_cb, NULL);
+ dts_check_eq("bt_device_set_authorization_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_device_set_authorization_changed_cb() failed");
+}
+
+/**
+ * @brief Positive test case of bt_device_cancel_bonding()
+ */
+static void utc_network_bluetooth_device_cancel_bonding_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ callback_result = false;
+ int timeout_id = 0;
+
+ if (bt_device_set_bond_created_cb(device_bonded_cb, "cancel") !=
+ BT_ERROR_NONE) {
+ dts_fail("bt_device_cancel_bonding",
+ "bt_device_set_bond_created_cb() failed");
+ }
+
+ /* bond device */
+ ret = bt_device_create_bond(target_address);
+ if (ret != BT_ERROR_NONE) {
+ dts_fail("bt_device_cancel_bonding",
+ "bt_device_create_bond failed");
+ }
+ tet_printf("bt_device_create_bond() was called");
+
+ /* cancel bonding */
+ ret = bt_device_cancel_bonding();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_device_cancel_bonding() will be called");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ bt_device_unset_bond_created_cb();
+ dts_check_eq("bt_device_cancel_bonding", callback_result, true,
+ "Failed");
+ } else {
+ bt_device_unset_bond_created_cb();
+ dts_fail("bt_device_cancel_bonding",
+ "bt_device_cancel_bonding() failed");
+ }
+}
+
+/**
+ * @brief Positive test case of bt_device_unset_bond_created_cb()
+ */
+static void utc_network_bluetooth_device_unset_bonded_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ /* Normal operation test */
+ ret = bt_device_unset_bond_created_cb();
+ dts_check_eq("bt_device_unset_bond_created_cb", ret, BT_ERROR_NONE,
+ "bt_device_unset_bond_created_cb() failed");
+}
+
+/**
+ * @brief Positive test case of bt_device_create_bond()
+ */
+static void utc_network_bluetooth_device_bond_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ callback_result = false;
+
+ /* bond device */
+ ret = bt_device_set_bond_created_cb(device_bonded_cb, "bond");
+ if (ret != BT_ERROR_NONE) {
+ dts_fail("bt_device_create_bond",
+ "bt_device_set_bond_created_cb() failed");
+ }
+
+ ret = bt_device_create_bond(target_address);
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_device_bond_created_cb() will be called");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ bt_device_unset_bond_created_cb();
+ dts_check_eq("bt_device_create_bond", callback_result, true,
+ "Failed");
+ } else {
+ bt_device_unset_bond_created_cb();
+ dts_fail("bt_device_create_bond",
+ "bt_device_create_bond() failed");
+ }
+}
+
+bool bonded_device_cb_for_device_p(bt_device_info_s * dev_info, void *user_data)
+{
+ int i = 0;
+ device_info = (bt_device_info_s *) malloc(sizeof(bt_device_info_s));
+ if (device_info == NULL) {
+ tet_printf("Callback: Memory allocation failed");;
+ } else if (dev_info != NULL) {
+ device_info->remote_address = strdup(dev_info->remote_address);
+ tet_printf("device address : %s", device_info->remote_address);
+ device_info->remote_name = strdup(dev_info->remote_name);
+ tet_printf("device name : %s", device_info->remote_name);
+ device_info->bt_class.major_device_class = dev_info->bt_class.major_device_class;
+ tet_printf("major clasee : %2.2X", device_info->bt_class.major_device_class);
+ device_info->bt_class.minor_device_class = dev_info->bt_class.minor_device_class;
+ tet_printf("minor clasee : %2.2X", device_info->bt_class.minor_device_class);
+ device_info->bt_class.major_service_class_mask = dev_info->bt_class.major_service_class_mask;
+ tet_printf("service clasee : %2.2X", device_info->bt_class.major_service_class_mask);
+ device_info->service_count = dev_info->service_count;
+ tet_printf("service count : %d", device_info->service_count);
+ if (device_info->service_count > 0) {
+ device_info->service_uuid = (char **)malloc(sizeof(char *) * device_info->service_count);
+ if (device_info->service_uuid == NULL) {
+ tet_printf("Failed to allocate memory");
+ } else {
+ if (dev_info->service_uuid == NULL) {
+ tet_printf("service_list is NULL");
+ } else {
+ tet_printf("Copy service list");
+ for (i = 0; i < device_info->service_count; i++) {
+ device_info->service_uuid[i] = strdup(dev_info->service_uuid[i]);
+ tet_printf("Callback: service list[%d] - %s", i + 1, device_info->service_uuid[i]);
+ }
+ }
+ }
+ } else
+ device_info->service_uuid = NULL;
+
+ device_info->is_bonded = dev_info->is_bonded;
+ tet_printf("is_bonded : %d", device_info->is_bonded);
+ device_info->is_connected = dev_info->is_connected;
+ tet_printf("is_connected : %d", device_info->is_connected);
+ tet_printf("Callback: device_info was selected.");
+ }
+
+ return false;
+}
+
+/**
+ * @brief Positive test case of bt_adapter_foreach_bonded_device()
+ */
+static void utc_network_bluetooth_device_foreach_bonded_device_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_adapter_foreach_bonded_device(bonded_device_cb_for_device_p, NULL);
+ if (ret == BT_ERROR_NONE) {
+ dts_pass("bt_adapter_foreach_bonded_device",
+ "bt_adapter_foreach_bonded_device pass");
+ } else {
+ dts_fail("bt_adapter_foreach_bonded_device",
+ "bt_adapter_foreach_bonded_device() failed");
+ }
+}
+
+/**
+ * @brief Positive test case of bt_device_set_alias()
+ */
+static void utc_network_bluetooth_device_set_alias_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ if (device_info == NULL) {
+ tet_printf("No device to alias");
+ dts_fail("bt_device_set_alias", "bt_device_set_alias() failed");
+ return;
+ }
+
+ ret = bt_device_set_alias(device_info->remote_address, "dts_alias");
+ dts_check_eq("bt_device_set_alias", ret, BT_ERROR_NONE,
+ "bt_device_set_alias() failed");
+}
+
+/**
+ * @brief Positive test case of bt_device_set_authorization()
+ */
+static void utc_network_bluetooth_device_set_authorization_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ callback_result = false;
+
+ ret = bt_device_set_authorization(target_address, BT_DEVICE_AUTHORIZED);
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("device_authorization_state_changed_cb will be called");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ dts_check_eq("bt_device_set_authorization", callback_result,
+ true, "Callback was called but failed");
+ callback_result = false;
+ } else {
+ dts_fail("bt_device_set_authorization",
+ "bt_device_set_authorization() failed");
+ }
+}
+
+/**
+ * @brief Positive test case of bt_device_destroy_bond()
+ */
+static void utc_network_bluetooth_device_unbond_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+ callback_result = false;
+
+ tet_printf("bt_device_destroy_bond() will start");
+ ret = bt_device_destroy_bond(target_address);
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_device_unbond_cb() will be called");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ dts_check_eq("bt_device_destroy_bond", callback_result, true,
+ "Failed");
+ } else {
+ dts_fail("bt_device_destroy_bond",
+ "bt_device_destroy_bond() failed");
+ }
+}
+
+/**
+ * @brief Positive test case of bt_device_unset_bond_destroyed_cb()
+ */
+static void utc_network_bluetooth_device_unset_unbonded_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ /* Normal operation test */
+ ret = bt_device_unset_bond_destroyed_cb();
+ dts_check_eq("bt_device_unset_bond_destroyed_cb", ret, BT_ERROR_NONE,
+ "bt_device_unset_bond_destroyed_cb() failed");
+}
+
+/**
+ * @brief Positive test case of bt_device_unset_authorization_changed_cb()
+ */
+static void utc_network_bluetooth_device_unset_authorization_state_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ /* Normal operation test */
+ ret = bt_device_unset_authorization_changed_cb();
+ dts_check_eq("bt_device_unset_authorization_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_device_unset_authorization_changed_cb() failed");
+}
diff --git a/TC/testcase/utc_network_bluetooth_gatt_negative.c b/TC/testcase/utc_network_bluetooth_gatt_negative.c
new file mode 100644
index 0000000..c58bdcf
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_gatt_negative.c
@@ -0,0 +1,238 @@
+/*
+ * utc_network_bluetooth_gatt_negative.c
+ *
+ * Created on: 23-Sep-2013
+ * Author: shagun.garg
+ */
+
+#include <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_gatt_foreach_primary_services_n(void);
+static void utc_network_bluetooth_gatt_discover_characteristics_n(void);
+static void utc_network_bluetooth_gatt_get_service_uuid_n(void);
+static void utc_network_bluetooth_gatt_foreach_included_services_n(void);
+static void utc_network_bluetooth_gatt_set_characteristic_changed_cb_n(void);
+static void utc_network_bluetooth_gatt_unset_characteristic_changed_cb_n(void);
+static void utc_network_bluetooth_gatt_get_characteristic_declaration_n(void);
+static void utc_network_bluetooth_gatt_set_characteristic_value_n(void);
+static void utc_network_bluetooth_gatt_clone_attribute_handle_n(void);
+static void utc_network_bluetooth_gatt_destroy_attribute_handle_n(void);
+
+void adapter_state_changed_cb_for_gatt_n(int result, bt_adapter_state_e adapter_state, void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_gatt_foreach_primary_services_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_discover_characteristics_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_get_service_uuid_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_foreach_included_services_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_set_characteristic_changed_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_unset_characteristic_changed_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_get_characteristic_declaration_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_set_characteristic_value_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_clone_attribute_handle_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_destroy_attribute_handle_n, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_gatt_n, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Callback funtions
+ */
+void adapter_state_changed_cb_for_gatt_n(int result, bt_adapter_state_e adapter_state, void *user_data)
+{
+ tet_printf("Callback: bt_adapter_state_changed_cb was called.");
+ if ((user_data != NULL) && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_DISABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was disabled. DTS will be started.");
+ } else {
+ tet_printf("Callback: BT was not disabled. DTS will be started but DTS may fail.");
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+}
+
+/**
+ * @brief Negative test case of bt_gatt_foreach_primary_services()
+ */
+static void utc_network_bluetooth_gatt_foreach_primary_services_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_gatt_foreach_primary_services(NULL, NULL, NULL);
+ dts_check_eq("bt_gatt_foreach_primary_services", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when remote address and callback parameters are NULL.");
+}
+
+/**
+ * @brief Negative test case of bt_gatt_discover_characteristics()
+ */
+static void utc_network_bluetooth_gatt_discover_characteristics_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_gatt_discover_characteristics(NULL, NULL, NULL);
+ dts_check_eq("bt_gatt_discover_characteristics", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when service and callback parameters are NULL.");
+}
+
+/**
+ * @brief Negative test case of bt_gatt_get_service_uuid()
+ */
+static void utc_network_bluetooth_gatt_get_service_uuid_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_gatt_get_service_uuid(NULL, NULL);
+ dts_check_eq("bt_gatt_get_service_uuid", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when service parameter is NULL.");
+}
+
+/**
+ * @brief Negative test case of bt_gatt_foreach_included_services()
+ */
+static void utc_network_bluetooth_gatt_foreach_included_services_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_gatt_foreach_included_services(NULL, NULL, NULL);
+ dts_check_eq("bt_socket_unset_connection_state_changed_cb", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when service and callback parameters are NULL.");
+}
+
+/**
+ * @brief Negative test case of bt_gatt_set_characteristic_changed_cb()
+ */
+static void utc_network_bluetooth_gatt_set_characteristic_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_gatt_set_characteristic_changed_cb(NULL, NULL, NULL);
+ dts_check_eq("bt_gatt_set_characteristic_changed_cb", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when service and callback parameters are NULL.");
+}
+
+/**
+ * @brief Negative test case of bt_gatt_unset_characteristic_changed_cb()
+ */
+static void utc_network_bluetooth_gatt_unset_characteristic_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_gatt_unset_characteristic_changed_cb(NULL);
+ dts_check_eq("bt_gatt_unset_characteristic_changed_cb", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when service parameter is NULL.");
+}
+
+/**
+ * @brief Negative test case of bt_gatt_get_characteristic_declaration()
+ */
+static void utc_network_bluetooth_gatt_get_characteristic_declaration_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_gatt_get_characteristic_declaration(NULL, NULL, NULL, 0);
+ dts_check_eq("bt_gatt_get_characteristic_declaration", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when characteristic parameter is NULL.");
+}
+
+/**
+ * @brief Negative test case of bt_gatt_set_characteristic_value()
+ */
+static void utc_network_bluetooth_gatt_set_characteristic_value_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_gatt_set_characteristic_value(NULL, NULL, -1);
+ dts_check_eq("bt_socket_connect_rfcomm", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when characteristic and value parameters are NULL.");
+}
+
+/**
+ * @brief Negative test case of bt_gatt_clone_attribute_handle()
+ */
+static void utc_network_bluetooth_gatt_clone_attribute_handle_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_gatt_clone_attribute_handle(NULL, NULL);
+ dts_check_eq("bt_gatt_clone_attribute_handle", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when origin parameter is NULL.");
+}
+
+/**
+ * @brief Negative test case of bt_gatt_destroy_attribute_handle()
+ */
+static void utc_network_bluetooth_gatt_destroy_attribute_handle_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_gatt_destroy_attribute_handle(NULL);
+ dts_check_eq("bt_gatt_destroy_attribute_handle", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when handle parameter is NULL.");
+}
diff --git a/TC/testcase/utc_network_bluetooth_gatt_positive.c b/TC/testcase/utc_network_bluetooth_gatt_positive.c
new file mode 100644
index 0000000..5df118c
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_gatt_positive.c
@@ -0,0 +1,282 @@
+/*
+ * utc_network_bluetooth_gatt_positive.c
+ *
+ * Created on: 23-Sep-2013
+ * Author: shagun.garg
+ */
+
+#include <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+const char target_name[128] = "dts_test";
+char target_address[18] = "";
+
+static GMainLoop *mainloop;
+
+static void utc_network_bluetooth_gatt_foreach_primary_services_p(void);
+static void utc_network_bluetooth_gatt_discover_characteristics_p(void);
+
+static void utc_network_bluetooth_gatt_get_service_uuid_p(void);
+static void utc_network_bluetooth_gatt_foreach_included_services_p(void);
+static void utc_network_bluetooth_gatt_set_characteristic_changed_cb_p(void);
+static void utc_network_bluetooth_gatt_unset_characteristic_changed_cb_p(void);
+static void utc_network_bluetooth_gatt_get_characteristic_declaration_p(void);
+static void utc_network_bluetooth_gatt_set_characteristic_value_p(void);
+static void utc_network_bluetooth_gatt_clone_attribute_handle_p(void);
+static void utc_network_bluetooth_gatt_destroy_attribute_handle_p(void);
+
+gboolean timeout_func(gpointer data);
+void adapter_state_changed_cb_for_gatt_p(int result, bt_adapter_state_e adapter_state, void *user_data);
+
+bool primary_service_cb_for_gatt_p(bt_gatt_attribute_h service, void *user_data);
+bool included_service_cb_for_gatt_p(bt_gatt_attribute_h service, void *user_data);
+bool characteristics_discovered_cb_for_gatt_p(int result, int index, int total, bt_gatt_attribute_h characteristic,
+ void *user_data);
+void characteristics_changed_cb_for_gatt_p(bt_gatt_attribute_h characteristic, unsigned char *value, int value_length,
+ void *user_data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_gatt_foreach_primary_services_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_discover_characteristics_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_get_service_uuid_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_foreach_included_services_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_set_characteristic_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_unset_characteristic_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_get_characteristic_declaration_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_set_characteristic_value_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_clone_attribute_handle_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_gatt_destroy_attribute_handle_p, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ bt_error_e ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ tet_printf("TC start.");
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_gatt_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("[%s] Callback: Timeout.", __FUNCTION__);
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+void adapter_state_changed_cb_for_gatt_p(int result, bt_adapter_state_e adapter_state, void *user_data)
+{
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_ENABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was enabled.");
+ bt_adapter_start_device_discovery();
+ } else {
+ tet_printf("Callback: BT was not enabled. DTS will be started but DTS may fail.");
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+ }
+}
+
+bool primary_service_cb_for_gatt_p(bt_gatt_attribute_h service, void *user_data)
+{
+ return false;
+}
+
+bool characteristics_discovered_cb_for_gatt_p(int result, int index, int total, bt_gatt_attribute_h characteristic,
+ void *user_data)
+{
+ return false;
+}
+
+bool included_service_cb_for_gatt_p(bt_gatt_attribute_h service, void *user_data)
+{
+ return false;
+}
+
+void characteristics_changed_cb_for_gatt_p(bt_gatt_attribute_h characteristic, unsigned char *value, int value_length,
+ void *user_data)
+{
+
+}
+
+/**
+ * @brief Positive test case of bt_gatt_foreach_primary_services()
+ */
+static void utc_network_bluetooth_gatt_foreach_primary_services_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ char *remote_addr = "dts_addr";
+
+ ret = bt_gatt_foreach_primary_services(remote_addr, primary_service_cb_for_gatt_p, NULL);
+ dts_check_eq("bt_gatt_foreach_primary_services", ret, BT_ERROR_NONE, "bt_gatt_foreach_primary_services() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_gatt_discover_characteristics()
+ */
+static void utc_network_bluetooth_gatt_discover_characteristics_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_call_list_h gatt_serv;
+ gatt_serv = g_malloc0(sizeof(bt_call_list_h));
+
+ ret = bt_gatt_discover_characteristics(gatt_serv, characteristics_discovered_cb_for_gatt_p, NULL);
+ dts_check_eq("bt_gatt_discover_characteristics", ret, BT_ERROR_NONE, "bt_gatt_discover_characteristics() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_gatt_get_service_uuid()
+ */
+static void utc_network_bluetooth_gatt_get_service_uuid_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ char *uid = "dts_uid";
+ bt_call_list_h gatt_serv;
+ gatt_serv = g_malloc0(sizeof(bt_call_list_h));
+
+ ret = bt_gatt_get_service_uuid(gatt_serv, &uid);
+ dts_check_eq("bt_gatt_get_service_uuid", ret, BT_ERROR_NONE, "bt_gatt_get_service_uuid() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_gatt_foreach_included_services()
+ */
+static void utc_network_bluetooth_gatt_foreach_included_services_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_call_list_h gatt_serv;
+ gatt_serv = g_malloc0(sizeof(bt_call_list_h));
+ ret = bt_gatt_foreach_included_services(gatt_serv, included_service_cb_for_gatt_p, NULL);
+ dts_check_eq("bt_gatt_foreach_included_services", ret, BT_ERROR_NONE, "bt_gatt_foreach_included_services() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_gatt_set_characteristic_changed_cb()
+ */
+static void utc_network_bluetooth_gatt_set_characteristic_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_call_list_h gatt_serv;
+ gatt_serv = g_malloc0(sizeof(bt_call_list_h));
+ ret = bt_gatt_set_characteristic_changed_cb(gatt_serv, characteristics_changed_cb_for_gatt_p, NULL);
+ dts_check_eq("bt_gatt_set_characteristic_changed_cb", ret, BT_ERROR_NONE,
+ "bt_gatt_set_characteristic_changed_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_gatt_unset_characteristic_changed_cb()
+ */
+static void utc_network_bluetooth_gatt_unset_characteristic_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_call_list_h gatt_serv;
+ gatt_serv = g_malloc0(sizeof(bt_call_list_h));
+ ret = bt_gatt_unset_characteristic_changed_cb(gatt_serv);
+ dts_check_eq("bt_gatt_unset_characteristic_changed_cb", ret, BT_ERROR_NONE,
+ "bt_gatt_unset_characteristic_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Positive test case of bt_gatt_get_characteristic_declaration()
+ */
+static void utc_network_bluetooth_gatt_get_characteristic_declaration_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ char **uid = "dts_uid";
+ unsigned char **val = "dts_value";
+ int l = 1;
+ bt_call_list_h gatt_charac;
+ gatt_charac = g_malloc0(sizeof(bt_call_list_h));
+ ret = bt_gatt_get_characteristic_declaration(gatt_charac, uid, val, &l);
+ dts_check_eq("bt_gatt_get_characteristic_declaration", ret, BT_ERROR_NONE,
+ "gatt_get_characteristic_declaration() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_gatt_set_characteristic_value()
+ */
+static void utc_network_bluetooth_gatt_set_characteristic_value_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_call_list_h gatt_charac;
+ gatt_charac = g_malloc0(sizeof(bt_call_list_h));
+ const unsigned char *gatt_value = "dts_value";
+ ret = bt_gatt_set_characteristic_value(gatt_charac, gatt_value, strlen("dts_value"));
+ dts_check_eq("bt_gatt_set_characteristic_value", ret, BT_ERROR_NONE, "bt_gatt_set_characteristic_value() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_gatt_clone_attribute_handle()
+ */
+static void utc_network_bluetooth_gatt_clone_attribute_handle_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_call_list_h gatt_origin;
+ gatt_origin = g_malloc0(sizeof(bt_call_list_h));
+
+ ret = bt_gatt_clone_attribute_handle(NULL, gatt_origin);
+ dts_check_eq("bt_gatt_clone_attribute_handle", ret, BT_ERROR_NONE, "bt_gatt_clone_attribute_handle() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_gatt_destroy_attribute_handle()
+ */
+static void utc_network_bluetooth_gatt_destroy_attribute_handle_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ bt_call_list_h gatt_handle;
+ gatt_handle = g_malloc0(sizeof(bt_call_list_h));
+
+ ret = bt_gatt_destroy_attribute_handle(gatt_handle);
+ dts_check_eq("bt_gatt_destroy_attribute_handle", ret, BT_ERROR_NONE, "bt_gatt_destroy_attribute_handle() failed.");
+}
diff --git a/TC/testcase/utc_network_bluetooth_hdp_negative.c b/TC/testcase/utc_network_bluetooth_hdp_negative.c
new file mode 100644
index 0000000..4313d0b
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_hdp_negative.c
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_hdp_register_sink_app_n(void);
+static void utc_network_bluetooth_hdp_unregister_sink_app_n(void);
+static void utc_network_bluetooth_hdp_connect_to_source_n(void);
+static void utc_network_bluetooth_hdp_disconnect_n(void);
+static void utc_network_bluetooth_hdp_send_data_n(void);
+static void utc_network_bluetooth_hdp_set_connection_state_changed_cb_n(void);
+static void utc_network_bluetooth_hdp_unset_connection_state_changed_cb_n(void);
+static void utc_network_bluetooth_hdp_set_data_received_cb_n(void);
+static void utc_network_bluetooth_hdp_unset_data_received_cb_n(void);
+
+void adapter_state_changed_cb_for_hdp_n(int result, bt_adapter_state_e adapter_state, void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_hdp_register_sink_app_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_unregister_sink_app_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_connect_to_source_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_disconnect_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_send_data_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_set_connection_state_changed_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_unset_connection_state_changed_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_set_data_received_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_unset_data_received_cb_n, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_hdp_n, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Callback funtions
+ */
+void adapter_state_changed_cb_for_hdp_n(int result, bt_adapter_state_e adapter_state, void *user_data)
+{
+ tet_printf("Callback: bt_adapter_state_changed_cb was called.");
+ if ((user_data != NULL) && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_DISABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was disabled. DTS will be started.");
+ } else {
+ tet_printf("Callback: BT was not disabled. DTS will be started but DTS may fail.");
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+}
+
+/**
+ * @brief Negative test case of bt_hdp_set_data_received_cb()
+ */
+static void utc_network_bluetooth_hdp_set_data_received_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hdp_set_data_received_cb(NULL, NULL);
+ dts_check_eq("bt_hdp_set_data_received_cb", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when callback parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_hdp_set_connection_state_changed_cb()
+ */
+static void utc_network_bluetooth_hdp_set_connection_state_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hdp_set_connection_state_changed_cb(NULL, NULL, NULL);
+ dts_check_eq("bt_hdp_set_connection_state_changed_cb", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when callback parameters are NULL");
+}
+
+/**
+ * @brief Negative test case of bt_hdp_unset_data_received_cb()
+ */
+static void utc_network_bluetooth_hdp_unset_data_received_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hdp_unset_data_received_cb();
+ dts_check_eq("bt_hdp_unset_data_received_cb", ret, BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned when BT service is not initialized.");
+}
+
+/**
+ * @brief Negative test case of bt_hdp_unset_connection_state_changed_cb()
+ */
+static void utc_network_bluetooth_hdp_unset_connection_state_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hdp_unset_connection_state_changed_cb();
+ dts_check_eq("bt_hdp_unset_connection_state_changed_cb", ret, BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned when BT service is not initialized.");
+}
+
+/**
+ * @brief Negative test case of bt_hdp_disconnect()
+ */
+static void utc_network_bluetooth_hdp_disconnect_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hdp_disconnect(NULL, 1);
+ dts_check_eq("bt_hdp_disconnect", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when remote address parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_hdp_connect_to_source()
+ */
+static void utc_network_bluetooth_hdp_connect_to_source_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hdp_connect_to_source(NULL, NULL);
+ dts_check_eq("bt_hdp_connect_to_source", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when remote address and app_id parameter are NULL");
+}
+
+/**
+ * @brief Negative test case of bt_hdp_register_sink_app()
+ */
+static void utc_network_bluetooth_hdp_register_sink_app_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hdp_register_sink_app(1, NULL);
+ dts_check_eq("bt_hdp_register_sink_app", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when app_id parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_hdp_unregister_sink_appe()
+ */
+static void utc_network_bluetooth_hdp_unregister_sink_app_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hdp_unregister_sink_app(NULL);
+ dts_check_eq("bt_shdp_unregister_sink", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when app_id parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_hdp_send_data()
+ */
+static void utc_network_bluetooth_hdp_send_data_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ char *data = "dts_test";
+
+ ret = bt_hdp_send_data(1, data, sizeof(data));
+ dts_check_eq("bt_hdp_send_data", ret, BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled");
+}
diff --git a/TC/testcase/utc_network_bluetooth_hdp_positive.c b/TC/testcase/utc_network_bluetooth_hdp_positive.c
new file mode 100644
index 0000000..aa0eaa9
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_hdp_positive.c
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_hdp_register_sink_app_p(void);
+static void utc_network_bluetooth_hdp_unregister_sink_app_p(void);
+static void utc_network_bluetooth_hdp_connect_to_source_p(void);
+static void utc_network_bluetooth_hdp_disconnect_p(void);
+static void utc_network_bluetooth_hdp_send_data_p(void);
+static void utc_network_bluetooth_hdp_set_connection_state_changed_cb_p(void);
+static void utc_network_bluetooth_hdp_unset_connection_state_changed_cb_p(void);
+static void utc_network_bluetooth_hdp_set_data_received_cb_p(void);
+static void utc_network_bluetooth_hdp_unset_data_received_cb_p(void);
+
+void data_received_cb_for_hdp_p(unsigned int channel, const char *data, unsigned int size, void *user_data);
+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);
+void disconnected_cb_for_hdp_p(int result, const char *remote_address, unsigned int channel, void *user_data);
+
+void adapter_state_changed_cb_for_hdp_p(int result, bt_adapter_state_e adapter_state, void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_hdp_register_sink_app_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_unregister_sink_app_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_connect_to_source_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_disconnect_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_send_data_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_set_connection_state_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_unset_connection_state_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_set_data_received_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_hdp_unset_data_received_cb_p, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_hdp_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+void adapter_state_changed_cb_for_hdp_p(int result, bt_adapter_state_e adapter_state, void *user_data)
+{
+ if ((user_data != NULL) && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_ENABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was enabled.");
+ bt_adapter_start_device_discovery();
+ } else {
+ tet_printf("Callback: BT was not enabled. DTS will be started but DTS may fail.");
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+ }
+}
+
+void data_received_cb_for_hdp_p(unsigned int channel, const char *data, unsigned int size, void *user_data)
+{
+
+}
+
+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)
+{
+
+}
+
+void disconnected_cb_for_hdp_p(int result, const char *remote_address, unsigned int channel, void *user_data)
+{
+
+}
+
+static void utc_network_bluetooth_hdp_set_data_received_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hdp_set_data_received_cb(data_received_cb_for_hdp_p, NULL);
+ dts_check_eq("bt_hdp_set_data_received_cb", ret, BT_ERROR_NONE, "bt_hdp_set_data_received_cb() failed.");
+}
+
+static void utc_network_bluetooth_hdp_unset_data_received_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hdp_unset_data_received_cb();
+ dts_check_eq("bt_hdp_unset_data_received_cb", ret, BT_ERROR_NONE, "bt_hdp_unset_data_received_cb() failed.");
+}
+
+static void utc_network_bluetooth_hdp_set_connection_state_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hdp_set_connection_state_changed_cb(connected_cb_for_hdp_p, disconnected_cb_for_hdp_p, NULL);
+ dts_check_eq("bt_hdp_set_connection_state_changed_cb", ret, BT_ERROR_NONE,
+ "bt_hdp_set_connection_state_changed_cb() failed.");
+}
+
+static void utc_network_bluetooth_hdp_unset_connection_state_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hdp_unset_connection_state_changed_cb();
+ dts_check_eq("bt_hdp_unset_connection_state_changed_cb", ret, BT_ERROR_NONE,
+ "bt_hdp_unset_connection_state_changed_cb() failed.");
+}
+
+static void utc_network_bluetooth_hdp_send_data_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ char *dts_test = "dts_test";
+
+ ret = bt_hdp_send_data(1, "dts_test", sizeof(dts_test));
+ dts_check_eq("bt_hdp_send_data", ret, BT_ERROR_NONE, "bt_hdp_send_data() failed.");
+}
+
+static void utc_network_bluetooth_hdp_disconnect_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ char *remote_adr = "";
+
+ ret = bt_hdp_disconnect(remote_adr, 1);
+ dts_check_eq("bt_hdp_disconnect", ret, BT_ERROR_NONE, "bt_hdp_disconnect() failed.");
+}
+
+static void utc_network_bluetooth_hdp_connect_to_source_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ char *remote_adr = "dts_remote";
+ char *appid = "dts_id";
+
+ ret = bt_hdp_connect_to_source(remote_adr, appid);
+ dts_check_eq("bt_hdp_connect_to_source", ret, BT_ERROR_NONE, "bt_hdp_connect_to_source() failed.");
+
+}
+
+static void utc_network_bluetooth_hdp_unregister_sink_app_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ char *appid = "dts_id";
+
+ ret = bt_hdp_unregister_sink_app(appid);
+ dts_check_eq("bt_hdp_unregister_sink_app", ret, BT_ERROR_NONE, "bt_hdp_unregister_sink_app() failed.");
+
+}
+
+static void utc_network_bluetooth_hdp_register_sink_app_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ char *appid = "dts_id";
+
+ ret = bt_hdp_register_sink_app(1, &appid);
+ dts_check_eq("bt_hdp_register_sink_app", ret, BT_ERROR_NONE, "bt_hdp_register_sink_app() failed.");
+
+}
diff --git a/TC/testcase/utc_network_bluetooth_hid_negative.c b/TC/testcase/utc_network_bluetooth_hid_negative.c
new file mode 100644
index 0000000..6b99d66
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_hid_negative.c
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_hid_host_initialize_n(void);
+static void utc_network_bluetooth_hid_host_deinitialize_n(void);
+static void utc_network_bluetooth_hid_host_connect_n(void);
+static void utc_network_bluetooth_hid_host_disconnect_n(void);
+
+void adapter_state_changed_cb_for_hid_n(int result, bt_adapter_state_e adapter_state, void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_hid_host_initialize_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_hid_host_deinitialize_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_hid_host_connect_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_hid_host_disconnect_n, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_hid_n, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+void adapter_state_changed_cb_for_hid_n(int result, bt_adapter_state_e adapter_state, void *user_data)
+{
+ if ((user_data != NULL) && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_ENABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was enabled.");
+ bt_adapter_start_device_discovery();
+ } else {
+ tet_printf("Callback: BT was not enabled. DTS will be started but DTS may fail.");
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+ }
+}
+
+static void utc_network_bluetooth_hid_host_initialize_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hid_host_initialize(NULL, NULL);
+ dts_check_eq("bt_socket_set_data_received_cb", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when callback parameter is NULL.");
+}
+
+static void utc_network_bluetooth_hid_host_deinitialize_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hid_host_deinitialize();
+ dts_check_eq("bt_hid_host_deinitialize", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned.");
+}
+
+static void utc_network_bluetooth_hid_host_connect_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ //char* remote_addr="dts_addr";
+
+ ret = bt_hid_host_connect(NULL);
+ dts_check_eq("bt_hid_host_connect", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when remote address parameter is NULL.");
+}
+
+static void utc_network_bluetooth_hid_host_disconnect_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hid_host_disconnect(NULL);
+ dts_check_eq("bt_hid_host_disconnect", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when remote address parameter is NULL.");
+}
diff --git a/TC/testcase/utc_network_bluetooth_hid_positive.c b/TC/testcase/utc_network_bluetooth_hid_positive.c
new file mode 100644
index 0000000..a06a164
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_hid_positive.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_hid_host_initialize_p(void);
+static void utc_network_bluetooth_hid_host_deinitialize_p(void);
+static void utc_network_bluetooth_hid_host_connect_p(void);
+static void utc_network_bluetooth_hid_host_disconnect_p(void);
+
+void adapter_state_changed_cb_for_hid_p(int result, bt_adapter_state_e adapter_state, void *user_data);
+void host_connection_state_changed_cb_for_hid_p(int result, bool connected, const char *remote_address, void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_hid_host_initialize_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_hid_host_deinitialize_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_hid_host_connect_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_hid_host_disconnect_p, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_hid_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+void adapter_state_changed_cb_for_hid_p(int result, bt_adapter_state_e adapter_state, void *user_data)
+{
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_ENABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was enabled.");
+ bt_adapter_start_device_discovery();
+ } else {
+ tet_printf("Callback: BT was not enabled. DTS will be started but DTS may fail.");
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+ }
+}
+
+void host_connection_state_changed_cb_for_hid_p(int result, bool connected, const char *remote_address, void *user_data)
+{
+
+}
+
+static void utc_network_bluetooth_hid_host_initialize_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hid_host_initialize(host_connection_state_changed_cb_for_hid_p, NULL);
+ dts_check_eq("bt_hid_host_initialize", ret, BT_ERROR_NONE, "bt_hid_host_initialize() failed.");
+}
+
+static void utc_network_bluetooth_hid_host_deinitialize_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_hid_host_deinitialize();
+ dts_check_eq("bt_hid_host_deinitialize", ret, BT_ERROR_NONE, "bt_hid_host_deinitialize() failed.");
+}
+
+static void utc_network_bluetooth_hid_host_connect_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ char *remote_addr = "dts_addr";
+
+ ret = bt_hid_host_connect(remote_addr);
+ dts_check_eq("bt_hid_host_connect", ret, BT_ERROR_NONE, "bt_hid_host_connect() failed.");
+}
+
+static void utc_network_bluetooth_hid_host_disconnect_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ char *remote_addr = "dts_addr";
+
+ ret = bt_hid_host_disconnect(remote_addr);
+ dts_check_eq("bt_hid_host_disconnect", ret, BT_ERROR_NONE, "bt_hid_host_disconnect() failed.");
+}
diff --git a/TC/testcase/utc_network_bluetooth_opp-client_negative.c b/TC/testcase/utc_network_bluetooth_opp-client_negative.c
new file mode 100644
index 0000000..67299e9
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_opp-client_negative.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_opp_client_initialize_n(void);
+static void utc_network_bluetooth_opp_client_deinitialize_n(void);
+static void utc_network_bluetooth_opp_client_add_file_n(void);
+static void utc_network_bluetooth_opp_client_clear_files_n(void);
+static void utc_network_bluetooth_opp_client_push_files_n(void);
+static void utc_network_bluetooth_opp_client_cancel_push_n(void);
+
+void adapter_state_changed_cb_for_opp_client_n(int result, bt_adapter_state_e adapter_state, void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_opp_client_initialize_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_opp_client_deinitialize_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_opp_client_add_file_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_opp_client_clear_files_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_opp_client_push_files_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_opp_client_cancel_push_n, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_opp_client_n, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+void adapter_state_changed_cb_for_opp_client_n(int result, bt_adapter_state_e adapter_state, void *user_data)
+{
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_ENABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was enabled.");
+ bt_adapter_start_device_discovery();
+ } else {
+ tet_printf("Callback: BT was not enabled. DTS will be started but DTS may fail.");
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+ }
+}
+
+static void utc_network_bluetooth_opp_client_initialize_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_client_initialize();
+ dts_check_eq("bt_opp_client_initialize", ret, BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned.");
+}
+
+static void utc_network_bluetooth_opp_client_deinitialize_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_client_deinitialize();
+ dts_check_eq("bt_opp_client_deinitialize", ret, BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned.");
+
+}
+
+static void utc_network_bluetooth_opp_client_add_file_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_client_add_file(NULL);
+ dts_check_eq("bt_opp_client_add_file", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when file parameter is NULL");
+}
+
+static void utc_network_bluetooth_opp_client_clear_files_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_client_clear_files();
+ dts_check_eq("bt_opp_client_clear_files", ret, BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned.");
+
+}
+
+static void utc_network_bluetooth_opp_client_push_files_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_client_push_files(NULL, NULL, NULL, NULL, NULL);
+ dts_check_eq("bt_opp_client_push_files", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when parameters are NULL");
+}
+
+static void utc_network_bluetooth_opp_client_cancel_push_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_client_cancel_push();
+ dts_check_eq("bt_opp_client_cancel_push", ret, BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned.");
+}
diff --git a/TC/testcase/utc_network_bluetooth_opp-client_positive.c b/TC/testcase/utc_network_bluetooth_opp-client_positive.c
new file mode 100644
index 0000000..341243d
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_opp-client_positive.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_opp_client_initialize_p(void);
+static void utc_network_bluetooth_opp_client_deinitialize_p(void);
+static void utc_network_bluetooth_opp_client_add_file_p(void);
+static void utc_network_bluetooth_opp_client_clear_files_p(void);
+static void utc_network_bluetooth_opp_client_push_files_p(void);
+static void utc_network_bluetooth_opp_client_cancel_push_p(void);
+
+void push_responded_cb_for_opp_client_p(int result, const char *remote_address, void *user_data);
+void push_progress_cb_for_opp_client_p(const char *file, long long size, int percent, void *user_data);
+void push_finished_cb_for_opp_client_p(int result, const char *remote_address, void *user_data);
+void adapter_state_changed_cb_for_opp_client_p(int result, bt_adapter_state_e adapter_state, void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_opp_client_initialize_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_opp_client_deinitialize_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_opp_client_add_file_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_opp_client_clear_files_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_opp_client_push_files_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_opp_client_cancel_push_p, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_opp_client_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+void adapter_state_changed_cb_for_opp_client_p(int result, bt_adapter_state_e adapter_state, void *user_data)
+{
+ if ((user_data != NULL) && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_ENABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was enabled.");
+ bt_adapter_start_device_discovery();
+ } else {
+ tet_printf("Callback: BT was not enabled. DTS will be started but DTS may fail.");
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+ }
+}
+
+void push_responded_cb_for_opp_client_p(int result, const char *remote_address, void *user_data)
+{
+
+}
+
+void push_progress_cb_for_opp_client_p(const char *file, long long size, int percent, void *user_data)
+{
+
+}
+
+void push_finished_cb_for_opp_client_p(int result, const char *remote_address, void *user_data)
+{
+
+}
+
+static void utc_network_bluetooth_opp_client_initialize_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_client_initialize();
+ dts_check_eq("bt_opp_client_initialize", ret, BT_ERROR_NONE, "bt_opp_client_initialize() failed.");
+}
+
+static void utc_network_bluetooth_opp_client_deinitialize_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_client_deinitialize();
+ dts_check_eq("bt_opp_client_deinitialize", ret, BT_ERROR_NONE, "bt_opp_client_deinitialize() failed.");
+
+}
+
+static void utc_network_bluetooth_opp_client_add_file_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_client_add_file("dts_file");
+ dts_check_eq("bt_opp_client_add_file", ret, BT_ERROR_NONE, "bt_opp_client_add_file() failed");
+}
+
+static void utc_network_bluetooth_opp_client_clear_files_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_client_clear_files();
+ dts_check_eq("bt_opp_client_clear_files", ret, BT_ERROR_NONE, "bt_opp_client_clear_files() failed.");
+
+}
+
+static void utc_network_bluetooth_opp_client_push_files_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret =
+ bt_opp_client_push_files(NULL, push_responded_cb_for_opp_client_p, push_progress_cb_for_opp_client_p,
+ push_finished_cb_for_opp_client_p, NULL);
+ if (ret == BT_ERROR_NONE) {
+ dts_pass("bt_opp_client_push_files", "bt_opp_client_push_files pass");
+ } else {
+ dts_fail("bt_opp_client_push_files", "bt_opp_client_push_files() failed");
+ }
+}
+
+static void utc_network_bluetooth_opp_client_cancel_push_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_client_cancel_push();
+ dts_check_eq("bt_opp_client_cancel_push", ret, BT_ERROR_NONE, "bt_opp_client_cancel_push() failed.");
+}
diff --git a/TC/testcase/utc_network_bluetooth_opp-server_negative.c b/TC/testcase/utc_network_bluetooth_opp-server_negative.c
new file mode 100644
index 0000000..d44db06
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_opp-server_negative.c
@@ -0,0 +1,174 @@
+/*
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_opp_server_initialize_n(void);
+static void utc_network_bluetooth_opp_server_initialize_by_connection_request_n(void);
+static void utc_network_bluetooth_opp_server_deinitialize_n(void);
+static void utc_network_bluetooth_opp_server_accept_n(void);
+static void utc_network_bluetooth_opp_server_reject_n(void);
+static void utc_network_bluetooth_opp_server_set_destination_n(void);
+
+void adapter_state_changed_cb_for_opp_server_n(int result, bt_adapter_state_e adapter_state, void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_opp_server_initialize_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_opp_server_initialize_by_connection_request_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_opp_server_deinitialize_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_opp_server_accept_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_opp_server_reject_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_opp_server_set_destination_n, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_opp_server_n, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Callback funtions
+ */
+void adapter_state_changed_cb_for_opp_server_n(int result, bt_adapter_state_e adapter_state, void *user_data)
+{
+ tet_printf("Callback: bt_adapter_state_changed_cb was called.");
+ if ((user_data != NULL) && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_DISABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was disabled. DTS will be started.");
+ } else {
+ tet_printf("Callback: BT was not disabled. DTS will be started but DTS may fail.");
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+}
+
+static void utc_network_bluetooth_opp_server_initialize_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_server_initialize(NULL, NULL, NULL);
+ dts_check_eq("bt_opp_server_initializa", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when destination parameter is NULL");
+}
+
+static void utc_network_bluetooth_opp_server_deinitialize_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_server_deinitialize();
+ dts_check_eq("bt_opp_server_deinitialize", ret, BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned.");
+}
+
+static void utc_network_bluetooth_opp_server_accept_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_opp_server_accept(NULL, NULL, NULL, NULL, NULL);
+ dts_check_eq("bt_opp_server_accept", ret, BT_ERROR_NOT_INITIALIZED, "BT_ERROR_NOT_INITIALIZED must be returned.");
+
+}
+
+static void utc_network_bluetooth_opp_server_reject_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_server_reject();
+ dts_check_eq("bt_opp_server_reject", ret, BT_ERROR_NOT_INITIALIZED, "BT_ERROR_NOT_INITIALIZED must be returned.");
+}
+
+static void utc_network_bluetooth_opp_server_set_destination_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_server_set_destination(NULL);
+ dts_check_eq("bt_opp_server_set_destination", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned destination parameter is NULL");
+}
+
+static void utc_network_bluetooth_opp_server_initialize_by_connection_request_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_server_initialize_by_connection_request(NULL, NULL, NULL);
+ dts_check_eq("bt_opp_server_initialize_by_connection_request", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned destination parameter is NULL");
+
+}
diff --git a/TC/testcase/utc_network_bluetooth_opp-server_positive.c b/TC/testcase/utc_network_bluetooth_opp-server_positive.c
new file mode 100644
index 0000000..fa93272
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_opp-server_positive.c
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+char dest[18] = "";
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_opp_server_initialize_p(void);
+static void utc_network_bluetooth_opp_server_initialize_by_connection_request_p(void);
+static void utc_network_bluetooth_opp_server_deinitialize_p(void);
+static void utc_network_bluetooth_opp_server_accept_p(void);
+static void utc_network_bluetooth_opp_server_reject_p(void);
+static void utc_network_bluetooth_opp_server_set_destination_p(void);
+
+void push_requested_cb_for_opp_server_p(const char *file, int size, void *user_data);
+void connection_requested_cb_for_opp_server_p(const char *remote_address, void *user_data);
+void adapter_state_changed_cb_for_opp_server_p(int result, bt_adapter_state_e adapter_state, void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_opp_server_initialize_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_opp_server_initialize_by_connection_request_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_opp_server_deinitialize_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_opp_server_accept_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_opp_server_reject_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_opp_server_set_destination_p, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_opp_server_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+void adapter_state_changed_cb_for_opp_server_p(int result, bt_adapter_state_e adapter_state, void *user_data)
+{
+ tet_printf("Callback: bt_adapter_state_changed_cb was called.");
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_DISABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was disabled. DTS will be started.");
+ } else {
+ tet_printf("Callback: BT was not disabled. DTS will be started but DTS may fail.");
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+}
+
+void push_requested_cb_for_opp_server_p(const char *file, int size, void *user_data)
+{
+
+}
+
+void connection_requested_cb_for_opp_server_p(const char *remote_address, void *user_data)
+{
+
+}
+
+static void utc_network_bluetooth_opp_server_initialize_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_server_initialize(dest, push_requested_cb_for_opp_server_p, NULL);
+ dts_check_eq("bt_opp_server_initialize", ret, BT_ERROR_NONE, "bt_opp_server_initialize() failed");
+
+}
+
+static void utc_network_bluetooth_opp_server_deinitialize_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_server_deinitialize();
+ dts_check_eq("bt_opp_server_deinitialize", ret, BT_ERROR_NONE, "bt_opp_server_deinitialize() failed.");
+}
+
+static void utc_network_bluetooth_opp_server_accept_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ int tid = 1;
+ ret = bt_opp_server_accept(NULL, NULL, "dts_name", NULL, &tid);
+ dts_check_eq("bt_opp_server_accept", ret, BT_ERROR_NONE, "bt_opp_server_accept() failed.");
+
+}
+
+static void utc_network_bluetooth_opp_server_reject_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_server_reject();
+ dts_check_eq("bt_opp_server_reject", ret, BT_ERROR_NONE, "bt_opp_server_reject() failed.");
+}
+
+static void utc_network_bluetooth_opp_server_set_destination_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_server_set_destination(dest);
+ dts_check_eq("bt_opp_server_set_destination", ret, BT_ERROR_NONE, "bt_opp_server_destination() failed");
+}
+
+static void utc_network_bluetooth_opp_server_initialize_by_connection_request_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_opp_server_initialize_by_connection_request(dest, connection_requested_cb_for_opp_server_p, NULL);
+ dts_check_eq("bt_opp_server_initialize_by_connection_request", ret, BT_ERROR_NONE,
+ "bt_opp_server_initialize_by_connection_request() failed");
+
+}
diff --git a/TC/testcase/utc_network_bluetooth_pan_negative.c b/TC/testcase/utc_network_bluetooth_pan_negative.c
new file mode 100644
index 0000000..a5a0712
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_pan_negative.c
@@ -0,0 +1,148 @@
+/*
+ * utc_network_bluetooth_pan_negative.c
+ *
+ * Created on: 20-Sep-2013
+ * Author: mrinal.m
+ */
+
+#include "bluetooth.h"
+#include <tet_api.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_nap_set_connection_state_changed_n(void);
+static void utc_network_bluetooth_panu_set_connection_state_changed_n(void);
+static void utc_network_bluetooth_panu_connect_n(void);
+static void utc_network_bluetooth_panu_disconnect_n(void);
+
+void adapter_state_changed_cb_for_pan_n(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_nap_set_connection_state_changed_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_panu_set_connection_state_changed_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_panu_connect_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_panu_disconnect_n, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_pan_n, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Negative test case of bt_nap_set_connection_state_changed_cb()
+ */
+
+void adapter_state_changed_cb_for_pan_n(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+
+}
+
+static void utc_network_bluetooth_nap_set_connection_state_changed_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_nap_set_connection_state_changed_cb(NULL, NULL);
+ dts_check_eq("bt_nap_set_connection_state_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_nap_set_connection_state_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Negative test case of bt_panu_set_connection_state_changed_cb()
+ */
+static void utc_network_bluetooth_panu_set_connection_state_changed_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_panu_set_connection_state_changed_cb(NULL, NULL);
+ dts_check_eq("bt_panu_set_connection_state_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "bt_panu_set_connection_state_changed_cb() failed.");
+
+}
+
+/**
+ * @brief Negative test case of bt_panu_connect()
+ */
+static void utc_network_bluetooth_panu_connect_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_panu_connect(NULL, BT_PANU_SERVICE_TYPE_NAP);
+ dts_check_eq("bt_panu_connect", ret, BT_ERROR_INVALID_PARAMETER,
+ "bt_panu_connect() failed.");
+
+}
+
+/**
+ * @brief Negative test case of bt_panu_disconnect()
+ */
+static void utc_network_bluetooth_panu_disconnect_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_panu_disconnect(NULL);
+ dts_check_eq("bt_panu_disconnect", ret, BT_ERROR_INVALID_PARAMETER,
+ "bt_panu_disconnect() failed.");
+
+}
diff --git a/TC/testcase/utc_network_bluetooth_pan_positive.c b/TC/testcase/utc_network_bluetooth_pan_positive.c
new file mode 100644
index 0000000..28d5632
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_pan_positive.c
@@ -0,0 +1,237 @@
+/*
+ * utc_network_bluetooth_pan_positive.c
+ *
+ * Created on: 20-Sep-2013
+ * Author: mrinal.m
+ */
+
+#include "bluetooth.h"
+#include <tet_api.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_nap_activate_p(void);
+static void utc_network_bluetooth_nap_deactivate_p(void);
+static void utc_network_bluetooth_nap_disconnect_all_p(void);
+static void utc_network_bluetooth_nap_set_connection_state_changed_p(void);
+static void utc_network_bluetooth_nap_unset_connection_state_changed_p(void);
+static void utc_network_bluetooth_panu_set_connection_state_changed_p(void);
+static void utc_network_bluetooth_panu_unset_connection_state_changed_p(void);
+static void utc_network_bluetooth_panu_connect_p(void);
+static void utc_network_bluetooth_panu_disconnect_p(void);
+
+void connection_state_changed_cb_for_nap_p(bool connected,
+ const char *remote_address,
+ const char *interface_name,
+ void *user_data);
+void connection_state_changed_cb_for_panu_p(int result,
+ bool connected,
+ const char *remote_address,
+ bt_panu_service_type_e type,
+ void *user_data);
+
+void adapter_state_changed_cb_for_pan_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_nap_activate_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_nap_set_connection_state_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_nap_unset_connection_state_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_nap_deactivate_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_nap_disconnect_all_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_panu_connect_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_panu_set_connection_state_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_panu_unset_connection_state_changed_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_panu_disconnect_p, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_pan_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_enable() was called.");
+
+ ret = bt_adapter_enable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_enable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret != BT_ERROR_ALREADY_DONE) {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Callback funtions
+*/
+
+void adapter_state_changed_cb_for_pan_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+
+}
+
+void connection_state_changed_cb_for_nap_p(bool connected,
+ const char *remote_address,
+ const char *interface_name,
+ void *user_data)
+{
+
+}
+
+void connection_state_changed_cb_for_panu_p(int result,
+ bool connected,
+ const char *remote_address,
+ bt_panu_service_type_e type,
+ void *user_data)
+{
+
+}
+
+/**
+ * @brief Positive test case of bt_nap_activate()
+*/
+static void utc_network_bluetooth_nap_activate_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_nap_activate();
+ if (ret != BT_ERROR_ALREADY_DONE) {
+ dts_check_eq("bt_nap_activate", ret, BT_ERROR_NONE, "bt_nap_activate() failed.");
+ } else {
+ dts_check_eq("bt_nap_activate", ret, BT_ERROR_ALREADY_DONE,
+ "bt_nap_activate() failed.");
+ }
+}
+
+/**
+ * @brief Positive test case of bt_nap_deactivate()
+*/
+static void utc_network_bluetooth_nap_deactivate_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_nap_deactivate();
+ dts_check_eq("bt_nap_deactivate", ret, BT_ERROR_NONE, "bt_nap_deactivate() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_nap_disconnect_all()
+ */
+static void utc_network_bluetooth_nap_disconnect_all_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_nap_disconnect_all();
+ dts_check_eq("bt_nap_disconnect_all", ret, BT_ERROR_NONE,
+ "bt_nap_disconnect_all() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_nap_set_connection_state_changed_cb()
+ */
+static void utc_network_bluetooth_nap_set_connection_state_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_nap_set_connection_state_changed_cb(connection_state_changed_cb_for_nap_p, NULL);
+ dts_check_eq("bt_nap_set_connection_state_changed_cb", ret, BT_ERROR_NONE,
+ "bt_nap_set_connection_state_changed_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_nap_unset_connection_state_changed_cb()
+*/
+static void utc_network_bluetooth_nap_unset_connection_state_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_nap_unset_connection_state_changed_cb();
+ dts_check_eq("bt_nap_unset_connection_state_changed_cb", ret, BT_ERROR_NONE,
+ "bt_nap_unset_connection_state_changed_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_panu_set_connection_state_changed_cb()
+*/
+static void utc_network_bluetooth_panu_set_connection_state_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_panu_set_connection_state_changed_cb(connection_state_changed_cb_for_panu_p, NULL);
+ dts_check_eq("bt_panu_set_connection_state_changed_cb", ret, BT_ERROR_NONE,
+ "bt_panu_set_connection_state_changed_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_panu_unset_connection_state_changed_cb()
+*/
+static void utc_network_bluetooth_panu_unset_connection_state_changed_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ ret = bt_panu_unset_connection_state_changed_cb();
+ dts_check_eq("bt_panu_unset_connection_state_changed_cb", ret, BT_ERROR_NONE,
+ "bt_panu_unset_connection_state_changed_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_panu_connect()
+*/
+static void utc_network_bluetooth_panu_connect_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ const char *remote_address = "00:00:00:00:00:00";
+ ret = bt_panu_connect(remote_address, BT_PANU_SERVICE_TYPE_NAP);
+ dts_check_eq("bt_panu_connect", ret, BT_ERROR_NONE, "bt_panu_connect() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_panu_disconnect()
+*/
+static void utc_network_bluetooth_panu_disconnect_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ const char *remote_address = "00:00:00:00:00:00";
+ ret = bt_panu_disconnect(remote_address);
+ dts_check_eq("bt_panu_disconnect", ret, BT_ERROR_NONE, "bt_panu_disconnect() failed.");
+}
diff --git a/TC/testcase/utc_network_bluetooth_service_search_negative.c b/TC/testcase/utc_network_bluetooth_service_search_negative.c
new file mode 100644
index 0000000..1e83157
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_service_search_negative.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_service_search_set_cb_n(void);
+static void utc_network_bluetooth_service_search_unset_cb_n(void);
+static void utc_network_bluetooth_service_search_n(void);
+static void utc_network_bluetooth_service_search_cancel_n(void);
+
+void adapter_state_changed_cb_for_service_search_n(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_service_search_set_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_service_search_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_service_search_cancel_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_service_search_unset_cb_n, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_service_search_n, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Callback funtions
+ */
+void adapter_state_changed_cb_for_service_search_n(int result,
+ bt_adapter_state_e
+ adapter_state,
+ void *user_data)
+{
+ tet_printf("Callback: bt_adapter_state_changed_cb was called.");
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_DISABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was disabled. DTS will be started.");
+ } else {
+ tet_printf("Callback: BT was not disabled. DTS will be started but DTS may fail.");
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+}
+
+/**
+ * @brief Negative test case of bt_device_set_service_searched_cb()
+ */
+static void utc_network_bluetooth_service_search_set_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_set_service_searched_cb(NULL, NULL);
+ dts_check_eq("bt_device_set_service_searched_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when callback parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_device_unset_service_searched_cb()
+ */
+static void utc_network_bluetooth_service_search_unset_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ if (bt_deinitialize() != BT_ERROR_NONE) {
+ dts_fail("bt_device_unset_service_searched_cb",
+ "bt_deinitialize() failed.");
+ }
+
+ ret = bt_device_unset_service_searched_cb();
+ dts_check_eq("bt_device_unset_service_searched_cb", ret,
+ BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned when BT service is not initialized.");
+}
+
+/**
+ * @brief Negative test case of bt_device_start_service_search()
+ */
+static void utc_network_bluetooth_service_search_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_start_service_search(NULL);
+ dts_check_eq("bt_device_start_service_search", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_device_cancel_service_search()
+ */
+static void utc_network_bluetooth_service_search_cancel_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_cancel_service_search();
+ dts_check_eq("bt_device_cancel_service_search", ret,
+ BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled");
+}
diff --git a/TC/testcase/utc_network_bluetooth_service_search_positive.c b/TC/testcase/utc_network_bluetooth_service_search_positive.c
new file mode 100644
index 0000000..eab85ed
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_service_search_positive.c
@@ -0,0 +1,366 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+char target_name[128] = "dts_test";
+char target_address[18] = "";
+bool callback_result = false;
+bool discovery_result = false;
+bool bonding_result = false;
+static GMainLoop *mainloop;
+
+static void utc_network_bluetooth_service_search_set_cb_p(void);
+static void utc_network_bluetooth_service_search_p(void);
+static void utc_network_bluetooth_service_search_cancel_p(void);
+static void utc_network_bluetooth_service_search_unset_cb_p(void);
+
+gboolean timeout_func(gpointer data);
+void adapter_state_changed_cb_for_service_search_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+void device_discovery_state_changed_cb_for_service_search_p(int result,
+ bt_adapter_device_discovery_state_e discovery_state,
+ bt_adapter_device_discovery_info_s *discovery_info,
+ void *user_data);
+void service_searched_cb_for_service_search_p(int result,
+ bt_device_sdp_info_s *sdp_info,
+ void *user_data);
+void device_bonded_cb_for_service_search_p(int result,
+ bt_device_info_s *device_info,
+ void *user_data);
+void device_unbonded_cb(int result, char *remote_address, void *user_data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_service_search_set_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_service_search_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_service_search_cancel_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_service_search_unset_cb_p, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ bt_error_e ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ callback_result = false;
+ discovery_result = false;
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_service_search_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ if (bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_service_search_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_device_discovery_state_changed_cb() failed.");
+ }
+
+ ret = bt_adapter_enable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_enable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+
+ tet_printf("BT was enabled. Device discovery will be started");
+ if (bt_adapter_start_device_discovery() == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_start_device_discovery() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else {
+ tet_printf("bt_adapter_start_device_discovery() failed.");
+ }
+ } else if (ret == BT_ERROR_ALREADY_DONE) {
+ tet_printf("BT was already enabled. Device discovery will be started");
+ if (bt_adapter_start_device_discovery() == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_start_device_discovery() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else {
+ tet_printf("bt_adapter_start_device_discovery() failed.");
+ }
+ } else {
+ tet_printf("DTS may fail because bt_adapter_enable() failed.");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_unset_state_changed_cb() failed.");
+ }
+
+ if (bt_adapter_unset_device_discovery_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_unset_device_discovery_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start.");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ int timeout_id = 0;
+
+ /* Destroy a bond */
+ bt_device_set_bond_destroyed_cb(device_unbonded_cb, NULL);
+ if (bt_device_destroy_bond(target_address) == BT_ERROR_NONE) {
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ }
+
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("[%s] Callback: Timeout.", __FUNCTION__);
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Callback funtions
+ */
+void device_unbonded_cb(int result, char *remote_address, void *user_data)
+{
+ tet_printf("Callback: bt_device_bond_destroyed_cb() was called.");
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+
+}
+
+void adapter_state_changed_cb_for_service_search_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+ tet_printf("Callback: bt_adapter_state_changed_cb() was called");
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_ENABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was enabled.");
+ } else {
+ tet_printf("Callback: BT was not enabled. DTS will be started but DTS may fail.");
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+}
+
+void device_discovery_state_changed_cb_for_service_search_p(int result,
+ bt_adapter_device_discovery_state_e
+ discovery_state,
+ bt_adapter_device_discovery_info_s
+ * discovery_info,
+ void *user_data)
+{
+ tet_printf("Callback: bt_adapter_device_discovery_state_changed_cb() was called");
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FINISHED) {
+ tet_printf("Callback: Device discovery finished. DTS will be started.");
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ } else if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FOUND) {
+ tet_printf("Callback: Devices were founded (%s)",
+ discovery_info->remote_name);
+ if (discovery_info->remote_name != NULL && !strcmp(discovery_info->remote_name, target_name)) {
+ discovery_result = true;
+ tet_printf("Callback: dts_test device was found.");
+ strncpy(target_address, discovery_info->remote_address, 18);
+ tet_printf("Callback: device address: %s", discovery_info->remote_address);
+ if (bt_adapter_stop_device_discovery() == BT_ERROR_NONE) {
+ tet_printf("Callback: Device discovery will be stopped");
+ }
+ }
+ }
+ }
+}
+
+void service_searched_cb_for_service_search_p(int result,
+ bt_device_sdp_info_s *sdp_info,
+ void *user_data)
+{
+ int i = 0;
+
+ tet_printf("Callback: bt_device_service_searched_cb() was called.");
+ if (result == BT_ERROR_NONE) {
+ if (sdp_info != NULL && !strcmp(sdp_info->remote_address, target_address)) {
+ tet_printf("Callback: Service search succeeded.");
+ tet_printf("Callback: Service count : %d", sdp_info->service_count);
+ for (i = 0; i < sdp_info->service_count; i++) {
+ tet_printf("Callback: uuid[%d] - %s", i + 1, sdp_info->service_uuid[i]);
+ }
+
+ callback_result = true;
+ }
+ } else if (result == BT_ERROR_CANCELLED) {
+ if (sdp_info != NULL && !strcmp(sdp_info->remote_address, target_address)) {
+ tet_printf("Callback: Calcellation of service search succeeded.");
+ callback_result = true;
+ }
+ } else {
+ tet_printf("Callback: Failed.");
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+}
+
+void device_bonded_cb_for_service_search_p(int result,
+ bt_device_info_s *device_info,
+ void *user_data)
+{
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (device_info->remote_address != NULL && !strcmp(device_info->remote_address, target_address)) {
+ if (result == BT_ERROR_NONE) {
+ tet_printf("Callback: Bonding succeeded");
+ bonding_result = true;
+ } else {
+ tet_printf("Callback: Bonding failed");
+ }
+ }
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+}
+
+/**
+ * @brief Positive test case of bt_device_set_service_searched_cb()
+ */
+static void utc_network_bluetooth_service_search_set_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ ret = bt_device_set_service_searched_cb(service_searched_cb_for_service_search_p, NULL);
+ if (ret == BT_ERROR_NONE) {
+ if (bt_device_set_bond_created_cb(device_bonded_cb_for_service_search_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("bt_device_set_bond_created_cb() failed.");
+ }
+
+ if (discovery_result == true && bt_device_create_bond(target_address) == BT_ERROR_NONE) {
+ tet_printf("bt_device_create_bond() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else {
+ tet_printf("bt_device_create_bond() failed.");
+ }
+ }
+
+ dts_check_eq("bt_device_set_service_searched_cb", ret, BT_ERROR_NONE,
+ "bt_device_set_service_searched_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_device_start_service_search()
+ */
+static void utc_network_bluetooth_service_search_p(void)
+{
+ int timeout_id = 0;
+
+ if (discovery_result != true) {
+ dts_fail("bt_device_start_service_search",
+ "device discovery failed.");
+ }
+
+ callback_result = false;
+ if (bt_device_start_service_search(target_address) == BT_ERROR_NONE) {
+ tet_printf("bt_device_start_service_search() succeeded.");
+ tet_printf("service_searched_cb_for_service_search_p() will be called.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ dts_check_eq("bt_device_start_service_search", callback_result,
+ true, "Service search failed.");
+ } else {
+ dts_fail("bt_device_start_service_search",
+ "bt_device_start_service_search() failed.");
+ }
+}
+
+/**
+ * @brief Positive test case of bt_device_cancel_service_search()
+ */
+static void utc_network_bluetooth_service_search_cancel_p(void)
+{
+ int timeout_id = 0;
+
+ if (discovery_result != true) {
+ dts_fail("bt_device_cancel_service_search",
+ "device discovery failed.");
+ }
+
+ callback_result = false;
+ if (bt_device_start_service_search(target_address) != BT_ERROR_NONE) {
+ dts_fail("bt_device_cancel_service_search",
+ "bt_device_start_service_search() failed.");
+ } else {
+ tet_printf("bt_device_cancel_service_search",
+ "bt_device_start_service_search() succeeded.");
+ }
+
+ if (bt_device_cancel_service_search() == BT_ERROR_NONE) {
+ tet_printf("bt_device_cancel_service_search() succeeded.");
+ tet_printf("service_searched_cb_for_service_search_p() will be called.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ dts_check_eq("bt_device_cancel_service_search", callback_result,
+ true, "Cancellation of service search failed.");
+ } else {
+ dts_fail("bt_device_cancel_service_search",
+ "bt_device_cancel_service_search() failed.");
+ }
+}
+
+/**
+ * @brief Positive test case of bt_device_unset_service_searched_cb()
+ */
+static void utc_network_bluetooth_service_search_unset_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_device_unset_service_searched_cb();
+ dts_check_eq("bt_device_unset_service_searched_cb", ret, BT_ERROR_NONE,
+ "bt_device_set_service_searched_cb() failed.");
+}
diff --git a/TC/testcase/utc_network_bluetooth_socket_negative.c b/TC/testcase/utc_network_bluetooth_socket_negative.c
new file mode 100644
index 0000000..9e3f490
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_socket_negative.c
@@ -0,0 +1,266 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+static GMainLoop *mainloop;
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_network_bluetooth_socket_set_data_received_cb_n(void);
+static void utc_network_bluetooth_socket_set_connection_state_changed_cb_n(void);
+static void utc_network_bluetooth_socket_unset_data_received_cb_n(void);
+static void utc_network_bluetooth_socket_unset_connection_state_changed_cb_n(void);
+static void utc_network_bluetooth_socket_create_rfcomm_n(void);
+static void utc_network_bluetooth_socket_destroy_rfcomm_n(void);
+static void utc_network_bluetooth_socket_listen_and_accept_rfcomm_n(void);
+static void utc_network_bluetooth_socket_connect_rfcomm_n(void);
+static void utc_network_bluetooth_socket_disconnect_rfcomm_n(void);
+static void utc_network_bluetooth_socket_send_data_n(void);
+
+void adapter_state_changed_cb_for_device_negative(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+gboolean timeout_func(gpointer data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_socket_set_data_received_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_socket_set_connection_state_changed_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_socket_create_rfcomm_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_socket_destroy_rfcomm_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_socket_listen_and_accept_rfcomm_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_socket_connect_rfcomm_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_socket_disconnect_rfcomm_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_socket_send_data_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_socket_unset_data_received_cb_n, NEGATIVE_TC_IDX},
+ {utc_network_bluetooth_socket_unset_connection_state_changed_cb_n, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_device_negative, "startup") != BT_ERROR_NONE) {
+ tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
+ }
+
+ tet_printf("bt_adapter_disable() was called.");
+ ret = bt_adapter_disable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_disable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else if (ret == BT_ERROR_NOT_ENABLED) {
+ tet_printf("Bluetooth adapter is not enabled.");
+ } else {
+ tet_printf("DTS may fail because bt_adapter_disable() failed");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ tet_printf("TC start");
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("Callback: Timeout.");
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Callback funtions
+ */
+void adapter_state_changed_cb_for_device_negative(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+ tet_printf("Callback: bt_adapter_state_changed_cb was called.");
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_DISABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was disabled. DTS will be started.");
+ } else {
+ tet_printf("Callback: BT was not disabled. DTS will be started but DTS may fail.");
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+}
+
+/**
+ * @brief Negative test case of bt_socket_set_data_received_cb()
+ */
+static void utc_network_bluetooth_socket_set_data_received_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_set_data_received_cb(NULL, NULL);
+ dts_check_eq("bt_socket_set_data_received_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when callback parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_socket_set_connection_state_changed_cb()
+ */
+static void utc_network_bluetooth_socket_set_connection_state_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_set_connection_state_changed_cb(NULL, NULL);
+ dts_check_eq("bt_socket_set_connection_state_changed_cb", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when callback parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_socket_unset_data_received_cb()
+ */
+static void utc_network_bluetooth_socket_unset_data_received_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ if (bt_deinitialize() != BT_ERROR_NONE) {
+ dts_fail("bt_socket_unset_data_received_cb",
+ "bt_deinitialize() failed.");
+ }
+
+ ret = bt_socket_unset_data_received_cb();
+ dts_check_eq("bt_socket_unset_data_received_cb", ret,
+ BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned when BT service is not initialized.");
+}
+
+/**
+ * @brief Negative test case of bt_socket_unset_connection_state_changed_cb()
+ */
+static void utc_network_bluetooth_socket_unset_connection_state_changed_cb_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_unset_connection_state_changed_cb();
+ dts_check_eq("bt_socket_unset_connection_state_changed_cb", ret,
+ BT_ERROR_NOT_INITIALIZED,
+ "BT_ERROR_NOT_INITIALIZED must be returned when BT service is not initialized.");
+}
+
+/**
+ * @brief Negative test case of bt_socket_create_rfcomm()
+ */
+static void utc_network_bluetooth_socket_create_rfcomm_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_create_rfcomm(NULL, NULL);
+ dts_check_eq("bt_socket_create_rfcomm", ret, BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when port_uuid parameter is NULL");
+}
+
+/**
+ * @brief Negative test case of bt_socket_destroy_rfcomm()
+ */
+static void utc_network_bluetooth_socket_destroy_rfcomm_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_destroy_rfcomm(-1);
+ dts_check_eq("bt_socket_listen_and_accept_rfcomm", ret,
+ BT_ERROR_INVALID_PARAMETER,
+ "BT_ERROR_INVALID_PARAMETER must be returned when socket_fd is below 0");
+}
+
+/**
+ * @brief Negative test case of bt_socket_listen_and_accept_rfcomm()
+ */
+static void utc_network_bluetooth_socket_listen_and_accept_rfcomm_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_listen_and_accept_rfcomm(1, 1);
+ dts_check_eq("bt_socket_listen_and_accept_rfcomm", ret,
+ BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled");
+}
+
+/**
+ * @brief Negative test case of bt_socket_connect_rfcomm()
+ */
+static void utc_network_bluetooth_socket_connect_rfcomm_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ char *address = "";
+ char *uuid = "";
+
+ ret = bt_socket_connect_rfcomm(address, uuid);
+ dts_check_eq("bt_socket_connect_rfcomm", ret, BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled");
+}
+
+/**
+ * @brief Negative test case of bt_socket_disconnect_rfcomm()
+ */
+static void utc_network_bluetooth_socket_disconnect_rfcomm_n(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_disconnect_rfcomm(-1);
+ dts_check_eq("bt_socket_disconnect_rfcomm", ret, BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled");
+}
+
+/**
+ * @brief Negative test case of bt_socket_send_data()
+ */
+static void utc_network_bluetooth_socket_send_data_n(void)
+{
+ int ret = BT_ERROR_NONE;
+ char *data = "dts_test";
+
+ ret = bt_socket_send_data(1, data, sizeof(data));
+ dts_check_eq("bt_socket_send_data", ret, BT_ERROR_NOT_ENABLED,
+ "BT_ERROR_NOT_ENABLED must be returned when BT is not enabled");
+}
diff --git a/TC/testcase/utc_network_bluetooth_socket_positive.c b/TC/testcase/utc_network_bluetooth_socket_positive.c
new file mode 100644
index 0000000..5754b4f
--- /dev/null
+++ b/TC/testcase/utc_network_bluetooth_socket_positive.c
@@ -0,0 +1,440 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <tet_api.h>
+#include <bluetooth.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+const char target_name[128] = "dts_test";
+const char *rfcomm_test_uuid_spp = "00001101-0000-1000-8000-00805F9B34FB";
+char target_address[18] = "";
+int socket_fd = 0;
+bool callback_result = false;
+bool discovery_result = false;
+bool bonding_result = false;
+bool is_connecting = false;
+static GMainLoop *mainloop;
+
+static void utc_network_bluetooth_socket_set_data_received_cb_p(void);
+static void utc_network_bluetooth_socket_set_connection_state_changed_cb_p(void);
+
+static void utc_network_bluetooth_socket_create_rfcomm_p(void);
+static void utc_network_bluetooth_socket_destroy_rfcomm_p(void);
+static void utc_network_bluetooth_socket_listen_and_accept_rfcomm_p(void);
+static void utc_network_bluetooth_socket_connect_rfcomm_p(void);
+static void utc_network_bluetooth_socket_disconnect_rfcomm_p(void);
+static void utc_network_bluetooth_socket_send_data_p(void);
+static void utc_network_bluetooth_socket_unset_data_received_cb_p(void);
+static void utc_network_bluetooth_socket_unset_connection_state_changed_cb_p(void);
+
+gboolean timeout_func(gpointer data);
+void adapter_state_changed_cb_for_socket_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data);
+void device_discovery_state_changed_cb_for_socket_p(int result,
+ bt_adapter_device_discovery_state_e discovery_state,
+ bt_adapter_device_discovery_info_s *discovery_info,
+ void *user_data);
+void device_bonded_cb_for_socket_p(int result, bt_device_info_s *device_info,
+ void *user_data);
+void socket_data_received_cb_for_socket_p(bt_socket_received_data_s *data,
+ void *user_data);
+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);
+void device_unbonded_cb(int result, char *remote_address, void *user_data);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_network_bluetooth_socket_set_connection_state_changed_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_socket_set_data_received_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_socket_create_rfcomm_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_socket_listen_and_accept_rfcomm_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_socket_destroy_rfcomm_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_socket_connect_rfcomm_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_socket_send_data_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_socket_disconnect_rfcomm_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_socket_unset_data_received_cb_p, POSITIVE_TC_IDX},
+ {utc_network_bluetooth_socket_unset_connection_state_changed_cb_p, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+ bt_error_e ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ /* start of TC */
+ tet_printf("TC start.");
+ callback_result = false;
+ discovery_result = false;
+ bonding_result = false;
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ bt_initialize();
+
+ if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_socket_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_state_changed_cb() failed.");
+ }
+
+ if (bt_adapter_set_device_discovery_state_changed_cb(device_discovery_state_changed_cb_for_socket_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_set_device_discovery_state_changed_cb() failed.");
+ }
+
+ if (bt_device_set_bond_created_cb(device_bonded_cb_for_socket_p, "startup") != BT_ERROR_NONE) {
+ tet_printf("bt_device_set_bond_created_cb() failed.");
+ }
+
+ ret = bt_adapter_enable();
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_enable() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+
+ tet_printf("BT was enabled. Device discovery will be started");
+ if (bt_adapter_start_device_discovery() == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_start_device_discovery() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else {
+ tet_printf("bt_adapter_start_device_discovery() failed.");
+ }
+ } else if (ret == BT_ERROR_ALREADY_DONE) {
+ tet_printf("BT was already enabled. Device discovery will be started");
+ if (bt_adapter_start_device_discovery() == BT_ERROR_NONE) {
+ tet_printf("bt_adapter_start_device_discovery() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else {
+ tet_printf("bt_adapter_start_device_discovery() failed.");
+ }
+ } else {
+ tet_printf("DTS may fail because bt_adapter_enable() failed.");
+ }
+
+ if (discovery_result == true && bt_device_create_bond(target_address) == BT_ERROR_NONE) {
+ tet_printf("bt_device_create_bond() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else {
+ tet_printf("bt_device_create_bond() failed.");
+ }
+
+ if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_unset_state_changed_cb() failed.");
+ }
+
+ if (bt_adapter_unset_device_discovery_state_changed_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_adapter_unset_device_discovery_state_changed_cb() failed.");
+ }
+
+ if (bt_device_unset_bond_created_cb() != BT_ERROR_NONE) {
+ tet_printf("bt_device_unset_bond_created_cb() failed.");
+ }
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ int timeout_id = 0;
+
+ /* Destroy a bond */
+ bt_device_set_bond_destroyed_cb(device_unbonded_cb, NULL);
+ if (bt_device_destroy_bond(target_address) == BT_ERROR_NONE) {
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ }
+
+ bt_deinitialize();
+ tet_printf("TC end.");
+}
+
+gboolean timeout_func(gpointer data)
+{
+ tet_printf("[%s] Callback: Timeout.", __FUNCTION__);
+ g_main_loop_quit((GMainLoop *) data);
+ return FALSE;
+}
+
+/**
+ * @brief Callback funtions
+ */
+void device_unbonded_cb(int result, char *remote_address, void *user_data)
+{
+ tet_printf("Callback: bt_device_bond_destroyed_cb() was called.");
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+
+}
+
+void adapter_state_changed_cb_for_socket_p(int result,
+ bt_adapter_state_e adapter_state,
+ void *user_data)
+{
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (adapter_state == BT_ADAPTER_ENABLED && result == BT_ERROR_NONE) {
+ tet_printf("Callback: BT was enabled.");
+ bt_adapter_start_device_discovery();
+ } else {
+ tet_printf("Callback: BT was not enabled. DTS will be started but DTS may fail.");
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+ }
+}
+
+void device_discovery_state_changed_cb_for_socket_p(int result,
+ bt_adapter_device_discovery_state_e discovery_state,
+ bt_adapter_device_discovery_info_s *discovery_info,
+ void *user_data)
+{
+ tet_printf("Callback: bt_adapter_device_discovery_state_changed_cb() was called");
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FINISHED) {
+ tet_printf("Callback: Device discovery finished. DTS will be started.");
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ } else if (discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FOUND) {
+ tet_printf("Callback: Devices were founded (%s)", discovery_info->remote_name);
+ if (discovery_info->remote_name != NULL && !strcmp(discovery_info->remote_name, target_name)) {
+ discovery_result = true;
+ tet_printf("Callback: dts_test device was found.");
+ strncpy(target_address, discovery_info->remote_address, 18);
+ tet_printf("Callback: device address: %s", discovery_info->remote_address);
+ if (bt_adapter_stop_device_discovery() == BT_ERROR_NONE) {
+ tet_printf("Callback: Device discovery will be stopped");
+ }
+ }
+ }
+ }
+}
+
+void device_bonded_cb_for_socket_p(int result, bt_device_info_s *device_info,
+ void *user_data)
+{
+ if (user_data != NULL && !strcmp((char *)user_data, "startup")) {
+ if (device_info->remote_address != NULL && !strcmp(device_info->remote_address, target_address)) {
+ if (result == BT_ERROR_NONE) {
+ tet_printf("Callback: Bonding succeeded");
+ bonding_result = true;
+ } else {
+ tet_printf("Callback: Bonding failed");
+ }
+ }
+ }
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+}
+
+void socket_data_received_cb_for_socket_p(bt_socket_received_data_s *data,
+ void *user_data)
+{
+}
+
+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)
+{
+ tet_printf("Callback: bt_socket_connection_state_changed_cb() was called");
+ if (connection_state == BT_SOCKET_CONNECTED)
+ tet_printf("Callback: Connected");
+ else
+ tet_printf("Callback: Disconnected");
+
+ if (connection_state == BT_SOCKET_CONNECTED) {
+ tet_printf("Callback: [BT_SOCKET_CONNECTED] result = %d", result);
+ if (result == BT_ERROR_NONE && is_connecting == true) {
+ callback_result = true;
+ socket_fd = connection->socket_fd;
+ tet_printf("Callback: socket_fd = %d", socket_fd);
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+ } else if (connection_state == BT_SOCKET_DISCONNECTED) {
+ tet_printf("Callback: [BT_SOCKET_DISCONNECTED] result = %d", result);
+ if (result == BT_ERROR_NONE && is_connecting == false) {
+ callback_result = true;
+ socket_fd = connection->socket_fd;
+ tet_printf("Callback: socket_fd = %d", socket_fd);
+
+ if (mainloop) {
+ g_main_loop_quit(mainloop);
+ }
+ }
+ }
+}
+
+/**
+ * @brief Positive test case of bt_socket_set_data_received_cb()
+ */
+static void utc_network_bluetooth_socket_set_data_received_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_set_data_received_cb(socket_data_received_cb_for_socket_p, NULL);
+ dts_check_eq("bt_socket_set_data_received_cb", ret, BT_ERROR_NONE,
+ "bt_socket_set_data_received_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_socket_set_connection_state_changed_cb()
+ */
+static void utc_network_bluetooth_socket_set_connection_state_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_set_connection_state_changed_cb(socket_connection_state_changed_cb_for_socket_p, NULL);
+ dts_check_eq("bt_socket_set_connection_state_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_socket_set_connection_state_changed_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_socket_create_rfcomm()
+ */
+static void utc_network_bluetooth_socket_create_rfcomm_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_create_rfcomm(rfcomm_test_uuid_spp, &socket_fd);
+ dts_check_eq("bt_socket_create_rfcomm", ret, BT_ERROR_NONE,
+ "bt_socket_create_rfcomm() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_socket_listen_and_accept_rfcomm()
+ */
+static void utc_network_bluetooth_socket_listen_and_accept_rfcomm_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_listen_and_accept_rfcomm(socket_fd, 1);
+ dts_check_eq("bt_socket_listen_and_accept_rfcomm", ret, BT_ERROR_NONE,
+ "bt_socket_listen_and_accept_rfcomm() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_socket_destroy_rfcomm()
+ */
+static void utc_network_bluetooth_socket_destroy_rfcomm_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_destroy_rfcomm(socket_fd);
+ dts_check_eq("bt_socket_destroy_rfcomm", ret, BT_ERROR_NONE,
+ "bt_socket_destroy_rfcomm() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_socket_connect_rfcomm()
+ */
+static void utc_network_bluetooth_socket_connect_rfcomm_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ int timeout_id = 0;
+
+ is_connecting = true;
+ callback_result = false;
+ ret = bt_socket_connect_rfcomm(target_address, rfcomm_test_uuid_spp);
+ if (ret == BT_ERROR_NONE) {
+ tet_printf("bt_socket_connect_rfcomm() succeeded.");
+ timeout_id = g_timeout_add(60000, timeout_func, mainloop);
+ g_main_loop_run(mainloop);
+ g_source_remove(timeout_id);
+ } else {
+ dts_fail("bt_socket_connect_rfcomm",
+ "bt_socket_connect_rfcomm() failed");
+ }
+ dts_check_eq("bt_socket_connect_rfcomm", callback_result, true,
+ "connecting failed.");
+}
+
+/**
+ * @brief Positive test case of bt_socket_disconnect_rfcomm()
+ */
+static void utc_network_bluetooth_socket_disconnect_rfcomm_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_disconnect_rfcomm(socket_fd);
+ dts_check_eq("bt_socket_disconnect_rfcomm", ret, BT_ERROR_NONE,
+ "bt_socket_disconnect_rfcomm() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_socket_send_data()
+ */
+static void utc_network_bluetooth_socket_send_data_p(void)
+{
+ int ret = BT_ERROR_NONE;
+ char *dts_test = "dts_test";
+
+ ret = bt_socket_send_data(socket_fd, "dts_test", sizeof(dts_test));
+ dts_check_eq("bt_socket_send_data", ret, BT_ERROR_NONE,
+ "bt_socket_send_data() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_socket_unset_data_received_cb()
+ */
+static void utc_network_bluetooth_socket_unset_data_received_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_unset_data_received_cb();
+ dts_check_eq("bt_socket_unset_data_received_cb", ret, BT_ERROR_NONE,
+ "bt_socket_unset_data_received_cb() failed.");
+}
+
+/**
+ * @brief Positive test case of bt_socket_unset_connection_state_changed_cb()
+ */
+static void utc_network_bluetooth_socket_unset_connection_state_changed_cb_p(void)
+{
+ int ret = BT_ERROR_NONE;
+
+ ret = bt_socket_unset_connection_state_changed_cb();
+ dts_check_eq("bt_socket_unset_connection_state_changed_cb", ret,
+ BT_ERROR_NONE,
+ "bt_socket_unset_connection_state_changed_cb() failed.");
+}
diff --git a/TC/tet_scen b/TC/tet_scen
new file mode 100755
index 0000000..03f029a
--- /dev/null
+++ b/TC/tet_scen
@@ -0,0 +1,7 @@
+all
+ ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+ :include:/testcase/tslist
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
new file mode 100644
index 0000000..f7eda55
--- /dev/null
+++ b/TC/tetbuild.cfg
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option for build operation checking
+TET_BUILD_TOOL=make # build with using make command
+TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build
+TET_API_COMPLIANT=True # use TET API in Test Case ?
+TET_PASS_TC_NAME=True # report passed TC name in Journal file?
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
new file mode 100644
index 0000000..02d7030
--- /dev/null
+++ b/TC/tetclean.cfg
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option
+TET_CLEAN_TOOL= make clean # clean tool
+TET_CLEAN_FILE= Makefile # file for clean
+TET_API_COMPLIANT=True # TET API useage
+TET_PASS_TC_NAME=True # showing name , passed TC
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100644
index 0000000..ef3e452
--- /dev/null
+++ b/TC/tetexec.cfg
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capturing execution or not
+TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional
+TET_EXEC_FILE= # ex) exectool : execution file/ Optional
+TET_API_COMPLIANT=True # Test case or Tool usesTET API?
+TET_PASS_TC_NAME=True # showing Passed TC name ?
diff --git a/debian/changelog b/debian/changelog
index 10dff27..62c177c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,35 +1,3 @@
-capi-network-bluetooth (0.1.40-1) unstable; urgency=low
-
- * Implement bt_reset_adapter API
- * Git: magnolia/framework/api/bluetooth
- * Tag: capi-network-bluetooth_0.1.40-1
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Mon, 04 Feb 2013 14:20:28 +0900
-
-capi-network-bluetooth (0.1.39-1) unstable; urgency=low
-
- * Implement bt_reset_adapter API
- * Git: magnolia/framework/api/bluetooth
- * Tag: capi-network-bluetooth_0.1.39-1
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Sat, 02 Feb 2013 13:42:02 +0900
-
-capi-network-bluetooth (0.1.38-1) unstable; urgency=low
-
- * Implement bluetooth_nap_disconnect_all API
- * Git: magnolia/framework/api/bluetooth
- * Tag: capi-network-bluetooth_0.1.38-1
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Mon, 21 Jan 2013 18:33:37 +0900
-
-capi-network-bluetooth (0.1.37-1) unstable; urgency=low
-
- * Implement GATT API's and Prevent defect fix
- * Git: magnolia/framework/api/bluetooth
- * Tag: capi-network-bluetooth_0.1.37-1
-
- -- Chethan T N <chethan.tn@samsung.com> Tue, 15 Jan 2013 18:16:50 +0530
-
capi-network-bluetooth (0.1.36-1) unstable; urgency=low
* Implement AVRCP callback functions
diff --git a/include/bluetooth.h b/include/bluetooth.h
index c286178..cf86c88 100644
--- a/include/bluetooth.h
+++ b/include/bluetooth.h
@@ -75,6 +75,7 @@ typedef enum
BT_ERROR_REMOTE_DEVICE_NOT_FOUND = TIZEN_ERROR_NETWORK_CLASS|0x0109, /**< Remote device not found */
BT_ERROR_SERVICE_SEARCH_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x010A, /**< Service search failed */
BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED = TIZEN_ERROR_NETWORK_CLASS|0x010B, /**< Remote device is not connected */
+ BT_ERROR_PERMISSION_DENIED = TIZEN_ERROR_NETWORK_CLASS|0x010C, /**< Permission denied */
} bt_error_e;
/**
@@ -111,6 +112,13 @@ typedef enum
BT_ADAPTER_DEVICE_DISCOVERY_FOUND, /**< The remote Bluetooth device is found */
} bt_adapter_device_discovery_state_e;
+typedef enum
+{
+ BT_ADAPTER_DEVICE_DISCOVERY_BREDR = 0x01, /**< Device discovery for BREDR devices only */
+ BT_ADAPTER_DEVICE_DISCOVERY_LE, /**< Device discovery for LE devices only */
+ BT_ADAPTER_DEVICE_DISCOVERY_LE_BREDR, /**< Device discovery for both LE and BREDR devices */
+} bt_adapter_discover_devices_type_e;
+
/**
* @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
* @brief Enumerations of device authorization state.
@@ -993,6 +1001,40 @@ int bt_adapter_set_visibility(bt_adapter_visibility_mode_e discoverable_mode, in
/**
* @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
+ * @brief Starts the device discovery for a particular type, asynchronously. The various
+ * supporting discovery types are BT_ADAPTER_DEVICE_DISCOVERY_BREDR, BT_ADAPTER_DEVICE_DISCOVERY_LE
+ * and BT_ADAPTER_DEVICE_DISCOVERY_LE_BREDR.
+ *
+ * @details If a device is discovered for a particular type, bt_adapter_device_discovery_state_changed_cb()
+* will be invoked with #BT_ADAPTER_DEVICE_DISCOVERY_FOUND, and then bt_adapter_device_discovery_state_changed_cb()
+ * will be called with #BT_ADAPTER_DEVICE_DISCOVERY_FINISHED in case of the completion or cancellation of the discovery.
+ *
+ * @remarks To connect to peer Bluetooth device, you need to know its Bluetooth address. \n
+ * The device discovery can be stopped by bt_adapter_stop_device_discovery(). This API is similar to
+ * bt_adapter_start_device_discovery() but here we can specify the device type to be discovered which
+ * could makes the discovery procedure faster.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #BT_ERROR_NOT_ENABLED Not enabled
+ * @retval #BT_ERROR_NOW_IN_PROGRESS Operation is now in progress
+ * @retval #BT_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @pre The state of local Bluetooth must be #BT_ADAPTER_ENABLED with bt_adapter_enable().
+ * @post This function invokes bt_adapter_device_discovery_state_changed_cb().
+ *
+ * @see bt_adapter_enable()
+ * @see bt_adapter_is_discovering()
+ * @see bt_adapter_stop_device_discovery()
+ * @see bt_adapter_device_discovery_state_changed_cb()
+ * @see bt_adapter_set_device_discovery_state_changed_cb()
+ * @see bt_adapter_unset_device_discovery_state_changed_cb()
+ */
+int bt_adapter_start_discover_devices(bt_adapter_discover_devices_type_e type);
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
* @brief Starts the device discovery, asynchronously.
*
* @details If a device is discovered, bt_adapter_device_discovery_state_changed_cb() will be invoked
diff --git a/include/bluetooth_private.h b/include/bluetooth_private.h
index c55a8fe..11731cf 100644
--- a/include/bluetooth_private.h
+++ b/include/bluetooth_private.h
@@ -84,8 +84,12 @@ typedef enum
BT_EVENT_AVRCP_SCAN_MODE_CHANGED, /**< AVRCP scan mode change callback */
BT_EVENT_HID_CONNECTION_STATUS, /**< HID connection status callback */
BT_EVENT_DEVICE_CONNECTION_STATUS, /**< Device connection status callback */
+ BT_EVENT_GATT_CONNECTION_STATUS, /** < GATT connection status callback */
+ BT_EVENT_GATT_RSSI_VALUE, /** < RSSI value for remote device */
BT_EVENT_GATT_CHARACTERISTIC_DISCOVERED, /**< GATT characteristic discovered callback */
BT_EVENT_GATT_VALUE_CHANGED, /**< GATT characteristic value changed callback */
+ BT_EVENT_GATT_READ_CHARACTERISTIC, /**< GATT characteristic value read callback */
+ BT_EVENT_GATT_WRITE_CHARACTERISTIC, /**< GATT characteristic value read callback */
} bt_event_e;
/**
diff --git a/src/bluetooth-adapter.c b/src/bluetooth-adapter.c
index 46c2947..ba125ce 100644
--- a/src/bluetooth-adapter.c
+++ b/src/bluetooth-adapter.c
@@ -243,6 +243,7 @@ int bt_adapter_foreach_bonded_device(bt_adapter_bonded_device_cb foreach_cb, voi
}
if (dev_list != NULL) {
+ g_ptr_array_foreach(dev_list, (GFunc)g_free, NULL);
g_ptr_array_free(dev_list, TRUE);
}
@@ -428,6 +429,19 @@ int bt_adapter_start_device_discovery(void)
return error_code;
}
+int bt_adapter_start_discover_devices(bt_adapter_discover_devices_type_e type)
+{
+ int error_code = BT_ERROR_NONE;
+
+ BT_CHECK_INIT_STATUS();
+ error_code = _bt_get_error_code(bluetooth_start_custom_discovery(type,
+ 0, 0, BLUETOOTH_DEVICE_MAJOR_MASK_MISC));
+ if (error_code != BT_ERROR_NONE) {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ }
+ return error_code;
+}
+
int bt_adapter_stop_device_discovery(void)
{
int error_code = BT_ERROR_NONE;
diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c
index 67a6cc1..7d01ba3 100644
--- a/src/bluetooth-common.c
+++ b/src/bluetooth-common.c
@@ -68,7 +68,9 @@ static bt_event_sig_event_slot_s bt_event_slot_container[] = {
{BT_EVENT_HID_CONNECTION_STATUS, NULL, NULL},
{BT_EVENT_DEVICE_CONNECTION_STATUS, NULL, NULL},
{BT_EVENT_GATT_CHARACTERISTIC_DISCOVERED, NULL, NULL},
- {BT_EVENT_GATT_VALUE_CHANGED, NULL, NULL}
+ {BT_EVENT_GATT_VALUE_CHANGED, NULL, NULL},
+ {BT_EVENT_GATT_READ_CHARACTERISTIC, NULL, NULL},
+ {BT_EVENT_GATT_WRITE_CHARACTERISTIC, NULL, NULL}
};
/*
@@ -184,6 +186,8 @@ int _bt_get_error_code(int origin_error)
return BT_ERROR_REMOTE_DEVICE_NOT_FOUND;
case BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR:
return BT_ERROR_SERVICE_SEARCH_FAILED;
+ case BLUETOOTH_ERROR_PERMISSION_DEINED :
+ return BT_ERROR_PERMISSION_DENIED;
case BLUETOOTH_ERROR_SERVICE_NOT_FOUND:
case BLUETOOTH_ERROR_PARING_FAILED:
case BLUETOOTH_ERROR_MAX_CONNECTION:
@@ -526,6 +530,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
(_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_FINISHED, NULL, bt_event_slot_container[event_index].user_data);
break;
case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+ case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
BT_INFO("bt_adapter_device_discovery_state_changed_cb() will be called with BT_ADAPTER_DEVICE_DISCOVERY_FOUND");
if (__bt_get_bt_adapter_device_discovery_info_s(&discovery_info, (bluetooth_device_info_t *)(param->param_data)) == BT_ERROR_NONE) {
((bt_adapter_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback)
@@ -1062,7 +1067,11 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
bt_event_slot_container[event_index].user_data);
break;
+ case BLUETOOTH_EVENT_GATT_READ_CHAR:
+ BT_INFO("BLUETOOTH_EVENT_GATT_READ_CHAR");
+ break;
default:
+ BT_INFO("__bt_event_proxy default case %d",event);
break;
}
}
@@ -1161,6 +1170,11 @@ static int __bt_get_cb_index(int event)
case BLUETOOTH_EVENT_DEVICE_CONNECTED:
case BLUETOOTH_EVENT_DEVICE_DISCONNECTED:
return BT_EVENT_DEVICE_CONNECTION_STATUS;
+ case BLUETOOTH_EVENT_GATT_CONNECTED:
+ case BLUETOOTH_EVENT_GATT_DISCONNECTED:
+ return BT_EVENT_GATT_CONNECTION_STATUS;
+ case BLUETOOTH_EVENT_GATT_RSSI:
+ return BT_EVENT_GATT_RSSI_VALUE;
case BLUETOOTH_EVENT_SERVICE_SEARCHED:
return BT_EVENT_SERVICE_SEARCHED;
case BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED:
@@ -1252,6 +1266,10 @@ static int __bt_get_cb_index(int event)
return BT_EVENT_GATT_CHARACTERISTIC_DISCOVERED;
case BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED:
return BT_EVENT_GATT_VALUE_CHANGED;
+ case BLUETOOTH_EVENT_GATT_READ_CHAR:
+ return BT_EVENT_GATT_READ_CHARACTERISTIC;
+ case BLUETOOTH_EVENT_GATT_WRITE_CHAR:
+ return BT_EVENT_GATT_WRITE_CHARACTERISTIC;
default:
return -1;
}
diff --git a/src/bluetooth-device.c b/src/bluetooth-device.c
index 442f0b9..85c6a9a 100644
--- a/src/bluetooth-device.c
+++ b/src/bluetooth-device.c
@@ -255,3 +255,20 @@ int bt_device_unset_connection_state_changed_cb(void)
return BT_ERROR_NONE;
}
+int bt_device_read_rssi_value(const char *address)
+{
+ int ret;
+ bluetooth_device_address_t bd_addr = { {0,} };
+
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(address);
+
+ _bt_convert_address_to_hex(&bd_addr, address);
+
+ ret = _bt_get_error_code(bluetooth_read_rssi(&bd_addr));
+
+ if (ret != BT_ERROR_NONE) {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
+ }
+ return ret;
+}
diff --git a/src/bluetooth-gatt.c b/src/bluetooth-gatt.c
index b159fb0..19315c4 100644
--- a/src/bluetooth-gatt.c
+++ b/src/bluetooth-gatt.c
@@ -211,7 +211,7 @@ int bt_gatt_get_characteristic_declaration(bt_gatt_attribute_h characteristic,
BT_CHECK_INIT_STATUS();
BT_CHECK_INPUT_PARAMETER(characteristic);
- memset(&property, 0x00, sizeof(bt_gatt_service_property_t));
+ memset(&property, 0x00, sizeof(bt_gatt_char_property_t));
ret = _bt_get_error_code(bluetooth_gatt_get_characteristics_property((const char *)characteristic, &property));
@@ -250,7 +250,7 @@ int bt_gatt_set_characteristic_value(bt_gatt_attribute_h characteristic,
return BT_ERROR_INVALID_PARAMETER;
ret = _bt_get_error_code(bluetooth_gatt_set_characteristics_value((const char *)characteristic,
- (const guint8 *)value, value_length));
+ (const guint8 *)value, value_length, 0));
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
diff --git a/src/bluetooth-pan.c b/src/bluetooth-pan.c
index eb27268..740b429 100644
--- a/src/bluetooth-pan.c
+++ b/src/bluetooth-pan.c
@@ -70,6 +70,23 @@ int bt_nap_disconnect_all(void)
return error;
}
+int bt_nap_disconnect(const char *remote_address)
+{
+ int error = BT_ERROR_INVALID_PARAMETER;
+ bluetooth_device_address_t addr_hex = { {0,} };
+
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(remote_address);
+ _bt_convert_address_to_hex(&addr_hex, remote_address);
+ error = bluetooth_network_server_disconnect(&addr_hex);
+ error = _bt_get_error_code(error);
+ if (error != BT_ERROR_NONE) {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error),
+ error);
+ }
+ return error;
+}
+
int bt_nap_set_connection_state_changed_cb(
bt_nap_connection_state_changed_cb callback,
void *user_data)
diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c
index ff02085..8b3ce00 100644
--- a/test/bt_unit_test.c
+++ b/test/bt_unit_test.c
@@ -32,6 +32,7 @@
#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args)
#define TC_PRT(format, args...) PRT(format"\n", ##args)
+#define DEVICE_ADDRESS "F6:FB:8F:D8:C8:7C"
const char *spp_uuid = "00001101-0000-1000-8000-00805F9B34FB";
const char *opp_uuid = "00001105-0000-1000-8000-00805f9b34fb";
@@ -76,6 +77,10 @@ tc_table_t tc_table[] = {
{"bt_adapter_get_local_oob_data" , 14},
{"bt_adapter_set_remote_oob_data" , 15},
{"bt_adapter_remove_remote_oob_data" , 16},
+ {"bt_adapter_start_discover_devices" , 17},
+ {"bt_adapter_set_visibility_mode_changed_cb" , 18},
+ {"bt_adapter_unset_visibility_mode_changed_cb" , 19},
+
/* Socket functions */
{"bt_socket_create_rfcomm" , 50},
@@ -85,7 +90,7 @@ tc_table_t tc_table[] = {
{"bt_socket_accept" , 54},
{"bt_socket_reject" , 55},
{"bt_socket_connect_rfcomm" , 56},
- {"bt_socket_disconnect_rfcomm" , 57},
+ {"bt_socket_disconnect_rfcomm" , 57},
{"bt_socket_send_data" , 58},
{"bt_socket_set_data_received_cb" , 59},
{"bt_socket_unset_data_received_cb" , 60},
@@ -140,6 +145,8 @@ tc_table_t tc_table[] = {
{"bt_device_set_connection_state_changed_cb" , 124},
{"bt_device_unset_connection_state_changed_cb" , 125},
{"bt_device_foreach_connected_profiles" , 126},
+ {"bt_device_set_bond_created_cb" , 127},
+ {"bt_device_create_bond" , 128},
/* Gatt functions */
{"bt_gatt_foreach_primary_services" , 140},
@@ -221,6 +228,13 @@ static void __bt_free_gatt_characteristics_services(void)
char_service_index = 0;
}
+static void __bt_adapter_device_visibility_mode_changed_cb(int result,
+ bt_adapter_visibility_mode_e visibility_mode,
+ void *user_data)
+{
+ TC_PRT("visibility_mode: %d", visibility_mode);
+}
+
static void __bt_adapter_device_discovery_state_changed_cb(int result,
bt_adapter_device_discovery_state_e discovery_state,
@@ -358,6 +372,26 @@ bool __bt_device_connected_profile(bt_profile_e profile, void *user_data)
return true;
}
+void __bt_device_bond_created_cb(int result, bt_device_info_s *device_info, void *user_data)
+{
+ if(result == BT_ERROR_NONE)
+ {
+ TC_PRT("Callback: A bond with chat_server is created.");
+ TC_PRT("Callback: The number of service - %d.", device_info->service_count);
+
+ int i = 0;
+ for(i=0; i<device_info->service_count; i++)
+ {
+ TC_PRT("Callback: service[%d] - %s", i+1, device_info->service_uuid[i]);
+ }
+ TC_PRT("Callback: is_bonded - %d.", device_info->is_bonded);
+ TC_PRT("Callback: is_connected - %d.", device_info->is_connected);
+ }
+ else
+ {
+ TC_PRT("Callback: Creating a bond is failed.");
+ }
+}
bool __bt_gatt_primary_service_cb(bt_gatt_attribute_h service, void *user_data)
{
TC_PRT("__bt_gatt_primary_service_cb");
@@ -453,7 +487,7 @@ void __bt_avrcp_scan_mode_changed_cb(bt_avrcp_scan_mode_e scan, void *user_data)
int test_input_callback(void *data)
{
int ret = 0;
- int test_id = (int)data;
+ long test_id = (long)data;
switch (test_id) {
case 0x00ff:
@@ -604,6 +638,25 @@ int test_input_callback(void *data)
break;
}
+ case 17: {
+ ret = bt_adapter_start_discover_devices(BT_ADAPTER_DEVICE_DISCOVERY_BREDR);
+ if (ret < BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+ break;
+ }
+
+ case 18:
+ ret = bt_adapter_set_visibility_mode_changed_cb(__bt_adapter_device_visibility_mode_changed_cb, NULL);
+ if (ret < BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+ break;
+ case 19:
+ ret = bt_adapter_unset_visibility_mode_changed_cb();
+ if (ret < BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+ break;
+
+
/* Socket functions */
case 50: {
int socket_fd = 0;
@@ -1022,6 +1075,27 @@ int test_input_callback(void *data)
break;
}
+ case 127 : {
+ ret = bt_device_set_bond_created_cb(__bt_device_bond_created_cb,
+ NULL);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ }
+ break;
+ }
+
+ case 128 : {
+ char *address;
+
+ address = g_strdup(DEVICE_ADDRESS);
+
+ ret = bt_device_create_bond(address);
+ if (ret < BT_ERROR_NONE) {
+ TC_PRT("failed with [0x%04x]", ret);
+ }
+ break;
+ }
+
case 140: {
char *address;
@@ -1185,7 +1259,6 @@ int test_input_callback(void *data)
TC_PRT("failed with [0x%04x]", ret);
}
break;
-
default:
break;
}
@@ -1199,8 +1272,8 @@ static gboolean key_event_cb(GIOChannel *chan,
{
char buf[BUFFER_LEN] = { 0 };
- unsigned int len = 0;
- int test_id;
+ gsize len = 0;
+ long test_id;
memset(buf, 0, sizeof(buf));