summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-09-04 00:21:36 +0000
committerHavoc Pennington <hp@redhat.com>2003-09-04 00:21:36 +0000
commit636be6f92d4d8effd392ad1f894738849ec7af76 (patch)
tree963e3d848ca3c3f78e07d1d92aaa3288558eb496
parent0453b2be603d4a8fcd12be3097b7eadc25838018 (diff)
2003-09-03 Havoc Pennington <hp@pobox.com>
* test/glib/Makefile.am: add this with random glib-linked test programs * glib/Makefile.am: remove the random test programs from here, leave only the unit tests * glib/dbus-gobject.c (_dbus_gobject_test): add test for uscore/javacaps conversion, and fix (get_object_property, set_object_property): change to .NET convention for mapping props to methods, set_FooBar/get_FooBar, since one language has such a convention we may as well copy it. Plus real methods in either getFooBar or get_foo_bar style won't collide with this convention.
-rw-r--r--ChangeLog16
-rw-r--r--configure.in1
-rw-r--r--glib/Makefile.am34
-rw-r--r--glib/dbus-gobject.c63
-rw-r--r--test/Makefile.am7
-rw-r--r--test/glib/Makefile.am44
-rw-r--r--test/glib/test-dbus-glib.c (renamed from glib/test-dbus-glib.c)0
-rw-r--r--test/glib/test-profile.c (renamed from glib/test-profile.c)0
-rw-r--r--test/glib/test-thread-client.c (renamed from glib/test-thread-client.c)0
-rw-r--r--test/glib/test-thread-server.c (renamed from glib/test-thread-server.c)0
-rw-r--r--test/glib/test-thread.h (renamed from glib/test-thread.h)0
11 files changed, 118 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index d9557bed..ccca8a8e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2003-09-03 Havoc Pennington <hp@pobox.com>
+
+ * test/glib/Makefile.am: add this with random glib-linked test
+ programs
+
+ * glib/Makefile.am: remove the random test programs from here,
+ leave only the unit tests
+
+ * glib/dbus-gobject.c (_dbus_gobject_test): add test for
+ uscore/javacaps conversion, and fix
+ (get_object_property, set_object_property): change to .NET
+ convention for mapping props to methods, set_FooBar/get_FooBar,
+ since one language has such a convention we may as well copy it.
+ Plus real methods in either getFooBar or get_foo_bar style won't
+ collide with this convention.
+
2003-09-01 Havoc Pennington <hp@pobox.com>
* glib/dbus-gparser.c: implement
diff --git a/configure.in b/configure.in
index 1125ef60..c403fd8c 100644
--- a/configure.in
+++ b/configure.in
@@ -826,6 +826,7 @@ mono/Makefile
bus/Makefile
tools/Makefile
test/Makefile
+test/glib/Makefile
doc/Makefile
dbus-1.pc
dbus-glib-1.pc
diff --git a/glib/Makefile.am b/glib/Makefile.am
index f3b43ed3..65d71cfd 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -34,30 +34,9 @@ dbus_glib_tool_LDADD= $(DBUS_GLIB_TOOL_LIBS) libdbus-glib-1.la $(top_builddir)/d
if DBUS_BUILD_TESTS
-if HAVE_GLIB_THREADS
-THREAD_APPS=test-thread-server test-thread-client test-profile
-
-test_thread_server_SOURCES= \
- test-thread-server.c \
- test-thread.h
-
-test_thread_server_LDADD= $(DBUS_GLIB_THREADS_LIBS) $(top_builddir)/glib/libdbus-glib-1.la
-
-test_thread_client_SOURCES= \
- test-thread-client.c \
- test-thread.h
-
-test_thread_client_LDADD= $(DBUS_GLIB_THREADS_LIBS) $(top_builddir)/glib/libdbus-glib-1.la
-endif
-
## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we
## build even when not doing "make check"
-noinst_PROGRAMS= $(TESTS) test-dbus-glib $(THREAD_APPS)
-
-test_dbus_glib_SOURCES= \
- test-dbus-glib.c
-
-test_dbus_glib_LDADD= $(top_builddir)/glib/libdbus-glib-1.la
+noinst_PROGRAMS= $(TESTS)
## note that TESTS has special meaning (stuff to use in make check)
## so if adding tests not to be run in make check, don't add them to
@@ -74,15 +53,4 @@ else
### not building tests
TESTS=
-if HAVE_GLIB_THREADS
-noinst_PROGRAMS=test-profile
-endif
-
endif
-
-if HAVE_GLIB_THREADS
-test_profile_SOURCES= \
- test-profile.c
-
-test_profile_LDADD= $(DBUS_GLIB_THREADS_LIBS) $(top_builddir)/glib/libdbus-glib-1.la
-endif \ No newline at end of file
diff --git a/glib/dbus-gobject.c b/glib/dbus-gobject.c
index aa53265b..b0f6c139 100644
--- a/glib/dbus-gobject.c
+++ b/glib/dbus-gobject.c
@@ -35,7 +35,7 @@ static GStaticMutex info_hash_mutex = G_STATIC_MUTEX_INIT;
static GHashTable *info_hash = NULL;
static char*
-javacaps_to_uscore (const char *caps)
+wincaps_to_uscore (const char *caps)
{
const char *p;
GString *str;
@@ -62,7 +62,7 @@ javacaps_to_uscore (const char *caps)
}
static char*
-uscore_to_javacaps (const char *uscore)
+uscore_to_wincaps (const char *uscore)
{
const char *p;
GString *str;
@@ -233,11 +233,11 @@ handle_introspect (DBusConnection *connection,
can_get = (spec->flags & G_PARAM_READABLE) != 0;
- s = uscore_to_javacaps (spec->name);
+ s = uscore_to_wincaps (spec->name);
if (can_set)
{
- g_string_append (xml, " <method name=\"set");
+ g_string_append (xml, " <method name=\"set_");
g_string_append (xml, s);
g_string_append (xml, "\">\n");
@@ -248,7 +248,7 @@ handle_introspect (DBusConnection *connection,
if (can_get)
{
- g_string_append (xml, " <method name=\"get");
+ g_string_append (xml, " <method name=\"get_");
g_string_append (xml, s);
g_string_append (xml, "\">\n");
@@ -578,13 +578,13 @@ gobject_message_function (DBusConnection *connection,
/* If no metainfo, we can still do properties and signals
* via standard GLib introspection
*/
- setter = (member[0] == 's' && member[1] == 'e' && member[2] == 't');
- getter = (member[0] == 'g' && member[1] == 'e' && member[2] == 't');
+ setter = (member[0] == 's' && member[1] == 'e' && member[2] == 't' && member[3] == '_');
+ getter = (member[0] == 'g' && member[1] == 'e' && member[2] == 't' && member[3] == '_');
if (!(setter || getter))
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- s = javacaps_to_uscore (&member[3]);
+ s = wincaps_to_uscore (&member[4]);
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
s);
@@ -757,6 +757,7 @@ dbus_connection_register_gobject (DBusConnection *connection,
/** @} */ /* end of public API */
#ifdef DBUS_BUILD_TESTS
+#include <stdlib.h>
/**
* @ingroup DBusGLibInternals
@@ -766,14 +767,48 @@ dbus_connection_register_gobject (DBusConnection *connection,
dbus_bool_t
_dbus_gobject_test (const char *test_data_dir)
{
- static struct { const char *javacaps; const char *uscore; } name_pairs[] = {
- { "setFoo", "set_foo" },
- { "foo", "foo" },
- { "getFooBar", "get_foo_bar" },
- { "Hello", "hello" },
- { "frobateUIHandler", "frobate_ui_handler" }
+ int i;
+ static struct { const char *wincaps; const char *uscore; } name_pairs[] = {
+ { "SetFoo", "set_foo" },
+ { "Foo", "foo" },
+ { "GetFooBar", "get_foo_bar" },
+ { "Hello", "hello" }
+
+ /* Impossible-to-handle cases */
+ /* { "FrobateUIHandler", "frobate_ui_handler" } */
};
+ i = 0;
+ while (i < (int) G_N_ELEMENTS (name_pairs))
+ {
+ char *uscore;
+ char *wincaps;
+
+ uscore = wincaps_to_uscore (name_pairs[i].wincaps);
+ wincaps = uscore_to_wincaps (name_pairs[i].uscore);
+
+ if (strcmp (uscore, name_pairs[i].uscore) != 0)
+ {
+ g_printerr ("\"%s\" should have been converted to \"%s\" not \"%s\"\n",
+ name_pairs[i].wincaps, name_pairs[i].uscore,
+ uscore);
+ exit (1);
+ }
+
+ if (strcmp (wincaps, name_pairs[i].wincaps) != 0)
+ {
+ g_printerr ("\"%s\" should have been converted to \"%s\" not \"%s\"\n",
+ name_pairs[i].uscore, name_pairs[i].wincaps,
+ wincaps);
+ exit (1);
+ }
+
+ g_free (uscore);
+ g_free (wincaps);
+
+ ++i;
+ }
+
return TRUE;
}
diff --git a/test/Makefile.am b/test/Makefile.am
index 04df3510..ab04496e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,6 +1,13 @@
+if HAVE_GLIB
+ GLIB_SUBDIR=glib
+endif
+
+SUBDIRS=$(GLIB_SUBDIR)
+
INCLUDES=-I$(top_srcdir) $(DBUS_TEST_CFLAGS)
+
if DBUS_BUILD_TESTS
TEST_BINARIES=test-service unbase64 break-loader spawn-test test-segfault test-exit test-sleep-forever
else
diff --git a/test/glib/Makefile.am b/test/glib/Makefile.am
new file mode 100644
index 00000000..9f900b13
--- /dev/null
+++ b/test/glib/Makefile.am
@@ -0,0 +1,44 @@
+INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_GLIB_CFLAGS) -I$(top_srcdir)/glib
+
+if DBUS_BUILD_TESTS
+
+if HAVE_GLIB_THREADS
+THREAD_APPS=test-thread-server test-thread-client test-profile
+
+test_thread_server_SOURCES= \
+ test-thread-server.c \
+ test-thread.h
+
+test_thread_server_LDADD= $(DBUS_GLIB_THREADS_LIBS) $(top_builddir)/glib/libdbus-glib-1.la
+
+test_thread_client_SOURCES= \
+ test-thread-client.c \
+ test-thread.h
+
+test_thread_client_LDADD= $(DBUS_GLIB_THREADS_LIBS) $(top_builddir)/glib/libdbus-glib-1.la
+endif
+
+## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we
+## build even when not doing "make check"
+noinst_PROGRAMS= test-dbus-glib $(THREAD_APPS)
+
+test_dbus_glib_SOURCES= \
+ test-dbus-glib.c
+
+test_dbus_glib_LDADD= $(top_builddir)/glib/libdbus-glib-1.la
+
+else
+### not building tests
+
+if HAVE_GLIB_THREADS
+noinst_PROGRAMS=test-profile
+endif
+
+endif
+
+if HAVE_GLIB_THREADS
+test_profile_SOURCES= \
+ test-profile.c
+
+test_profile_LDADD= $(DBUS_GLIB_THREADS_LIBS) $(top_builddir)/glib/libdbus-glib-1.la
+endif \ No newline at end of file
diff --git a/glib/test-dbus-glib.c b/test/glib/test-dbus-glib.c
index beda0a7a..beda0a7a 100644
--- a/glib/test-dbus-glib.c
+++ b/test/glib/test-dbus-glib.c
diff --git a/glib/test-profile.c b/test/glib/test-profile.c
index 6d9d8e7f..6d9d8e7f 100644
--- a/glib/test-profile.c
+++ b/test/glib/test-profile.c
diff --git a/glib/test-thread-client.c b/test/glib/test-thread-client.c
index d51d4e6a..d51d4e6a 100644
--- a/glib/test-thread-client.c
+++ b/test/glib/test-thread-client.c
diff --git a/glib/test-thread-server.c b/test/glib/test-thread-server.c
index 8898ca7f..8898ca7f 100644
--- a/glib/test-thread-server.c
+++ b/test/glib/test-thread-server.c
diff --git a/glib/test-thread.h b/test/glib/test-thread.h
index 8c78fba2..8c78fba2 100644
--- a/glib/test-thread.h
+++ b/test/glib/test-thread.h