tizen 2.3 release
[framework/api/bluetooth.git] / TC / testcase / utc_network_bluetooth_audio_positive.c
old mode 100644 (file)
new mode 100755 (executable)
similarity index 81%
rename from mobile/TC/testcase/utc_network_bluetooth_audio_positive.c
rename to TC/testcase/utc_network_bluetooth_audio_positive.c
index 1f7c6a5..d1fffbc
@@ -9,6 +9,8 @@
 #include <bluetooth.h>
 #include <glib.h>
 
+#define CONFIG_FILE_PATH "/opt/home/capi-network-bluetooth/tetware.conf"
+
 enum {
        POSITIVE_TC_IDX = 0x01,
        NEGATIVE_TC_IDX,
@@ -20,7 +22,7 @@ static void cleanup(void);
 void (*tet_startup) (void) = startup;
 void (*tet_cleanup) (void) = cleanup;
 
-char target_address[18] = "";
+char *remote_address;
 static GMainLoop *mainloop;
 
 static void utc_network_bluetooth_audio_initialize_p(void);
@@ -50,6 +52,8 @@ static void utc_network_bluetooth_ag_set_multi_call_handling_event_cb_p(void);
 static void utc_network_bluetooth_ag_unset_multi_call_handling_event_cb_p(void);
 static void utc_network_bluetooth_ag_set_dtmf_transmitted_cb_p(void);
 static void utc_network_bluetooth_ag_unset_dtmf_transmitted_cb_p(void);
+static void utc_network_bluetooth_ag_set_vendor_cmd_cb_p(void);
+static void utc_network_bluetooth_ag_unset_vendor_cmd_cb_p(void);
 static void utc_network_bluetooth_ag_call_list_create_p(void);
 static void utc_network_bluetooth_ag_call_list_destroy_p(void);
 static void utc_network_bluetooth_ag_call_list_reset_p(void);
@@ -86,7 +90,10 @@ struct tet_testlist tet_testlist[] = {
        {utc_network_bluetooth_ag_unset_microphone_gain_changed_p, POSITIVE_TC_IDX},
        {utc_network_bluetooth_ag_unset_speaker_gain_changed_p, POSITIVE_TC_IDX},
        {utc_network_bluetooth_ag_set_sco_state_changed_p, POSITIVE_TC_IDX},
+       {utc_network_bluetooth_ag_set_vendor_cmd_cb_p, POSITIVE_TC_IDX},
+       {utc_network_bluetooth_ag_unset_vendor_cmd_cb_p, POSITIVE_TC_IDX},
        {utc_network_bluetooth_ag_is_sco_opened_p, POSITIVE_TC_IDX},
+       {utc_network_bluetooth_ag_close_sco_p, POSITIVE_TC_IDX},
        {utc_network_bluetooth_ag_notify_call_event_p, POSITIVE_TC_IDX},
        {utc_network_bluetooth_ag_notify_call_list_p, POSITIVE_TC_IDX},
        {utc_network_bluetooth_ag_notify_voice_recognition_state_p, POSITIVE_TC_IDX},
@@ -96,7 +103,6 @@ struct tet_testlist tet_testlist[] = {
        {utc_network_bluetooth_ag_unset_multi_call_handling_event_cb_p, POSITIVE_TC_IDX},
        {utc_network_bluetooth_ag_set_dtmf_transmitted_cb_p, POSITIVE_TC_IDX},
        {utc_network_bluetooth_ag_unset_dtmf_transmitted_cb_p, POSITIVE_TC_IDX},
-       {utc_network_bluetooth_ag_close_sco_p, POSITIVE_TC_IDX},
        {utc_network_bluetooth_ag_unset_sco_state_changed_p, POSITIVE_TC_IDX},
        {utc_network_bluetooth_ag_call_list_create_p, POSITIVE_TC_IDX},
        {utc_network_bluetooth_ag_call_list_destroy_p, POSITIVE_TC_IDX},
@@ -109,11 +115,51 @@ struct tet_testlist tet_testlist[] = {
        {NULL, 0},
 };
 
+int get_value_from_file(void)
+{
+       FILE *fp;
+       char *token;
+       char buf[100];
+
+       fp = fopen(CONFIG_FILE_PATH, "r");
+       if (fp == NULL) {
+               tet_printf("Default configuration is used\n");
+               return -1;
+       }
+       while (fgets(buf, sizeof(buf), fp)) {
+               if (buf[0] == '#' || buf[0] == '\n')
+                       continue;
+
+               token = strrchr(buf, '\n');
+               if (token == NULL) {
+                       tet_printf("g_conf is too long\n");
+                       break;
+               }
+               *token = '\0';
+
+               token = strtok(buf, "=");
+               if (token == NULL) {
+                       continue;
+               }
+               if (strcasecmp(token, "BT_ADDR_HEADSET") == 0) {
+                       token = strtok(NULL, "=");
+                       remote_address = strdup(token);
+                       fclose(fp);
+                       return 0;
+               }
+       }
+       return -1;
+}
+
 static void startup(void)
 {
        bt_error_e ret = BT_ERROR_NONE;
        int timeout_id = 0;
 
+       if(get_value_from_file() == -1) {
+               tet_printf("Failed to read.");
+       }
+
        /* start of TC */
        tet_printf("TC start.");
        mainloop = g_main_loop_new(NULL, FALSE);
@@ -161,16 +207,16 @@ gboolean timeout_func(gpointer data)
  */
 
 void adapter_state_changed_cb_for_audio_p(int result,
-                                         bt_adapter_state_e adapter_state,
-                                         void *user_data)
+                                       bt_adapter_state_e adapter_state,
+                                       void *user_data)
 {
 
 }
 
 void connection_state_changed_cb_for_audio_p(int result, bool connected,
-                                            const char *remote_address,
-                                            bt_audio_profile_type_e type,
-                                            void *user_data)
+                                               const char *remote_address,
+                                               bt_audio_profile_type_e type,
+                                               void *user_data)
 {
 
 }
@@ -191,7 +237,7 @@ void sco_state_changed_cb_for_ag_p(int result, bool opened, void *user_data)
 }
 
 void call_handling_event_cb_for_ag_p(bt_ag_call_handling_event_e event,
-                                    unsigned int call_id, void *user_data)
+                               unsigned int call_id, void *user_data)
 {
 
 }
@@ -206,6 +252,12 @@ void dtmf_transmitted_cb_for_ag_p(const char *dtmf, void *user_data)
 
 }
 
+void vendor_cmd_event_cb_for_ag_p(char *cmd, void *user_data)
+{
+       tet_printf("Callback : vendor_cmd_cb was called.");
+       tet_printf("Vendor Command[%s]", cmd);
+}
+
 /**
  * @brief Positive test case of bt_audio_initialize()
  */
@@ -215,7 +267,7 @@ static void utc_network_bluetooth_audio_initialize_p(void)
 
        ret = bt_audio_initialize();
        dts_check_eq("bt_audio_initialize", ret, BT_ERROR_NONE,
-                    "bt_audio_initialize() failed. %x", ret);
+                       "bt_audio_initialize() failed. %x", ret);
 
 }
 
@@ -228,7 +280,7 @@ static void utc_network_bluetooth_audio_connect_p(void)
        const char *remote_address = "00:23:78:AB:C4:20";
        ret = bt_audio_connect(remote_address, BT_AUDIO_PROFILE_TYPE_HSP_HFP);
        dts_check_eq("bt_audio_connect", ret, BT_ERROR_NONE,
-                    "bt_audio_connect() failed. %x", ret);
+                       "bt_audio_connect() failed. %x", ret);
 }
 
 /**
@@ -237,10 +289,9 @@ static void utc_network_bluetooth_audio_connect_p(void)
 static void utc_network_bluetooth_audio_disconnect_p(void)
 {
        int ret = BT_ERROR_NONE;
-       const char *remote_address = "00:23:78:AB:C4:20";
-       ret = bt_audio_disconnect(remote_address, BT_AUDIO_PROFILE_TYPE_A2DP);
+       ret = bt_audio_disconnect(remote_address, BT_AUDIO_PROFILE_TYPE_HSP_HFP);
        dts_check_eq("bt_audio_disconnect", ret, BT_ERROR_NONE,
-                    "bt_audio_disconnect() failed. %x", ret);
+                       "bt_audio_disconnect() failed. %x", ret);
 }
 
 /**
@@ -249,12 +300,11 @@ static void utc_network_bluetooth_audio_disconnect_p(void)
 static void utc_network_bluetooth_audio_set_connection_p(void)
 {
        int ret = BT_ERROR_NONE;
-       ret =
-           bt_audio_set_connection_state_changed_cb
-           (connection_state_changed_cb_for_audio_p, NULL);
+       ret = bt_audio_set_connection_state_changed_cb
+               (connection_state_changed_cb_for_audio_p, NULL);
        dts_check_eq("bt_audio_set_connection_state_changed_cb", ret,
-                    BT_ERROR_NONE,
-                    "bt_audio_set_connection_state_changed_cb() failed.");
+                       BT_ERROR_NONE,
+                       "bt_audio_set_connection_state_changed_cb() failed.");
 }
 
 /**
@@ -265,8 +315,8 @@ static void utc_network_bluetooth_audio_unset_connection_p(void)
        int ret = BT_ERROR_NONE;
        ret = bt_audio_unset_connection_state_changed_cb();
        dts_check_eq("bt_audio_set_connection_state_changed_cb", ret,
-                    BT_ERROR_NONE,
-                    "bt_audio_set_connection_state_changed_cb() failed.");
+                       BT_ERROR_NONE,
+                       "bt_audio_set_connection_state_changed_cb() failed.");
 }
 
 /**
@@ -278,7 +328,7 @@ static void utc_network_bluetooth_ag_notify_speaker_gain_p(void)
        int gain = 10;
        ret = bt_ag_notify_speaker_gain(gain);
        dts_check_eq("bt_ag_notify_speaker_gain", ret, BT_ERROR_NONE,
-                    "bt_ag_notify_speaker_gain() failed.%x", ret);
+                       "bt_ag_notify_speaker_gain() failed.%x", ret);
 }
 
 /**
@@ -290,7 +340,7 @@ static void utc_network_bluetooth_ag_get_speaker_gain_p(void)
        int gain = 0;
        ret = bt_ag_get_speaker_gain(&gain);
        dts_check_eq("bt_ag_get_speaker_gain", ret, BT_ERROR_NONE,
-                    "bt_ag_get_speaker_gain() failed.");
+                       "bt_ag_get_speaker_gain() failed.");
 
 }
 
@@ -303,7 +353,7 @@ static void utc_network_bluetooth_ag_is_nrec_enabled_p(void)
        bool enabled = 1;
        ret = bt_ag_is_nrec_enabled(&enabled);
        dts_check_eq("bt_ag_is_nrec_enabled", ret, BT_ERROR_NONE,
-                    "bt_ag_is_nrec_enabled() failed.");
+                       "bt_ag_is_nrec_enabled() failed.");
 
 }
 
@@ -315,7 +365,7 @@ static void utc_network_bluetooth_ag_set_microphone_gain_changed_p(void)
        int ret = BT_ERROR_NONE;
        ret = bt_ag_set_microphone_gain_changed_cb(microphone_gain_changed_cb_for_ag_p, NULL);
        dts_check_eq("bt_ag_set_microphone_gain_changed_cb", ret, BT_ERROR_NONE,
-                    "bt_ag_set_microphone_gain_changed_cb() failed.");
+                       "bt_ag_set_microphone_gain_changed_cb() failed.");
 
 }
 
@@ -327,8 +377,8 @@ static void utc_network_bluetooth_ag_unset_microphone_gain_changed_p(void)
        int ret = BT_ERROR_NONE;
        ret = bt_ag_unset_microphone_gain_changed_cb();
        dts_check_eq("bt_ag_unset_microphone_gain_changed_cb", ret,
-                    BT_ERROR_NONE,
-                    "bt_ag_unset_microphone_gain_changed_cb() failed.");
+                       BT_ERROR_NONE,
+                       "bt_ag_unset_microphone_gain_changed_cb() failed.");
 
 }
 
@@ -340,7 +390,7 @@ static void utc_network_bluetooth_ag_set_speaker_gain_changed_p(void)
        int ret = BT_ERROR_NONE;
        ret = bt_ag_set_speaker_gain_changed_cb(speaker_gain_changed_cb_for_ag_p, NULL);
        dts_check_eq("bt_ag_set_speaker_gain_changed_cb", ret, BT_ERROR_NONE,
-                    "bt_ag_set_speaker_gain_changed_cb() failed.");
+                       "bt_ag_set_speaker_gain_changed_cb() failed.");
 
 }
 
@@ -352,7 +402,7 @@ static void utc_network_bluetooth_ag_unset_speaker_gain_changed_p(void)
        int ret = BT_ERROR_NONE;
        ret = bt_ag_unset_speaker_gain_changed_cb();
        dts_check_eq("bt_ag_unset_speaker_gain_changed_cb", ret, BT_ERROR_NONE,
-                    "bt_ag_unset_speaker_gain_changed_cb() failed.");
+                       "bt_ag_unset_speaker_gain_changed_cb() failed.");
 
 }
 
@@ -364,7 +414,7 @@ static void utc_network_bluetooth_ag_open_sco_p(void)
        int ret = BT_ERROR_NONE;
        ret = bt_ag_open_sco();
        dts_check_eq("bt_ag_open_sco", ret, BT_ERROR_NONE,
-                    "bt_ag_open_sco() failed.");
+                       "bt_ag_open_sco() failed.");
 
 }
 
@@ -376,7 +426,7 @@ static void utc_network_bluetooth_ag_close_sco_p(void)
        int ret = BT_ERROR_NONE;
        ret = bt_ag_close_sco();
        dts_check_eq("bt_ag_close_sco", ret, BT_ERROR_NONE,
-                    "bt_ag_close_sco() failed.");
+                       "bt_ag_close_sco() failed.");
 
 }
 
@@ -389,7 +439,7 @@ static void utc_network_bluetooth_ag_is_sco_opened_p(void)
        bool opened = 1;
        ret = bt_ag_is_sco_opened(&opened);
        dts_check_eq("bt_ag_is_sco_opened", ret, BT_ERROR_NONE,
-                    "bt_ag_is_sco_opened() failed.");
+                       "bt_ag_is_sco_opened() failed.");
 
 }
 
@@ -401,7 +451,7 @@ static void utc_network_bluetooth_ag_set_sco_state_changed_p(void)
        int ret = BT_ERROR_NONE;
        ret = bt_ag_set_sco_state_changed_cb(sco_state_changed_cb_for_ag_p, NULL);
        dts_check_eq("bt_ag_set_sco_state_changed_cb", ret, BT_ERROR_NONE,
-                    "bt_ag_set_sco_state_changed_cb() failed.");
+                       "bt_ag_set_sco_state_changed_cb() failed.");
 
 }
 
@@ -413,7 +463,7 @@ static void utc_network_bluetooth_ag_unset_sco_state_changed_p(void)
        int ret = BT_ERROR_NONE;
        ret = bt_ag_unset_sco_state_changed_cb();
        dts_check_eq("bt_ag_unset_sco_state_changed_cb", ret, BT_ERROR_NONE,
-                    "bt_ag_unset_sco_state_changed_cb() failed.");
+                       "bt_ag_unset_sco_state_changed_cb() failed.");
 
 }
 
@@ -426,9 +476,9 @@ static void utc_network_bluetooth_ag_notify_call_event_p(void)
        const char *phone_number = "9663868998";
        unsigned int call_id = 0;
        ret = bt_ag_notify_call_event(BT_AG_CALL_EVENT_INCOMING,
-                                     call_id, phone_number);
+                               call_id, phone_number);
        dts_check_eq("bt_ag_notify_call_event", ret, BT_ERROR_NONE,
-                    "bt_ag_notify_call_event() failed.");
+                               "bt_ag_notify_call_event() failed.");
 
 }
 
@@ -439,11 +489,13 @@ static void utc_network_bluetooth_ag_notify_call_list_p(void)
 {
        int ret = BT_ERROR_NONE;
        bt_call_list_h handle;
+       const char *phone_number = "9663868998";
+
        handle = g_malloc0(sizeof(bt_call_list_h));
-       bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE);
+       bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE, phone_number);
        ret = bt_ag_notify_call_list(handle);
        dts_check_eq("bt_ag_notify_call_list", ret, BT_ERROR_NONE,
-                    "bt_ag_notify_call_list() failed.");
+                               "bt_ag_notify_call_list() failed.");
 
 }
 
@@ -453,11 +505,11 @@ static void utc_network_bluetooth_ag_notify_call_list_p(void)
 static void utc_network_bluetooth_ag_notify_voice_recognition_state_p(void)
 {
        int ret = BT_ERROR_NONE;
-       bool state = true;
+       bool state = 1;
 
        ret = bt_ag_notify_voice_recognition_state(state);
        dts_check_eq("bt_ag_notify_voice_recognition_state", ret, BT_ERROR_NONE,
-                    "bt_ag_notify_voice_recognition_state() failed.");
+                               "bt_ag_notify_voice_recognition_state() failed.");
 
 }
 
@@ -468,9 +520,9 @@ static void utc_network_bluetooth_ag_set_call_handling_event_cb_p(void)
 {
        int ret = BT_ERROR_NONE;
        ret = bt_ag_set_call_handling_event_cb(call_handling_event_cb_for_ag_p,
-                                              NULL);
+                               NULL);
        dts_check_eq("bt_ag_set_call_handling_event_cb", ret, BT_ERROR_NONE,
-                    "bt_ag_set_call_handling_event_cb() failed.");
+                               "bt_ag_set_call_handling_event_cb() failed.");
 
 }
 
@@ -482,7 +534,7 @@ static void utc_network_bluetooth_ag_unset_call_handling_event_cb_p(void)
        int ret = BT_ERROR_NONE;
        ret = bt_ag_unset_call_handling_event_cb();
        dts_check_eq("bt_ag_unset_call_handling_event_cb", ret, BT_ERROR_NONE,
-                    "bt_ag_unset_call_handling_event_cb() failed.");
+                               "bt_ag_unset_call_handling_event_cb() failed.");
 
 }
 
@@ -494,8 +546,8 @@ static void utc_network_bluetooth_ag_set_multi_call_handling_event_cb_p(void)
        int ret = BT_ERROR_NONE;
        ret = bt_ag_set_multi_call_handling_event_cb(multi_call_handling_event_cb_for_ag_p, NULL);
        dts_check_eq("bt_ag_set_multi_call_handling_event_cb", ret,
-                    BT_ERROR_NONE,
-                    "bt_ag_set_multi_call_handling_event_cb() failed.");
+                       BT_ERROR_NONE,
+                       "bt_ag_set_multi_call_handling_event_cb() failed.");
 
 }
 
@@ -507,8 +559,8 @@ static void utc_network_bluetooth_ag_unset_multi_call_handling_event_cb_p(void)
        int ret = BT_ERROR_NONE;
        ret = bt_ag_unset_multi_call_handling_event_cb();
        dts_check_eq("bt_ag_unset_multi_call_handling_event_cb", ret,
-                    BT_ERROR_NONE,
-                    "bt_ag_unset_multi_call_handling_event_cb() failed.");
+                       BT_ERROR_NONE,
+                       "bt_ag_unset_multi_call_handling_event_cb() failed.");
 
 }
 
@@ -520,7 +572,7 @@ static void utc_network_bluetooth_ag_set_dtmf_transmitted_cb_p(void)
        int ret = BT_ERROR_NONE;
        ret = bt_ag_set_dtmf_transmitted_cb(dtmf_transmitted_cb_for_ag_p, NULL);
        dts_check_eq("bt_ag_set_dtmf_transmitted_cb", ret, BT_ERROR_NONE,
-                    "bt_ag_set_dtmf_transmitted_cb() failed.");
+                       "bt_ag_set_dtmf_transmitted_cb() failed.");
 
 }
 
@@ -532,7 +584,7 @@ static void utc_network_bluetooth_ag_unset_dtmf_transmitted_cb_p(void)
        int ret = BT_ERROR_NONE;
        ret = bt_ag_unset_dtmf_transmitted_cb();
        dts_check_eq("bt_ag_unset_dtmf_transmitted_cb", ret, BT_ERROR_NONE,
-                    "bt_ag_unset_dtmf_transmitted_cb() failed.");
+                       "bt_ag_unset_dtmf_transmitted_cb() failed.");
 
 }
 
@@ -543,11 +595,13 @@ static void utc_network_bluetooth_ag_call_list_create_p(void)
 {
        int ret = BT_ERROR_NONE;
        bt_call_list_h handle;
-       handle = g_malloc0(sizeof(bt_call_list_h));
-       bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE);
+       const char *phone_number = "9663868998";
+
        ret = bt_call_list_create(&handle);
+       ret = bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE, phone_number);
+
        dts_check_eq("bt_call_list_create", ret, BT_ERROR_NONE,
-                    "bt_call_list_create() failed.");
+                       "bt_call_list_create() failed.");
 }
 
 /**
@@ -557,11 +611,13 @@ static void utc_network_bluetooth_ag_call_list_destroy_p(void)
 {
        int ret = BT_ERROR_NONE;
        bt_call_list_h handle;
+       const char *phone_number = "9663868998";
+
        handle = g_malloc0(sizeof(bt_call_list_h));
-       bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE);
+       bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE, phone_number);
        ret = bt_call_list_destroy(handle);
        dts_check_eq("bt_call_list_destroy", ret, BT_ERROR_NONE,
-                    "bt_call_list_destroy() failed.");
+                       "bt_call_list_destroy() failed.");
 }
 
 /**
@@ -571,11 +627,13 @@ static void utc_network_bluetooth_ag_call_list_reset_p(void)
 {
        int ret = BT_ERROR_NONE;
        bt_call_list_h handle;
+       const char *phone_number = "9663868998";
+
        handle = g_malloc0(sizeof(bt_call_list_h));
-       bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE);
+       bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE, phone_number);
        ret = bt_call_list_reset(handle);
        dts_check_eq("bt_call_list_reset", ret, BT_ERROR_NONE,
-                    "bt_call_list_reset() failed.");
+                       "bt_call_list_reset() failed.");
 }
 
 /**
@@ -586,23 +644,13 @@ static void utc_network_bluetooth_ag_call_list_add_p(void)
        int ret = BT_ERROR_NONE;
        unsigned int call_id = 0;
        bt_call_list_h handle;
+       const char *phone_number = "9663868998";
+
        handle = g_malloc0(sizeof(bt_call_list_h));
-       bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE);
-       ret = bt_call_list_add(handle, call_id, BT_AG_CALL_STATE_INCOMING);
+       bt_call_list_add(handle, 1, BT_AG_CALL_STATE_ACTIVE, phone_number);
+       ret = bt_call_list_add(handle, call_id, BT_AG_CALL_STATE_INCOMING, phone_number);
        dts_check_eq("bt_call_list_add", ret, BT_ERROR_NONE,
-                    "bt_call_list_add() failed.");
-}
-
-/**
- * @brief Positive test case of bt_a2dp_set_content_protection()
- */
-static void utc_network_bluetooth_ag_ca2dp_set_content_protection_p(void)
-{
-       int ret = BT_ERROR_NONE;
-       bool status = true;
-       ret = bt_a2dp_set_content_protection(status);
-       dts_check_eq("bt_a2dp_set_content_protection", ret, BT_ERROR_NONE,
-                    "bt_a2dp_set_content_protection() failed.");
+                       "bt_call_list_add() failed.");
 }
 
 /**
@@ -614,5 +662,5 @@ static void utc_network_bluetooth_audio_deinitialize_p(void)
 
        ret = bt_audio_deinitialize();
        dts_check_eq("bt_audio_deinitialize", ret, BT_ERROR_NONE,
-                    "bt_audio_deinitialize() failed.");
+                       "bt_audio_deinitialize() failed.");
 }