dbus/test/glib test-service-glib.xml, 1.7, 1.8 test-service-glib.c,
1.17, 1.18 test-dbus-glib.c, 1.23, 1.24 Makefile.am, 1.14, 1.15
Colin Walters
walters at freedesktop.org
Thu Jun 30 11:22:15 PDT 2005
- Previous message: dbus ChangeLog,1.820,1.821
- Next message: dbus/glib dbus-gproxy.c, 1.32, 1.33 dbus-gparser.c, 1.15,
1.16 dbus-gobject.c, 1.37, 1.38 dbus-gmain.c, 1.43,
1.44 dbus-glib.c, 1.6, 1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/dbus/dbus/test/glib
In directory gabe:/tmp/cvs-serv29039/test/glib
Modified Files:
test-service-glib.xml test-service-glib.c test-dbus-glib.c
Makefile.am
Log Message:
2005-06-30 Colin Walters <walters at verbum.org>
* test/glib/test-dbus-glib.c:
* test/glib/test-service-glib.c:
* test/glib/test-service-glib.xml: Update tests for new error
setting bits, also add async tests (patch from Ross Burton).
* test/glib/Makefile.am (test_service_glib_LDADD): Add
DBUS_GLIB_THREADS_LIBS.
* glib/dbus-gproxy.c (get_name_owner)
(dbus_g_pending_call_end_valist): Ditto.
* glib/dbus-gobject.c (error_metadata): New mapping from GError
domain (GQuark) to DBusGErrorInfo.
(gerror_domaincode_to_dbus_error_name): Attempt to look up error
quark in error_metadata. Take message interface as default
error message interface.
(gerror_to_dbus_error_message): Pass message interface.
(dbus_set_g_error): Resurrected.
(dbus_g_error_info_free): New function.
(dbus_g_object_type_install_info): Use g_type_class_ref instead
of _peek to actually create the object class if it hasn't been
created yet.
(dbus_g_error_domain_register): New function.
* glib/dbus-gmain.c (dbus_g_bus_get): Switch to dbus_set_g_error.
* glib/dbus-gparser.c (validate_signature): Ditto.
* dbus/dbus-glib.h (dbus_g_error_set): Delete.
(dbus_g_error_domain_register): Prototype.
* glib/dbus-glib.c (dbus_g_error_set): Delete.
Update tests.
Index: test-service-glib.xml
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-service-glib.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- test-service-glib.xml 29 Jun 2005 16:58:59 -0000 1.7
+++ test-service-glib.xml 30 Jun 2005 18:22:09 -0000 1.8
@@ -77,6 +77,16 @@
<method name="IncrementVal">
</method>
+ <method name="AsyncIncrement">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="u" name="x" />
+ <arg type="u" direction="out" />
+ </method>
+
+ <method name="AsyncThrowError">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ </method>
+
<method name="GetVal">
<arg type="u" direction="out" />
</method>
Index: test-service-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-service-glib.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- test-service-glib.c 29 Jun 2005 23:52:35 -0000 1.17
+++ test-service-glib.c 30 Jun 2005 18:22:09 -0000 1.18
@@ -44,7 +44,9 @@
MY_OBJECT_ERROR_BAR
} MyObjectError;
-#define MY_OBJECT_ERROR my_object_error_quark ()
+#define MY_OBJECT_ERROR (my_object_error_quark ())
+
+#define MY_TYPE_ERROR (my_object_error_get_type ())
gboolean my_object_do_nothing (MyObject *obj, GError **error);
@@ -85,10 +87,16 @@
gboolean my_object_terminate (MyObject *obj, GError **error);
+gboolean my_object_async_increment (MyObject *obj, gint32 x, DBusGMethodInvocation *context);
+
+gboolean my_object_async_throw_error (MyObject *obj, DBusGMethodInvocation *context);
+
#include "test-service-glib-glue.h"
GQuark my_object_error_quark (void);
+GType my_object_error_get_type (void);
+
/* Properties */
enum
{
@@ -231,6 +239,30 @@
return quark;
}
+/* This should really be standard. */
+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
+
+GType
+my_object_error_get_type (void)
+{
+ static GType etype = 0;
+
+ if (etype == 0)
+ {
+ static const GEnumValue values[] =
+ {
+
+ ENUM_ENTRY (MY_OBJECT_ERROR_FOO, "Foo"),
+ ENUM_ENTRY (MY_OBJECT_ERROR_BAR, "Bar"),
+ { 0, 0, 0 }
+ };
+
+ etype = g_enum_register_static ("MyObjectError", values);
+ }
+
+ return etype;
+}
+
static GObject *obj;
static GObject *obj2;
@@ -250,9 +282,11 @@
gboolean
my_object_throw_error (MyObject *obj, GError **error)
{
- dbus_g_error_set (error,
- "org.freedesktop.DBus.Tests.MyObject.Foo",
- "this method always loses");
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "%s",
+ "this method always loses");
return FALSE;
}
@@ -464,6 +498,53 @@
return TRUE;
}
+typedef struct {
+ gint32 x;
+ DBusGMethodInvocation *context;
+} IncrementData;
+
+static gboolean
+do_async_increment (IncrementData *data)
+{
+ gint32 newx = data->x + 1;
+ dbus_g_method_return (data->context, newx);
+ g_free (data);
+ return FALSE;
+}
+
+gboolean
+my_object_async_increment (MyObject *obj, gint32 x, DBusGMethodInvocation *context)
+{
+ IncrementData *data = g_new0 (IncrementData, 1);
+ data->x = x;
+ data->context = context;
+ g_idle_add ((GSourceFunc)do_async_increment, data);
+ return TRUE;
+}
+
+static gboolean
+do_async_error (IncrementData *data)
+{
+ GError *error;
+ error = g_error_new (MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "%s",
+ "this method always loses");
+ dbus_g_method_return_error (data->context, error);
+ g_free (data);
+ return FALSE;
+}
+
+gboolean
+my_object_async_throw_error (MyObject *obj, DBusGMethodInvocation *context)
+{
+ IncrementData *data = g_new0(IncrementData, 1);
+ data->context = context;
+ g_idle_add ((GSourceFunc)do_async_error, data);
+ return TRUE;
+}
+
+
static GMainLoop *loop;
gboolean
@@ -484,6 +565,14 @@
guint32 request_name_ret;
g_type_init ();
+ g_thread_init (NULL); dbus_g_thread_init ();
+
+ dbus_g_object_type_install_info (MY_TYPE_OBJECT,
+ &dbus_glib_my_object_object_info);
+
+ dbus_g_error_domain_register (MY_OBJECT_ERROR,
+ NULL,
+ MY_TYPE_ERROR);
g_printerr ("Launching test-service-glib\n");
@@ -506,8 +595,6 @@
obj = g_object_new (MY_TYPE_OBJECT, NULL);
obj2 = g_object_new (MY_TYPE_OBJECT, NULL);
- dbus_g_object_type_install_info (MY_TYPE_OBJECT,
- &dbus_glib_my_object_object_info);
dbus_g_connection_register_g_object (connection,
"/org/freedesktop/DBus/Tests/MyTestObject",
obj);
Index: test-dbus-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-dbus-glib.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- test-dbus-glib.c 29 Jun 2005 23:52:35 -0000 1.23
+++ test-dbus-glib.c 30 Jun 2005 18:22:09 -0000 1.24
@@ -441,7 +441,8 @@
if (dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID) != FALSE)
lose ("ThrowError call unexpectedly succeeded!");
if (!dbus_g_error_has_name (error, "org.freedesktop.DBus.Tests.MyObject.Foo"))
- lose ("ThrowError call returned unexpected error %s", dbus_g_error_get_name (error));
+ lose ("ThrowError call returned unexpected error \"%s\": %s", dbus_g_error_get_name (error),
+ error->message);
g_print ("ThrowError failed (as expected) returned error: %s\n", error->message);
g_clear_error (&error);
@@ -490,6 +491,13 @@
if (v_UINT32_2 != 43)
lose ("(wrapped) increment call returned %d, should be 43", v_UINT32_2);
+ v_UINT32_2 = 0;
+ if (!org_freedesktop_DBus_Tests_MyObject_async_increment (proxy, 42, &v_UINT32_2, &error))
+ lose_gerror ("Failed to complete (wrapped) AsyncIncrement call", error);
+
+ if (v_UINT32_2 != 43)
+ lose ("(wrapped) async increment call returned %d, should be 43", v_UINT32_2);
+
g_print ("Calling (wrapped) throw_error\n");
if (org_freedesktop_DBus_Tests_MyObject_throw_error (proxy, &error) != FALSE)
lose ("(wrapped) ThrowError call unexpectedly succeeded!");
@@ -497,6 +505,12 @@
g_print ("(wrapped) ThrowError failed (as expected) returned error: %s\n", error->message);
g_clear_error (&error);
+ if (org_freedesktop_DBus_Tests_MyObject_async_throw_error (proxy, &error) != FALSE)
+ lose ("(wrapped) AsyncThrowError call unexpectedly succeeded!");
+
+ g_print ("(wrapped) AsyncThrowError failed (as expected) returned error: %s\n", error->message);
+ g_clear_error (&error);
+
g_print ("Calling (wrapped) uppercase\n");
if (!org_freedesktop_DBus_Tests_MyObject_uppercase (proxy, "foobar", &v_STRING_2, &error))
lose_gerror ("Failed to complete (wrapped) Uppercase call", error);
Index: Makefile.am
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/Makefile.am,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Makefile.am 17 Jun 2005 14:29:48 -0000 1.14
+++ Makefile.am 30 Jun 2005 18:22:09 -0000 1.15
@@ -61,7 +61,7 @@
CLEANFILES = $(BUILT_SOURCES)
-test_service_glib_LDADD= $(top_builddir)/glib/libdbus-glib-1.la
+test_service_glib_LDADD= $(top_builddir)/glib/libdbus-glib-1.la $(DBUS_GLIB_THREADS_LIBS)
else
### not building tests
- Previous message: dbus ChangeLog,1.820,1.821
- Next message: dbus/glib dbus-gproxy.c, 1.32, 1.33 dbus-gparser.c, 1.15,
1.16 dbus-gobject.c, 1.37, 1.38 dbus-gmain.c, 1.43,
1.44 dbus-glib.c, 1.6, 1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dbus-commit
mailing list