summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-message-handler.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-05-05 03:13:35 +0000
committerHavoc Pennington <hp@redhat.com>2003-05-05 03:13:35 +0000
commitd1c7eefb66483c3ea4d9e7fb6dca23dcfac8cad5 (patch)
treed012f30757e2319ff1862f51d406291506be5b55 /dbus/dbus-message-handler.c
parent3d0dcbf536601e39d3d5125ed29f5afa217c9bf6 (diff)
2003-05-04 Havoc Pennington <hp@pobox.com>
* dbus/dbus-message-handler.c (_dbus_message_handler_test): add unit test * dbus/dbus-marshal.c (_dbus_demarshal_string_array): fix this function, which assumed length was in # of strings, not bytes * dbus/dbus-message.c (_dbus_message_test): add tests for some missing coverage * dbus/dbus-connection.c (_dbus_connection_queue_received_message): disable function for now, we are only using it in test mode * dbus/dbus-message.c (_dbus_message_loader_queue_messages): remove a mistaken FIXME
Diffstat (limited to 'dbus/dbus-message-handler.c')
-rw-r--r--dbus/dbus-message-handler.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/dbus/dbus-message-handler.c b/dbus/dbus-message-handler.c
index 964f7d72..0b44e133 100644
--- a/dbus/dbus-message-handler.c
+++ b/dbus/dbus-message-handler.c
@@ -25,6 +25,7 @@
#include "dbus-message-handler.h"
#include "dbus-list.h"
#include "dbus-threads.h"
+#include "dbus-test.h"
#include "dbus-connection-internal.h"
/**
@@ -318,3 +319,53 @@ dbus_message_handler_set_function (DBusMessageHandler *handler,
}
/** @} */
+
+#ifdef DBUS_BUILD_TESTS
+static DBusHandlerResult
+test_handler (DBusMessageHandler *handler,
+ DBusConnection *connection,
+ DBusMessage *message,
+ void *user_data)
+{
+ return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+}
+
+static void
+free_test_data (void *data)
+{
+ /* does nothing */
+}
+
+/**
+ * @ingroup DBusMessageInternals
+ * Unit test for DBusMessageHandler.
+ *
+ * @returns #TRUE on success.
+ */
+dbus_bool_t
+_dbus_message_handler_test (const char *test_data_dir)
+{
+ DBusMessageHandler *handler;
+
+#define TEST_DATA ((void*) 0xcafebabe)
+
+ handler = dbus_message_handler_new (test_handler,
+ TEST_DATA,
+ free_test_data);
+
+ _dbus_assert (handler != NULL);
+ _dbus_assert (handler->function == test_handler);
+
+ if (dbus_message_handler_get_data (handler) != TEST_DATA)
+ _dbus_assert_not_reached ("got wrong data");
+
+ dbus_message_handler_set_function (handler, NULL);
+ _dbus_assert (handler->function == NULL);
+
+ dbus_message_handler_ref (handler);
+ dbus_message_handler_unref (handler);
+ dbus_message_handler_unref (handler);
+
+ return TRUE;
+}
+#endif /* DBUS_BUILD_TESTS */