summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPyun DoHyun <dh79.pyun@samsung.com>2019-11-26 00:18:50 +0000
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>2019-11-26 00:18:50 +0000
commit79b6b1f47b46f771c31848b89a248f4e84d8211d (patch)
tree9c48f49f3d74e8586d92e52976d6d3b2e810671c /test
parent6d08bdb88929f7d1b425ec69feb048b011b105bc (diff)
parentc251183b99d9d3b4615b650d0b071892bdae4d1e (diff)
downloadbluetooth-79b6b1f47b46f771c31848b89a248f4e84d8211d.tar.gz
bluetooth-79b6b1f47b46f771c31848b89a248f4e84d8211d.tar.bz2
bluetooth-79b6b1f47b46f771c31848b89a248f4e84d8211d.zip
Merge "Modify unit tc" into tizen
Diffstat (limited to 'test')
-rw-r--r--test/bt_unit_test.c169
-rw-r--r--test/bt_unit_test.h4
2 files changed, 170 insertions, 3 deletions
diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c
index f2745c3..8cf14fa 100644
--- a/test/bt_unit_test.c
+++ b/test/bt_unit_test.c
@@ -304,6 +304,8 @@ tc_table_t tc_adapter_le[] = {
, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE},
{"bt_adapter_le_set_scan_type"
, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE},
+ {"bt_adapter_le_set_customized_scan_mode"
+ , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_CUSTOMIZED},
{"bt_adapter_le_start_scan"
, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_SCAN},
{"bt_adapter_le_stop_scan"
@@ -334,6 +336,8 @@ tc_table_t tc_adapter_le[] = {
, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_REMOTE_OOB_EXT_DATA},
{"Register scan filter (Device Address)"
, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_ADDRESS},
+ {"Register scan filter (Device Name)"
+ , BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_NAME},
{"Register scan filter (Service UUID)"
, BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_UUID},
{"Register scan filter (Service Solicitation UUID)"
@@ -391,6 +395,10 @@ tc_table_t tc_device[] = {
, BT_UNIT_TEST_FUNCTION_DEVICE_CREATE_BOND_BY_TYPE},
{"bt_device_destroy_bond"
, BT_UNIT_TEST_FUNCTION_DEVICE_DESTROY_BOND},
+ {"bt_device_update_le_connection_mode"
+ , BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION_MODE},
+ {"bt_device_le_conn_update"
+ , BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION},
{"bt_device_request_att_mtu"
, BT_UNIT_TEST_FUNCTION_DEVICE_REQUEST_ATT_MTU},
{"bt_device_set_att_mtu_changed_cb"
@@ -1582,6 +1590,9 @@ static bool __bt_adapter_bonded_device_cb(bt_device_info_s *device_info,
TC_PRT("remote_name: %s", device_info->remote_name);
TC_PRT("is_connected: %d", device_info->is_connected);
TC_PRT("service_count: %d", device_info->service_count);
+ TC_PRT("service 0x%x, major 0x%x, minor 0x%x", device_info->bt_class.major_service_class_mask,
+ device_info->bt_class.major_device_class,
+ device_info->bt_class.minor_device_class);
if (device_info->service_uuid == NULL) {
TC_PRT("No uuids");
@@ -1635,6 +1646,9 @@ static void __bt_adapter_device_discovery_state_changed_cb(
TC_PRT("remote_name: %s", discovery_info->remote_name);
TC_PRT("rssi: %d", discovery_info->rssi);
TC_PRT("is_bonded: %d", discovery_info->is_bonded);
+ TC_PRT("service 0x%x, major 0x%x, minor 0x%x", discovery_info->bt_class.major_service_class_mask,
+ discovery_info->bt_class.major_device_class,
+ discovery_info->bt_class.minor_device_class);
TC_PRT("service_count: %d", discovery_info->service_count);
if (discovery_info->service_uuid == NULL) {
@@ -1654,12 +1668,21 @@ static void __bt_adapter_device_discovery_state_changed_cb(
}
}
+static GSList *le_scan_list;
+gint __bt_compare_address(gpointer *a, gpointer *b)
+{
+ bt_adapter_le_device_scan_result_info_s *info = (bt_adapter_le_device_scan_result_info_s *)a;
+ char *address = (char *)b;
+ return g_strcmp0(info->remote_address, address);
+}
+
static void __bt_adapter_le_scan_result_cb(
int result, bt_adapter_le_device_scan_result_info_s *info,
void *user_data)
{
int i;
bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING;
+ bt_adapter_le_device_scan_result_info_s *adv_info;
if (info == NULL) {
TC_PRT("No discovery_info!");
@@ -1679,6 +1702,19 @@ static void __bt_adapter_le_scan_result_cb(
return;
}
+ GSList *l = NULL;
+ l = g_slist_find_custom(le_scan_list, info->remote_address,
+ (GCompareFunc)__bt_compare_address);
+ if (l == NULL) {
+ adv_info = g_malloc0(sizeof(bt_adapter_le_device_scan_result_info_s));
+ adv_info->remote_address= g_strdup(info->remote_address);
+ adv_info->rssi = info->rssi;
+ le_scan_list = g_slist_append(le_scan_list, adv_info);
+ } else {
+ adv_info = l->data;
+ adv_info->rssi = info->rssi;
+ }
+
for (i = 0; i < 2; i++) {
char **uuids;
char *device_name;
@@ -1709,6 +1745,8 @@ static void __bt_adapter_le_scan_result_cb(
if (bt_adapter_le_get_scan_result_device_name(
info, pkt_type, &device_name) == BT_ERROR_NONE) {
TC_PRT("Device name = %s", device_name);
+ if (adv_info->adv_data == NULL)
+ adv_info->adv_data= g_strdup(device_name);
g_free(device_name);
}
if (bt_adapter_le_get_scan_result_tx_power_level(
@@ -3465,6 +3503,22 @@ int test_set_params(int test_id, char *param)
param_count = 1;
TC_PRT("Scan type\n (0 : Passive, 1: Active)");
break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_CUSTOMIZED:
+ param_count = 2;
+ switch (param_index) {
+ case 0:
+ TC_PRT("Input Scan Interval (Unit : ms)");
+ break;
+ case 1:
+ TC_PRT("Input Scan Window (Unit : ms)");
+ break;
+ }
+ break;
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_ADDRESS:
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_NAME:
+ param_count = 1;
+ TC_PRT("Input data for LE scan filter");
+ break;
case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA:
param_count = 1;
TC_PRT("Select advertising data \n (0 : Service uuid, 1: Service solicitation 2 : Appearance & Tx power, 3 : All, 4 : ANCS");
@@ -3534,6 +3588,23 @@ int test_set_params(int test_id, char *param)
param_count = 1;
TC_PRT("Input param(%d) mode (0 : balanced, 1 : low latency, 2 : low power) ", param_index + 1);
break;
+ case BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION:
+ param_count = 4;
+ switch (param_index) {
+ case 0:
+ TC_PRT("Input interval min (8 ~ 4000)");
+ break;
+ case 1:
+ TC_PRT("Input interval max (8 ~ 4000)");
+ break;
+ case 2:
+ TC_PRT("Input slave latency ( 0 ~ 499)");
+ break;
+ case 3:
+ TC_PRT("Input supervision timeout ( 100 ~ 32000)");
+ break;
+ }
+ break;
case BT_UNIT_TEST_FUNCTION_DEVICE_REQUEST_ATT_MTU:
param_count = 1;
param_type = "int(1, 2, 10, ...., 512)";
@@ -4138,6 +4209,8 @@ int test_input_callback(void *data)
}
case BT_UNIT_TEST_FUNCTION_ADAPTER_GET_BONDED_DEVICE_INFO: {
bt_device_info_s *device_info = NULL;
+ int i;
+ char *str = NULL;
ret = bt_adapter_get_bonded_device_info(remote_addr,
&device_info);
@@ -4146,6 +4219,34 @@ int test_input_callback(void *data)
if (device_info) {
TC_PRT("address: %s", device_info->remote_address);
TC_PRT("name: %s", device_info->remote_name);
+ TC_PRT("is_connected: %d", device_info->is_connected);
+ TC_PRT("is_authorized: %d", device_info->is_authorized);
+ TC_PRT("service 0x%x, major 0x%x, minor 0x%x", device_info->bt_class.major_service_class_mask,
+ device_info->bt_class.major_device_class,
+ device_info->bt_class.minor_device_class);
+
+ TC_PRT("service_count: %d", device_info->service_count);
+ if (device_info->service_uuid == NULL) {
+ TC_PRT("No uuids");
+ } else {
+ for (i = 0; i < device_info->service_count; i++) {
+ bt_get_uuid_name(device_info->service_uuid[i], &str);
+
+ TC_PRT("[%d / %d] %s (%s)", i, device_info->service_count,
+ str ? str : "Unknown", device_info->service_uuid[i]);
+ g_free(str);
+ }
+ }
+
+ if (device_info->manufacturer_data_len > 0) {
+ TC_PRT("manufacturer specific data(len:%d)",
+ device_info->manufacturer_data_len);
+ printf("data [");
+ for (i = 0; i < device_info->manufacturer_data_len; i++)
+ printf("%02x ", device_info->manufacturer_data[i]);
+ printf("]\n");
+ }
+ printf("\n");
}
bt_adapter_free_device_info(device_info);
@@ -4615,6 +4716,26 @@ int test_input_callback(void *data)
case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_SCAN:
ret = bt_adapter_le_stop_scan();
TC_PRT("returns %s\n", __bt_get_error_message(ret));
+
+ GSList *l = NULL;
+ int cnt = 0;
+ bt_adapter_le_device_scan_result_info_s *info;
+ printf("LE scan result :\n");
+ for (l = le_scan_list; l != NULL; l = g_slist_next(l)) {
+ info = l->data;
+ if (info) {
+ printf("[%d] %s, %d dBm", ++cnt, info->remote_address, info->rssi);
+ if (info->adv_data)
+ printf(", %s", info->adv_data);
+ printf("\n");
+ g_free(info->remote_address);
+ g_free(info->adv_data);
+ g_free(info);
+ }
+ }
+ g_slist_free(le_scan_list);
+ le_scan_list = NULL;
+
break;
case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ADD_ADVERTISING_DATA: {
@@ -5093,7 +5214,39 @@ int test_input_callback(void *data)
if (ret != BT_ERROR_NONE)
TC_PRT("failed with [0x%04x]", ret);
- ret = bt_adapter_le_scan_filter_set_device_address(scan_filter, remote_addr);
+ if (g_test_param.param_count > 0) {
+ ret = bt_adapter_le_scan_filter_set_device_address(scan_filter, g_test_param.params[0]);
+ __bt_free_test_param(&g_test_param);
+ } else {
+ ret = bt_adapter_le_scan_filter_set_device_address(scan_filter, remote_addr);
+ }
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ ret = bt_adapter_le_scan_filter_register(scan_filter);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ ret = bt_adapter_le_scan_filter_destroy(scan_filter);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ break;
+ }
+
+ case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_NAME: {
+ bt_scan_filter_h scan_filter;
+
+ ret = bt_adapter_le_scan_filter_create(&scan_filter);
+ if (ret != BT_ERROR_NONE)
+ TC_PRT("failed with [0x%04x]", ret);
+
+ if (g_test_param.param_count > 0) {
+ ret = bt_adapter_le_scan_filter_set_device_name(scan_filter, g_test_param.params[0]);
+ __bt_free_test_param(&g_test_param);
+ } else {
+ ret = bt_adapter_le_scan_filter_set_device_name(scan_filter, "Galaxy");
+ }
if (ret != BT_ERROR_NONE)
TC_PRT("failed with [0x%04x]", ret);
@@ -5108,6 +5261,7 @@ int test_input_callback(void *data)
break;
}
+
case BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_UUID: {
bt_scan_filter_h scan_filter;
@@ -5470,6 +5624,17 @@ int test_input_callback(void *data)
break;
}
+ case BT_UNIT_TEST_FUNCTION_DEVICE_UPDATE_LE_CONNECTION_MODE: {
+ int mode = BT_DEVICE_LE_CONNECTION_MODE_BALANCED;
+
+ if (g_test_param.param_count > 0) {
+ mode = atoi(g_test_param.params[0]);
+ __bt_free_test_param(&g_test_param);
+ }
+ ret = bt_device_update_le_connection_mode(remote_addr, mode);
+ TC_PRT("returns %s\n", __bt_get_error_message(ret));
+ break;
+ }
case BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS:
need_to_set_params = true;
TC_PRT("Select the function again");
@@ -7537,7 +7702,7 @@ int test_input_callback(void *data)
__bt_gatt_client_value_changed_cb, NULL);
if (ret != BT_ERROR_NONE)
TC_PRT("bt_gatt_client_set_characteristic_value_changed_cb is failed : %d", ret);
- break;
+ break;
}
case BT_UNIT_TEST_FUNCTION_HPS_CLIENT_UNSET_STATUS_NOTIFICATION: {
bt_gatt_h svc = NULL;
diff --git a/test/bt_unit_test.h b/test/bt_unit_test.h
index 1da019b..ad51ed1 100644
--- a/test/bt_unit_test.h
+++ b/test/bt_unit_test.h
@@ -112,7 +112,8 @@ typedef enum {
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_ENABLE,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_DISABLE,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_MODE,
-BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_CUSTOMIZED,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_START_SCAN,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_SCAN,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_STOP_DEVICE_DISCOVERY,
@@ -132,6 +133,7 @@ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_GET_LOCAL_OOB_EXT_DATA,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_REMOTE_OOB_EXT_DATA,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_ADDRESS,
+ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_DEVICE_NAME,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_UUID,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_SERVICE_SOLICITATION_UUID,
BT_UNIT_TEST_FUNCTION_ADAPTER_LE_REGISTER_SCAN_FILTER_MANUFACTURER_DATA,