[next] telepathy-glib: simple-conn: add tp_tests_simple_connection_ensure_room_list_chan()

Simon McVittie smcv at kemper.freedesktop.org
Mon Apr 30 11:03:59 PDT 2012


Module: telepathy-glib
Branch: next
Commit: 0b291b59709c9da444ed87ec80447ce177145266
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=0b291b59709c9da444ed87ec80447ce177145266

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Tue Apr 17 15:36:28 2012 +0200

simple-conn: add tp_tests_simple_connection_ensure_room_list_chan()

---

 tests/lib/simple-conn.c |   49 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/lib/simple-conn.h |    5 ++++
 2 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/tests/lib/simple-conn.c b/tests/lib/simple-conn.c
index 476db0e..27f1835 100644
--- a/tests/lib/simple-conn.c
+++ b/tests/lib/simple-conn.c
@@ -25,6 +25,7 @@
 #include <telepathy-glib/util.h>
 
 #include "textchan-null.h"
+#include "room-list-chan.h"
 #include "util.h"
 
 static void conn_iface_init (TpSvcConnectionClass *);
@@ -410,6 +411,54 @@ tp_tests_simple_connection_ensure_text_chan (TpTestsSimpleConnection *self,
   return chan_path;
 }
 
+static void
+room_list_chan_closed_cb (TpBaseChannel *channel,
+    TpTestsSimpleConnection *self)
+{
+  g_hash_table_remove (self->priv->channels, GUINT_TO_POINTER (0));
+}
+
+gchar *
+tp_tests_simple_connection_ensure_room_list_chan (TpTestsSimpleConnection *self,
+    const gchar *server,
+    GHashTable **props)
+{
+  TpTestsRoomListChan *chan;
+  gchar *chan_path;
+  TpBaseConnection *base_conn = (TpBaseConnection *) self;
+
+  chan = g_hash_table_lookup (self->priv->channels, GUINT_TO_POINTER (0));
+  if (chan != NULL)
+    {
+      /* Channel already exist, reuse it */
+      g_object_get (chan, "object-path", &chan_path, NULL);
+    }
+  else
+    {
+      chan_path = g_strdup_printf ("%s/RoomListChannel",
+          base_conn->object_path);
+
+       chan = TP_TESTS_ROOM_LIST_CHAN (
+          tp_tests_object_new_static_class (
+            TP_TESTS_TYPE_ROOM_LIST_CHAN,
+            "connection", self,
+            "object-path", chan_path,
+            "server", server ? server : "",
+            NULL));
+
+       g_signal_connect (chan, "closed",
+           G_CALLBACK (room_list_chan_closed_cb), self);
+
+      g_hash_table_insert (self->priv->channels, GUINT_TO_POINTER (0),
+          chan);
+    }
+
+  if (props != NULL)
+    g_object_get (chan, "channel-properties", props, NULL);
+
+  return chan_path;
+}
+
 void
 tp_tests_simple_connection_set_get_self_handle_error (
     TpTestsSimpleConnection *self,
diff --git a/tests/lib/simple-conn.h b/tests/lib/simple-conn.h
index 6322f4b..837400b 100644
--- a/tests/lib/simple-conn.h
+++ b/tests/lib/simple-conn.h
@@ -72,6 +72,11 @@ void tp_tests_simple_connection_set_get_self_handle_error (
     gint code,
     const gchar *message);
 
+gchar * tp_tests_simple_connection_ensure_room_list_chan (
+    TpTestsSimpleConnection *self,
+    const gchar *server,
+    GHashTable **props);
+
 G_END_DECLS
 
 #endif /* #ifndef __TP_TESTS_SIMPLE_CONN_H__ */



More information about the telepathy-commits mailing list