From: Havoc Pennington Date: Thu, 4 Sep 2003 00:21:36 +0000 (+0000) Subject: 2003-09-03 Havoc Pennington X-Git-Tag: dbus-0.20~37^2~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=636be6f92d4d8effd392ad1f894738849ec7af76;p=thirdparty%2Fdbus.git 2003-09-03 Havoc Pennington * 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. --- diff --git a/ChangeLog b/ChangeLog index d9557beda..ccca8a8e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2003-09-03 Havoc Pennington + + * 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 * glib/dbus-gparser.c: implement diff --git a/configure.in b/configure.in index 1125ef60b..c403fd8cc 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 f3b43ed3a..65d71cfd7 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 aa53265bc..b0f6c139e 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, " \n"); @@ -248,7 +248,7 @@ handle_introspect (DBusConnection *connection, if (can_get) { - 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 /** * @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 04df3510c..ab04496ea 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 000000000..9f900b131 --- /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 similarity index 100% rename from glib/test-dbus-glib.c rename to test/glib/test-dbus-glib.c diff --git a/glib/test-profile.c b/test/glib/test-profile.c similarity index 100% rename from glib/test-profile.c rename to test/glib/test-profile.c diff --git a/glib/test-thread-client.c b/test/glib/test-thread-client.c similarity index 100% rename from glib/test-thread-client.c rename to test/glib/test-thread-client.c diff --git a/glib/test-thread-server.c b/test/glib/test-thread-server.c similarity index 100% rename from glib/test-thread-server.c rename to test/glib/test-thread-server.c diff --git a/glib/test-thread.h b/test/glib/test-thread.h similarity index 100% rename from glib/test-thread.h rename to test/glib/test-thread.h