[Telepathy-commits] [telepathy-glib/master] Run group proxy tests on channels without Properties

Will Thompson will.thompson at collabora.co.uk
Mon Jan 5 16:27:16 PST 2009


---
 tests/dbus/cli-group.c     |   26 ++++++++++++++++++--------
 tests/lib/textchan-group.c |   20 +++++++++++++++++++-
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/tests/dbus/cli-group.c b/tests/dbus/cli-group.c
index ec4cbcf..8a1d3a3 100644
--- a/tests/dbus/cli-group.c
+++ b/tests/dbus/cli-group.c
@@ -77,13 +77,14 @@ group_members_changed_detailed_cb (TpChannel *chan_,
 static void
 test_channel_proxy (TestTextChannelGroup *service_chan,
                     TpChannel *chan,
-                    gboolean detailed)
+                    gboolean detailed,
+                    gboolean properties)
 {
   TpIntSet *add, *rem, *expected_members;
   GArray *arr, *yarr;
   GError *error = NULL;
   TpChannelGroupFlags flags;
-  gboolean has_detailed_flag;
+  gboolean has_detailed_flag, has_properties_flag;
 
   MYASSERT (tp_channel_run_until_ready (chan, &error, NULL), "");
   MYASSERT_NO_ERROR (error);
@@ -104,6 +105,10 @@ test_channel_proxy (TestTextChannelGroup *service_chan,
   MYASSERT (detailed == has_detailed_flag,
       ": expected Members_Changed_Detailed to be %sset",
       (detailed ? "" : "un"));
+  has_properties_flag = !!(flags & TP_CHANNEL_GROUP_FLAG_PROPERTIES);
+  MYASSERT (properties == has_properties_flag,
+      ": expected Properties to be %sset",
+      (detailed ? "" : "un"));
 
   /* Add a couple of members. */
   add = tp_intset_new ();
@@ -190,7 +195,8 @@ test_channel_proxy (TestTextChannelGroup *service_chan,
 
 static void
 run_test (guint channel_number,
-          gboolean detailed)
+          gboolean detailed,
+          gboolean properties)
 {
   gchar *chan_path;
   TestTextChannelGroup *service_chan;
@@ -203,13 +209,14 @@ run_test (guint channel_number,
       "connection", service_conn,
       "object-path", chan_path,
       "detailed", detailed,
+      "properties", properties,
       NULL));
   chan = tp_channel_new (conn, chan_path, NULL, TP_UNKNOWN_HANDLE_TYPE, 0,
       &error);
 
   MYASSERT_NO_ERROR (error);
 
-  test_channel_proxy (service_chan, chan, detailed);
+  test_channel_proxy (service_chan, chan, detailed, properties);
 
   g_object_unref (chan);
   g_object_unref (service_chan);
@@ -219,11 +226,14 @@ run_test (guint channel_number,
 static void
 run_tests (void)
 {
-  /* Run a set of sanity checks on two channels, one of which has the
-   * Members_Changed_Details flag cleared and one of which has it set.
+  /* Run a set of sanity checks on a series of channels, with all 4
+   * combinations of states of the of the Members_Changed_Detailed and
+   * Properties group flags.
    */
-  run_test (1, FALSE);
-  run_test (2, TRUE);
+  run_test (1, FALSE, FALSE);
+  run_test (2, FALSE, TRUE);
+  run_test (3, TRUE, FALSE);
+  run_test (4, TRUE, TRUE);
 }
 
 int
diff --git a/tests/lib/textchan-group.c b/tests/lib/textchan-group.c
index 3e3a2b3..82c3f46 100644
--- a/tests/lib/textchan-group.c
+++ b/tests/lib/textchan-group.c
@@ -53,6 +53,7 @@ enum
   PROP_INITIATOR_HANDLE,
   PROP_INITIATOR_ID,
   PROP_DETAILED,
+  PROP_PROPERTIES,
   N_PROPS
 };
 
@@ -61,6 +62,7 @@ struct _TestTextChannelGroupPrivate
   gchar *object_path;
 
   gboolean detailed;
+  gboolean properties;
 
   gboolean closed;
   gboolean disposed;
@@ -103,7 +105,7 @@ constructor (GType type,
   TpHandleRepoIface *contact_repo = tp_base_connection_get_handles
       (self->conn, TP_HANDLE_TYPE_CONTACT);
   DBusGConnection *bus;
-  TpChannelGroupFlags flags = TP_CHANNEL_GROUP_FLAG_PROPERTIES;
+  TpChannelGroupFlags flags = 0;
 
   bus = tp_get_bus ();
   dbus_g_connection_register_g_object (bus, self->priv->object_path, object);
@@ -120,6 +122,9 @@ constructor (GType type,
   if (self->priv->detailed)
     flags |= TP_CHANNEL_GROUP_FLAG_MEMBERS_CHANGED_DETAILED;
 
+  if (self->priv->properties)
+    flags |= TP_CHANNEL_GROUP_FLAG_PROPERTIES;
+
   tp_group_mixin_init (object, G_STRUCT_OFFSET (TestTextChannelGroup, group),
       contact_repo, self->conn->self_handle);
   tp_group_mixin_change_flags (object, flags, 0);
@@ -176,6 +181,9 @@ get_property (GObject *object,
     case PROP_DETAILED:
       g_value_set_boolean (value, self->priv->detailed);
       break;
+    case PROP_PROPERTIES:
+      g_value_set_boolean (value, self->priv->properties);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -208,6 +216,9 @@ set_property (GObject *object,
     case PROP_DETAILED:
       self->priv->detailed = g_value_get_boolean (value);
       break;
+    case PROP_PROPERTIES:
+      self->priv->properties = g_value_get_boolean (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -333,6 +344,13 @@ test_text_channel_group_class_init (TestTextChannelGroupClass *klass)
       G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
   g_object_class_install_property (object_class, PROP_DETAILED, param_spec);
 
+  param_spec = g_param_spec_boolean ("properties",
+      "Has the Properties flag?",
+      "True if the Properties group flag should be set",
+      TRUE,
+      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, PROP_PROPERTIES, param_spec);
+
   tp_text_mixin_class_init (object_class,
       G_STRUCT_OFFSET (TestTextChannelGroupClass, text_class));
   tp_group_mixin_class_init (object_class,
-- 
1.5.6.5




More information about the Telepathy-commits mailing list