telepathy-glib: add TpTestsRoomListChan for tests
Guillaume Desmottes
gdesmott at kemper.freedesktop.org
Mon Apr 30 02:47:37 PDT 2012
Module: telepathy-glib
Branch: master
Commit: de890e68890a89c9d2d5656e03d6723bec5197df
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=de890e68890a89c9d2d5656e03d6723bec5197df
Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date: Wed Apr 11 14:37:58 2012 +0200
add TpTestsRoomListChan for tests
---
tests/lib/Makefile.am | 2 +
tests/lib/room-list-chan.c | 164 ++++++++++++++++++++++++++++++++++++++++++++
tests/lib/room-list-chan.h | 50 +++++++++++++
3 files changed, 216 insertions(+), 0 deletions(-)
diff --git a/tests/lib/Makefile.am b/tests/lib/Makefile.am
index 57e95fc..8fad58a 100644
--- a/tests/lib/Makefile.am
+++ b/tests/lib/Makefile.am
@@ -44,6 +44,8 @@ libtp_glib_tests_la_SOURCES = \
my-conn-proxy.c \
params-cm.h \
params-cm.c \
+ room-list-chan.h \
+ room-list-chan.c \
simple-account.c \
simple-account.h \
simple-account-manager.c\
diff --git a/tests/lib/room-list-chan.c b/tests/lib/room-list-chan.c
new file mode 100644
index 0000000..de4be4f
--- /dev/null
+++ b/tests/lib/room-list-chan.c
@@ -0,0 +1,164 @@
+
+#include "config.h"
+
+#include "room-list-chan.h"
+
+#include <telepathy-glib/telepathy-glib.h>
+#include <telepathy-glib/channel-iface.h>
+#include <telepathy-glib/svc-channel.h>
+
+static void room_list_iface_init (gpointer iface,
+ gpointer data);
+
+G_DEFINE_TYPE_WITH_CODE (TpTestsRoomListChan, tp_tests_room_list_chan, TP_TYPE_BASE_CHANNEL,
+ G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_TYPE_ROOM_LIST, room_list_iface_init))
+
+enum {
+ PROP_SERVER = 1,
+ LAST_PROPERTY,
+};
+
+/*
+enum {
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+*/
+
+struct _TpTestsRoomListChanPriv {
+ gchar *server;
+};
+
+static void
+tp_tests_room_list_chan_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ TpTestsRoomListChan *self = TP_TESTS_ROOM_LIST_CHAN (object);
+
+ switch (property_id)
+ {
+ case PROP_SERVER:
+ g_value_set_string (value, self->priv->server);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+tp_tests_room_list_chan_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ TpTestsRoomListChan *self = TP_TESTS_ROOM_LIST_CHAN (object);
+
+ switch (property_id)
+ {
+ case PROP_SERVER:
+ g_assert (self->priv->server == NULL); /* construct only */
+ self->priv->server = g_value_dup_string (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+tp_tests_room_list_chan_constructed (GObject *object)
+{
+ TpTestsRoomListChan *self = TP_TESTS_ROOM_LIST_CHAN (object);
+ void (*chain_up) (GObject *) =
+ ((GObjectClass *) tp_tests_room_list_chan_parent_class)->constructed;
+
+ if (chain_up != NULL)
+ chain_up (object);
+
+ tp_base_channel_register (TP_BASE_CHANNEL (self));
+}
+
+static void
+tp_tests_room_list_chan_finalize (GObject *object)
+{
+ TpTestsRoomListChan *self = TP_TESTS_ROOM_LIST_CHAN (object);
+ void (*chain_up) (GObject *) =
+ ((GObjectClass *) tp_tests_room_list_chan_parent_class)->finalize;
+
+ g_free (self->priv->server);
+
+ if (chain_up != NULL)
+ chain_up (object);
+}
+
+static void
+fill_immutable_properties (TpBaseChannel *chan,
+ GHashTable *properties)
+{
+ TpBaseChannelClass *klass = TP_BASE_CHANNEL_CLASS (
+ tp_tests_room_list_chan_parent_class);
+
+ klass->fill_immutable_properties (chan, properties);
+
+ tp_dbus_properties_mixin_fill_properties_hash (
+ G_OBJECT (chan), properties,
+ TP_IFACE_CHANNEL_TYPE_ROOM_LIST, "Server",
+ NULL);
+}
+
+static void
+tp_tests_room_list_chan_class_init (
+ TpTestsRoomListChanClass *klass)
+{
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+ TpBaseChannelClass *base_class = TP_BASE_CHANNEL_CLASS (klass);
+ GParamSpec *spec;
+ static TpDBusPropertiesMixinPropImpl room_list_props[] = {
+ { "Server", "server", NULL, },
+ { NULL }
+ };
+
+ oclass->get_property = tp_tests_room_list_chan_get_property;
+ oclass->set_property = tp_tests_room_list_chan_set_property;
+ oclass->constructed = tp_tests_room_list_chan_constructed;
+ oclass->finalize = tp_tests_room_list_chan_finalize;
+
+ base_class->channel_type = TP_IFACE_CHANNEL_TYPE_ROOM_LIST;
+ base_class->target_handle_type = TP_HANDLE_TYPE_NONE;
+ base_class->fill_immutable_properties = fill_immutable_properties;
+
+ spec = g_param_spec_string ("server", "server",
+ "Server",
+ "",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (oclass, PROP_SERVER, spec);
+
+ tp_dbus_properties_mixin_implement_interface (oclass,
+ TP_IFACE_QUARK_CHANNEL_TYPE_ROOM_LIST,
+ tp_dbus_properties_mixin_getter_gobject_properties, NULL,
+ room_list_props);
+
+ g_type_class_add_private (klass, sizeof (TpTestsRoomListChanPriv));
+}
+
+static void
+tp_tests_room_list_chan_init (TpTestsRoomListChan *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ TP_TESTS_TYPE_ROOM_LIST_CHAN, TpTestsRoomListChanPriv);
+}
+
+static void
+room_list_iface_init (gpointer iface,
+ gpointer data)
+{
+ //TpSvcChannelTypeRoomListClass *klass = iface;
+
+#define IMPLEMENT(x) \
+ tp_svc_channel_type_room_list_implement_##x (klass, room_list_##x)
+#undef IMPLEMENT
+}
diff --git a/tests/lib/room-list-chan.h b/tests/lib/room-list-chan.h
new file mode 100644
index 0000000..b41be27
--- /dev/null
+++ b/tests/lib/room-list-chan.h
@@ -0,0 +1,50 @@
+
+#ifndef __TP_TESTS_ROOM_LIST_CHAN_H__
+#define __TP_TESTS_ROOM_LIST_CHAN_H__
+
+#include <glib-object.h>
+#include <telepathy-glib/base-channel.h>
+
+G_BEGIN_DECLS
+
+typedef struct _TpTestsRoomListChan TpTestsRoomListChan;
+typedef struct _TpTestsRoomListChanClass TpTestsRoomListChanClass;
+typedef struct _TpTestsRoomListChanPriv TpTestsRoomListChanPriv;
+
+struct _TpTestsRoomListChanClass {
+ TpBaseChannelClass parent_class;
+ TpDBusPropertiesMixinClass dbus_properties_class;
+};
+
+struct _TpTestsRoomListChan {
+ TpBaseChannel parent;
+ TpTestsRoomListChanPriv *priv;
+};
+
+GType tp_tests_room_list_chan_get_type (void);
+
+/* TYPE MACROS */
+#define TP_TESTS_TYPE_ROOM_LIST_CHAN \
+ (tp_tests_room_list_chan_get_type ())
+#define TP_TESTS_ROOM_LIST_CHAN(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ TP_TESTS_TYPE_ROOM_LIST_CHAN, \
+ TpTestsRoomListChan))
+#define TP_TESTS_ROOM_LIST_CHAN_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ TP_TESTS_TYPE_ROOM_LIST_CHAN, \
+ TpTestsRoomListChanClass))
+#define TP_TESTS_IS_ROOM_LIST_CHAN(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ TP_TESTS_TYPE_ROOM_LIST_CHAN))
+#define TP_TESTS_IS_ROOM_LIST_CHAN_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ TP_TESTS_TYPE_ROOM_LIST_CHAN))
+#define TP_TESTS_ROOM_LIST_CHAN_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ TP_TESTS_TYPE_ROOM_LIST_CHAN, \
+ TpTestsRoomListChanClass))
+
+G_END_DECLS
+
+#endif /* #ifndef __TP_TESTS_ROOM_LIST_CHAN_H__*/
More information about the telepathy-commits
mailing list