summaryrefslogtreecommitdiff
path: root/android/tester-gatt.c
diff options
context:
space:
mode:
authorGrzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>2014-10-06 14:54:02 +0200
committerSzymon Janc <szymon.janc@tieto.com>2014-10-06 16:02:03 +0200
commit4856dd3625f9f8776957ea6f93d0b5699fb3a64a (patch)
tree1cc423223b2bd0b0d3e501872730ca48db853f5e /android/tester-gatt.c
parentecd374f9911eae1269592bd5875d3bd8155c30e6 (diff)
downloadbluez-4856dd3625f9f8776957ea6f93d0b5699fb3a64a.tar.gz
android/tester: Add GATT server add characteristic test cases
This adds characteristic add by server test cases.
Diffstat (limited to 'android/tester-gatt.c')
-rw-r--r--android/tester-gatt.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index f4b12b4bb..6ad9bfe59 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
@@ -123,6 +123,14 @@ struct add_included_service_data {
int *inc_srvc_handle;
int *srvc_handle;
};
+struct add_char_data {
+ int app_id;
+ int *srvc_handle;
+ bt_uuid_t *uuid;
+ int properties;
+ int permissions;
+};
+
static bt_bdaddr_t emu_remote_bdaddr_val = {
.address = { 0x00, 0xaa, 0x01, 0x01, 0x00, 0x00 },
};
@@ -369,6 +377,12 @@ static struct add_service_data add_service_data_4 = {
.num_handles = 2
};
+static struct add_service_data add_service_data_5 = {
+ .app_id = APP1_ID,
+ .service = &service_add_1,
+ .num_handles = 3
+};
+
static struct add_service_data add_bad_service_data_1 = {
.app_id = APP1_ID,
.service = &service_add_1,
@@ -395,6 +409,22 @@ static struct add_included_service_data add_bad_inc_service_data_1 = {
.srvc_handle = &srvc1_handle
};
+static struct add_char_data add_char_data_1 = {
+ .app_id = APP1_ID,
+ .srvc_handle = &srvc1_handle,
+ .uuid = &app1_uuid,
+ .properties = 0,
+ .permissions = 0
+};
+
+static struct add_char_data add_bad_char_data_1 = {
+ .app_id = APP1_ID,
+ .srvc_handle = &srvc_bad_handle,
+ .uuid = &app1_uuid,
+ .properties = 0,
+ .permissions = 0
+};
+
struct set_read_params {
btgatt_read_params_t *params;
btgatt_srvc_id_t *srvc_id;
@@ -1125,6 +1155,23 @@ static void gatt_server_add_inc_service_action(void)
schedule_action_verification(step);
}
+static void gatt_server_add_char_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step *current_data_step = queue_peek_head(data->steps);
+ struct add_char_data *add_char_data = current_data_step->set_data;
+ struct step *step = g_new0(struct step, 1);
+
+ step->action_status = data->if_gatt->server->add_characteristic(
+ add_char_data->app_id,
+ *add_char_data->srvc_handle,
+ add_char_data->uuid,
+ add_char_data->properties,
+ add_char_data->permissions);
+
+ schedule_action_verification(step);
+}
+
static void gatt_cid_hook_cb(const void *data, uint16_t len, void *user_data)
{
struct test_data *t_data = tester_get_data();
@@ -2469,6 +2516,33 @@ static struct test_case test_cases[] = {
CALLBACK_GATTS_INC_SERVICE_ADDED(GATT_STATUS_FAILURE, APP1_ID,
&srvc1_handle, NULL),
),
+ TEST_CASE_BREDRLE("Gatt Server - Add Single Characteristic Successful",
+ ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
+ CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
+ ACTION_SUCCESS(gatt_server_add_service_action,
+ &add_service_data_5),
+ CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
+ &service_add_1, NULL,
+ &srvc1_handle),
+ ACTION_SUCCESS(gatt_server_add_char_action, &add_char_data_1),
+ CALLBACK_GATTS_CHARACTERISTIC_ADDED(GATT_STATUS_SUCCESS,
+ APP1_ID, &app1_uuid,
+ &srvc1_handle, NULL,
+ NULL),
+ ),
+ TEST_CASE_BREDRLE("Gatt Server - Add Char. wrong service handle",
+ ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
+ CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
+ ACTION_SUCCESS(gatt_server_add_service_action,
+ &add_service_data_5),
+ CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
+ &service_add_1, NULL,
+ &srvc1_handle),
+ ACTION_FAIL(gatt_server_add_char_action, &add_bad_char_data_1),
+ CALLBACK_GATTS_CHARACTERISTIC_ADDED(GATT_STATUS_FAILURE,
+ APP1_ID, &app1_uuid,
+ NULL, NULL, NULL),
+ ),
};
struct queue *get_gatt_tests(void)