diff --git a/android/android-tester.c b/android/android-tester.c
index 0b9624d..69bccca 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
struct generic_data {
uint8_t expected_adapter_status;
uint32_t expect_settings_set;
+ bt_property_t expected_property;
uint8_t expected_hal_callbacks[];
};
bool mgmt_settings_set;
bool hal_cb_called;
bool status_checked;
+ bool property_checked;
+ bt_property_t test_property;
GSList *expected_callbacks;
};
return;
if (!(data->status_checked))
return;
+ if (!(data->property_checked))
+ return;
tester_test_passed();
}
data->status_checked = true;
}
+static void test_property_init(struct test_data *data)
+{
+ const struct generic_data *test_data = data->test_data;
+
+ if (!(test_data->expected_property.type))
+ data->property_checked = true;
+}
+
static void init_test_conditions(struct test_data *data)
{
hal_cb_init(data);
mgmt_cb_init(data);
expected_status_init(data);
+ test_property_init(data);
}
static void check_expected_status(uint8_t status)
test_update_state();
}
+static void check_test_property(void)
+{
+ struct test_data *data = tester_get_data();
+ bt_property_t expected_prop = data->test_property;
+ const struct generic_data *test_data = data->test_data;
+ bt_property_t test_prop = test_data->expected_property;
+
+ if (test_prop.type && (expected_prop.type != test_prop.type)) {
+ tester_test_failed();
+ return;
+ }
+
+ if (test_prop.len && (expected_prop.len != test_prop.len)) {
+ tester_test_failed();
+ return;
+ }
+
+ if (test_prop.val && memcmp(expected_prop.val, test_prop.val,
+ expected_prop.len)) {
+ tester_test_failed();
+ return;
+ }
+
+ data->property_checked = true;
+ test_update_state();
+}
+
static int get_expected_hal_cb(void)
{
struct test_data *data = tester_get_data();
bt_property_t *properties)
{
enum hal_bluetooth_callbacks_id hal_cb;
+ struct test_data *data = tester_get_data();
int i;
for (i = 0; i < num_properties; i++) {
if (hal_cb == adapter_test_setup_mode)
break;
+ data->test_property = *properties;
+
+ if (g_slist_next(data->expected_callbacks) ==
+ adapter_test_end)
+ check_test_property();
+
switch (properties[i].type) {
case BT_PROPERTY_BDADDR:
if (hal_cb != adapter_prop_bdaddr)
.expected_hal_callbacks = {adapter_state_changed_off, adapter_test_end}
};
+static const struct generic_data bluetooth_setprop_bdname_success_test = {
+ .expected_hal_callbacks = {adapter_prop_bdname, adapter_test_end},
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+ .expected_property.type = BT_PROPERTY_BDNAME,
+ .expected_property.val = "test_bdname",
+ .expected_property.len = 11
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
close(sock_fd);
}
+static void test_setprop_bdname_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+
+ check_expected_status(adapter_status);
+}
+
#define test_bredrle(name, data, test_setup, test, test_teardown) \
do { \
struct test_data *user; \
test_bredrle("Test Disable - Success", &bluetooth_disable_success_test,
setup_enabled_adapter, test_disable, teardown);
+ test_bredrle("Test Set BDNAME - Success",
+ &bluetooth_setprop_bdname_success_test,
+ setup_enabled_adapter,
+ test_setprop_bdname_success, teardown);
+
test_bredrle("Test Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);