X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git;a=blobdiff_plain;f=droute%2Fdroute-test.c;h=1865622ffb17368adef150b2b4c77a5350043444;hp=8b3fb7c9b838be45cd9a8aae58ea4db15872ef1b;hb=dd563f2f65b447454cae7c39943470af72fc7a25;hpb=dc745797c46af3dcf093e75ef0758d8cc433427f diff --git a/droute/droute-test.c b/droute/droute-test.c index 8b3fb7c..1865622 100644 --- a/droute/droute-test.c +++ b/droute/droute-test.c @@ -1,10 +1,10 @@ #include +#include #include #include #include -#include -#include "dbus/dbus-glib-lowlevel.h" +#include "atspi/atspi.h" #define TEST_OBJECT_PATH "/test/object" #define TEST_INTERFACE_ONE "test.interface.One" @@ -13,10 +13,6 @@ #define OBJECT_ONE "ObjectOne"; #define OBJECT_TWO "ObjectTwo"; -#if !defined TEST_INTROSPECTION_DIRECTORY - #error "No introspection XML directory defined" -#endif - #define STRING_ONE "StringOne" #define STRING_TWO "StringTwo" @@ -25,6 +21,40 @@ #define NONE_REPLY_STRING "NoneMethod" +const gchar *test_interface_One = \ +"" +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +""; + +const gchar *test_interface_Two = \ +"" +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +""; + typedef struct _AnObject { gchar *astring; @@ -155,11 +185,39 @@ static DRouteProperty test_properties[] = { {NULL, NULL, NULL} }; +static void +set_reply (DBusPendingCall *pending, void *user_data) +{ + void **replyptr = (void **)user_data; + + *replyptr = dbus_pending_call_steal_reply (pending); +} + +static DBusMessage * +send_and_allow_reentry (DBusConnection *bus, DBusMessage *message, DBusError *error) +{ + DBusPendingCall *pending; + DBusMessage *reply = NULL; + + if (!dbus_connection_send_with_reply (bus, message, &pending, -1)) + { + return NULL; + } + dbus_pending_call_set_notify (pending, set_reply, (void *)&reply, NULL); + while (!reply) + { + if (!dbus_connection_read_write_dispatch (bus, -1)) + return NULL; + } + return reply; +} + gboolean do_tests_func (gpointer data) { DBusError error; const gchar *bus_name; + DBusMessage *message, *reply; gchar *expected_string; gchar *result_string; @@ -169,30 +227,33 @@ do_tests_func (gpointer data) /* --------------------------------------------------------*/ - dbind_method_call_reentrant (bus, - bus_name, - TEST_OBJECT_PATH, - TEST_INTERFACE_ONE, - "null", - NULL, - ""); + message = dbus_message_new_method_call (bus_name, + TEST_OBJECT_PATH, + TEST_INTERFACE_ONE, + "null"); + reply = send_and_allow_reentry (bus, message, NULL); + dbus_message_unref (message); + if (reply) + dbus_message_unref (reply); /* --------------------------------------------------------*/ expected_string = TEST_INTERFACE_ONE; result_string = NULL; - dbind_method_call_reentrant (bus, - bus_name, - TEST_OBJECT_PATH, - TEST_INTERFACE_ONE, - "getInterfaceOne", - NULL, - "=>s", - &result_string); + message = dbus_message_new_method_call (bus_name, + TEST_OBJECT_PATH, + TEST_INTERFACE_ONE, + "getInterfaceOne"); + reply = send_and_allow_reentry (bus, message, NULL); + dbus_message_unref (message); + dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &result_string, + DBUS_TYPE_INVALID); + dbus_message_unref (reply); if (g_strcmp0(expected_string, result_string)) { - g_print ("Failed: reply to getInterfaceOne not as expected\n"); - goto out; + g_print ("Failed: reply to getInterfaceOne was %s; expected %s\n", + result_string, expected_string); + exit (1); } /* --------------------------------------------------------*/ @@ -219,23 +280,27 @@ int main (int argc, char **argv) dbus_error_init (&error); main_loop = g_main_loop_new(NULL, FALSE); bus = dbus_bus_get (DBUS_BUS_SESSION, &error); - dbus_connection_setup_with_g_main(bus, g_main_context_default()); + atspi_dbus_connection_setup_with_g_main(bus, g_main_context_default()); - cnx = droute_new (bus, TEST_INTROSPECTION_DIRECTORY); + cnx = droute_new (); path = droute_add_one (cnx, TEST_OBJECT_PATH, object); droute_path_add_interface (path, TEST_INTERFACE_ONE, + test_interface_One, test_methods_one, test_properties); droute_path_add_interface (path, TEST_INTERFACE_TWO, + test_interface_Two, test_methods_two, test_properties); + droute_path_register (path, bus); + g_idle_add (do_tests_func, NULL); - g_main_run(main_loop); + g_main_loop_run(main_loop); if (success) return 0; else