This significantly shortens the action definitions.
---
android/tester-bluetooth.c | 460 +++++++++------------------------------------
android/tester-gatt.c | 4 +-
android/tester-hidhost.c | 4 +-
android/tester-main.h | 23 +++
android/tester-socket.c | 4 +-
5 files changed, 112 insertions(+), 383 deletions(-)
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index 78a27f7..75df62d 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -20,9 +20,7 @@
static struct queue *list; /* List of bluetooth test cases */
static struct step dummy_steps[] = {
- {
- .action = dummy_action,
- },
+ ACTION_SUCCESS(dummy_action, NULL),
};
static struct test_case bluetooth_init = {
.step = dummy_steps,
@@ -63,19 +61,9 @@ static bt_property_t enable_props[] = {
};
static struct step bluetooth_enable_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = enable_props,
- .callback_result.num_properties = 8,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_ADAPTER_PROPS(enable_props, 8),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
};
static struct test_case bluetooth_enable_success_tc = {
.step = bluetooth_enable_success_steps,
@@ -84,23 +72,10 @@ static struct test_case bluetooth_enable_success_tc = {
};
static struct step bluetooth_enable_success2_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = enable_props,
- .callback_result.num_properties = 8,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_ADAPTER_PROPS(enable_props, 8),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
};
static struct test_case bluetooth_enable_success2_tc = {
.step = bluetooth_enable_success2_steps,
@@ -109,22 +84,10 @@ static struct test_case bluetooth_enable_success2_tc = {
};
static struct step bluetooth_disable_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_disable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_OFF,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bluetooth_disable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
};
static struct test_case bluetooth_disable_success_tc = {
.step = bluetooth_disable_success_steps,
@@ -141,24 +104,10 @@ static bt_property_t setprop_bdname_prop = {
};
static struct step bluetooth_setprop_bdname_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .set_data = &setprop_bdname_prop,
- .action = bt_set_property_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = &setprop_bdname_prop,
- .callback_result.num_properties = 1,
- }
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_set_property_action, &setprop_bdname_prop),
+ CALLBACK_ADAPTER_PROPS(&setprop_bdname_prop, 1),
};
static struct test_case bluetooth_setprop_bdname_success_tc = {
.step = bluetooth_setprop_bdname_success_steps,
@@ -177,24 +126,10 @@ static bt_property_t setprop_scanmode_prop = {
};
static struct step bluetooth_setprop_scanmode_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .set_data = &setprop_scanmode_prop,
- .action = bt_set_property_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = &setprop_scanmode_prop,
- .callback_result.num_properties = 1,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_set_property_action, &setprop_scanmode_prop),
+ CALLBACK_ADAPTER_PROPS(&setprop_scanmode_prop, 1),
};
static struct test_case bluetooth_setprop_scanmode_success_tc = {
.step = bluetooth_setprop_scanmode_success_steps,
@@ -212,23 +147,10 @@ static bt_property_t setprop_disctimeout_prop = {
};
static struct step bluetooth_setprop_disctimeout_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .set_data = &setprop_disctimeout_prop,
- .action = bt_set_property_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = NULL,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_set_property_action, &setprop_disctimeout_prop),
+ CALLBACK_ADAPTER_PROPS(&setprop_disctimeout_prop, 1),
};
static struct test_case bluetooth_setprop_disctimeout_success_tc = {
.step = bluetooth_setprop_disctimeout_success_steps,
@@ -248,24 +170,10 @@ static bt_property_t getprop_bdaddr_prop = {
};
static struct step bluetooth_getprop_bdaddr_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .set_data = &getprop_bdaddr_prop,
- .action = bt_get_property_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = &getprop_bdaddr_prop,
- .callback_result.num_properties = 1,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action, &getprop_bdaddr_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_bdaddr_prop, 1),
};
static struct test_case bluetooth_getprop_bdaddr_success_tc = {
.step = bluetooth_getprop_bdaddr_success_steps,
@@ -283,24 +191,10 @@ static bt_property_t getprop_bdname_prop = {
};
static struct step bluetooth_getprop_bdname_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .set_data = &getprop_bdname_prop,
- .action = bt_get_property_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = &getprop_bdname_prop,
- .callback_result.num_properties = 1,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action, &getprop_bdname_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_bdname_prop, 1),
};
static struct test_case bluetooth_getprop_bdname_success_tc = {
.step = bluetooth_getprop_bdname_success_steps,
@@ -321,19 +215,9 @@ static bt_property_t setprop_uuid_prop = {
};
static struct step bluetooth_setprop_uuid_fail_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_FAIL,
- .set_data = &setprop_uuid_prop,
- .action = bt_set_property_action,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_FAIL(bt_set_property_action, &setprop_uuid_prop),
};
static struct test_case bluetooth_setprop_uuid_fail_tc = {
.step = bluetooth_setprop_uuid_fail_steps,
@@ -350,19 +234,9 @@ static bt_property_t setprop_cod_prop = {
};
static struct step bluetooth_setprop_cod_fail_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_FAIL,
- .set_data = &setprop_cod_prop,
- .action = bt_set_property_action,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_FAIL(bt_set_property_action, &setprop_cod_prop),
};
static struct test_case bluetooth_setprop_cod_fail_tc = {
.step = bluetooth_setprop_cod_fail_steps,
@@ -379,19 +253,9 @@ static bt_property_t setprop_tod_prop = {
};
static struct step bluetooth_setprop_tod_fail_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_FAIL,
- .set_data = &setprop_tod_prop,
- .action = bt_set_property_action,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_FAIL(bt_set_property_action, &setprop_tod_prop),
};
static struct test_case bluetooth_setprop_tod_fail_tc = {
.step = bluetooth_setprop_tod_fail_steps,
@@ -408,19 +272,9 @@ static bt_property_t setprop_remote_rssi_prop = {
};
static struct step bluetooth_setprop_remote_rssi_fail_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_FAIL,
- .set_data = &setprop_remote_rssi_prop,
- .action = bt_set_property_action,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_FAIL(bt_set_property_action, &setprop_remote_rssi_prop),
};
static struct test_case bluetooth_setprop_remote_rssi_fail_tc = {
.step = bluetooth_setprop_remote_rssi_fail_steps,
@@ -442,19 +296,9 @@ static bt_property_t setprop_srvc_record_prop = {
};
static struct step bluetooth_setprop_srvc_record_fail_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_FAIL,
- .set_data = &setprop_srvc_record_prop,
- .action = bt_set_property_action,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_FAIL(bt_set_property_action, &setprop_srvc_record_prop),
};
static struct test_case bluetooth_setprop_srvc_record_fail_tc = {
.step = bluetooth_setprop_srvc_record_fail_steps,
@@ -474,19 +318,9 @@ static bt_property_t setprop_bdaddr_prop = {
};
static struct step bluetooth_setprop_bdaddr_fail_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_FAIL,
- .set_data = &setprop_bdaddr_prop,
- .action = bt_set_property_action,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_FAIL(bt_set_property_action, &setprop_bdaddr_prop),
};
static struct test_case bluetooth_setprop_bdaddr_fail_tc = {
.step = bluetooth_setprop_bdaddr_fail_steps,
@@ -506,19 +340,9 @@ static bt_property_t setprop_bonded_dev_prop = {
};
static struct step bluetooth_setprop_bonded_dev_fail_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_FAIL,
- .set_data = &setprop_bonded_dev_prop,
- .action = bt_set_property_action,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_FAIL(bt_set_property_action, &setprop_bonded_dev_prop),
};
static struct test_case bluetooth_setprop_bonded_dev_fail_tc = {
.step = bluetooth_setprop_bonded_dev_fail_steps,
@@ -536,24 +360,10 @@ static bt_property_t setprop_scan_mode_conn_prop = {
};
static struct step bluetooth_setprop_scan_mode_conn_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .set_data = &setprop_scan_mode_conn_prop,
- .action = bt_set_property_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = &setprop_scan_mode_conn_prop,
- .callback_result.num_properties = 1,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_set_property_action, &setprop_scan_mode_conn_prop),
+ CALLBACK_ADAPTER_PROPS(&setprop_scan_mode_conn_prop, 1),
};
static struct test_case bluetooth_setprop_scan_mode_conn_success_tc = {
.step = bluetooth_setprop_scan_mode_conn_success_steps,
@@ -571,24 +381,10 @@ static bt_property_t getprop_cod_prop = {
};
static struct step bluetooth_getprop_cod_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .set_data = &getprop_cod_prop,
- .action = bt_get_property_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = &getprop_cod_prop,
- .callback_result.num_properties = 1,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action, &getprop_cod_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_cod_prop, 1),
};
static struct test_case bluetooth_getprop_cod_success_tc = {
.step = bluetooth_getprop_cod_success_steps,
@@ -605,24 +401,10 @@ static bt_property_t getprop_tod_prop = {
};
static struct step bluetooth_getprop_tod_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .set_data = &getprop_tod_prop,
- .action = bt_get_property_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = &getprop_tod_prop,
- .callback_result.num_properties = 1,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action, &getprop_tod_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_tod_prop, 1),
};
static struct test_case bluetooth_getprop_tod_success_tc = {
.step = bluetooth_getprop_tod_success_steps,
@@ -639,24 +421,10 @@ static bt_property_t getprop_scan_mode_prop = {
};
static struct step bluetooth_getprop_scan_mode_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .set_data = &getprop_scan_mode_prop,
- .action = bt_get_property_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = &getprop_scan_mode_prop,
- .callback_result.num_properties = 1,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action, &getprop_scan_mode_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_scan_mode_prop, 1),
};
static struct test_case bluetooth_getprop_scan_mode_success_tc = {
.step = bluetooth_getprop_scan_mode_success_steps,
@@ -674,24 +442,10 @@ static bt_property_t getprop_disc_timeout_prop = {
};
static struct step bluetooth_getprop_disc_timeout_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .set_data = &getprop_disc_timeout_prop,
- .action = bt_get_property_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = &getprop_disc_timeout_prop,
- .callback_result.num_properties = 1,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action, &getprop_disc_timeout_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_disc_timeout_prop, 1),
};
static struct test_case bluetooth_getprop_disc_timeout_success_tc = {
.step = bluetooth_getprop_disc_timeout_success_steps,
@@ -716,24 +470,10 @@ static bt_property_t getprop_uuids_prop = {
};
static struct step bluetooth_getprop_uuids_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .set_data = &getprop_uuids_prop,
- .action = bt_get_property_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = &getprop_uuids_prop,
- .callback_result.num_properties = 1,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action, &getprop_uuids_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_uuids_prop, 1),
};
static struct test_case bluetooth_getprop_uuids_success_tc = {
.step = bluetooth_getprop_uuids_success_steps,
@@ -749,24 +489,10 @@ static bt_property_t getprop_bonded_devs_prop = {
};
static struct step bluetooth_getprop_bonded_devs_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .set_data = &getprop_bonded_devs_prop,
- .action = bt_get_property_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = &getprop_bonded_devs_prop,
- .callback_result.num_properties = 1,
- },
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action, &getprop_bonded_devs_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_bonded_devs_prop, 1),
};
static struct test_case bluetooth_getprop_bonded_devs_success_tc = {
.step = bluetooth_getprop_bonded_devs_success_steps,
@@ -784,28 +510,14 @@ static bt_property_t setprop_scan_mode2_prop = {
};
static struct step bluetooth_setprop_scan_mode2_success_steps[] = {
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .action = bluetooth_enable_action,
- },
- {
- .callback = CB_BT_ADAPTER_STATE_CHANGED,
- .callback_result.state = BT_STATE_ON,
- },
- {
- .action_result.status = BT_STATUS_SUCCESS,
- .set_data = &setprop_scan_mode2_prop,
- .action = bt_set_property_action,
- },
- {
- .callback = CB_BT_ADAPTER_PROPERTIES,
- .callback_result.properties = &setprop_scan_mode2_prop,
- .callback_result.num_properties = 1,
- }
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_set_property_action, &setprop_scan_mode2_prop),
+ CALLBACK_ADAPTER_PROPS(&setprop_scan_mode2_prop, 1),
};
static struct test_case bluetooth_setprop_scan_mode2_success_tc = {
.step = bluetooth_setprop_scan_mode2_success_steps,
- .title = "Bluetooth Set SCAN_MODE - Success",
+ .title = "Bluetooth Set SCAN_MODE - Success 2",
.step_num = get_test_case_step_num(
bluetooth_setprop_scan_mode2_success_steps),
};
diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index 4a7c9b1..db2ed27 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
@@ -20,9 +20,7 @@
static struct queue *list; /* List of gatt test cases */
static struct step dummy_steps[] = {
- {
- .action = dummy_action,
- },
+ ACTION_SUCCESS(dummy_action, NULL),
};
static struct test_case gatt_init = {
.step = dummy_steps,
diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index 413c6b8..49c34bd 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -20,9 +20,7 @@
static struct queue *list; /* List of hidhost test cases */
static struct step dummy_steps[] = {
- {
- .action = dummy_action,
- },
+ ACTION_SUCCESS(dummy_action, NULL),
};
static struct test_case hidhost_init = {
.step = dummy_steps,
diff --git a/android/tester-main.h b/android/tester-main.h
index c10513e..d8c2986 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -52,6 +52,29 @@
#define get_test_case_step_num(tc) (sizeof(tc) / sizeof(struct step))
+#define ACTION_SUCCESS(act_fun, data_set) { \
+ .action_result.status = BT_STATUS_SUCCESS, \
+ .action = act_fun, \
+ .set_data = data_set, \
+ }
+
+#define ACTION_FAIL(act_fun, data_set) { \
+ .action_result.status = BT_STATUS_FAIL, \
+ .action = act_fun, \
+ .set_data = data_set, \
+ }
+
+#define CALLBACK_STATE(cb, cb_res) { \
+ .callback = cb, \
+ .callback_result.state = cb_res, \
+ }
+
+#define CALLBACK_ADAPTER_PROPS(props, prop_cnt) { \
+ .callback = CB_BT_ADAPTER_PROPERTIES, \
+ .callback_result.properties = props, \
+ .callback_result.num_properties = prop_cnt, \
+ }
+
/*
* NOTICE:
* Callback enum sections should be
diff --git a/android/tester-socket.c b/android/tester-socket.c
index a57b324..0afab4a 100644
--- a/android/tester-socket.c
+++ b/android/tester-socket.c
@@ -20,9 +20,7 @@
static struct queue *list; /* List of socket test cases */
static struct step dummy_steps[] = {
- {
- .action = dummy_action,
- },
+ ACTION_SUCCESS(dummy_action, NULL),
};
static struct test_case socket_init = {
.step = dummy_steps,
--
1.9.1
Hi Szymon,
On Fri, Jul 18, 2014, Szymon Janc wrote:
> > @@ -2080,6 +2083,23 @@ void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable)
> > send_command(bthost, BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
> > &cp, sizeof(cp));
> >
> > + if (disc_type) {
>
> So this should be called flags since it pass whole flags AD.
>
> Other option would be to expect whole 31 bytes here. I'm not sure how flexible
> this could be ie. if providing function for adding AD in TLV style and just
> build this to build adv_data here?
I think just calling the parameter "flags" is good enough for now.
Johan
Hi Jakub,
On Thursday 17 of July 2014 10:29:54 Jakub Tyszkowski wrote:
> This allows to pass additional parameter describing wheter to set
> discoverable flag in advertising data.
> ---
> android/android-tester.c | 2 +-
> emulator/bthost.c | 22 +++++++++++++++++++++-
> emulator/bthost.h | 3 ++-
> tools/l2cap-tester.c | 2 +-
> tools/mgmt-tester.c | 2 +-
> tools/smp-tester.c | 2 +-
> 6 files changed, 27 insertions(+), 6 deletions(-)
>
> diff --git a/android/android-tester.c b/android/android-tester.c
> index eb5c513..ff14fc8 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -701,7 +701,7 @@ static void setup_powered_emulated_remote(void)
> bthost_set_cmd_complete_cb(bthost, emu_connectable_complete, data);
>
> if (data->hciemu_type == HCIEMU_TYPE_LE)
> - bthost_set_adv_enable(bthost, 0x01);
> + bthost_set_adv_enable(bthost, 0x01, 0x00);
> else
> bthost_write_scan_enable(bthost, 0x03);
> }
> diff --git a/emulator/bthost.c b/emulator/bthost.c
> index 298edcf..d86e02b 100644
> --- a/emulator/bthost.c
> +++ b/emulator/bthost.c
> @@ -747,6 +747,8 @@ static void evt_cmd_complete(struct bthost *bthost, const void *data,
> break;
> case BT_HCI_CMD_LE_LTK_REQ_NEG_REPLY:
> break;
> + case BT_HCI_CMD_LE_SET_ADV_DATA:
> + break;
> default:
> printf("Unhandled cmd_complete opcode 0x%04x\n", opcode);
> break;
> @@ -2072,7 +2074,8 @@ void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan)
> send_command(bthost, BT_HCI_CMD_WRITE_SCAN_ENABLE, &scan, 1);
> }
>
> -void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable)
> +void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable,
> + uint8_t disc_type)
> {
> struct bt_hci_cmd_le_set_adv_parameters cp;
>
> @@ -2080,6 +2083,23 @@ void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable)
> send_command(bthost, BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
> &cp, sizeof(cp));
>
> + if (disc_type) {
So this should be called flags since it pass whole flags AD.
Other option would be to expect whole 31 bytes here. I'm not sure how flexible
this could be ie. if providing function for adding AD in TLV style and just
build this to build adv_data here?
> + struct bt_hci_cmd_le_set_adv_data adv_cp;
> +
> + memset(adv_cp.data, 0, 31);
> +
> + adv_cp.data[0] = 0x02; /* Field length */
> + adv_cp.data[1] = 0x01; /* Flags */
> + adv_cp.data[2] = disc_type;
> +
> + adv_cp.data[3] = 0x00; /* Field terminator */
> +
> + adv_cp.len = 1 + adv_cp.data[0];
> +
> + send_command(bthost, BT_HCI_CMD_LE_SET_ADV_DATA, &adv_cp,
> + sizeof(adv_cp));
> + }
> +
> send_command(bthost, BT_HCI_CMD_LE_SET_ADV_ENABLE, &enable, 1);
> }
>
> diff --git a/emulator/bthost.h b/emulator/bthost.h
> index b00bcd6..578e38a 100644
> --- a/emulator/bthost.h
> +++ b/emulator/bthost.h
> @@ -70,7 +70,8 @@ bool bthost_l2cap_req(struct bthost *bthost, uint16_t handle, uint8_t req,
>
> void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan);
>
> -void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable);
> +void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable,
> + uint8_t disc_type);
>
> void bthost_write_ssp_mode(struct bthost *bthost, uint8_t mode);
>
> diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c
> index 79362b2..6841341 100644
> --- a/tools/l2cap-tester.c
> +++ b/tools/l2cap-tester.c
> @@ -535,7 +535,7 @@ static void setup_powered_client_callback(uint8_t status, uint16_t length,
> bthost = hciemu_client_get_host(data->hciemu);
> bthost_set_cmd_complete_cb(bthost, client_cmd_complete, user_data);
> if (data->hciemu_type == HCIEMU_TYPE_LE)
> - bthost_set_adv_enable(bthost, 0x01);
> + bthost_set_adv_enable(bthost, 0x01, 0x00);
> else
> bthost_write_scan_enable(bthost, 0x03);
> }
> diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
> index a860228..f559a06 100644
> --- a/tools/mgmt-tester.c
> +++ b/tools/mgmt-tester.c
> @@ -2890,7 +2890,7 @@ static void setup_bthost(void)
> bthost = hciemu_client_get_host(data->hciemu);
> bthost_set_cmd_complete_cb(bthost, client_cmd_complete, data);
> if (data->hciemu_type == HCIEMU_TYPE_LE)
> - bthost_set_adv_enable(bthost, 0x01);
> + bthost_set_adv_enable(bthost, 0x01, 0x00);
> else
> bthost_write_scan_enable(bthost, 0x03);
> }
> diff --git a/tools/smp-tester.c b/tools/smp-tester.c
> index 12e0bed..c9639e6 100644
> --- a/tools/smp-tester.c
> +++ b/tools/smp-tester.c
> @@ -411,7 +411,7 @@ static void setup_powered_client_callback(uint8_t status, uint16_t length,
>
> bthost = hciemu_client_get_host(data->hciemu);
> bthost_set_cmd_complete_cb(bthost, client_connectable_complete, data);
> - bthost_set_adv_enable(bthost, 0x01);
> + bthost_set_adv_enable(bthost, 0x01, 0x00);
> }
>
> static void setup_powered_client(const void *test_data)
>
--
Best regards,
Szymon Janc
Hi Jakub,
On Thursday 17 of July 2014 10:29:48 Jakub Tyszkowski wrote:
> This significantly shortens the action definitions.
> ---
> android/tester-bluetooth.c | 460 +++++++++------------------------------------
> android/tester-gatt.c | 4 +-
> android/tester-hidhost.c | 4 +-
> android/tester-main.h | 23 +++
> android/tester-socket.c | 4 +-
> 5 files changed, 112 insertions(+), 383 deletions(-)
>
> diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
> index 78a27f7..75df62d 100644
> --- a/android/tester-bluetooth.c
> +++ b/android/tester-bluetooth.c
> @@ -20,9 +20,7 @@
> static struct queue *list; /* List of bluetooth test cases */
>
> static struct step dummy_steps[] = {
> - {
> - .action = dummy_action,
> - },
> + ACTION_SUCCESS(dummy_action, NULL),
> };
> static struct test_case bluetooth_init = {
> .step = dummy_steps,
> @@ -63,19 +61,9 @@ static bt_property_t enable_props[] = {
> };
>
> static struct step bluetooth_enable_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = enable_props,
> - .callback_result.num_properties = 8,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_ADAPTER_PROPS(enable_props, 8),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> };
> static struct test_case bluetooth_enable_success_tc = {
> .step = bluetooth_enable_success_steps,
> @@ -84,23 +72,10 @@ static struct test_case bluetooth_enable_success_tc = {
> };
>
> static struct step bluetooth_enable_success2_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = enable_props,
> - .callback_result.num_properties = 8,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_ADAPTER_PROPS(enable_props, 8),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> };
> static struct test_case bluetooth_enable_success2_tc = {
> .step = bluetooth_enable_success2_steps,
> @@ -109,22 +84,10 @@ static struct test_case bluetooth_enable_success2_tc = {
> };
>
> static struct step bluetooth_disable_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_disable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_OFF,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bluetooth_disable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
> };
> static struct test_case bluetooth_disable_success_tc = {
> .step = bluetooth_disable_success_steps,
> @@ -141,24 +104,10 @@ static bt_property_t setprop_bdname_prop = {
> };
>
> static struct step bluetooth_setprop_bdname_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .set_data = &setprop_bdname_prop,
> - .action = bt_set_property_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = &setprop_bdname_prop,
> - .callback_result.num_properties = 1,
> - }
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bt_set_property_action, &setprop_bdname_prop),
> + CALLBACK_ADAPTER_PROPS(&setprop_bdname_prop, 1),
> };
> static struct test_case bluetooth_setprop_bdname_success_tc = {
> .step = bluetooth_setprop_bdname_success_steps,
> @@ -177,24 +126,10 @@ static bt_property_t setprop_scanmode_prop = {
> };
>
> static struct step bluetooth_setprop_scanmode_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .set_data = &setprop_scanmode_prop,
> - .action = bt_set_property_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = &setprop_scanmode_prop,
> - .callback_result.num_properties = 1,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bt_set_property_action, &setprop_scanmode_prop),
> + CALLBACK_ADAPTER_PROPS(&setprop_scanmode_prop, 1),
> };
> static struct test_case bluetooth_setprop_scanmode_success_tc = {
> .step = bluetooth_setprop_scanmode_success_steps,
> @@ -212,23 +147,10 @@ static bt_property_t setprop_disctimeout_prop = {
> };
>
> static struct step bluetooth_setprop_disctimeout_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .set_data = &setprop_disctimeout_prop,
> - .action = bt_set_property_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = NULL,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bt_set_property_action, &setprop_disctimeout_prop),
> + CALLBACK_ADAPTER_PROPS(&setprop_disctimeout_prop, 1),
> };
> static struct test_case bluetooth_setprop_disctimeout_success_tc = {
> .step = bluetooth_setprop_disctimeout_success_steps,
> @@ -248,24 +170,10 @@ static bt_property_t getprop_bdaddr_prop = {
> };
>
> static struct step bluetooth_getprop_bdaddr_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .set_data = &getprop_bdaddr_prop,
> - .action = bt_get_property_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = &getprop_bdaddr_prop,
> - .callback_result.num_properties = 1,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bt_get_property_action, &getprop_bdaddr_prop),
> + CALLBACK_ADAPTER_PROPS(&getprop_bdaddr_prop, 1),
> };
> static struct test_case bluetooth_getprop_bdaddr_success_tc = {
> .step = bluetooth_getprop_bdaddr_success_steps,
> @@ -283,24 +191,10 @@ static bt_property_t getprop_bdname_prop = {
> };
>
> static struct step bluetooth_getprop_bdname_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .set_data = &getprop_bdname_prop,
> - .action = bt_get_property_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = &getprop_bdname_prop,
> - .callback_result.num_properties = 1,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bt_get_property_action, &getprop_bdname_prop),
> + CALLBACK_ADAPTER_PROPS(&getprop_bdname_prop, 1),
> };
> static struct test_case bluetooth_getprop_bdname_success_tc = {
> .step = bluetooth_getprop_bdname_success_steps,
> @@ -321,19 +215,9 @@ static bt_property_t setprop_uuid_prop = {
> };
>
> static struct step bluetooth_setprop_uuid_fail_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_FAIL,
> - .set_data = &setprop_uuid_prop,
> - .action = bt_set_property_action,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_FAIL(bt_set_property_action, &setprop_uuid_prop),
> };
> static struct test_case bluetooth_setprop_uuid_fail_tc = {
> .step = bluetooth_setprop_uuid_fail_steps,
> @@ -350,19 +234,9 @@ static bt_property_t setprop_cod_prop = {
> };
>
> static struct step bluetooth_setprop_cod_fail_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_FAIL,
> - .set_data = &setprop_cod_prop,
> - .action = bt_set_property_action,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_FAIL(bt_set_property_action, &setprop_cod_prop),
> };
> static struct test_case bluetooth_setprop_cod_fail_tc = {
> .step = bluetooth_setprop_cod_fail_steps,
> @@ -379,19 +253,9 @@ static bt_property_t setprop_tod_prop = {
> };
>
> static struct step bluetooth_setprop_tod_fail_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_FAIL,
> - .set_data = &setprop_tod_prop,
> - .action = bt_set_property_action,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_FAIL(bt_set_property_action, &setprop_tod_prop),
> };
> static struct test_case bluetooth_setprop_tod_fail_tc = {
> .step = bluetooth_setprop_tod_fail_steps,
> @@ -408,19 +272,9 @@ static bt_property_t setprop_remote_rssi_prop = {
> };
>
> static struct step bluetooth_setprop_remote_rssi_fail_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_FAIL,
> - .set_data = &setprop_remote_rssi_prop,
> - .action = bt_set_property_action,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_FAIL(bt_set_property_action, &setprop_remote_rssi_prop),
> };
> static struct test_case bluetooth_setprop_remote_rssi_fail_tc = {
> .step = bluetooth_setprop_remote_rssi_fail_steps,
> @@ -442,19 +296,9 @@ static bt_property_t setprop_srvc_record_prop = {
> };
>
> static struct step bluetooth_setprop_srvc_record_fail_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_FAIL,
> - .set_data = &setprop_srvc_record_prop,
> - .action = bt_set_property_action,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_FAIL(bt_set_property_action, &setprop_srvc_record_prop),
> };
> static struct test_case bluetooth_setprop_srvc_record_fail_tc = {
> .step = bluetooth_setprop_srvc_record_fail_steps,
> @@ -474,19 +318,9 @@ static bt_property_t setprop_bdaddr_prop = {
> };
>
> static struct step bluetooth_setprop_bdaddr_fail_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_FAIL,
> - .set_data = &setprop_bdaddr_prop,
> - .action = bt_set_property_action,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_FAIL(bt_set_property_action, &setprop_bdaddr_prop),
> };
> static struct test_case bluetooth_setprop_bdaddr_fail_tc = {
> .step = bluetooth_setprop_bdaddr_fail_steps,
> @@ -506,19 +340,9 @@ static bt_property_t setprop_bonded_dev_prop = {
> };
>
> static struct step bluetooth_setprop_bonded_dev_fail_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_FAIL,
> - .set_data = &setprop_bonded_dev_prop,
> - .action = bt_set_property_action,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_FAIL(bt_set_property_action, &setprop_bonded_dev_prop),
> };
> static struct test_case bluetooth_setprop_bonded_dev_fail_tc = {
> .step = bluetooth_setprop_bonded_dev_fail_steps,
> @@ -536,24 +360,10 @@ static bt_property_t setprop_scan_mode_conn_prop = {
> };
>
> static struct step bluetooth_setprop_scan_mode_conn_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .set_data = &setprop_scan_mode_conn_prop,
> - .action = bt_set_property_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = &setprop_scan_mode_conn_prop,
> - .callback_result.num_properties = 1,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bt_set_property_action, &setprop_scan_mode_conn_prop),
> + CALLBACK_ADAPTER_PROPS(&setprop_scan_mode_conn_prop, 1),
> };
> static struct test_case bluetooth_setprop_scan_mode_conn_success_tc = {
> .step = bluetooth_setprop_scan_mode_conn_success_steps,
> @@ -571,24 +381,10 @@ static bt_property_t getprop_cod_prop = {
> };
>
> static struct step bluetooth_getprop_cod_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .set_data = &getprop_cod_prop,
> - .action = bt_get_property_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = &getprop_cod_prop,
> - .callback_result.num_properties = 1,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bt_get_property_action, &getprop_cod_prop),
> + CALLBACK_ADAPTER_PROPS(&getprop_cod_prop, 1),
> };
> static struct test_case bluetooth_getprop_cod_success_tc = {
> .step = bluetooth_getprop_cod_success_steps,
> @@ -605,24 +401,10 @@ static bt_property_t getprop_tod_prop = {
> };
>
> static struct step bluetooth_getprop_tod_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .set_data = &getprop_tod_prop,
> - .action = bt_get_property_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = &getprop_tod_prop,
> - .callback_result.num_properties = 1,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bt_get_property_action, &getprop_tod_prop),
> + CALLBACK_ADAPTER_PROPS(&getprop_tod_prop, 1),
> };
> static struct test_case bluetooth_getprop_tod_success_tc = {
> .step = bluetooth_getprop_tod_success_steps,
> @@ -639,24 +421,10 @@ static bt_property_t getprop_scan_mode_prop = {
> };
>
> static struct step bluetooth_getprop_scan_mode_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .set_data = &getprop_scan_mode_prop,
> - .action = bt_get_property_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = &getprop_scan_mode_prop,
> - .callback_result.num_properties = 1,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bt_get_property_action, &getprop_scan_mode_prop),
> + CALLBACK_ADAPTER_PROPS(&getprop_scan_mode_prop, 1),
> };
> static struct test_case bluetooth_getprop_scan_mode_success_tc = {
> .step = bluetooth_getprop_scan_mode_success_steps,
> @@ -674,24 +442,10 @@ static bt_property_t getprop_disc_timeout_prop = {
> };
>
> static struct step bluetooth_getprop_disc_timeout_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .set_data = &getprop_disc_timeout_prop,
> - .action = bt_get_property_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = &getprop_disc_timeout_prop,
> - .callback_result.num_properties = 1,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bt_get_property_action, &getprop_disc_timeout_prop),
> + CALLBACK_ADAPTER_PROPS(&getprop_disc_timeout_prop, 1),
> };
> static struct test_case bluetooth_getprop_disc_timeout_success_tc = {
> .step = bluetooth_getprop_disc_timeout_success_steps,
> @@ -716,24 +470,10 @@ static bt_property_t getprop_uuids_prop = {
> };
>
> static struct step bluetooth_getprop_uuids_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .set_data = &getprop_uuids_prop,
> - .action = bt_get_property_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = &getprop_uuids_prop,
> - .callback_result.num_properties = 1,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bt_get_property_action, &getprop_uuids_prop),
> + CALLBACK_ADAPTER_PROPS(&getprop_uuids_prop, 1),
> };
> static struct test_case bluetooth_getprop_uuids_success_tc = {
> .step = bluetooth_getprop_uuids_success_steps,
> @@ -749,24 +489,10 @@ static bt_property_t getprop_bonded_devs_prop = {
> };
>
> static struct step bluetooth_getprop_bonded_devs_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .set_data = &getprop_bonded_devs_prop,
> - .action = bt_get_property_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = &getprop_bonded_devs_prop,
> - .callback_result.num_properties = 1,
> - },
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bt_get_property_action, &getprop_bonded_devs_prop),
> + CALLBACK_ADAPTER_PROPS(&getprop_bonded_devs_prop, 1),
> };
> static struct test_case bluetooth_getprop_bonded_devs_success_tc = {
> .step = bluetooth_getprop_bonded_devs_success_steps,
> @@ -784,28 +510,14 @@ static bt_property_t setprop_scan_mode2_prop = {
> };
>
> static struct step bluetooth_setprop_scan_mode2_success_steps[] = {
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .action = bluetooth_enable_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_STATE_CHANGED,
> - .callback_result.state = BT_STATE_ON,
> - },
> - {
> - .action_result.status = BT_STATUS_SUCCESS,
> - .set_data = &setprop_scan_mode2_prop,
> - .action = bt_set_property_action,
> - },
> - {
> - .callback = CB_BT_ADAPTER_PROPERTIES,
> - .callback_result.properties = &setprop_scan_mode2_prop,
> - .callback_result.num_properties = 1,
> - }
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(bt_set_property_action, &setprop_scan_mode2_prop),
> + CALLBACK_ADAPTER_PROPS(&setprop_scan_mode2_prop, 1),
> };
> static struct test_case bluetooth_setprop_scan_mode2_success_tc = {
> .step = bluetooth_setprop_scan_mode2_success_steps,
> - .title = "Bluetooth Set SCAN_MODE - Success",
> + .title = "Bluetooth Set SCAN_MODE - Success 2",
> .step_num = get_test_case_step_num(
> bluetooth_setprop_scan_mode2_success_steps),
> };
> diff --git a/android/tester-gatt.c b/android/tester-gatt.c
> index 4a7c9b1..db2ed27 100644
> --- a/android/tester-gatt.c
> +++ b/android/tester-gatt.c
> @@ -20,9 +20,7 @@
> static struct queue *list; /* List of gatt test cases */
>
> static struct step dummy_steps[] = {
> - {
> - .action = dummy_action,
> - },
> + ACTION_SUCCESS(dummy_action, NULL),
> };
> static struct test_case gatt_init = {
> .step = dummy_steps,
> diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
> index 413c6b8..49c34bd 100644
> --- a/android/tester-hidhost.c
> +++ b/android/tester-hidhost.c
> @@ -20,9 +20,7 @@
> static struct queue *list; /* List of hidhost test cases */
>
> static struct step dummy_steps[] = {
> - {
> - .action = dummy_action,
> - },
> + ACTION_SUCCESS(dummy_action, NULL),
> };
> static struct test_case hidhost_init = {
> .step = dummy_steps,
> diff --git a/android/tester-main.h b/android/tester-main.h
> index c10513e..d8c2986 100644
> --- a/android/tester-main.h
> +++ b/android/tester-main.h
> @@ -52,6 +52,29 @@
>
> #define get_test_case_step_num(tc) (sizeof(tc) / sizeof(struct step))
>
> +#define ACTION_SUCCESS(act_fun, data_set) { \
> + .action_result.status = BT_STATUS_SUCCESS, \
> + .action = act_fun, \
> + .set_data = data_set, \
> + }
> +
> +#define ACTION_FAIL(act_fun, data_set) { \
> + .action_result.status = BT_STATUS_FAIL, \
> + .action = act_fun, \
> + .set_data = data_set, \
> + }
> +
> +#define CALLBACK_STATE(cb, cb_res) { \
> + .callback = cb, \
> + .callback_result.state = cb_res, \
> + }
> +
> +#define CALLBACK_ADAPTER_PROPS(props, prop_cnt) { \
> + .callback = CB_BT_ADAPTER_PROPERTIES, \
> + .callback_result.properties = props, \
> + .callback_result.num_properties = prop_cnt, \
> + }
> +
> /*
> * NOTICE:
> * Callback enum sections should be
> diff --git a/android/tester-socket.c b/android/tester-socket.c
> index a57b324..0afab4a 100644
> --- a/android/tester-socket.c
> +++ b/android/tester-socket.c
> @@ -20,9 +20,7 @@
> static struct queue *list; /* List of socket test cases */
>
> static struct step dummy_steps[] = {
> - {
> - .action = dummy_action,
> - },
> + ACTION_SUCCESS(dummy_action, NULL),
> };
> static struct test_case socket_init = {
> .step = dummy_steps,
>
Patches 1-6 are now applied. Thanks.
--
Best regards,
Szymon Janc
This replaces test cases declaration with simplier macro call.
---
android/tester-bluetooth.c | 256 +++++++++++++--------------------------------
android/tester-gatt.c | 10 +-
android/tester-hidhost.c | 10 +-
android/tester-main.c | 2 +-
android/tester-main.h | 18 ++--
android/tester-socket.c | 10 +-
6 files changed, 93 insertions(+), 213 deletions(-)
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index 75df62d..86f5e5c 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -19,14 +19,10 @@
static struct queue *list; /* List of bluetooth test cases */
-static struct step dummy_steps[] = {
+TEST_CASE(bluetooth_init,
+ "Bluetooth Init",
ACTION_SUCCESS(dummy_action, NULL),
-};
-static struct test_case bluetooth_init = {
- .step = dummy_steps,
- .title = "Bluetooth Init",
- .step_num = get_test_case_step_num(dummy_steps),
-};
+);
static bt_bdaddr_t enable_bdaddr_val = {
.address = { 0x00, 0xaa, 0x01, 0x00, 0x00, 0x00 },
@@ -60,40 +56,28 @@ static bt_property_t enable_props[] = {
{ BT_PROPERTY_UUIDS, sizeof(enable_uuids_val), &enable_uuids_val },
};
-static struct step bluetooth_enable_success_steps[] = {
+TEST_CASE(bluetooth_enable_success_tc,
+ "Bluetooth Enable - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_ADAPTER_PROPS(enable_props, 8),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
-};
-static struct test_case bluetooth_enable_success_tc = {
- .step = bluetooth_enable_success_steps,
- .title = "Bluetooth Enable - Success",
- .step_num = get_test_case_step_num(bluetooth_enable_success_steps),
-};
+);
-static struct step bluetooth_enable_success2_steps[] = {
+TEST_CASE(bluetooth_enable_success2_tc,
+ "Bluetooth Enable - Success 2",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_ADAPTER_PROPS(enable_props, 8),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bluetooth_enable_action, NULL),
-};
-static struct test_case bluetooth_enable_success2_tc = {
- .step = bluetooth_enable_success2_steps,
- .title = "Bluetooth Enable - Success 2",
- .step_num = get_test_case_step_num(bluetooth_enable_success2_steps),
-};
+);
-static struct step bluetooth_disable_success_steps[] = {
+TEST_CASE(bluetooth_disable_success_tc,
+ "Bluetooth Disable - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bluetooth_disable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
-};
-static struct test_case bluetooth_disable_success_tc = {
- .step = bluetooth_disable_success_steps,
- .title = "Bluetooth Disable - Success",
- .step_num = get_test_case_step_num(bluetooth_disable_success_steps),
-};
+);
static char test_set_bdname[] = "test_bdname_set";
@@ -103,18 +87,13 @@ static bt_property_t setprop_bdname_prop = {
.len = sizeof(test_set_bdname) - 1,
};
-static struct step bluetooth_setprop_bdname_success_steps[] = {
+TEST_CASE(bluetooth_setprop_bdname_success_tc,
+ "Bluetooth Set BDNAME - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_set_property_action, &setprop_bdname_prop),
CALLBACK_ADAPTER_PROPS(&setprop_bdname_prop, 1),
-};
-static struct test_case bluetooth_setprop_bdname_success_tc = {
- .step = bluetooth_setprop_bdname_success_steps,
- .title = "Bluetooth Set BDNAME - Success",
- .step_num =
- get_test_case_step_num(bluetooth_setprop_bdname_success_steps),
-};
+);
static bt_scan_mode_t test_setprop_scanmode_val =
BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
@@ -125,18 +104,13 @@ static bt_property_t setprop_scanmode_prop = {
.len = sizeof(bt_scan_mode_t),
};
-static struct step bluetooth_setprop_scanmode_success_steps[] = {
+TEST_CASE(bluetooth_setprop_scanmode_success_tc,
+ "Bluetooth Set SCAN_MODE - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_set_property_action, &setprop_scanmode_prop),
CALLBACK_ADAPTER_PROPS(&setprop_scanmode_prop, 1),
-};
-static struct test_case bluetooth_setprop_scanmode_success_tc = {
- .step = bluetooth_setprop_scanmode_success_steps,
- .title = "Bluetooth Set SCAN_MODE - Success",
- .step_num = get_test_case_step_num(
- bluetooth_setprop_scanmode_success_steps),
-};
+);
static uint32_t test_setprop_disctimeout_val = 600;
@@ -146,18 +120,13 @@ static bt_property_t setprop_disctimeout_prop = {
.len = sizeof(test_setprop_disctimeout_val),
};
-static struct step bluetooth_setprop_disctimeout_success_steps[] = {
+TEST_CASE(bluetooth_setprop_disctimeout_success_tc,
+ "Bluetooth Set DISCOVERY_TIMEOUT - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_set_property_action, &setprop_disctimeout_prop),
CALLBACK_ADAPTER_PROPS(&setprop_disctimeout_prop, 1),
-};
-static struct test_case bluetooth_setprop_disctimeout_success_tc = {
- .step = bluetooth_setprop_disctimeout_success_steps,
- .title = "Bluetooth Set DISCOVERY_TIMEOUT - Success",
- .step_num = get_test_case_step_num(
- bluetooth_setprop_disctimeout_success_steps),
-};
+);
static bt_bdaddr_t test_getprop_bdaddr_val = {
{0x00, 0xaa, 0x01, 0x00, 0x00, 0x00},
@@ -169,18 +138,13 @@ static bt_property_t getprop_bdaddr_prop = {
.len = sizeof(test_getprop_bdaddr_val),
};
-static struct step bluetooth_getprop_bdaddr_success_steps[] = {
+TEST_CASE(bluetooth_getprop_bdaddr_success_tc,
+ "Bluetooth Get BDADDR - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_get_property_action, &getprop_bdaddr_prop),
CALLBACK_ADAPTER_PROPS(&getprop_bdaddr_prop, 1),
-};
-static struct test_case bluetooth_getprop_bdaddr_success_tc = {
- .step = bluetooth_getprop_bdaddr_success_steps,
- .title = "Bluetooth Get BDADDR - Success",
- .step_num = get_test_case_step_num(
- bluetooth_getprop_bdaddr_success_steps),
-};
+);
static const char test_getprop_bdname_val[] = "BlueZ for Android";
@@ -190,19 +154,13 @@ static bt_property_t getprop_bdname_prop = {
.len = sizeof(test_getprop_bdname_val) - 1,
};
-static struct step bluetooth_getprop_bdname_success_steps[] = {
+TEST_CASE(bluetooth_getprop_bdname_success_tc,
+ "Bluetooth Get BDNAME - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_get_property_action, &getprop_bdname_prop),
CALLBACK_ADAPTER_PROPS(&getprop_bdname_prop, 1),
-};
-static struct test_case bluetooth_getprop_bdname_success_tc = {
- .step = bluetooth_getprop_bdname_success_steps,
- .title = "Bluetooth Get BDNAME - Success",
- .step_num = get_test_case_step_num(
- bluetooth_getprop_bdname_success_steps),
-};
-
+);
static unsigned char setprop_uuids[] = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00,
0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -214,16 +172,12 @@ static bt_property_t setprop_uuid_prop = {
.len = sizeof(setprop_uuids),
};
-static struct step bluetooth_setprop_uuid_fail_steps[] = {
+TEST_CASE(bluetooth_setprop_uuid_fail_tc,
+ "Bluetooth Set UUID - Fail",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_FAIL(bt_set_property_action, &setprop_uuid_prop),
-};
-static struct test_case bluetooth_setprop_uuid_fail_tc = {
- .step = bluetooth_setprop_uuid_fail_steps,
- .title = "Bluetooth Set UUID - Fail",
- .step_num = get_test_case_step_num(bluetooth_setprop_uuid_fail_steps),
-};
+);
static uint32_t setprop_cod_val = 0;
@@ -233,16 +187,12 @@ static bt_property_t setprop_cod_prop = {
.len = sizeof(setprop_cod_val),
};
-static struct step bluetooth_setprop_cod_fail_steps[] = {
+TEST_CASE(bluetooth_setprop_cod_fail_tc,
+ "Bluetooth Set CLASS_OF_DEVICE - Fail",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_FAIL(bt_set_property_action, &setprop_cod_prop),
-};
-static struct test_case bluetooth_setprop_cod_fail_tc = {
- .step = bluetooth_setprop_cod_fail_steps,
- .title = "Bluetooth Set CLASS_OF_DEVICE - Fail",
- .step_num = get_test_case_step_num(bluetooth_setprop_cod_fail_steps),
-};
+);
static uint32_t setprop_tod_val = BT_DEVICE_DEVTYPE_DUAL;
@@ -252,16 +202,12 @@ static bt_property_t setprop_tod_prop = {
.len = sizeof(setprop_tod_val),
};
-static struct step bluetooth_setprop_tod_fail_steps[] = {
+TEST_CASE(bluetooth_setprop_tod_fail_tc,
+ "Bluetooth Set TYPE_OF_DEVICE - Fail",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_FAIL(bt_set_property_action, &setprop_tod_prop),
-};
-static struct test_case bluetooth_setprop_tod_fail_tc = {
- .step = bluetooth_setprop_tod_fail_steps,
- .title = "Bluetooth Set TYPE_OF_DEVICE - Fail",
- .step_num = get_test_case_step_num(bluetooth_setprop_tod_fail_steps),
-};
+);
static int32_t setprop_remote_rssi_val = -9;
@@ -271,17 +217,12 @@ static bt_property_t setprop_remote_rssi_prop = {
.len = sizeof(setprop_remote_rssi_val),
};
-static struct step bluetooth_setprop_remote_rssi_fail_steps[] = {
+TEST_CASE(bluetooth_setprop_remote_rssi_fail_tc,
+ "Bluetooth Set REMOTE_RSSI - Fail",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_FAIL(bt_set_property_action, &setprop_remote_rssi_prop),
-};
-static struct test_case bluetooth_setprop_remote_rssi_fail_tc = {
- .step = bluetooth_setprop_remote_rssi_fail_steps,
- .title = "Bluetooth Set REMOTE_RSSI - Fail",
- .step_num = get_test_case_step_num(
- bluetooth_setprop_remote_rssi_fail_steps),
-};
+);
static bt_service_record_t setprop_srvc_record_val = {
.uuid = { {0x00} },
@@ -295,17 +236,12 @@ static bt_property_t setprop_srvc_record_prop = {
.len = sizeof(setprop_srvc_record_val),
};
-static struct step bluetooth_setprop_srvc_record_fail_steps[] = {
+TEST_CASE(bluetooth_setprop_srvc_record_fail_tc,
+ "Bluetooth Set SERVICE_RECORD - Fail",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_FAIL(bt_set_property_action, &setprop_srvc_record_prop),
-};
-static struct test_case bluetooth_setprop_srvc_record_fail_tc = {
- .step = bluetooth_setprop_srvc_record_fail_steps,
- .title = "Bluetooth Set SERVICE_RECORD - Fail",
- .step_num = get_test_case_step_num(
- bluetooth_setprop_srvc_record_fail_steps),
-};
+);
static bt_bdaddr_t setprop_bdaddr_val = {
.address = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
@@ -317,17 +253,12 @@ static bt_property_t setprop_bdaddr_prop = {
.len = sizeof(setprop_bdaddr_val),
};
-static struct step bluetooth_setprop_bdaddr_fail_steps[] = {
+TEST_CASE(bluetooth_setprop_bdaddr_fail_tc,
+ "Bluetooth Set BDADDR - Fail",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_FAIL(bt_set_property_action, &setprop_bdaddr_prop),
-};
-static struct test_case bluetooth_setprop_bdaddr_fail_tc = {
- .step = bluetooth_setprop_bdaddr_fail_steps,
- .title = "Bluetooth Set BDADDR - Fail",
- .step_num = get_test_case_step_num(
- bluetooth_setprop_bdaddr_fail_steps),
-};
+);
static bt_bdaddr_t setprop_bonded_dev_val = {
.address = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 },
@@ -339,17 +270,12 @@ static bt_property_t setprop_bonded_dev_prop = {
.len = sizeof(setprop_bonded_dev_val),
};
-static struct step bluetooth_setprop_bonded_dev_fail_steps[] = {
+TEST_CASE(bluetooth_setprop_bonded_dev_fail_tc,
+ "Bluetooth Set BONDED_DEVICES - Fail",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_FAIL(bt_set_property_action, &setprop_bonded_dev_prop),
-};
-static struct test_case bluetooth_setprop_bonded_dev_fail_tc = {
- .step = bluetooth_setprop_bonded_dev_fail_steps,
- .title = "Bluetooth Set BONDED_DEVICES - Fail",
- .step_num = get_test_case_step_num(
- bluetooth_setprop_bonded_dev_fail_steps),
-};
+);
static bt_scan_mode_t setprop_scan_mode_conn_val = BT_SCAN_MODE_CONNECTABLE;
@@ -359,18 +285,13 @@ static bt_property_t setprop_scan_mode_conn_prop = {
.len = sizeof(setprop_scan_mode_conn_val),
};
-static struct step bluetooth_setprop_scan_mode_conn_success_steps[] = {
+TEST_CASE(bluetooth_setprop_scan_mode_conn_success_tc,
+ "Bluetooth Set SCAN_MODE_CONNECTABLE - SUCCESS",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_set_property_action, &setprop_scan_mode_conn_prop),
CALLBACK_ADAPTER_PROPS(&setprop_scan_mode_conn_prop, 1),
-};
-static struct test_case bluetooth_setprop_scan_mode_conn_success_tc = {
- .step = bluetooth_setprop_scan_mode_conn_success_steps,
- .title = "Bluetooth Set SCAN_MODE_CONNECTABLE - SUCCESS",
- .step_num = get_test_case_step_num(
- bluetooth_setprop_scan_mode_conn_success_steps),
-};
+);
static uint32_t test_getprop_cod_val = 0x00020c;
@@ -380,17 +301,13 @@ static bt_property_t getprop_cod_prop = {
.len = sizeof(test_getprop_cod_val),
};
-static struct step bluetooth_getprop_cod_success_steps[] = {
+TEST_CASE(bluetooth_getprop_cod_success_tc,
+ "Bluetooth Get CLASS_OF_DEVICE - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_get_property_action, &getprop_cod_prop),
CALLBACK_ADAPTER_PROPS(&getprop_cod_prop, 1),
-};
-static struct test_case bluetooth_getprop_cod_success_tc = {
- .step = bluetooth_getprop_cod_success_steps,
- .title = "Bluetooth Get CLASS_OF_DEVICE - Success",
- .step_num = get_test_case_step_num(bluetooth_getprop_cod_success_steps),
-};
+);
static bt_device_type_t test_getprop_tod_val = BT_DEVICE_DEVTYPE_DUAL;
@@ -400,17 +317,13 @@ static bt_property_t getprop_tod_prop = {
.len = sizeof(test_getprop_tod_val),
};
-static struct step bluetooth_getprop_tod_success_steps[] = {
+TEST_CASE(bluetooth_getprop_tod_success_tc,
+ "Bluetooth Get TYPE_OF_DEVICE - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_get_property_action, &getprop_tod_prop),
CALLBACK_ADAPTER_PROPS(&getprop_tod_prop, 1),
-};
-static struct test_case bluetooth_getprop_tod_success_tc = {
- .step = bluetooth_getprop_tod_success_steps,
- .title = "Bluetooth Get TYPE_OF_DEVICE - Success",
- .step_num = get_test_case_step_num(bluetooth_getprop_tod_success_steps),
-};
+);
static bt_scan_mode_t test_getprop_scan_mode_val = BT_SCAN_MODE_NONE;
@@ -420,18 +333,13 @@ static bt_property_t getprop_scan_mode_prop = {
.len = sizeof(test_getprop_scan_mode_val),
};
-static struct step bluetooth_getprop_scan_mode_success_steps[] = {
+TEST_CASE(bluetooth_getprop_scan_mode_success_tc,
+ "Bluetooth Get SCAN_MODE - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_get_property_action, &getprop_scan_mode_prop),
CALLBACK_ADAPTER_PROPS(&getprop_scan_mode_prop, 1),
-};
-static struct test_case bluetooth_getprop_scan_mode_success_tc = {
- .step = bluetooth_getprop_scan_mode_success_steps,
- .title = "Bluetooth Get SCAN_MODE - Success",
- .step_num = get_test_case_step_num(
- bluetooth_getprop_scan_mode_success_steps),
-};
+);
static uint32_t test_getprop_disc_timeout_val = 120;
@@ -441,18 +349,13 @@ static bt_property_t getprop_disc_timeout_prop = {
.len = sizeof(test_getprop_disc_timeout_val),
};
-static struct step bluetooth_getprop_disc_timeout_success_steps[] = {
+TEST_CASE(bluetooth_getprop_disc_timeout_success_tc,
+ "Bluetooth Get DISCOVERY_TIMEOUT - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_get_property_action, &getprop_disc_timeout_prop),
CALLBACK_ADAPTER_PROPS(&getprop_disc_timeout_prop, 1),
-};
-static struct test_case bluetooth_getprop_disc_timeout_success_tc = {
- .step = bluetooth_getprop_disc_timeout_success_steps,
- .title = "Bluetooth Get DISCOVERY_TIMEOUT - Success",
- .step_num = get_test_case_step_num(
- bluetooth_getprop_disc_timeout_success_steps),
-};
+);
static const char test_getprop_uuids_val[] = {
/* Multi profile UUID */
@@ -469,18 +372,13 @@ static bt_property_t getprop_uuids_prop = {
.len = sizeof(test_getprop_uuids_val),
};
-static struct step bluetooth_getprop_uuids_success_steps[] = {
+TEST_CASE(bluetooth_getprop_uuids_success_tc,
+ "Bluetooth Get BONDED_DEVICES - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_get_property_action, &getprop_uuids_prop),
CALLBACK_ADAPTER_PROPS(&getprop_uuids_prop, 1),
-};
-static struct test_case bluetooth_getprop_uuids_success_tc = {
- .step = bluetooth_getprop_uuids_success_steps,
- .title = "Bluetooth Get UUIDS - Success",
- .step_num = get_test_case_step_num(
- bluetooth_getprop_uuids_success_steps),
-};
+);
static bt_property_t getprop_bonded_devs_prop = {
.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
@@ -488,18 +386,13 @@ static bt_property_t getprop_bonded_devs_prop = {
.len = 0,
};
-static struct step bluetooth_getprop_bonded_devs_success_steps[] = {
+TEST_CASE(bluetooth_getprop_bonded_devs_success_tc,
+ "Bluetooth Get BONDED_DEVICES - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_get_property_action, &getprop_bonded_devs_prop),
CALLBACK_ADAPTER_PROPS(&getprop_bonded_devs_prop, 1),
-};
-static struct test_case bluetooth_getprop_bonded_devs_success_tc = {
- .step = bluetooth_getprop_bonded_devs_success_steps,
- .title = "Bluetooth Get BONDED_DEVICES - Success",
- .step_num = get_test_case_step_num(
- bluetooth_getprop_bonded_devs_success_steps),
-};
+);
static bt_scan_mode_t test_setprop_scanmode_val2 = BT_SCAN_MODE_NONE;
@@ -509,18 +402,13 @@ static bt_property_t setprop_scan_mode2_prop = {
.len = sizeof(test_setprop_scanmode_val2),
};
-static struct step bluetooth_setprop_scan_mode2_success_steps[] = {
+TEST_CASE(bluetooth_setprop_scan_mode2_success_tc,
+ "Bluetooth Set SCAN_MODE - Success 2",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_set_property_action, &setprop_scan_mode2_prop),
CALLBACK_ADAPTER_PROPS(&setprop_scan_mode2_prop, 1),
-};
-static struct test_case bluetooth_setprop_scan_mode2_success_tc = {
- .step = bluetooth_setprop_scan_mode2_success_steps,
- .title = "Bluetooth Set SCAN_MODE - Success 2",
- .step_num = get_test_case_step_num(
- bluetooth_setprop_scan_mode2_success_steps),
-};
+);
static struct test_case *test_cases[] = {
&bluetooth_init,
diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index db2ed27..87a11a1 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
@@ -19,14 +19,10 @@
static struct queue *list; /* List of gatt test cases */
-static struct step dummy_steps[] = {
+TEST_CASE(gatt_init,
+ "Gatt Init",
ACTION_SUCCESS(dummy_action, NULL),
-};
-static struct test_case gatt_init = {
- .step = dummy_steps,
- .title = "Socket Init",
- .step_num = get_test_case_step_num(dummy_steps),
-};
+);
static struct test_case *test_cases[] = {
&gatt_init,
diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index 49c34bd..6260825 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -19,14 +19,10 @@
static struct queue *list; /* List of hidhost test cases */
-static struct step dummy_steps[] = {
+TEST_CASE(hidhost_init,
+ "Hidhost Init",
ACTION_SUCCESS(dummy_action, NULL),
-};
-static struct test_case hidhost_init = {
- .step = dummy_steps,
- .title = "Hidhost Init",
- .step_num = get_test_case_step_num(dummy_steps),
-};
+);
static struct test_case *test_cases[] = {
&hidhost_init,
diff --git a/android/tester-main.c b/android/tester-main.c
index e8cd4f2..7f52083 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -440,7 +440,7 @@ static void init_test_steps(struct test_data *data)
int i = 0;
for (i = 0; i < test_steps->step_num; i++)
- queue_push_tail(data->steps, &(test_steps->step[i]));
+ queue_push_tail(data->steps, (void *) &(test_steps->step[i]));
tester_print("tester: Number of test steps=%d",
queue_length(data->steps));
diff --git a/android/tester-main.h b/android/tester-main.h
index d8c2986..f838831 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -50,7 +50,11 @@
#include <hardware/bt_gatt_client.h>
#include <hardware/bt_gatt_server.h>
-#define get_test_case_step_num(tc) (sizeof(tc) / sizeof(struct step))
+#define TEST_CASE(decl_name, text, ...) static struct test_case decl_name = { \
+ text, \
+ sizeof((struct step[]) {__VA_ARGS__}) / sizeof(struct step), \
+ {__VA_ARGS__}, \
+ }
#define ACTION_SUCCESS(act_fun, data_set) { \
.action_result.status = BT_STATUS_SUCCESS, \
@@ -157,12 +161,6 @@ struct test_data {
pid_t bluetoothd_pid;
};
-struct test_case {
- struct step *step;
- char *title;
- uint16_t step_num;
-};
-
/*
* Struct of data to check within step action.
*/
@@ -197,6 +195,12 @@ struct step {
int set_data_len;
};
+struct test_case {
+ char *title;
+ uint16_t step_num;
+ struct step step[];
+};
+
/* Get, remove test cases API */
struct queue *get_bluetooth_tests(void);
void remove_bluetooth_tests(void);
diff --git a/android/tester-socket.c b/android/tester-socket.c
index 0afab4a..ba283fa 100644
--- a/android/tester-socket.c
+++ b/android/tester-socket.c
@@ -19,14 +19,10 @@
static struct queue *list; /* List of socket test cases */
-static struct step dummy_steps[] = {
+TEST_CASE(socket_init,
+ "Socket Init",
ACTION_SUCCESS(dummy_action, NULL),
-};
-static struct test_case socket_init = {
- .step = dummy_steps,
- .title = "Socket Init",
- .step_num = get_test_case_step_num(dummy_steps),
-};
+);
static struct test_case *test_cases[] = {
&socket_init,
--
1.9.1
---
android/tester-bluetooth.c | 15 +++++++++++++++
android/tester-main.c | 22 +++++++++++++++++++++-
android/tester-main.h | 1 +
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index d65917d..ea59a57 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -329,6 +329,21 @@ static struct test_case test_cases[] = {
&prop_test_scan_mode_none),
CALLBACK_ADAPTER_PROPS(&prop_test_scan_mode_none, 1),
),
+ TEST_CASE("Bluetooth BR/EDR Discovery Start - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ),
+ TEST_CASE("Bluetooth BR/EDR Discovery Start - Done",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_start_discovery_action, NULL),
+ ),
};
struct queue *get_bluetooth_tests(void)
diff --git a/android/tester-main.c b/android/tester-main.c
index 7f52083..eb588d1 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -575,13 +575,23 @@ static void adapter_properties_cb(bt_status_t status, int num_properties,
schedule_callback_call(step);
}
+static void discovery_state_changed_cb(bt_discovery_state_t state)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback = CB_BT_DISCOVERY_STATE_CHANGED;
+ step->callback_result.state = state;
+
+ schedule_callback_call(step);
+}
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
.adapter_properties_cb = adapter_properties_cb,
.remote_device_properties_cb = NULL,
.device_found_cb = NULL,
- .discovery_state_changed_cb = NULL,
+ .discovery_state_changed_cb = discovery_state_changed_cb,
.pin_request_cb = NULL,
.ssp_request_cb = NULL,
.bond_state_changed_cb = NULL,
@@ -933,6 +943,16 @@ void bt_get_property_action(void)
verify_step(&step, NULL);
}
+void bt_start_discovery_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step step;
+
+ step.action_result.status = data->if_bluetooth->start_discovery();
+
+ verify_step(&step, NULL);
+}
+
static void generic_test_function(const void *test_data)
{
struct test_data *data = tester_get_data();
diff --git a/android/tester-main.h b/android/tester-main.h
index 066615a..9e40907 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -217,3 +217,4 @@ void bluetooth_enable_action(void);
void bluetooth_disable_action(void);
void bt_set_property_action(void);
void bt_get_property_action(void);
+void bt_start_discovery_action(void);
--
1.9.1
This is yet another macro that hides the test implementation details and
shortens the amount of code that needs to be written for each test case.
---
android/tester-bluetooth.c | 347 ++++++++++++++++++---------------------------
android/tester-gatt.c | 13 +-
android/tester-hidhost.c | 13 +-
android/tester-main.h | 6 +-
android/tester-socket.c | 13 +-
5 files changed, 158 insertions(+), 234 deletions(-)
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index 86f5e5c..57d6a10 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -19,11 +19,6 @@
static struct queue *list; /* List of bluetooth test cases */
-TEST_CASE(bluetooth_init,
- "Bluetooth Init",
- ACTION_SUCCESS(dummy_action, NULL),
-);
-
static bt_bdaddr_t enable_bdaddr_val = {
.address = { 0x00, 0xaa, 0x01, 0x00, 0x00, 0x00 },
};
@@ -56,29 +51,6 @@ static bt_property_t enable_props[] = {
{ BT_PROPERTY_UUIDS, sizeof(enable_uuids_val), &enable_uuids_val },
};
-TEST_CASE(bluetooth_enable_success_tc,
- "Bluetooth Enable - Success",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_ADAPTER_PROPS(enable_props, 8),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
-);
-
-TEST_CASE(bluetooth_enable_success2_tc,
- "Bluetooth Enable - Success 2",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_ADAPTER_PROPS(enable_props, 8),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
-);
-
-TEST_CASE(bluetooth_disable_success_tc,
- "Bluetooth Disable - Success",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bluetooth_disable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
-);
-
static char test_set_bdname[] = "test_bdname_set";
static bt_property_t setprop_bdname_prop = {
@@ -87,14 +59,6 @@ static bt_property_t setprop_bdname_prop = {
.len = sizeof(test_set_bdname) - 1,
};
-TEST_CASE(bluetooth_setprop_bdname_success_tc,
- "Bluetooth Set BDNAME - Success",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_set_property_action, &setprop_bdname_prop),
- CALLBACK_ADAPTER_PROPS(&setprop_bdname_prop, 1),
-);
-
static bt_scan_mode_t test_setprop_scanmode_val =
BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
@@ -104,14 +68,6 @@ static bt_property_t setprop_scanmode_prop = {
.len = sizeof(bt_scan_mode_t),
};
-TEST_CASE(bluetooth_setprop_scanmode_success_tc,
- "Bluetooth Set SCAN_MODE - Success",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_set_property_action, &setprop_scanmode_prop),
- CALLBACK_ADAPTER_PROPS(&setprop_scanmode_prop, 1),
-);
-
static uint32_t test_setprop_disctimeout_val = 600;
static bt_property_t setprop_disctimeout_prop = {
@@ -120,14 +76,6 @@ static bt_property_t setprop_disctimeout_prop = {
.len = sizeof(test_setprop_disctimeout_val),
};
-TEST_CASE(bluetooth_setprop_disctimeout_success_tc,
- "Bluetooth Set DISCOVERY_TIMEOUT - Success",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_set_property_action, &setprop_disctimeout_prop),
- CALLBACK_ADAPTER_PROPS(&setprop_disctimeout_prop, 1),
-);
-
static bt_bdaddr_t test_getprop_bdaddr_val = {
{0x00, 0xaa, 0x01, 0x00, 0x00, 0x00},
};
@@ -138,14 +86,6 @@ static bt_property_t getprop_bdaddr_prop = {
.len = sizeof(test_getprop_bdaddr_val),
};
-TEST_CASE(bluetooth_getprop_bdaddr_success_tc,
- "Bluetooth Get BDADDR - Success",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action, &getprop_bdaddr_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_bdaddr_prop, 1),
-);
-
static const char test_getprop_bdname_val[] = "BlueZ for Android";
static bt_property_t getprop_bdname_prop = {
@@ -154,14 +94,6 @@ static bt_property_t getprop_bdname_prop = {
.len = sizeof(test_getprop_bdname_val) - 1,
};
-TEST_CASE(bluetooth_getprop_bdname_success_tc,
- "Bluetooth Get BDNAME - Success",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action, &getprop_bdname_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_bdname_prop, 1),
-);
-
static unsigned char setprop_uuids[] = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00,
0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00 };
@@ -172,13 +104,6 @@ static bt_property_t setprop_uuid_prop = {
.len = sizeof(setprop_uuids),
};
-TEST_CASE(bluetooth_setprop_uuid_fail_tc,
- "Bluetooth Set UUID - Fail",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_FAIL(bt_set_property_action, &setprop_uuid_prop),
-);
-
static uint32_t setprop_cod_val = 0;
static bt_property_t setprop_cod_prop = {
@@ -187,13 +112,6 @@ static bt_property_t setprop_cod_prop = {
.len = sizeof(setprop_cod_val),
};
-TEST_CASE(bluetooth_setprop_cod_fail_tc,
- "Bluetooth Set CLASS_OF_DEVICE - Fail",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_FAIL(bt_set_property_action, &setprop_cod_prop),
-);
-
static uint32_t setprop_tod_val = BT_DEVICE_DEVTYPE_DUAL;
static bt_property_t setprop_tod_prop = {
@@ -202,13 +120,6 @@ static bt_property_t setprop_tod_prop = {
.len = sizeof(setprop_tod_val),
};
-TEST_CASE(bluetooth_setprop_tod_fail_tc,
- "Bluetooth Set TYPE_OF_DEVICE - Fail",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_FAIL(bt_set_property_action, &setprop_tod_prop),
-);
-
static int32_t setprop_remote_rssi_val = -9;
static bt_property_t setprop_remote_rssi_prop = {
@@ -217,13 +128,6 @@ static bt_property_t setprop_remote_rssi_prop = {
.len = sizeof(setprop_remote_rssi_val),
};
-TEST_CASE(bluetooth_setprop_remote_rssi_fail_tc,
- "Bluetooth Set REMOTE_RSSI - Fail",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_FAIL(bt_set_property_action, &setprop_remote_rssi_prop),
-);
-
static bt_service_record_t setprop_srvc_record_val = {
.uuid = { {0x00} },
.channel = 12,
@@ -236,13 +140,6 @@ static bt_property_t setprop_srvc_record_prop = {
.len = sizeof(setprop_srvc_record_val),
};
-TEST_CASE(bluetooth_setprop_srvc_record_fail_tc,
- "Bluetooth Set SERVICE_RECORD - Fail",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_FAIL(bt_set_property_action, &setprop_srvc_record_prop),
-);
-
static bt_bdaddr_t setprop_bdaddr_val = {
.address = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
};
@@ -253,13 +150,6 @@ static bt_property_t setprop_bdaddr_prop = {
.len = sizeof(setprop_bdaddr_val),
};
-TEST_CASE(bluetooth_setprop_bdaddr_fail_tc,
- "Bluetooth Set BDADDR - Fail",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_FAIL(bt_set_property_action, &setprop_bdaddr_prop),
-);
-
static bt_bdaddr_t setprop_bonded_dev_val = {
.address = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 },
};
@@ -270,13 +160,6 @@ static bt_property_t setprop_bonded_dev_prop = {
.len = sizeof(setprop_bonded_dev_val),
};
-TEST_CASE(bluetooth_setprop_bonded_dev_fail_tc,
- "Bluetooth Set BONDED_DEVICES - Fail",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_FAIL(bt_set_property_action, &setprop_bonded_dev_prop),
-);
-
static bt_scan_mode_t setprop_scan_mode_conn_val = BT_SCAN_MODE_CONNECTABLE;
static bt_property_t setprop_scan_mode_conn_prop = {
@@ -285,14 +168,6 @@ static bt_property_t setprop_scan_mode_conn_prop = {
.len = sizeof(setprop_scan_mode_conn_val),
};
-TEST_CASE(bluetooth_setprop_scan_mode_conn_success_tc,
- "Bluetooth Set SCAN_MODE_CONNECTABLE - SUCCESS",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_set_property_action, &setprop_scan_mode_conn_prop),
- CALLBACK_ADAPTER_PROPS(&setprop_scan_mode_conn_prop, 1),
-);
-
static uint32_t test_getprop_cod_val = 0x00020c;
static bt_property_t getprop_cod_prop = {
@@ -301,14 +176,6 @@ static bt_property_t getprop_cod_prop = {
.len = sizeof(test_getprop_cod_val),
};
-TEST_CASE(bluetooth_getprop_cod_success_tc,
- "Bluetooth Get CLASS_OF_DEVICE - Success",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action, &getprop_cod_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_cod_prop, 1),
-);
-
static bt_device_type_t test_getprop_tod_val = BT_DEVICE_DEVTYPE_DUAL;
static bt_property_t getprop_tod_prop = {
@@ -317,14 +184,6 @@ static bt_property_t getprop_tod_prop = {
.len = sizeof(test_getprop_tod_val),
};
-TEST_CASE(bluetooth_getprop_tod_success_tc,
- "Bluetooth Get TYPE_OF_DEVICE - Success",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action, &getprop_tod_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_tod_prop, 1),
-);
-
static bt_scan_mode_t test_getprop_scan_mode_val = BT_SCAN_MODE_NONE;
static bt_property_t getprop_scan_mode_prop = {
@@ -333,14 +192,6 @@ static bt_property_t getprop_scan_mode_prop = {
.len = sizeof(test_getprop_scan_mode_val),
};
-TEST_CASE(bluetooth_getprop_scan_mode_success_tc,
- "Bluetooth Get SCAN_MODE - Success",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action, &getprop_scan_mode_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_scan_mode_prop, 1),
-);
-
static uint32_t test_getprop_disc_timeout_val = 120;
static bt_property_t getprop_disc_timeout_prop = {
@@ -349,14 +200,6 @@ static bt_property_t getprop_disc_timeout_prop = {
.len = sizeof(test_getprop_disc_timeout_val),
};
-TEST_CASE(bluetooth_getprop_disc_timeout_success_tc,
- "Bluetooth Get DISCOVERY_TIMEOUT - Success",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action, &getprop_disc_timeout_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_disc_timeout_prop, 1),
-);
-
static const char test_getprop_uuids_val[] = {
/* Multi profile UUID */
0x00, 0x00, 0x11, 0x3b, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
@@ -372,28 +215,12 @@ static bt_property_t getprop_uuids_prop = {
.len = sizeof(test_getprop_uuids_val),
};
-TEST_CASE(bluetooth_getprop_uuids_success_tc,
- "Bluetooth Get BONDED_DEVICES - Success",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action, &getprop_uuids_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_uuids_prop, 1),
-);
-
static bt_property_t getprop_bonded_devs_prop = {
.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
.val = NULL,
.len = 0,
};
-TEST_CASE(bluetooth_getprop_bonded_devs_success_tc,
- "Bluetooth Get BONDED_DEVICES - Success",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action, &getprop_bonded_devs_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_bonded_devs_prop, 1),
-);
-
static bt_scan_mode_t test_setprop_scanmode_val2 = BT_SCAN_MODE_NONE;
static bt_property_t setprop_scan_mode2_prop = {
@@ -402,39 +229,145 @@ static bt_property_t setprop_scan_mode2_prop = {
.len = sizeof(test_setprop_scanmode_val2),
};
-TEST_CASE(bluetooth_setprop_scan_mode2_success_tc,
- "Bluetooth Set SCAN_MODE - Success 2",
- ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_set_property_action, &setprop_scan_mode2_prop),
- CALLBACK_ADAPTER_PROPS(&setprop_scan_mode2_prop, 1),
-);
-
-static struct test_case *test_cases[] = {
- &bluetooth_init,
- &bluetooth_enable_success_tc,
- &bluetooth_enable_success2_tc,
- &bluetooth_disable_success_tc,
- &bluetooth_setprop_bdname_success_tc,
- &bluetooth_setprop_scanmode_success_tc,
- &bluetooth_setprop_disctimeout_success_tc,
- &bluetooth_getprop_bdaddr_success_tc,
- &bluetooth_getprop_bdname_success_tc,
- &bluetooth_setprop_uuid_fail_tc,
- &bluetooth_setprop_cod_fail_tc,
- &bluetooth_setprop_tod_fail_tc,
- &bluetooth_setprop_remote_rssi_fail_tc,
- &bluetooth_setprop_srvc_record_fail_tc,
- &bluetooth_setprop_bdaddr_fail_tc,
- &bluetooth_setprop_bonded_dev_fail_tc,
- &bluetooth_setprop_scan_mode_conn_success_tc,
- &bluetooth_getprop_cod_success_tc,
- &bluetooth_getprop_tod_success_tc,
- &bluetooth_getprop_scan_mode_success_tc,
- &bluetooth_getprop_disc_timeout_success_tc,
- &bluetooth_getprop_uuids_success_tc,
- &bluetooth_getprop_bonded_devs_success_tc,
- &bluetooth_setprop_scan_mode2_success_tc,
+static struct test_case test_cases[] = {
+ TEST_CASE("Bluetooth Init",
+ ACTION_SUCCESS(dummy_action, NULL),
+ ),
+ TEST_CASE("Bluetooth Enable - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_ADAPTER_PROPS(enable_props, 8),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ),
+ TEST_CASE("Bluetooth Enable - Success 2",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_ADAPTER_PROPS(enable_props, 8),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ ),
+ TEST_CASE("Bluetooth Disable - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bluetooth_disable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
+ ),
+ TEST_CASE("Bluetooth Set BDNAME - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_set_property_action, &setprop_bdname_prop),
+ CALLBACK_ADAPTER_PROPS(&setprop_bdname_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Set SCAN_MODE - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_set_property_action, &setprop_scanmode_prop),
+ CALLBACK_ADAPTER_PROPS(&setprop_scanmode_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Set DISCOVERY_TIMEOUT - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_set_property_action,
+ &setprop_disctimeout_prop),
+ CALLBACK_ADAPTER_PROPS(&setprop_disctimeout_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Get BDADDR - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action, &getprop_bdaddr_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_bdaddr_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Get BDNAME - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action, &getprop_bdname_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_bdname_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Set UUID - Fail",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_FAIL(bt_set_property_action, &setprop_uuid_prop),
+ ),
+ TEST_CASE("Bluetooth Set CLASS_OF_DEVICE - Fail",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_FAIL(bt_set_property_action, &setprop_cod_prop),
+ ),
+ TEST_CASE("Bluetooth Set TYPE_OF_DEVICE - Fail",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_FAIL(bt_set_property_action, &setprop_tod_prop),
+ ),
+ TEST_CASE("Bluetooth Set REMOTE_RSSI - Fail",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_FAIL(bt_set_property_action, &setprop_remote_rssi_prop),
+ ),
+ TEST_CASE("Bluetooth Set SERVICE_RECORD - Fail",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_FAIL(bt_set_property_action, &setprop_srvc_record_prop),
+ ),
+ TEST_CASE("Bluetooth Set BDADDR - Fail",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_FAIL(bt_set_property_action, &setprop_bdaddr_prop),
+ ),
+ TEST_CASE("Bluetooth Set SCAN_MODE_CONNECTABLE - SUCCESS",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_set_property_action,
+ &setprop_scan_mode_conn_prop),
+ CALLBACK_ADAPTER_PROPS(&setprop_scan_mode_conn_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Set BONDED_DEVICES - Fail",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_FAIL(bt_set_property_action, &setprop_bonded_dev_prop),
+ ),
+ TEST_CASE("Bluetooth Get CLASS_OF_DEVICE - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action, &getprop_cod_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_cod_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Get TYPE_OF_DEVICE - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action, &getprop_tod_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_tod_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Get SCAN_MODE - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action, &getprop_scan_mode_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_scan_mode_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Get DISCOVERY_TIMEOUT - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action,
+ &getprop_disc_timeout_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_disc_timeout_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Get BONDED_DEVICES - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action, &getprop_uuids_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_uuids_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Get BONDED_DEVICES - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_get_property_action,
+ &getprop_bonded_devs_prop),
+ CALLBACK_ADAPTER_PROPS(&getprop_bonded_devs_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Set SCAN_MODE - Success 2",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_set_property_action,
+ &setprop_scan_mode2_prop),
+ CALLBACK_ADAPTER_PROPS(&setprop_scan_mode2_prop, 1),
+ ),
};
struct queue *get_bluetooth_tests(void)
@@ -444,7 +377,7 @@ struct queue *get_bluetooth_tests(void)
list = queue_new();
for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i)
- if (!queue_push_tail(list, test_cases[i]))
+ if (!queue_push_tail(list, &test_cases[i]))
return NULL;
return list;
diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index 87a11a1..a55fbe0 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
@@ -19,13 +19,10 @@
static struct queue *list; /* List of gatt test cases */
-TEST_CASE(gatt_init,
- "Gatt Init",
- ACTION_SUCCESS(dummy_action, NULL),
-);
-
-static struct test_case *test_cases[] = {
- &gatt_init,
+static struct test_case test_cases[] = {
+ TEST_CASE("Gatt Init",
+ ACTION_SUCCESS(dummy_action, NULL),
+ ),
};
struct queue *get_gatt_tests(void)
@@ -35,7 +32,7 @@ struct queue *get_gatt_tests(void)
list = queue_new();
for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i)
- if (!queue_push_tail(list, test_cases[i]))
+ if (!queue_push_tail(list, &test_cases[i]))
return NULL;
return list;
diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index 6260825..b00a4e9 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -19,13 +19,10 @@
static struct queue *list; /* List of hidhost test cases */
-TEST_CASE(hidhost_init,
- "Hidhost Init",
- ACTION_SUCCESS(dummy_action, NULL),
-);
-
-static struct test_case *test_cases[] = {
- &hidhost_init,
+static struct test_case test_cases[] = {
+ TEST_CASE("Hidhost Init",
+ ACTION_SUCCESS(dummy_action, NULL),
+ ),
};
struct queue *get_hidhost_tests(void)
@@ -35,7 +32,7 @@ struct queue *get_hidhost_tests(void)
list = queue_new();
for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i)
- if (!queue_push_tail(list, test_cases[i]))
+ if (!queue_push_tail(list, &test_cases[i]))
return NULL;
return list;
diff --git a/android/tester-main.h b/android/tester-main.h
index f838831..066615a 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -50,10 +50,10 @@
#include <hardware/bt_gatt_client.h>
#include <hardware/bt_gatt_server.h>
-#define TEST_CASE(decl_name, text, ...) static struct test_case decl_name = { \
+#define TEST_CASE(text, ...) { \
text, \
sizeof((struct step[]) {__VA_ARGS__}) / sizeof(struct step), \
- {__VA_ARGS__}, \
+ (struct step[]) {__VA_ARGS__}, \
}
#define ACTION_SUCCESS(act_fun, data_set) { \
@@ -198,7 +198,7 @@ struct step {
struct test_case {
char *title;
uint16_t step_num;
- struct step step[];
+ const struct step const *step;
};
/* Get, remove test cases API */
diff --git a/android/tester-socket.c b/android/tester-socket.c
index ba283fa..254b539 100644
--- a/android/tester-socket.c
+++ b/android/tester-socket.c
@@ -19,13 +19,10 @@
static struct queue *list; /* List of socket test cases */
-TEST_CASE(socket_init,
- "Socket Init",
- ACTION_SUCCESS(dummy_action, NULL),
-);
-
-static struct test_case *test_cases[] = {
- &socket_init,
+static struct test_case test_cases[] = {
+ TEST_CASE("Socket Init",
+ ACTION_SUCCESS(dummy_action, NULL),
+ ),
};
struct queue *get_socket_tests(void)
@@ -35,7 +32,7 @@ struct queue *get_socket_tests(void)
list = queue_new();
for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i)
- if (!queue_push_tail(list, test_cases[i]))
+ if (!queue_push_tail(list, &test_cases[i]))
return NULL;
return list;
--
1.9.1
This removes old device discovery test cases that were porrted to newer
testing framework.
---
android/android-tester.c | 74 ------------------------------------------------
1 file changed, 74 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index ff14fc8..e17f3ea 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -2163,55 +2163,6 @@ static void test_dummy(const void *test_data)
tester_test_passed();
}
-static void test_discovery_start_success(const void *test_data)
-{
- struct test_data *data = tester_get_data();
- bt_status_t status;
-
- init_test_conditions(data);
-
- status = data->if_bluetooth->start_discovery();
- check_expected_status(status);
-}
-
-static void test_discovery_stop_done(const void *test_data)
-{
- struct test_data *data = tester_get_data();
- bt_status_t status;
-
- init_test_conditions(data);
-
- status = data->if_bluetooth->cancel_discovery();
- check_expected_status(status);
-}
-
-static void test_discovery_stop_success(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_discovery_start_done(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_discovery_device_found(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
static void test_dev_getprops_success(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -3659,31 +3610,6 @@ int main(int argc, char *argv[])
tester_init(&argc, &argv);
- test_bredrle("Bluetooth BR/EDR Discovery Start - Success",
- &bluetooth_discovery_start_success_test,
- setup_enabled_adapter,
- test_discovery_start_success, teardown);
-
- test_bredrle("Bluetooth BR/EDR Discovery Start - Success 2",
- &bluetooth_discovery_start_success2_test,
- setup_enabled_adapter,
- test_discovery_start_done, teardown);
-
- test_bredrle("Bluetooth BR/EDR Discovery Stop - Success",
- &bluetooth_discovery_stop_success_test,
- setup_enabled_adapter,
- test_discovery_stop_success, teardown);
-
- test_bredrle("Bluetooth BR/EDR Discovery Stop - Success 2",
- &bluetooth_discovery_stop_success2_test,
- setup_enabled_adapter,
- test_discovery_stop_done, teardown);
-
- test_bredr("Bluetooth BR/EDR Discovery Device Found",
- &bluetooth_discovery_device_found_test,
- setup_enabled_adapter,
- test_discovery_device_found, teardown);
-
test_bredr("Bluetooth Device Get Props - Success",
&bt_dev_getprops_success_test,
setup_enabled_adapter,
--
1.9.1
---
android/tester-bluetooth.c | 21 +++++++++++++++++++++
android/tester-main.c | 11 +++++++++++
android/tester-main.h | 1 +
3 files changed, 33 insertions(+)
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index ea59a57..fd5837d 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -344,6 +344,27 @@ static struct test_case test_cases[] = {
BT_DISCOVERY_STARTED),
ACTION_SUCCESS(bt_start_discovery_action, NULL),
),
+ TEST_CASE("Bluetooth BR/EDR Discovery Stop - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ),
+ TEST_CASE("Bluetooth BR/EDR Discovery Stop - Done",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_SUCCESS(bt_start_discovery_action, NULL),
+ ),
};
struct queue *get_bluetooth_tests(void)
diff --git a/android/tester-main.c b/android/tester-main.c
index eb588d1..7e2cc09 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -953,6 +953,17 @@ void bt_start_discovery_action(void)
verify_step(&step, NULL);
}
+void bt_cancel_discovery_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step step;
+
+ memset(&step, 0, sizeof(step));
+ step.action_result.status = data->if_bluetooth->cancel_discovery();
+
+ verify_step(&step, NULL);
+}
+
static void generic_test_function(const void *test_data)
{
struct test_data *data = tester_get_data();
diff --git a/android/tester-main.h b/android/tester-main.h
index 9e40907..1e1dd51 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -218,3 +218,4 @@ void bluetooth_disable_action(void);
void bt_set_property_action(void);
void bt_get_property_action(void);
void bt_start_discovery_action(void);
+void bt_cancel_discovery_action(void);
--
1.9.1
This allows to pass additional parameter describing wheter to set
discoverable flag in advertising data.
---
android/android-tester.c | 2 +-
emulator/bthost.c | 22 +++++++++++++++++++++-
emulator/bthost.h | 3 ++-
tools/l2cap-tester.c | 2 +-
tools/mgmt-tester.c | 2 +-
tools/smp-tester.c | 2 +-
6 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index eb5c513..ff14fc8 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -701,7 +701,7 @@ static void setup_powered_emulated_remote(void)
bthost_set_cmd_complete_cb(bthost, emu_connectable_complete, data);
if (data->hciemu_type == HCIEMU_TYPE_LE)
- bthost_set_adv_enable(bthost, 0x01);
+ bthost_set_adv_enable(bthost, 0x01, 0x00);
else
bthost_write_scan_enable(bthost, 0x03);
}
diff --git a/emulator/bthost.c b/emulator/bthost.c
index 298edcf..d86e02b 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -747,6 +747,8 @@ static void evt_cmd_complete(struct bthost *bthost, const void *data,
break;
case BT_HCI_CMD_LE_LTK_REQ_NEG_REPLY:
break;
+ case BT_HCI_CMD_LE_SET_ADV_DATA:
+ break;
default:
printf("Unhandled cmd_complete opcode 0x%04x\n", opcode);
break;
@@ -2072,7 +2074,8 @@ void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan)
send_command(bthost, BT_HCI_CMD_WRITE_SCAN_ENABLE, &scan, 1);
}
-void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable)
+void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable,
+ uint8_t disc_type)
{
struct bt_hci_cmd_le_set_adv_parameters cp;
@@ -2080,6 +2083,23 @@ void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable)
send_command(bthost, BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
&cp, sizeof(cp));
+ if (disc_type) {
+ struct bt_hci_cmd_le_set_adv_data adv_cp;
+
+ memset(adv_cp.data, 0, 31);
+
+ adv_cp.data[0] = 0x02; /* Field length */
+ adv_cp.data[1] = 0x01; /* Flags */
+ adv_cp.data[2] = disc_type;
+
+ adv_cp.data[3] = 0x00; /* Field terminator */
+
+ adv_cp.len = 1 + adv_cp.data[0];
+
+ send_command(bthost, BT_HCI_CMD_LE_SET_ADV_DATA, &adv_cp,
+ sizeof(adv_cp));
+ }
+
send_command(bthost, BT_HCI_CMD_LE_SET_ADV_ENABLE, &enable, 1);
}
diff --git a/emulator/bthost.h b/emulator/bthost.h
index b00bcd6..578e38a 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -70,7 +70,8 @@ bool bthost_l2cap_req(struct bthost *bthost, uint16_t handle, uint8_t req,
void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan);
-void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable);
+void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable,
+ uint8_t disc_type);
void bthost_write_ssp_mode(struct bthost *bthost, uint8_t mode);
diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c
index 79362b2..6841341 100644
--- a/tools/l2cap-tester.c
+++ b/tools/l2cap-tester.c
@@ -535,7 +535,7 @@ static void setup_powered_client_callback(uint8_t status, uint16_t length,
bthost = hciemu_client_get_host(data->hciemu);
bthost_set_cmd_complete_cb(bthost, client_cmd_complete, user_data);
if (data->hciemu_type == HCIEMU_TYPE_LE)
- bthost_set_adv_enable(bthost, 0x01);
+ bthost_set_adv_enable(bthost, 0x01, 0x00);
else
bthost_write_scan_enable(bthost, 0x03);
}
diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index a860228..f559a06 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -2890,7 +2890,7 @@ static void setup_bthost(void)
bthost = hciemu_client_get_host(data->hciemu);
bthost_set_cmd_complete_cb(bthost, client_cmd_complete, data);
if (data->hciemu_type == HCIEMU_TYPE_LE)
- bthost_set_adv_enable(bthost, 0x01);
+ bthost_set_adv_enable(bthost, 0x01, 0x00);
else
bthost_write_scan_enable(bthost, 0x03);
}
diff --git a/tools/smp-tester.c b/tools/smp-tester.c
index 12e0bed..c9639e6 100644
--- a/tools/smp-tester.c
+++ b/tools/smp-tester.c
@@ -411,7 +411,7 @@ static void setup_powered_client_callback(uint8_t status, uint16_t length,
bthost = hciemu_client_get_host(data->hciemu);
bthost_set_cmd_complete_cb(bthost, client_connectable_complete, data);
- bthost_set_adv_enable(bthost, 0x01);
+ bthost_set_adv_enable(bthost, 0x01, 0x00);
}
static void setup_powered_client(const void *test_data)
--
1.9.1
This patch adds first test case that requires remote emulated device to be
discovered. New action step was added to activate this device on demand.
---
android/tester-bluetooth.c | 27 +++++++++++++++++++++
android/tester-main.c | 60 +++++++++++++++++++++++++++++++++++++++++++++-
android/tester-main.h | 9 +++++++
3 files changed, 95 insertions(+), 1 deletion(-)
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index fd5837d..6bc67da 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -83,6 +83,12 @@ static bt_property_t prop_emu_bonded_devs = {
.len = 0,
};
+static uint32_t emu_remote_type_val = BT_DEVICE_DEVTYPE_BLE;
+static int32_t emu_remote_rssi_val = 127;
+static bt_bdaddr_t emu_remote_bdaddr_val = {
+ .address = { 0x00, 0xaa, 0x01, 0x01, 0x00, 0x00 },
+};
+
static bt_property_t prop_emu_default_set[] = {
{ BT_PROPERTY_BDADDR, sizeof(emu_bdaddr_val), NULL },
{ BT_PROPERTY_BDNAME, sizeof(emu_bdname_val) - 1, &emu_bdname_val },
@@ -96,6 +102,15 @@ static bt_property_t prop_emu_default_set[] = {
{ BT_PROPERTY_UUIDS, sizeof(emu_uuids_val), &emu_uuids_val },
};
+static bt_property_t prop_emu_ble_remotes_default_set[] = {
+ { BT_PROPERTY_BDADDR, sizeof(emu_remote_bdaddr_val),
+ &emu_remote_bdaddr_val },
+ { BT_PROPERTY_TYPE_OF_DEVICE, sizeof(emu_remote_type_val),
+ &emu_remote_type_val },
+ { BT_PROPERTY_REMOTE_RSSI, sizeof(emu_remote_rssi_val),
+ &emu_remote_rssi_val },
+};
+
static char test_bdname[] = "test_bdname";
static bt_property_t prop_test_bdname = {
.type = BT_PROPERTY_BDNAME,
@@ -365,6 +380,18 @@ static struct test_case test_cases[] = {
BT_DISCOVERY_STOPPED),
ACTION_SUCCESS(bt_start_discovery_action, NULL),
),
+ TEST_CASE("Bluetooth BR/EDR Discovery Device Found",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
+ ACTION_SUCCESS(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ CALLBACK_DEVICE_FOUND(prop_emu_ble_remotes_default_set, 3),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ),
};
struct queue *get_bluetooth_tests(void)
diff --git a/android/tester-main.c b/android/tester-main.c
index 7e2cc09..5849c0c 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -17,6 +17,9 @@
#include "tester-main.h"
+#include "emulator/bthost.h"
+#include "monitor/bt.h"
+
static char exec_dir[PATH_MAX + 1];
static gint scheduled_cbacks_num;
@@ -585,12 +588,25 @@ static void discovery_state_changed_cb(bt_discovery_state_t state)
schedule_callback_call(step);
}
+static void device_found_cb(int num_properties, bt_property_t *properties)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback_result.num_properties = num_properties;
+ step->callback_result.properties = copy_properties(num_properties,
+ properties);
+
+ step->callback = CB_BT_DEVICE_FOUND;
+
+ schedule_callback_call(step);
+}
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
.adapter_properties_cb = adapter_properties_cb,
.remote_device_properties_cb = NULL,
- .device_found_cb = NULL,
+ .device_found_cb = device_found_cb,
.discovery_state_changed_cb = discovery_state_changed_cb,
.pin_request_cb = NULL,
.ssp_request_cb = NULL,
@@ -867,6 +883,48 @@ static void teardown(const void *test_data)
tester_teardown_complete();
}
+static void emu_connectable_complete(uint16_t opcode, uint8_t status,
+ const void *param, uint8_t len,
+ void *user_data)
+{
+ struct step step;
+
+ switch (opcode) {
+ case BT_HCI_CMD_WRITE_SCAN_ENABLE:
+ case BT_HCI_CMD_LE_SET_ADV_ENABLE:
+ break;
+ default:
+ return;
+ }
+
+ memset(&step, 0, sizeof(step));
+
+ if (status) {
+ tester_warn("Emulated remote setup failed.");
+ step.action_result.status = BT_STATUS_FAIL;
+ } else {
+ tester_warn("Emulated remote setup done.");
+ step.action_result.status = BT_STATUS_SUCCESS;
+ }
+
+ verify_step(&step, NULL);
+}
+
+void emu_setup_powered_remote_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost;
+
+ bthost = hciemu_client_get_host(data->hciemu);
+ bthost_set_cmd_complete_cb(bthost, emu_connectable_complete, data);
+
+ if ((data->hciemu_type == HCIEMU_TYPE_LE) ||
+ (data->hciemu_type == HCIEMU_TYPE_BREDRLE))
+ bthost_set_adv_enable(bthost, 0x01, 0x02);
+ else
+ bthost_write_scan_enable(bthost, 0x03);
+}
+
void dummy_action(void)
{
struct step step;
diff --git a/android/tester-main.h b/android/tester-main.h
index 1e1dd51..3919713 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -79,6 +79,12 @@
.callback_result.num_properties = prop_cnt, \
}
+#define CALLBACK_DEVICE_FOUND(props, prop_cnt) { \
+ .callback = CB_BT_DEVICE_FOUND, \
+ .callback_result.properties = props, \
+ .callback_result.num_properties = prop_cnt, \
+ }
+
/*
* NOTICE:
* Callback enum sections should be
@@ -211,6 +217,9 @@ void remove_hidhost_tests(void);
struct queue *get_gatt_tests(void);
void remove_gatt_tests(void);
+/* Emulator actions */
+void emu_setup_powered_remote_action(void);
+
/* Actions */
void dummy_action(void);
void bluetooth_enable_action(void);
--
1.9.1
This patch abstracts out data from the specific test cases. Every data
that is sent through the hal (i.e. properties) and then the result is
verified is a test data thus uses 'test_prop_<dataname>' convention.
Data that is retrieved from the deamon and is adapter's default settings
use 'emu_prop_<dataname>' notation.
Data name now represents it's content and is no longer bound to specific
test case thus can be reused. Its also easier to actually see what the
test case do without browsing through its data set.
---
android/tester-bluetooth.c | 325 ++++++++++++++++++++-------------------------
1 file changed, 143 insertions(+), 182 deletions(-)
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index 57d6a10..d65917d 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -19,11 +19,23 @@
static struct queue *list; /* List of bluetooth test cases */
-static bt_bdaddr_t enable_bdaddr_val = {
+static bt_bdaddr_t emu_bdaddr_val = {
.address = { 0x00, 0xaa, 0x01, 0x00, 0x00, 0x00 },
};
-static const char enable_bdname_val[] = "BlueZ for Android";
-static const char enable_uuids_val[] = {
+static bt_property_t prop_emu_bdaddr = {
+ .type = BT_PROPERTY_BDADDR,
+ .val = &emu_bdaddr_val,
+ .len = sizeof(emu_bdaddr_val),
+};
+
+static const char emu_bdname_val[] = "BlueZ for Android";
+static bt_property_t prop_emu_bdname = {
+ .type = BT_PROPERTY_BDNAME,
+ .val = &emu_bdname_val,
+ .len = sizeof(emu_bdname_val) - 1,
+};
+
+static const char emu_uuids_val[] = {
/* Multi profile UUID */
0x00, 0x00, 0x11, 0x3b, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB,
@@ -31,202 +43,153 @@ static const char enable_uuids_val[] = {
0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB,
};
-static bt_device_type_t enable_tod_val = BT_DEVICE_DEVTYPE_DUAL;
-static bt_scan_mode_t enable_scanmode_val = BT_SCAN_MODE_NONE;
-static uint32_t enable_disctimeout_val = 120;
-
-static bt_property_t enable_props[] = {
- { BT_PROPERTY_BDADDR, sizeof(enable_bdaddr_val), NULL },
- { BT_PROPERTY_BDNAME, sizeof(enable_bdname_val) - 1,
- &enable_bdname_val },
- { BT_PROPERTY_CLASS_OF_DEVICE, sizeof(uint32_t), NULL },
- { BT_PROPERTY_TYPE_OF_DEVICE, sizeof(enable_tod_val),
- &enable_tod_val },
- { BT_PROPERTY_ADAPTER_SCAN_MODE, sizeof(enable_scanmode_val),
- &enable_scanmode_val },
- { BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
- sizeof(enable_disctimeout_val),
- &enable_disctimeout_val },
- { BT_PROPERTY_ADAPTER_BONDED_DEVICES, 0, NULL },
- { BT_PROPERTY_UUIDS, sizeof(enable_uuids_val), &enable_uuids_val },
+static bt_property_t prop_emu_uuids = {
+ .type = BT_PROPERTY_UUIDS,
+ .val = &emu_uuids_val,
+ .len = sizeof(emu_uuids_val),
};
-static char test_set_bdname[] = "test_bdname_set";
-
-static bt_property_t setprop_bdname_prop = {
- .type = BT_PROPERTY_BDNAME,
- .val = test_set_bdname,
- .len = sizeof(test_set_bdname) - 1,
+static uint32_t emu_cod_val = 0x00020c;
+static bt_property_t prop_emu_cod = {
+ .type = BT_PROPERTY_CLASS_OF_DEVICE,
+ .val = &emu_cod_val,
+ .len = sizeof(emu_cod_val),
};
-static bt_scan_mode_t test_setprop_scanmode_val =
- BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
+static bt_device_type_t emu_tod_val = BT_DEVICE_DEVTYPE_DUAL;
+static bt_property_t prop_emu_tod = {
+ .type = BT_PROPERTY_TYPE_OF_DEVICE,
+ .val = &emu_tod_val,
+ .len = sizeof(emu_tod_val),
+};
-static bt_property_t setprop_scanmode_prop = {
+static bt_scan_mode_t emu_scan_mode_val = BT_SCAN_MODE_NONE;
+static bt_property_t prop_emu_scan_mode = {
.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
- .val = &test_setprop_scanmode_val,
- .len = sizeof(bt_scan_mode_t),
+ .val = &emu_scan_mode_val,
+ .len = sizeof(emu_scan_mode_val),
};
-static uint32_t test_setprop_disctimeout_val = 600;
-
-static bt_property_t setprop_disctimeout_prop = {
+static uint32_t emu_disc_timeout_val = 120;
+static bt_property_t prop_emu_disc_timeout = {
.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
- .val = &test_setprop_disctimeout_val,
- .len = sizeof(test_setprop_disctimeout_val),
+ .val = &emu_disc_timeout_val,
+ .len = sizeof(emu_disc_timeout_val),
};
-static bt_bdaddr_t test_getprop_bdaddr_val = {
- {0x00, 0xaa, 0x01, 0x00, 0x00, 0x00},
+static bt_property_t prop_emu_bonded_devs = {
+ .type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
+ .val = NULL,
+ .len = 0,
};
-static bt_property_t getprop_bdaddr_prop = {
- .type = BT_PROPERTY_BDADDR,
- .val = &test_getprop_bdaddr_val,
- .len = sizeof(test_getprop_bdaddr_val),
+static bt_property_t prop_emu_default_set[] = {
+ { BT_PROPERTY_BDADDR, sizeof(emu_bdaddr_val), NULL },
+ { BT_PROPERTY_BDNAME, sizeof(emu_bdname_val) - 1, &emu_bdname_val },
+ { BT_PROPERTY_CLASS_OF_DEVICE, sizeof(uint32_t), NULL },
+ { BT_PROPERTY_TYPE_OF_DEVICE, sizeof(emu_tod_val), &emu_tod_val },
+ { BT_PROPERTY_ADAPTER_SCAN_MODE, sizeof(emu_scan_mode_val),
+ &emu_scan_mode_val },
+ { BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT, sizeof(emu_disc_timeout_val),
+ &emu_disc_timeout_val},
+ { BT_PROPERTY_ADAPTER_BONDED_DEVICES, 0, NULL },
+ { BT_PROPERTY_UUIDS, sizeof(emu_uuids_val), &emu_uuids_val },
};
-static const char test_getprop_bdname_val[] = "BlueZ for Android";
-
-static bt_property_t getprop_bdname_prop = {
+static char test_bdname[] = "test_bdname";
+static bt_property_t prop_test_bdname = {
.type = BT_PROPERTY_BDNAME,
- .val = &test_getprop_bdname_val,
- .len = sizeof(test_getprop_bdname_val) - 1,
+ .val = test_bdname,
+ .len = sizeof(test_bdname) - 1,
+};
+
+static bt_scan_mode_t test_scan_mode_connectable_discoverable =
+ BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
+static bt_property_t prop_test_scanmode_conn_discov = {
+ .type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+ .val = &test_scan_mode_connectable_discoverable,
+ .len = sizeof(bt_scan_mode_t),
};
-static unsigned char setprop_uuids[] = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00,
+static uint32_t test_disctimeout_val = 600;
+static bt_property_t prop_test_disctimeout = {
+ .type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
+ .val = &test_disctimeout_val,
+ .len = sizeof(test_disctimeout_val),
+};
+
+static unsigned char test_uuids_val[] = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00,
0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00 };
-
-static bt_property_t setprop_uuid_prop = {
+static bt_property_t prop_test_uuid = {
.type = BT_PROPERTY_UUIDS,
- .val = &setprop_uuids,
- .len = sizeof(setprop_uuids),
+ .val = &test_uuids_val,
+ .len = sizeof(test_uuids_val),
};
-static uint32_t setprop_cod_val = 0;
-
-static bt_property_t setprop_cod_prop = {
+static uint32_t test_cod_val = 0;
+static bt_property_t prop_test_cod = {
.type = BT_PROPERTY_CLASS_OF_DEVICE,
- .val = &setprop_cod_val,
- .len = sizeof(setprop_cod_val),
+ .val = &test_cod_val,
+ .len = sizeof(test_cod_val),
};
-static uint32_t setprop_tod_val = BT_DEVICE_DEVTYPE_DUAL;
-
-static bt_property_t setprop_tod_prop = {
+static uint32_t test_tod_val = BT_DEVICE_DEVTYPE_BLE;
+static bt_property_t prop_test_tod = {
.type = BT_PROPERTY_TYPE_OF_DEVICE,
- .val = &setprop_tod_val,
- .len = sizeof(setprop_tod_val),
+ .val = &test_tod_val,
+ .len = sizeof(test_tod_val),
};
-static int32_t setprop_remote_rssi_val = -9;
-
-static bt_property_t setprop_remote_rssi_prop = {
+static int32_t test_remote_rssi_val = -9;
+static bt_property_t prop_test_remote_rssi = {
.type = BT_PROPERTY_REMOTE_RSSI,
- .val = &setprop_remote_rssi_val,
- .len = sizeof(setprop_remote_rssi_val),
+ .val = &test_remote_rssi_val,
+ .len = sizeof(test_remote_rssi_val),
};
-static bt_service_record_t setprop_srvc_record_val = {
+static bt_service_record_t test_srvc_record_val = {
.uuid = { {0x00} },
.channel = 12,
.name = "bt_name",
};
-
-static bt_property_t setprop_srvc_record_prop = {
+static bt_property_t prop_test_srvc_record = {
.type = BT_PROPERTY_SERVICE_RECORD,
- .val = &setprop_srvc_record_val,
- .len = sizeof(setprop_srvc_record_val),
+ .val = &test_srvc_record_val,
+ .len = sizeof(test_srvc_record_val),
};
-static bt_bdaddr_t setprop_bdaddr_val = {
+static bt_bdaddr_t test_bdaddr_val = {
.address = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
};
-
-static bt_property_t setprop_bdaddr_prop = {
+static bt_property_t prop_test_bdaddr = {
.type = BT_PROPERTY_BDADDR,
- .val = &setprop_bdaddr_val,
- .len = sizeof(setprop_bdaddr_val),
-};
-
-static bt_bdaddr_t setprop_bonded_dev_val = {
- .address = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 },
-};
-
-static bt_property_t setprop_bonded_dev_prop = {
- .type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
- .val = &setprop_bonded_dev_val,
- .len = sizeof(setprop_bonded_dev_val),
+ .val = &test_bdaddr_val,
+ .len = sizeof(test_bdaddr_val),
};
static bt_scan_mode_t setprop_scan_mode_conn_val = BT_SCAN_MODE_CONNECTABLE;
-static bt_property_t setprop_scan_mode_conn_prop = {
+static bt_property_t prop_test_scan_mode_conn = {
.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
.val = &setprop_scan_mode_conn_val,
.len = sizeof(setprop_scan_mode_conn_val),
};
-static uint32_t test_getprop_cod_val = 0x00020c;
-
-static bt_property_t getprop_cod_prop = {
- .type = BT_PROPERTY_CLASS_OF_DEVICE,
- .val = &test_getprop_cod_val,
- .len = sizeof(test_getprop_cod_val),
-};
-
-static bt_device_type_t test_getprop_tod_val = BT_DEVICE_DEVTYPE_DUAL;
-
-static bt_property_t getprop_tod_prop = {
- .type = BT_PROPERTY_TYPE_OF_DEVICE,
- .val = &test_getprop_tod_val,
- .len = sizeof(test_getprop_tod_val),
-};
-
-static bt_scan_mode_t test_getprop_scan_mode_val = BT_SCAN_MODE_NONE;
-
-static bt_property_t getprop_scan_mode_prop = {
+static bt_scan_mode_t test_scan_mode_none_val = BT_SCAN_MODE_NONE;
+static bt_property_t prop_test_scan_mode_none = {
.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
- .val = &test_getprop_scan_mode_val,
- .len = sizeof(test_getprop_scan_mode_val),
+ .val = &test_scan_mode_none_val,
+ .len = sizeof(test_scan_mode_none_val),
};
-static uint32_t test_getprop_disc_timeout_val = 120;
-
-static bt_property_t getprop_disc_timeout_prop = {
- .type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
- .val = &test_getprop_disc_timeout_val,
- .len = sizeof(test_getprop_disc_timeout_val),
-};
-
-static const char test_getprop_uuids_val[] = {
- /* Multi profile UUID */
- 0x00, 0x00, 0x11, 0x3b, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
- 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB,
- /* Device identification profile UUID */
- 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
- 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB,
-};
-
-static bt_property_t getprop_uuids_prop = {
- .type = BT_PROPERTY_UUIDS,
- .val = &test_getprop_uuids_val,
- .len = sizeof(test_getprop_uuids_val),
+static bt_bdaddr_t test_bonded_dev_addr_val = {
+ .address = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 },
};
-
-static bt_property_t getprop_bonded_devs_prop = {
+static bt_property_t prop_test_bonded_dev_addr = {
.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
- .val = NULL,
- .len = 0,
-};
-
-static bt_scan_mode_t test_setprop_scanmode_val2 = BT_SCAN_MODE_NONE;
-
-static bt_property_t setprop_scan_mode2_prop = {
- .type = BT_PROPERTY_ADAPTER_SCAN_MODE,
- .val = &test_setprop_scanmode_val2,
- .len = sizeof(test_setprop_scanmode_val2),
+ .val = &test_bonded_dev_addr_val,
+ .len = sizeof(test_bonded_dev_addr_val),
};
static struct test_case test_cases[] = {
@@ -235,12 +198,12 @@ static struct test_case test_cases[] = {
),
TEST_CASE("Bluetooth Enable - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_ADAPTER_PROPS(enable_props, 8),
+ CALLBACK_ADAPTER_PROPS(prop_emu_default_set, 8),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
),
TEST_CASE("Bluetooth Enable - Success 2",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
- CALLBACK_ADAPTER_PROPS(enable_props, 8),
+ CALLBACK_ADAPTER_PROPS(prop_emu_default_set, 8),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bluetooth_enable_action, NULL),
),
@@ -253,120 +216,118 @@ static struct test_case test_cases[] = {
TEST_CASE("Bluetooth Set BDNAME - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_set_property_action, &setprop_bdname_prop),
- CALLBACK_ADAPTER_PROPS(&setprop_bdname_prop, 1),
+ ACTION_SUCCESS(bt_set_property_action, &prop_test_bdname),
+ CALLBACK_ADAPTER_PROPS(&prop_test_bdname, 1),
),
TEST_CASE("Bluetooth Set SCAN_MODE - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_set_property_action, &setprop_scanmode_prop),
- CALLBACK_ADAPTER_PROPS(&setprop_scanmode_prop, 1),
+ ACTION_SUCCESS(bt_set_property_action,
+ &prop_test_scanmode_conn_discov),
+ CALLBACK_ADAPTER_PROPS(&prop_test_scanmode_conn_discov, 1),
),
TEST_CASE("Bluetooth Set DISCOVERY_TIMEOUT - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_set_property_action,
- &setprop_disctimeout_prop),
- CALLBACK_ADAPTER_PROPS(&setprop_disctimeout_prop, 1),
+ ACTION_SUCCESS(bt_set_property_action, &prop_test_disctimeout),
+ CALLBACK_ADAPTER_PROPS(&prop_test_disctimeout, 1),
),
TEST_CASE("Bluetooth Get BDADDR - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action, &getprop_bdaddr_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_bdaddr_prop, 1),
+ ACTION_SUCCESS(bt_get_property_action, &prop_emu_bdaddr),
+ CALLBACK_ADAPTER_PROPS(&prop_emu_bdaddr, 1),
),
TEST_CASE("Bluetooth Get BDNAME - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action, &getprop_bdname_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_bdname_prop, 1),
+ ACTION_SUCCESS(bt_get_property_action, &prop_emu_bdname),
+ CALLBACK_ADAPTER_PROPS(&prop_emu_bdname, 1),
),
TEST_CASE("Bluetooth Set UUID - Fail",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_FAIL(bt_set_property_action, &setprop_uuid_prop),
+ ACTION_FAIL(bt_set_property_action, &prop_test_uuid),
),
TEST_CASE("Bluetooth Set CLASS_OF_DEVICE - Fail",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_FAIL(bt_set_property_action, &setprop_cod_prop),
+ ACTION_FAIL(bt_set_property_action, &prop_test_cod),
),
TEST_CASE("Bluetooth Set TYPE_OF_DEVICE - Fail",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_FAIL(bt_set_property_action, &setprop_tod_prop),
+ ACTION_FAIL(bt_set_property_action, &prop_test_tod),
),
TEST_CASE("Bluetooth Set REMOTE_RSSI - Fail",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_FAIL(bt_set_property_action, &setprop_remote_rssi_prop),
+ ACTION_FAIL(bt_set_property_action, &prop_test_remote_rssi),
),
TEST_CASE("Bluetooth Set SERVICE_RECORD - Fail",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_FAIL(bt_set_property_action, &setprop_srvc_record_prop),
+ ACTION_FAIL(bt_set_property_action, &prop_test_srvc_record),
),
TEST_CASE("Bluetooth Set BDADDR - Fail",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_FAIL(bt_set_property_action, &setprop_bdaddr_prop),
+ ACTION_FAIL(bt_set_property_action, &prop_test_bdaddr),
),
TEST_CASE("Bluetooth Set SCAN_MODE_CONNECTABLE - SUCCESS",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_set_property_action,
- &setprop_scan_mode_conn_prop),
- CALLBACK_ADAPTER_PROPS(&setprop_scan_mode_conn_prop, 1),
+ &prop_test_scan_mode_conn),
+ CALLBACK_ADAPTER_PROPS(&prop_test_scan_mode_conn, 1),
),
TEST_CASE("Bluetooth Set BONDED_DEVICES - Fail",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_FAIL(bt_set_property_action, &setprop_bonded_dev_prop),
+ ACTION_FAIL(bt_set_property_action, &prop_test_bonded_dev_addr),
),
TEST_CASE("Bluetooth Get CLASS_OF_DEVICE - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action, &getprop_cod_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_cod_prop, 1),
+ ACTION_SUCCESS(bt_get_property_action, &prop_emu_cod),
+ CALLBACK_ADAPTER_PROPS(&prop_emu_cod, 1),
),
TEST_CASE("Bluetooth Get TYPE_OF_DEVICE - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action, &getprop_tod_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_tod_prop, 1),
+ ACTION_SUCCESS(bt_get_property_action, &prop_emu_tod),
+ CALLBACK_ADAPTER_PROPS(&prop_emu_tod, 1),
),
TEST_CASE("Bluetooth Get SCAN_MODE - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action, &getprop_scan_mode_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_scan_mode_prop, 1),
+ ACTION_SUCCESS(bt_get_property_action, &prop_emu_scan_mode),
+ CALLBACK_ADAPTER_PROPS(&prop_emu_scan_mode, 1),
),
TEST_CASE("Bluetooth Get DISCOVERY_TIMEOUT - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action,
- &getprop_disc_timeout_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_disc_timeout_prop, 1),
+ ACTION_SUCCESS(bt_get_property_action, &prop_emu_disc_timeout),
+ CALLBACK_ADAPTER_PROPS(&prop_emu_disc_timeout, 1),
),
- TEST_CASE("Bluetooth Get BONDED_DEVICES - Success",
+ TEST_CASE("Bluetooth Get UUIDS - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action, &getprop_uuids_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_uuids_prop, 1),
+ ACTION_SUCCESS(bt_get_property_action, &prop_emu_uuids),
+ CALLBACK_ADAPTER_PROPS(&prop_emu_uuids, 1),
),
TEST_CASE("Bluetooth Get BONDED_DEVICES - Success",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
- ACTION_SUCCESS(bt_get_property_action,
- &getprop_bonded_devs_prop),
- CALLBACK_ADAPTER_PROPS(&getprop_bonded_devs_prop, 1),
+ ACTION_SUCCESS(bt_get_property_action, &prop_emu_bonded_devs),
+ CALLBACK_ADAPTER_PROPS(&prop_emu_bonded_devs, 1),
),
TEST_CASE("Bluetooth Set SCAN_MODE - Success 2",
ACTION_SUCCESS(bluetooth_enable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
ACTION_SUCCESS(bt_set_property_action,
- &setprop_scan_mode2_prop),
- CALLBACK_ADAPTER_PROPS(&setprop_scan_mode2_prop, 1),
+ &prop_test_scan_mode_none),
+ CALLBACK_ADAPTER_PROPS(&prop_test_scan_mode_none, 1),
),
};
--
1.9.1