Patchset contains HDP initial (app register and unregister) test cases.
Ravi kumar Veeramally (3):
android/tester: Add HDP init test case
android/tester: Add HDP App Register test cases
android/tester: Add HDP App Unregister test case
android/Makefile.am | 1 +
android/tester-hdp.c | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++
android/tester-main.c | 111 +++++++++++++++++++++++++
android/tester-main.h | 29 +++++++
4 files changed, 366 insertions(+)
create mode 100644 android/tester-hdp.c
--
1.9.1
Hi Ravi,
On Wed, Aug 06, 2014, Ravi kumar Veeramally wrote:
> Patchset contains HDP initial (app register and unregister) test cases.
>
> Ravi kumar Veeramally (3):
> android/tester: Add HDP init test case
> android/tester: Add HDP App Register test cases
> android/tester: Add HDP App Unregister test case
>
> android/Makefile.am | 1 +
> android/tester-hdp.c | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++
> android/tester-main.c | 111 +++++++++++++++++++++++++
> android/tester-main.h | 29 +++++++
> 4 files changed, 366 insertions(+)
> create mode 100644 android/tester-hdp.c
All three patches have been applied. Thanks.
Johan
---
android/Makefile.am | 1 +
android/tester-hdp.c | 48 ++++++++++++++++++++++
android/tester-main.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++
android/tester-main.h | 29 +++++++++++++
4 files changed, 189 insertions(+)
create mode 100644 android/tester-hdp.c
diff --git a/android/Makefile.am b/android/Makefile.am
index 79f6a0d..ac3a766 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -158,6 +158,7 @@ android_android_tester_SOURCES = emulator/btdev.h emulator/btdev.c \
android/tester-socket.c \
android/tester-hidhost.c \
android/tester-pan.c \
+ android/tester-hdp.c \
android/tester-gatt.c \
android/tester-main.h android/tester-main.c
diff --git a/android/tester-hdp.c b/android/tester-hdp.c
new file mode 100644
index 0000000..0988fec
--- /dev/null
+++ b/android/tester-hdp.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * 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 <stdbool.h>
+
+#include "emulator/bthost.h"
+#include "tester-main.h"
+#include "android/utils.h"
+
+static struct queue *list; /* List of hdp test cases */
+
+static struct test_case test_cases[] = {
+ TEST_CASE_BREDRLE("HDP Init",
+ ACTION_SUCCESS(dummy_action, NULL),
+ ),
+};
+
+struct queue *get_hdp_tests(void)
+{
+ uint16_t i = 0;
+
+ list = queue_new();
+
+ for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i)
+ if (!queue_push_tail(list, &test_cases[i]))
+ return NULL;
+
+ return list;
+}
+
+void remove_hdp_tests(void)
+{
+ queue_destroy(list, NULL);
+}
diff --git a/android/tester-main.c b/android/tester-main.c
index 203a1b6..a9ccfcd 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -467,6 +467,36 @@ static bool match_data(struct step *step)
return false;
}
+ if (exp->callback_result.app_id !=
+ step->callback_result.app_id) {
+ tester_debug("Callback app_id don't match");
+ return false;
+ }
+
+ if (exp->callback_result.channel_id !=
+ step->callback_result.channel_id) {
+ tester_debug("Callback channel_id don't match");
+ return false;
+ }
+
+ if (exp->callback_result.mdep_cfg_index !=
+ step->callback_result.mdep_cfg_index) {
+ tester_debug("Callback mdep_cfg_index don't match");
+ return false;
+ }
+
+ if (exp->callback_result.app_state !=
+ step->callback_result.app_state) {
+ tester_debug("Callback app_state don't match");
+ return false;
+ }
+
+ if (exp->callback_result.channel_state !=
+ step->callback_result.channel_state) {
+ tester_debug("Callback channel_state don't match");
+ return false;
+ }
+
if (exp->callback_result.pairing_variant !=
step->callback_result.pairing_variant) {
tester_debug("Callback pairing result don't match");
@@ -1023,6 +1053,38 @@ static btpan_callbacks_t btpan_callbacks = {
.connection_state_cb = pan_connection_state_cb,
};
+static void hdp_app_reg_state_cb(int app_id, bthl_app_reg_state_t state)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback = CB_HDP_APP_REG_STATE;
+ step->callback_result.app_id = app_id;
+ step->callback_result.app_state = state;
+
+ schedule_callback_call(step);
+}
+
+static void hdp_channel_state_cb(int app_id, bt_bdaddr_t *bd_addr,
+ int mdep_cfg_index, int channel_id,
+ bthl_channel_state_t state, int fd)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback = CB_HDP_CHANNEL_STATE;
+ step->callback_result.app_id = app_id;
+ step->callback_result.channel_id = channel_id;
+ step->callback_result.mdep_cfg_index = mdep_cfg_index;
+ step->callback_result.channel_state = state;
+
+ schedule_callback_call(step);
+}
+
+static bthl_callbacks_t bthl_callbacks = {
+ .size = sizeof(bthl_callbacks),
+ .app_reg_state_cb = hdp_app_reg_state_cb,
+ .channel_state_cb = hdp_channel_state_cb,
+};
+
static const btgatt_client_callbacks_t btgatt_client_callbacks = {
.register_client_cb = gattc_register_client_cb,
.scan_result_cb = gattc_scan_result_cb,
@@ -1250,6 +1312,42 @@ static void setup_pan(const void *test_data)
tester_setup_complete();
}
+static void setup_hdp(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ bt_status_t status;
+ const void *hdp;
+
+ if (!setup_base(data)) {
+ tester_setup_failed();
+ return;
+ }
+
+ status = data->if_bluetooth->init(&bt_callbacks);
+ if (status != BT_STATUS_SUCCESS) {
+ data->if_bluetooth = NULL;
+ tester_setup_failed();
+ return;
+ }
+
+ hdp = data->if_bluetooth->get_profile_interface(BT_PROFILE_HEALTH_ID);
+ if (!hdp) {
+ tester_setup_failed();
+ return;
+ }
+
+ data->if_hdp = hdp;
+
+ status = data->if_hdp->init(&bthl_callbacks);
+ if (status != BT_STATUS_SUCCESS) {
+ data->if_hdp = NULL;
+ tester_setup_failed();
+ return;
+ }
+
+ tester_setup_complete();
+}
+
static void setup_gatt(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -1309,6 +1407,11 @@ static void teardown(const void *test_data)
data->if_pan = NULL;
}
+ if (data->if_hdp) {
+ data->if_hdp->cleanup();
+ data->if_hdp = NULL;
+ }
+
if (data->if_bluetooth) {
data->if_bluetooth->cleanup();
data->if_bluetooth = NULL;
@@ -1758,6 +1861,13 @@ static void add_pan_tests(void *data, void *user_data)
test(tc, setup_pan, generic_test_function, teardown);
}
+static void add_hdp_tests(void *data, void *user_data)
+{
+ struct test_case *tc = data;
+
+ test(tc, setup_hdp, generic_test_function, teardown);
+}
+
static void add_gatt_tests(void *data, void *user_data)
{
struct test_case *tc = data;
@@ -1775,6 +1885,7 @@ int main(int argc, char *argv[])
queue_foreach(get_socket_tests(), add_socket_tests, NULL);
queue_foreach(get_hidhost_tests(), add_hidhost_tests, NULL);
queue_foreach(get_pan_tests(), add_pan_tests, NULL);
+ queue_foreach(get_hdp_tests(), add_hdp_tests, NULL);
queue_foreach(get_gatt_tests(), add_gatt_tests, NULL);
if (tester_run())
diff --git a/android/tester-main.h b/android/tester-main.h
index 5a5cba4..f0ea095 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -47,6 +47,7 @@
#include <hardware/bt_sock.h>
#include <hardware/bt_hh.h>
#include <hardware/bt_pan.h>
+#include <hardware/bt_hl.h>
#include <hardware/bt_gatt.h>
#include <hardware/bt_gatt_client.h>
#include <hardware/bt_gatt_server.h>
@@ -162,6 +163,21 @@
.callback_result.remote_role = cb_remote_role, \
}
+#define CALLBACK_HDP_APP_REG_STATE(cb, cb_app_id, cb_state) { \
+ .callback = cb, \
+ .callback_result.app_id = cb_app_id, \
+ .callback_result.app_state = cb_state, \
+ }
+
+#define CALLBACK_HDP_CHANNEL_STATE(cb, cb_app_id, cb_channel_id, \
+ cb_mdep_cfg_index, cb_state) { \
+ .callback = cb, \
+ .callback_result.app_id = cb_app_id, \
+ .callback_result.channel_id = cb_channel_id, \
+ .callback_result.mdep_cfg_index = cb_mdep_cfg_index, \
+ .callback_result.channel_state = cb_state, \
+ }
+
#define CALLBACK_DEVICE_PROPS(props, prop_cnt) \
CALLBACK_PROPS(CB_BT_REMOTE_DEVICE_PROPERTIES, props, prop_cnt)
@@ -221,6 +237,10 @@ typedef enum {
CB_PAN_CONTROL_STATE,
CB_PAN_CONNECTION_STATE,
+ /* HDP cb */
+ CB_HDP_APP_REG_STATE,
+ CB_HDP_CHANNEL_STATE,
+
/* Gatt client */
CB_GATTC_REGISTER_CLIENT,
CB_GATTC_SCAN_RESULT,
@@ -267,6 +287,7 @@ struct test_data {
const btsock_interface_t *if_sock;
const bthh_interface_t *if_hid;
const btpan_interface_t *if_pan;
+ const bthl_interface_t *if_hdp;
const btgatt_interface_t *if_gatt;
const void *test_data;
@@ -337,6 +358,12 @@ struct bt_callback_data {
btpan_connection_state_t conn_state;
int local_role;
int remote_role;
+
+ int app_id;
+ int channel_id;
+ int mdep_cfg_index;
+ bthl_app_reg_state_t app_state;
+ bthl_channel_state_t channel_state;
};
/*
@@ -370,6 +397,8 @@ struct queue *get_hidhost_tests(void);
void remove_hidhost_tests(void);
struct queue *get_pan_tests(void);
void remove_pan_tests(void);
+struct queue *get_hdp_tests(void);
+void remove_hdp_tests(void);
struct queue *get_gatt_tests(void);
void remove_gatt_tests(void);
--
1.9.1
---
android/tester-hdp.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/android/tester-hdp.c b/android/tester-hdp.c
index 1f5fee2..9193609 100644
--- a/android/tester-hdp.c
+++ b/android/tester-hdp.c
@@ -162,6 +162,16 @@ static void hdp_register_source_stream_app_action(void)
free(reg);
}
+static void hdp_unregister_app_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step *step = g_new0(struct step, 1);
+
+ step->action_status = data->if_hdp->unregister_application(1);
+
+ schedule_action_verification(step);
+}
+
static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("HDP Init",
ACTION_SUCCESS(dummy_action, NULL),
@@ -186,6 +196,14 @@ static struct test_case test_cases[] = {
CALLBACK_HDP_APP_REG_STATE(CB_HDP_APP_REG_STATE, 1,
BTHL_APP_REG_STATE_REG_SUCCESS),
),
+ TEST_CASE_BREDRLE("HDP Unegister Application",
+ ACTION_SUCCESS(hdp_register_source_stream_app_action, NULL),
+ CALLBACK_HDP_APP_REG_STATE(CB_HDP_APP_REG_STATE, 1,
+ BTHL_APP_REG_STATE_REG_SUCCESS),
+ ACTION_SUCCESS(hdp_unregister_app_action, NULL),
+ CALLBACK_HDP_APP_REG_STATE(CB_HDP_APP_REG_STATE, 1,
+ BTHL_APP_REG_STATE_DEREG_SUCCESS),
+ ),
};
struct queue *get_hdp_tests(void)
--
1.9.1
---
android/tester-hdp.c | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 159 insertions(+)
diff --git a/android/tester-hdp.c b/android/tester-hdp.c
index 0988fec..1f5fee2 100644
--- a/android/tester-hdp.c
+++ b/android/tester-hdp.c
@@ -21,12 +21,171 @@
#include "tester-main.h"
#include "android/utils.h"
+typedef enum {
+ HDP_APP_SINK_RELIABLE,
+ HDP_APP_SINK_STREAM,
+ HDP_APP_SOURCE_RELIABLE,
+ HDP_APP_SOURCE_STREAM,
+} hdp_app_reg_type;
+
static struct queue *list; /* List of hdp test cases */
+static bthl_reg_param_t *create_app(hdp_app_reg_type type)
+{
+ bthl_reg_param_t *reg;
+ bthl_mdep_cfg_t mdep1, mdep2;
+
+ reg = malloc(sizeof(bthl_reg_param_t));
+ reg->application_name = "bluez-android";
+ reg->provider_name = "Bluez";
+ reg->srv_name = "bluez-hdp";
+ reg->srv_desp = "health-device-profile";
+
+ mdep1.data_type = 4100;
+ mdep1.mdep_description = "pulse-oximeter";
+ mdep2.data_type = 4100;
+ mdep1.mdep_description = "pulse-oximeter";
+
+ switch (type) {
+ case HDP_APP_SINK_RELIABLE:
+ reg->number_of_mdeps = 1;
+ mdep1.mdep_role = BTHL_MDEP_ROLE_SINK;
+ mdep1.channel_type = BTHL_CHANNEL_TYPE_RELIABLE;
+ reg->mdep_cfg = malloc(reg->number_of_mdeps *
+ sizeof(bthl_mdep_cfg_t));
+ reg->mdep_cfg[0] = mdep1;
+ break;
+
+ case HDP_APP_SINK_STREAM:
+ reg->number_of_mdeps = 2;
+
+ mdep1.mdep_role = BTHL_MDEP_ROLE_SINK;
+ mdep1.channel_type = BTHL_CHANNEL_TYPE_RELIABLE;
+
+ mdep2.mdep_role = BTHL_MDEP_ROLE_SINK;
+ mdep2.channel_type = BTHL_CHANNEL_TYPE_STREAMING;
+
+ reg->mdep_cfg = malloc(reg->number_of_mdeps *
+ sizeof(bthl_mdep_cfg_t));
+ reg->mdep_cfg[0] = mdep1;
+ reg->mdep_cfg[1] = mdep2;
+ break;
+
+ case HDP_APP_SOURCE_RELIABLE:
+ reg->number_of_mdeps = 1;
+
+ mdep1.mdep_role = BTHL_MDEP_ROLE_SOURCE;
+ mdep1.channel_type = BTHL_CHANNEL_TYPE_RELIABLE;
+
+ reg->mdep_cfg = malloc(reg->number_of_mdeps *
+ sizeof(bthl_mdep_cfg_t));
+ reg->mdep_cfg[0] = mdep1;
+ break;
+
+ case HDP_APP_SOURCE_STREAM:
+ reg->number_of_mdeps = 2;
+
+ mdep1.mdep_role = BTHL_MDEP_ROLE_SOURCE;
+ mdep1.channel_type = BTHL_CHANNEL_TYPE_RELIABLE;
+
+ mdep2.mdep_role = BTHL_MDEP_ROLE_SOURCE;
+ mdep2.channel_type = BTHL_CHANNEL_TYPE_STREAMING;
+
+ reg->mdep_cfg = malloc(reg->number_of_mdeps *
+ sizeof(bthl_mdep_cfg_t));
+ reg->mdep_cfg[0] = mdep1;
+ reg->mdep_cfg[1] = mdep2;
+ break;
+ }
+
+
+ return reg;
+}
+
+static void hdp_register_sink_reliable_app_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step *step = g_new0(struct step, 1);
+ int app_id = 0;
+ bthl_reg_param_t *reg;
+
+ reg = create_app(HDP_APP_SINK_RELIABLE);
+ step->action_status = data->if_hdp->register_application(reg, &app_id);
+
+ schedule_action_verification(step);
+ free(reg->mdep_cfg);
+ free(reg);
+}
+
+static void hdp_register_sink_stream_app_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step *step = g_new0(struct step, 1);
+ int app_id = 0;
+ bthl_reg_param_t *reg;
+
+ reg = create_app(HDP_APP_SINK_STREAM);
+ step->action_status = data->if_hdp->register_application(reg, &app_id);
+
+ schedule_action_verification(step);
+ free(reg->mdep_cfg);
+ free(reg);
+}
+
+static void hdp_register_source_reliable_app_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step *step = g_new0(struct step, 1);
+ int app_id = 0;
+ bthl_reg_param_t *reg;
+
+ reg = create_app(HDP_APP_SOURCE_RELIABLE);
+ step->action_status = data->if_hdp->register_application(reg, &app_id);
+
+ schedule_action_verification(step);
+ free(reg->mdep_cfg);
+ free(reg);
+}
+
+static void hdp_register_source_stream_app_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step *step = g_new0(struct step, 1);
+ int app_id = 0;
+ bthl_reg_param_t *reg;
+
+ reg = create_app(HDP_APP_SOURCE_STREAM);
+ step->action_status = data->if_hdp->register_application(reg, &app_id);
+
+ schedule_action_verification(step);
+ free(reg->mdep_cfg);
+ free(reg);
+}
+
static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("HDP Init",
ACTION_SUCCESS(dummy_action, NULL),
),
+ TEST_CASE_BREDRLE("HDP Register Sink Reliable Application",
+ ACTION_SUCCESS(hdp_register_sink_reliable_app_action, NULL),
+ CALLBACK_HDP_APP_REG_STATE(CB_HDP_APP_REG_STATE, 1,
+ BTHL_APP_REG_STATE_REG_SUCCESS),
+ ),
+ TEST_CASE_BREDRLE("HDP Register Sink Stream Application",
+ ACTION_SUCCESS(hdp_register_sink_stream_app_action, NULL),
+ CALLBACK_HDP_APP_REG_STATE(CB_HDP_APP_REG_STATE, 1,
+ BTHL_APP_REG_STATE_REG_SUCCESS),
+ ),
+ TEST_CASE_BREDRLE("HDP Register Source Reliable Application",
+ ACTION_SUCCESS(hdp_register_source_reliable_app_action, NULL),
+ CALLBACK_HDP_APP_REG_STATE(CB_HDP_APP_REG_STATE, 1,
+ BTHL_APP_REG_STATE_REG_SUCCESS),
+ ),
+ TEST_CASE_BREDRLE("HDP Register Source Stream Application",
+ ACTION_SUCCESS(hdp_register_source_stream_app_action, NULL),
+ CALLBACK_HDP_APP_REG_STATE(CB_HDP_APP_REG_STATE, 1,
+ BTHL_APP_REG_STATE_REG_SUCCESS),
+ ),
};
struct queue *get_hdp_tests(void)
--
1.9.1