Add test for device profile trust 45/223345/1
authorAnupam Roy <anupam.r@samsung.com>
Thu, 23 Jan 2020 08:05:01 +0000 (17:05 +0900)
committerAnupam Roy <anupam.r@samsung.com>
Wed, 29 Jan 2020 02:42:25 +0000 (11:42 +0900)
This patch will enable/disable trust for
HFP HF and A2DP SINK profiles(for remote device)

Change-Id: I42fcb1ff65c7d0412f23868c61e014c564e464ec
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
include/bluetooth_type_internal.h
test/bt_unit_test.c
test/bt_unit_test.h

index 24fefba..82feedb 100644 (file)
@@ -688,6 +688,8 @@ typedef enum {
        BT_TRUSTED_PROFILE_PBAP = 1,
        BT_TRUSTED_PROFILE_MAP,
        BT_TRUSTED_PROFILE_SAP,
+       BT_TRUSTED_PROFILE_HFP_HF,
+       BT_TRUSTED_PROFILE_A2DP,
        BT_TRUSTED_PROFILE_ALL = 0xFFFFFFFF,
 } bt_trusted_profile_t;
 
index 7ff1449..abf2ec4 100644 (file)
@@ -413,6 +413,18 @@ tc_table_t tc_device[] = {
                , BT_UNIT_TEST_FUNCTION_LE_DEVICE_DATA_LENGTH_CHANGED_CB},
        {"Select this menu to set parameters and then select the function again."
                , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS},
+       {"bt_device_set_profile_trusted_A2DP(true)"
+               , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_TRUE},
+       {"bt_device_set_profile_trusted_A2DP(false)"
+               , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_FALSE},
+       {"bt_device_set_profile_trusted_HFP_HF(true)"
+               , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_TRUE},
+       {"bt_device_set_profile_trusted_HFP_HF(false)"
+               , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_FALSE},
+       {"bt_device_set_trusted_profile_cb"
+               , BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_CB},
+       {"bt_device_unset_trusted_profile_cb"
+               , BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_PROFILE_TRUSTED_CB},
        {NULL                                   , 0x0000},
 };
 
@@ -2138,6 +2150,17 @@ void __bt_device_authorization_changed_cb(bt_device_authorization_e authorizatio
        TC_PRT("address: %s", remote_address);
 }
 
+void __bt_device_profile_trusted_cb(int result, char *remote_address,
+               int trusted_profile, bool supported,
+               bool trusted, void *user_data)
+{
+       TC_PRT("result [%s]", __bt_get_error_message(result));
+       TC_PRT("trusted profile [%d]", trusted_profile);
+       TC_PRT("Is supported [%d]", supported);
+       TC_PRT("Is trusted [%d]", trusted);
+       TC_PRT("address: %s", remote_address);
+}
+
 void __bt_device_connection_state_changed_cb(bool connected,
                bt_device_connection_info_s *conn_info, void *user_data)
 {
@@ -5419,6 +5442,35 @@ int test_input_callback(void *data)
 
        case BT_UNIT_TEST_TABLE_DEVICE: {
                switch (test_id) {
+               case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_TRUE: {
+                       ret = bt_device_set_profile_trusted(remote_addr, BT_TRUSTED_PROFILE_A2DP, TRUE);
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_FALSE: {
+                       ret = bt_device_set_profile_trusted(remote_addr, BT_TRUSTED_PROFILE_A2DP, FALSE);
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_TRUE: {
+                       ret = bt_device_set_profile_trusted(remote_addr, BT_TRUSTED_PROFILE_HFP_HF, TRUE);
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_FALSE: {
+                       ret = bt_device_set_profile_trusted(remote_addr, BT_TRUSTED_PROFILE_HFP_HF, FALSE);
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       break;
+               }
+               case BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_CB:
+                       ret = bt_device_set_trusted_profile_cb(
+                               __bt_device_profile_trusted_cb, NULL);
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       break;
+               case BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_PROFILE_TRUSTED_CB:
+                       ret = bt_device_unset_trusted_profile_cb();
+                       TC_PRT("returns %s\n", __bt_get_error_message(ret));
+                       break;
                case BT_UNIT_TEST_FUNCTION_DEVICE_SET_AUTHORIZATION_TRUE: {
                        ret = bt_device_set_authorization(remote_addr, BT_DEVICE_AUTHORIZED);
                        TC_PRT("returns %s\n", __bt_get_error_message(ret));
index ad51ed1..e932fbf 100644 (file)
@@ -172,6 +172,12 @@ typedef enum {
        BT_UNIT_TEST_FUNCTION_DEVICE_GET_ATT_MTU,
        BT_UNIT_TEST_FUNCTION_LE_DEVICE_SET_DATA_LENGTH,
        BT_UNIT_TEST_FUNCTION_LE_DEVICE_DATA_LENGTH_CHANGED_CB,
+       BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_TRUE,
+       BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_A2DP_FALSE,
+       BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_TRUE,
+       BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_HFP_FALSE,
+       BT_UNIT_TEST_FUNCTION_DEVICE_SET_PROFILE_TRUSTED_CB,
+       BT_UNIT_TEST_FUNCTION_DEVICE_UNSET_PROFILE_TRUSTED_CB,
        BT_UNIT_TEST_FUNCTION_SOCKET_CREATE_RFCOMM = 1,
        BT_UNIT_TEST_FUNCTION_SOCKET_DESTROY_RFCOMM,
        BT_UNIT_TEST_FUNCTION_SOCKET_LISTEN_AND_ACCEPT_RFCOMM,