Apply tizen 3.0 based product patchsets
[platform/core/connectivity/bluetooth-frwk.git] / test / bluetooth-frwk-test.c
index efbfb61..ea4dba1 100644 (file)
@@ -23,9 +23,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <glib.h>
-#include <dbus/dbus-glib.h>
+#include <gio/gio.h>
 #include <pthread.h>
-#include <dbus/dbus.h>
+#include <stdint.h>
 
 #include "bluetooth-api.h"
 #include "bluetooth-hid-api.h"
@@ -274,7 +274,14 @@ int test_input_callback(void *data)
        int ret = 0;
        int test_id;
 
+#ifdef ARCH64
+       test_id = find_tc_number((uintptr_t)data);
+#else
        test_id = find_tc_number((int)data);
+#endif
+       if (test_id == -1)
+               return 0;
+
        TC_PRT("TC : %s[%d]", tc_table[test_id].tc_name, tc_table[test_id].tc_code);
 
        switch (tc_table[test_id].tc_code) {
@@ -284,7 +291,7 @@ int test_input_callback(void *data)
                break;
 
        case 1:
-               bluetooth_register_callback(bt_event_callback, NULL);
+               ret = bluetooth_register_callback(bt_event_callback, NULL);
                if (ret < 0) {
                        TC_PRT("%s failed with [0x%04x]", tc_table[0].tc_name, ret);
                        tc_result(TC_FAIL, 1);
@@ -292,7 +299,7 @@ int test_input_callback(void *data)
                break;
 
        case 2:
-               bluetooth_unregister_callback();
+               ret = bluetooth_unregister_callback();
                if (ret < 0) {
                        TC_PRT("%s failed with [0x%04x]", tc_table[1].tc_name, ret);
                        tc_result(TC_FAIL, 1);
@@ -555,7 +562,7 @@ int test_input_callback(void *data)
                ret = bluetooth_authorize_device(&device_address, FALSE);
                if (ret < 0)
                        TC_PRT("%s failed with [0x%04x]", tc_table[23].tc_name, ret);
-                       break;
+               break;
        }
        case 25:
        {
@@ -777,6 +784,7 @@ int test_input_callback(void *data)
                TC_PRT("randomizer_len: %d\n", g_local_oob_data.oob_data.randomizer_len);
 
                if (bluetooth_oob_add_remote_data(&g_local_oob_data.address,
+                       BLUETOOTH_BDADDR_BREDR,
                        &g_local_oob_data.oob_data))
                        TC_PRT("ERROR in bluetooth_oob_add_remote_data\n");
                else
@@ -1160,6 +1168,8 @@ int test_input_callback(void *data)
 
                TC_PRT("service obj_path is %s", svc_obj_path);
 
+               g_free(service_uuid);
+
                break;
        }
 
@@ -1178,19 +1188,20 @@ int test_input_callback(void *data)
                        perms, props, &char_obj_path);
 
                TC_PRT("characteristic obj_path is %s", char_obj_path);
-
+               g_free(char_uuid);
                break;
        }
 
        case 96: {
                char *desc_uuid = g_strdup("000026ff-0000-1000-8000-00805f9b34fb");
                bt_gatt_permission_t perms = BLUETOOTH_GATT_PERMISSION_READ |
-                               BLUETOOTH_GATT_PERMISSION_WRITE;
+                       BLUETOOTH_GATT_PERMISSION_WRITE;
 
                ret = bluetooth_gatt_add_descriptor(char_obj_path,
-                       desc_uuid, perms, &desc_obj_path);
-               TC_PRT("add descriptor error is %d", ret);
+                               desc_uuid, perms, &desc_obj_path);
 
+               TC_PRT("add descriptor error is %d", ret);
+               g_free(desc_uuid);
                break;
        }
 
@@ -1243,8 +1254,6 @@ void startup()
 {
        TC_PRT("bluetooth framework TC startup");
 
-       dbus_threads_init_default();
-
        main_loop = g_main_loop_new(NULL, FALSE);
 }
 
@@ -1749,9 +1758,13 @@ void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_dat
 
 static gboolean key_event_cb(GIOChannel * chan, GIOCondition cond , gpointer data)
 {
-       char buf[10] = {0};
+       char buf[49] = {0};
 
+#ifdef ARCH64
+       unsigned long len = 0;
+#else
        unsigned int len = 0;
+#endif
        int test_id;
        memset(buf, 0, sizeof(buf));
 
@@ -1766,8 +1779,11 @@ static gboolean key_event_cb(GIOChannel * chan, GIOCondition cond , gpointer dat
 
        test_id = atoi(buf);
 
-       if (test_id)
-               g_idle_add(test_input_callback, (void*)test_id);
+#ifdef ARCH64
+       g_idle_add(test_input_callback, (void *)(uintptr_t)test_id);
+#else
+       g_idle_add(test_input_callback, (void *)test_id);
+#endif
 
        return TRUE;
 }