Add new unit tests 38/293038/1
authorManika Shrivastava <manika.sh@samsung.com>
Thu, 18 May 2023 07:01:00 +0000 (12:31 +0530)
committerManika Shrivastava <manika.sh@samsung.com>
Thu, 18 May 2023 10:26:32 +0000 (15:56 +0530)
This patch adds UTCs for following apis:
bt_adapter_le_set_advertising_flags
bt_adapter_le_add_advertising_custom_name
bt_adapter_le_remove_advertising_custom_name

Change-Id: Ifd28b08a6b31eac885d30f1e360f43f446a77b43
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
tests/unittest/tct-bluetooth-core_mobile.h
tests/unittest/utc_bluetooth_adapter_negative.c
tests/unittest/utc_bluetooth_adapter_positive.c

index c179f88bceea029bfc731a9870b2a09de036214f..d5e21954665ab392019aecbb56bdb778403fb681 100644 (file)
@@ -122,9 +122,12 @@ extern int utc_bluetooth_bt_adapter_le_get_scan_result_manufacturer_data_n(void)
 extern int utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_n(void);
 extern int utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_n(void);
 extern int utc_bluetooth_bt_adapter_le_add_advertising_service_data_n(void);
+extern int utc_bluetooth_bt_adapter_le_set_advertising_flags_n(void);
 extern int utc_bluetooth_bt_adapter_le_set_advertising_appearance_n(void);
 extern int utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_n(void);
 extern int utc_bluetooth_bt_adapter_le_set_advertising_device_name_n(void);
+extern int utc_bluetooth_bt_adapter_le_add_advertising_custom_name_n(void);
+extern int utc_bluetooth_bt_adapter_le_remove_advertising_custom_name_n(void);
 extern int utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_n(void);
 extern int utc_bluetooth_bt_adapter_le_start_advertising_new_n(void);
 extern int utc_bluetooth_bt_adapter_le_set_advertising_mode_n(void);
@@ -180,9 +183,12 @@ extern int utc_bluetooth_bt_adapter_le_stop_scan_p(void);
 extern int utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_p(void);
 extern int utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_p(void);
 extern int utc_bluetooth_bt_adapter_le_add_advertising_service_data_p(void);
+extern int utc_bluetooth_bt_adapter_le_set_advertising_flags_p(void);
 extern int utc_bluetooth_bt_adapter_le_set_advertising_appearance_p(void);
 extern int utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_p(void);
 extern int utc_bluetooth_bt_adapter_le_set_advertising_device_name_p(void);
+extern int utc_bluetooth_bt_adapter_le_add_advertising_custom_name_p(void);
+extern int utc_bluetooth_bt_adapter_le_remove_advertising_custom_name_p(void);
 extern int utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_p(void);
 extern int utc_bluetooth_bt_adapter_le_start_advertising_new_p(void);
 extern int utc_bluetooth_bt_adapter_le_set_advertising_mode_p(void);
@@ -712,9 +718,12 @@ testcase tc_array[] = {
        {"utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_n",utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup},
        {"utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_n",utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup},
        {"utc_bluetooth_bt_adapter_le_add_advertising_service_data_n",utc_bluetooth_bt_adapter_le_add_advertising_service_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup},
+       {"utc_bluetooth_bt_adapter_le_set_advertising_flags_n",utc_bluetooth_bt_adapter_le_set_advertising_flags_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup},
        {"utc_bluetooth_bt_adapter_le_set_advertising_appearance_n",utc_bluetooth_bt_adapter_le_set_advertising_appearance_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup},
        {"utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_n",utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup},
        {"utc_bluetooth_bt_adapter_le_set_advertising_device_name_n",utc_bluetooth_bt_adapter_le_set_advertising_device_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup},
+       {"utc_bluetooth_bt_adapter_le_add_advertising_custom_name_n",utc_bluetooth_bt_adapter_le_add_advertising_custom_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup},
+       {"utc_bluetooth_bt_adapter_le_remove_advertising_custom_name_n",utc_bluetooth_bt_adapter_le_remove_advertising_custom_name_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup},
        {"utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_n",utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup},
        {"utc_bluetooth_bt_adapter_le_start_advertising_new_n",utc_bluetooth_bt_adapter_le_start_advertising_new_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup},
        {"utc_bluetooth_bt_adapter_le_set_advertising_mode_n",utc_bluetooth_bt_adapter_le_set_advertising_mode_n,utc_bluetooth_adapter_negative_startup,utc_bluetooth_adapter_negative_cleanup},
@@ -770,9 +779,12 @@ testcase tc_array[] = {
        {"utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_p",utc_bluetooth_bt_adapter_le_add_advertising_service_uuid_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup},
        {"utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_p",utc_bluetooth_bt_adapter_le_add_advertising_service_solicitation_uuid_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup},
        {"utc_bluetooth_bt_adapter_le_add_advertising_service_data_p",utc_bluetooth_bt_adapter_le_add_advertising_service_data_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup},
+       {"utc_bluetooth_bt_adapter_le_set_advertising_flags_p",utc_bluetooth_bt_adapter_le_set_advertising_flags_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup},
        {"utc_bluetooth_bt_adapter_le_set_advertising_appearance_p",utc_bluetooth_bt_adapter_le_set_advertising_appearance_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup},
        {"utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_p",utc_bluetooth_bt_adapter_le_add_advertising_manufacturer_data_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup},
        {"utc_bluetooth_bt_adapter_le_set_advertising_device_name_p",utc_bluetooth_bt_adapter_le_set_advertising_device_name_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup},
+       {"utc_bluetooth_bt_adapter_le_add_advertising_custom_name_p",utc_bluetooth_bt_adapter_le_add_advertising_custom_name_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup},
+       {"utc_bluetooth_bt_adapter_le_remove_advertising_custom_name_p",utc_bluetooth_bt_adapter_le_remove_advertising_custom_name_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup},
        {"utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_p",utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup},
        {"utc_bluetooth_bt_adapter_le_start_advertising_new_p",utc_bluetooth_bt_adapter_le_start_advertising_new_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup},
        {"utc_bluetooth_bt_adapter_le_set_advertising_mode_p",utc_bluetooth_bt_adapter_le_set_advertising_mode_p,utc_bluetooth_adapter_positive_startup,utc_bluetooth_adapter_positive_cleanup},
index a1b18d33249afc400fbbf6f71a9b1445faefdf68..7c6797e428b487a4f48dc62d340f74f9301d8ed4 100644 (file)
@@ -15,6 +15,7 @@
 //
 #include "assert_local.h"
 #include <bluetooth.h>
+#include <bluetooth_internal.h>
 #include <stdlib.h>
 #include <stdbool.h>
 #include <glib.h>
@@ -1227,6 +1228,30 @@ int utc_bluetooth_bt_adapter_le_add_advertising_service_data_n(void)
        return 0;
 }
 
+/**
+* @testcase            utc_bluetooth_bt_adapter_le_set_advertising_flags_n
+* @since_tizen         7.5
+* @description         Call to set the advertising flags of local device to advertise or scan response data with
+*                                      "NULL" advertiser parameter and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is
+*                                      supported otherwise just try to set the advertising flags of this device to advertise or scan response
+*                                      data with "NULL"advertiser parameter and check the "ret" flag with BT_ERROR_NOT_SUPPORTED.
+* @scenario            Negative scenario to set the advertising flags of local device to advertise with "NULL" parameter.
+*/
+int utc_bluetooth_bt_adapter_le_set_advertising_flags_n(void)
+{
+       if (le_supported) {
+               assert_eq(startup_flag, BT_ERROR_NONE);
+
+               ret = bt_adapter_le_set_advertising_flags(NULL, BT_ADAPTER_LE_ADVERTISING_FLAGS_GEN_DISC);
+               assert_eq(ret, BT_ERROR_INVALID_PARAMETER);
+       } else {
+               ret = bt_adapter_le_set_advertising_flags(NULL, BT_ADAPTER_LE_ADVERTISING_FLAGS_GEN_DISC);
+               assert_eq(ret, BT_ERROR_NOT_SUPPORTED);
+       }
+
+       return 0;
+}
+
 /**
 * @testcase            utc_bluetooth_bt_adapter_le_set_advertising_appearance_n
 * @since_tizen         2.3
@@ -1299,6 +1324,55 @@ int utc_bluetooth_bt_adapter_le_set_advertising_device_name_n(void)
        return 0;
 }
 
+/**
+* @testcase            utc_bluetooth_bt_adapter_le_add_advertising_custom_name_n
+* @since_tizen         7.5
+* @description         Call to set the custom name in advertising data or scan response data with "NULL"
+*                                      parameters and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported
+*                                      otherwise just try to set the custom name in advertising data or scan response data with
+*                                      "NULL" parameters and check the "ret" flag with BT_ERROR_NOT_SUPPORTED.
+* @scenario            Negative scenario to set the custom name in advertising data or scan response data with "NULL" parameters.
+*/
+int utc_bluetooth_bt_adapter_le_add_advertising_custom_name_n(void)
+{
+       if (le_supported) {
+               assert_eq(startup_flag, BT_ERROR_NONE);
+
+               ret = bt_adapter_le_add_advertising_custom_name(NULL, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, NULL, 0);
+               assert_eq(ret, BT_ERROR_INVALID_PARAMETER);
+       } else {
+               ret = bt_adapter_le_add_advertising_custom_name(NULL, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, NULL, 0);
+               assert_eq(ret, BT_ERROR_NOT_SUPPORTED);
+       }
+
+       return 0;
+}
+
+/**
+* @testcase            utc_bluetooth_bt_adapter_le_remove_advertising_custom_name_n
+* @since_tizen         7.5
+* @description         Call to add custom name and then remove the custom name in advertising data or scan response data with "NULL"
+*                                      parameters and check the "ret" flag with BT_ERROR_INVALID_PARAMETER if le is supported
+*                                      otherwise just try to remove the custom name in advertising data or scan response data with
+*                                      "NULL" parameters and check the "ret" flag with BT_ERROR_NOT_SUPPORTED.
+* @scenario            Negative scenario to remove the custom name in advertising data or scan response data with "NULL" parameters.
+*/
+int utc_bluetooth_bt_adapter_le_remove_advertising_custom_name_n(void)
+{
+       if (le_supported) {
+               assert_eq(startup_flag, BT_ERROR_NONE);
+
+               bt_adapter_le_add_advertising_custom_name(NULL, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, "1st custom name", strlen("1st custom name"));
+               ret = bt_adapter_le_remove_advertising_custom_name(NULL, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE);
+               assert_eq(ret, BT_ERROR_INVALID_PARAMETER);
+       } else {
+               ret = bt_adapter_le_remove_advertising_custom_name(NULL, BT_ADAPTER_LE_PACKET_SCAN_RESPONSE);
+               assert_eq(ret, BT_ERROR_NOT_SUPPORTED);
+       }
+
+       return 0;
+}
+
 /**
 * @testcase            utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_n
 * @since_tizen         2.3
index 23b41f4aa62744b14c00275a416244cda0c1faf3..d7d76986ba42892eb42e6c36e8261c668113a961 100644 (file)
@@ -15,6 +15,7 @@
 //
 #include "assert_local.h"
 #include <bluetooth.h>
+#include <bluetooth_internal.h>
 #include <stdlib.h>
 #include <stdbool.h>
 #include <glib.h>
@@ -951,6 +952,43 @@ int utc_bluetooth_bt_adapter_le_add_advertising_service_data_p(void)
        return 0;
 }
 
+/**
+* @testcase            utc_bluetooth_bt_adapter_le_set_advertising_flags_p
+* @since_tizen         7.5
+* @description         Does assert check for "startup_flag", create advertiser to advertise device's
+*                                      existence then sets the advertising flags of local device to advertise
+*                                      then clear the advertsing data and destroy the advertiser if le is supported otherwise
+*                                      sets the advertising flags of local device to advertise and clear the advertising data.
+* @scenario            Call to set advertising flags of local device to advertise.
+*/
+int utc_bluetooth_bt_adapter_le_set_advertising_flags_p(void)
+{
+       bt_advertiser_h advertiser = NULL;
+       bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_SCAN_RESPONSE;
+
+       if (le_supported) {
+               assert_eq(startup_flag, BT_ERROR_NONE);
+               ret = bt_adapter_le_create_advertiser(&advertiser);
+               assert_eq(ret, BT_ERROR_NONE);
+
+               ret = bt_adapter_le_set_advertising_flags(advertiser, BT_ADAPTER_LE_ADVERTISING_FLAGS_GEN_DISC);
+               assert_eq(ret, BT_ERROR_NONE);
+               if (ret == BT_ERROR_NONE) {
+                       bt_adapter_le_clear_advertising_data(advertiser, pkt_type);
+                       bt_adapter_le_destroy_advertiser(advertiser);
+               }
+       } else {
+               ret = bt_adapter_le_set_advertising_flags(advertiser, BT_ADAPTER_LE_ADVERTISING_FLAGS_GEN_DISC);
+               if (ret == BT_ERROR_NONE) {
+                       bt_adapter_le_clear_advertising_data(advertiser, pkt_type);
+               }
+
+               assert_eq(ret, BT_ERROR_NOT_SUPPORTED);
+       }
+
+       return 0;
+}
+
 /**
 * @testcase            utc_bluetooth_bt_adapter_le_set_advertising_appearance_p
 * @since_tizen         2.3
@@ -1058,6 +1096,71 @@ int utc_bluetooth_bt_adapter_le_set_advertising_device_name_p(void)
        return 0;
 }
 
+/**
+* @testcase            utc_bluetooth_bt_adapter_le_add_advertising_custom_name_p
+* @since_tizen         7.5
+* @description         Does assert check for "startup_flag", create advertiser to advertise device's
+*                                      existence then add custom name to advertise
+*                                      and then destroy the advertiser if le is supported otherwise
+*                                      just add custom name to advertising data.
+* @scenario            Call to add custom name to advertise.
+*/
+int utc_bluetooth_bt_adapter_le_add_advertising_custom_name_p(void)
+{
+       bt_advertiser_h advertiser = NULL;
+       bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_SCAN_RESPONSE;
+
+       if (le_supported) {
+               assert_eq(startup_flag, BT_ERROR_NONE);
+               ret = bt_adapter_le_create_advertiser(&advertiser);
+               assert_eq(ret, BT_ERROR_NONE);
+
+               ret = bt_adapter_le_add_advertising_custom_name(advertiser, pkt_type, "1st custom name", strlen("1st custom name"));
+               assert_eq(ret, BT_ERROR_NONE);
+               if (ret == BT_ERROR_NONE) {
+                       bt_adapter_le_destroy_advertiser(advertiser);
+               }
+       } else {
+               ret = bt_adapter_le_add_advertising_custom_name(advertiser, pkt_type, "1st custom name", strlen("1st custom name"));
+               assert_eq(ret, BT_ERROR_NOT_SUPPORTED);
+       }
+
+       return 0;
+}
+
+/**
+* @testcase            utc_bluetooth_bt_adapter_le_remove_advertising_custom_name_p
+* @since_tizen         7.5
+* @description         Does assert check for "startup_flag", create advertiser to advertise device's
+*                                      existence then add custom name and then remove custom name to advertise
+*                                      and then destroy the advertiser if le is supported otherwise
+*                                      just remove custom name to advertising data.
+* @scenario            Call to remove custom name to advertise.
+*/
+int utc_bluetooth_bt_adapter_le_remove_advertising_custom_name_p(void)
+{
+       bt_advertiser_h advertiser = NULL;
+       bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_SCAN_RESPONSE;
+
+       if (le_supported) {
+               assert_eq(startup_flag, BT_ERROR_NONE);
+               ret = bt_adapter_le_create_advertiser(&advertiser);
+               assert_eq(ret, BT_ERROR_NONE);
+
+               bt_adapter_le_add_advertising_custom_name(advertiser, pkt_type, "1st custom name", strlen("1st custom name"));
+               ret = bt_adapter_le_remove_advertising_custom_name(advertiser, pkt_type);
+               assert_eq(ret, BT_ERROR_NONE);
+               if (ret == BT_ERROR_NONE) {
+                       bt_adapter_le_destroy_advertiser(advertiser);
+               }
+       } else {
+               ret = bt_adapter_le_remove_advertising_custom_name(advertiser, pkt_type);
+               assert_eq(ret, BT_ERROR_NOT_SUPPORTED);
+       }
+
+       return 0;
+}
+
 /**
 * @testcase            utc_bluetooth_bt_adapter_le_set_advertising_tx_power_level_p
 * @since_tizen         2.3