summaryrefslogtreecommitdiffstats
path: root/test/test-service.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-service.c')
-rw-r--r--test/test-service.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/test-service.c b/test/test-service.c
index bd2a4638..ee0086ca 100644
--- a/test/test-service.c
+++ b/test/test-service.c
@@ -1,5 +1,6 @@
#include "test-utils.h"
+#include <unistd.h>
static DBusLoop *loop;
static dbus_bool_t already_quit = FALSE;
@@ -223,6 +224,62 @@ handle_echo (DBusConnection *connection,
return DBUS_HANDLER_RESULT_HANDLED;
}
+static DBusHandlerResult
+handle_delay_echo (DBusConnection *connection,
+ DBusMessage *message)
+{
+ DBusError error;
+ DBusMessage *reply;
+ char *s;
+
+ _dbus_verbose ("sleeping for a short time\n");
+
+ usleep (50000);
+
+ _dbus_verbose ("sending reply to DelayEcho method\n");
+
+ dbus_error_init (&error);
+
+ if (!dbus_message_get_args (message,
+ &error,
+ DBUS_TYPE_STRING, &s,
+ DBUS_TYPE_INVALID))
+ {
+ reply = dbus_message_new_error (message,
+ error.name,
+ error.message);
+
+ if (reply == NULL)
+ die ("No memory\n");
+
+ if (!dbus_connection_send (connection, reply, NULL))
+ die ("No memory\n");
+
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+ reply = dbus_message_new_method_return (message);
+ if (reply == NULL)
+ die ("No memory\n");
+
+ if (!dbus_message_append_args (reply,
+ DBUS_TYPE_STRING, &s,
+ DBUS_TYPE_INVALID))
+ die ("No memory");
+
+ if (!dbus_connection_send (connection, reply, NULL))
+ die ("No memory\n");
+
+ fprintf (stderr, "DelayEcho service echoed string: \"%s\"\n", s);
+
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+
static void
path_unregistered_func (DBusConnection *connection,
void *user_data)
@@ -241,6 +298,10 @@ path_message_func (DBusConnection *connection,
return handle_echo (connection, message);
else if (dbus_message_is_method_call (message,
"org.freedesktop.TestSuite",
+ "DelayEcho"))
+ return handle_delay_echo (connection, message);
+ else if (dbus_message_is_method_call (message,
+ "org.freedesktop.TestSuite",
"Exit"))
{
quit ();