[Telepathy-commits] [telepathy-glib/master] Echo example CM: adjust order of events for spec 0.17.14 compliance
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu Oct 30 11:08:40 PDT 2008
This requires that the tests wait for the Sent and Received signals,
since they are now emitted after Send returns.
---
examples/cm/echo/chan.c | 11 ++++-------
tests/dbus/text-mixin.c | 7 +++++++
tests/dbus/text-respawn.c | 3 +++
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/examples/cm/echo/chan.c b/examples/cm/echo/chan.c
index 0efb1ef..aa96148 100644
--- a/examples/cm/echo/chan.c
+++ b/examples/cm/echo/chan.c
@@ -461,11 +461,10 @@ text_send (TpSvcChannelTypeText *iface,
gchar *echo;
guint echo_type = type;
- /* Tell the client that the message was sent successfully. If it's possible
- * to tell whether a message has been delivered, you should delay emitting
- * this signal until it's actually been successful, and emit SendError
- * instead if there was an error; if you can't tell, emit Sent immediately,
- * like this */
+ /* Send should return just before Sent is emitted. */
+ tp_svc_channel_type_text_return_from_send (context);
+
+ /* Tell the client that the message was submitted for sending */
tp_svc_channel_type_text_emit_sent ((GObject *) self, timestamp, type, text);
/* Pretend that the remote contact has replied. Normally,
@@ -492,8 +491,6 @@ text_send (TpSvcChannelTypeText *iface,
timestamp, echo);
g_free (echo);
-
- tp_svc_channel_type_text_return_from_send (context);
}
static void
diff --git a/tests/dbus/text-mixin.c b/tests/dbus/text-mixin.c
index f1c7b69..7e4bd2e 100644
--- a/tests/dbus/text-mixin.c
+++ b/tests/dbus/text-mixin.c
@@ -18,6 +18,7 @@
#include "examples/cm/echo/chan.h"
#include "examples/cm/echo/conn.h"
#include "tests/lib/myassert.h"
+#include "tests/lib/util.h"
static int fail = 0;
@@ -159,6 +160,8 @@ main (int argc,
TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, "Hello, world!",
&error, NULL);
MYASSERT_NO_ERROR (error);
+
+ test_connection_run_until_dbus_queue_processed (conn);
MYASSERT (sent_count == 1, ": %u != 1", sent_count);
MYASSERT (received_count == 1, ": %u != 1", received_count);
MYASSERT (last_sent_type == TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
@@ -179,6 +182,8 @@ main (int argc,
TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION, "drinks coffee",
&error, NULL);
MYASSERT_NO_ERROR (error);
+
+ test_connection_run_until_dbus_queue_processed (conn);
MYASSERT (sent_count == 1, ": %u != 1", sent_count);
MYASSERT (received_count == 1, ": %u != 1", received_count);
MYASSERT (last_sent_type == TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION,
@@ -200,6 +205,8 @@ main (int argc,
TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE, "Printer on fire",
&error, NULL);
MYASSERT_NO_ERROR (error);
+
+ test_connection_run_until_dbus_queue_processed (conn);
MYASSERT (sent_count == 1, ": %u != 1", sent_count);
MYASSERT (received_count == 1, ": %u != 1", received_count);
MYASSERT (last_sent_type == TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE,
diff --git a/tests/dbus/text-respawn.c b/tests/dbus/text-respawn.c
index 352c30f..f040457 100644
--- a/tests/dbus/text-respawn.c
+++ b/tests/dbus/text-respawn.c
@@ -18,6 +18,7 @@
#include "examples/cm/echo/chan.h"
#include "examples/cm/echo/conn.h"
#include "tests/lib/myassert.h"
+#include "tests/lib/util.h"
static int fail = 0;
@@ -161,6 +162,8 @@ main (int argc,
TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, "Hello, world!",
&error, NULL);
MYASSERT_NO_ERROR (error);
+
+ test_connection_run_until_dbus_queue_processed (conn);
MYASSERT (sent_count == 1, ": %u != 1", sent_count);
MYASSERT (received_count == 1, ": %u != 1", received_count);
MYASSERT (last_sent_type == TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
--
1.5.6.5
More information about the Telepathy-commits
mailing list