[folks/next] sync test code with tp-glib next HEAD



commit 50dd7e38c3ffbee2aca5aa9b01e41bb2217be487
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri May 16 15:33:40 2014 +0200

    sync test code with tp-glib next HEAD

 .../telepathy/contactlist/contact-list-manager.c   |   95 ++++++++++++--------
 tests/lib/telepathy/contactlist/contacts-conn.c    |   32 +++-----
 tests/lib/telepathy/contactlist/contacts-conn.h    |    2 -
 .../telepathy/contactlist/simple-account-manager.c |   16 +---
 .../telepathy/contactlist/simple-account-manager.h |    1 -
 tests/lib/telepathy/contactlist/simple-account.c   |   42 +++------
 tests/lib/telepathy/contactlist/simple-account.h   |    1 -
 7 files changed, 85 insertions(+), 104 deletions(-)
---
diff --git a/tests/lib/telepathy/contactlist/contact-list-manager.c 
b/tests/lib/telepathy/contactlist/contact-list-manager.c
index 452bcce..d51bf42 100644
--- a/tests/lib/telepathy/contactlist/contact-list-manager.c
+++ b/tests/lib/telepathy/contactlist/contact-list-manager.c
@@ -427,13 +427,18 @@ contact_list_request_subscription_async (TpBaseContactList *self,
     GAsyncReadyCallback callback,
     gpointer user_data)
 {
-  GArray *handles;
+  GVariant *handles;
+  gconstpointer arr;
+  gsize len;
+
+  handles = tp_handle_set_to_variant (contacts);
+  g_variant_ref_sink (handles);
+  arr = g_variant_get_fixed_array (handles, &len, sizeof (TpHandle));
 
-  handles = tp_handle_set_to_array (contacts);
   tp_tests_contact_list_manager_request_subscription (
       (TpTestsContactListManager *) self,
-      handles->len, (TpHandle *) handles->data, message);
-  g_array_unref (handles);
+      len, (TpHandle *) arr, message);
+  g_variant_unref (handles);
 
   tp_simple_async_report_success_in_idle ((GObject *) self, callback,
       user_data, contact_list_request_subscription_async);
@@ -445,13 +450,16 @@ contact_list_authorize_publication_async (TpBaseContactList *self,
     GAsyncReadyCallback callback,
     gpointer user_data)
 {
-  GArray *handles;
+  GVariant *handles;
+  gconstpointer arr;
+  gsize len;
+
+  handles = tp_handle_set_to_variant (contacts);
+  arr = g_variant_get_fixed_array (handles, &len, sizeof (TpHandle));
 
-  handles = tp_handle_set_to_array (contacts);
   tp_tests_contact_list_manager_authorize_publication (
-      (TpTestsContactListManager *) self,
-      handles->len, (TpHandle *) handles->data);
-  g_array_unref (handles);
+      (TpTestsContactListManager *) self, len, (TpHandle *) arr);
+  g_variant_unref (handles);
 
   tp_simple_async_report_success_in_idle ((GObject *) self, callback,
       user_data, contact_list_authorize_publication_async);
@@ -463,13 +471,16 @@ contact_list_remove_contacts_async (TpBaseContactList *self,
     GAsyncReadyCallback callback,
     gpointer user_data)
 {
-  GArray *handles;
+  GVariant *handles;
+  gconstpointer arr;
+  gsize len;
+
+  handles = tp_handle_set_to_variant (contacts);
+  arr = g_variant_get_fixed_array (handles, &len, sizeof (TpHandle));
 
-  handles = tp_handle_set_to_array (contacts);
   tp_tests_contact_list_manager_remove (
-      (TpTestsContactListManager *) self,
-      handles->len, (TpHandle *) handles->data);
-  g_array_unref (handles);
+      (TpTestsContactListManager *) self, len, (TpHandle *) arr);
+  g_variant_unref (handles);
 
   tp_simple_async_report_success_in_idle ((GObject *) self, callback,
       user_data, contact_list_remove_contacts_async);
@@ -481,13 +492,15 @@ contact_list_unsubscribe_async (TpBaseContactList *self,
     GAsyncReadyCallback callback,
     gpointer user_data)
 {
-  GArray *handles;
+  GVariant *handles;
+  gconstpointer arr;
+  gsize len;
 
-  handles = tp_handle_set_to_array (contacts);
+  handles = tp_handle_set_to_variant (contacts);
+  arr = g_variant_get_fixed_array (handles, &len, sizeof (TpHandle));
   tp_tests_contact_list_manager_unsubscribe (
-      (TpTestsContactListManager *) self,
-      handles->len, (TpHandle *) handles->data);
-  g_array_unref (handles);
+      (TpTestsContactListManager *) self, len, (TpHandle *) arr);
+  g_variant_unref (handles);
 
   tp_simple_async_report_success_in_idle ((GObject *) self, callback,
       user_data, contact_list_unsubscribe_async);
@@ -499,13 +512,15 @@ contact_list_unpublish_async (TpBaseContactList *self,
     GAsyncReadyCallback callback,
     gpointer user_data)
 {
-  GArray *handles;
+  GVariant *handles;
+  gconstpointer arr;
+  gsize len;
 
-  handles = tp_handle_set_to_array (contacts);
+  handles = tp_handle_set_to_variant (contacts);
+  arr = g_variant_get_fixed_array (handles, &len, sizeof (TpHandle));
   tp_tests_contact_list_manager_unpublish (
-      (TpTestsContactListManager *) self,
-      handles->len, (TpHandle *) handles->data);
-  g_array_unref (handles);
+      (TpTestsContactListManager *) self, len, (TpHandle *) arr);
+  g_variant_unref (handles);
 
   tp_simple_async_report_success_in_idle ((GObject *) self, callback,
       user_data, contact_list_unpublish_async);
@@ -668,14 +683,16 @@ static gboolean
 receive_authorized (gpointer p)
 {
   SelfAndContact *s = p;
-  GArray *handles_array;
-  guint i;
+  GVariant *handles;
+  GVariantIter iter;
+  TpHandle handle;
+
+  handles = tp_handle_set_to_variant (s->handles);
 
-  handles_array = tp_handle_set_to_array (s->handles);
-  for (i = 0; i < handles_array->len; i++)
+  g_variant_iter_init (&iter, handles);
+  while (g_variant_iter_loop (&iter, "u", &handle))
     {
-      ContactDetails *d = lookup_contact (s->self,
-          g_array_index (handles_array, TpHandle, i));
+      ContactDetails *d = lookup_contact (s->self, handle);
 
       if (d == NULL)
         continue;
@@ -690,7 +707,7 @@ receive_authorized (gpointer p)
           d->publish_request = g_strdup ("automatic publish request");
         }
     }
-  g_array_unref (handles_array);
+  g_variant_unref (handles);
 
   tp_base_contact_list_contacts_changed (TP_BASE_CONTACT_LIST (s->self),
       s->handles, NULL);
@@ -702,21 +719,23 @@ static gboolean
 receive_unauthorized (gpointer p)
 {
   SelfAndContact *s = p;
-  GArray *handles_array;
-  guint i;
+  GVariant *handles;
+  GVariantIter iter;
+  TpHandle handle;
+
+  handles = tp_handle_set_to_variant (s->handles);
 
-  handles_array = tp_handle_set_to_array (s->handles);
-  for (i = 0; i < handles_array->len; i++)
+  g_variant_iter_init (&iter, handles);
+  while (g_variant_iter_loop (&iter, "u", &handle))
     {
-      ContactDetails *d = lookup_contact (s->self,
-          g_array_index (handles_array, TpHandle, i));
+      ContactDetails *d = lookup_contact (s->self, handle);
 
       if (d == NULL)
         continue;
 
       d->subscribe = TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY;
     }
-  g_array_unref (handles_array);
+  g_variant_unref (handles);
 
   tp_base_contact_list_contacts_changed (TP_BASE_CONTACT_LIST (s->self),
       s->handles, NULL);
diff --git a/tests/lib/telepathy/contactlist/contacts-conn.c b/tests/lib/telepathy/contactlist/contacts-conn.c
index a418cb7..a835d37 100644
--- a/tests/lib/telepathy/contactlist/contacts-conn.c
+++ b/tests/lib/telepathy/contactlist/contacts-conn.c
@@ -532,24 +532,6 @@ tp_tests_contacts_connection_class_init (TpTestsContactsConnectionClass *klass)
     { "AliasFlags", GUINT_TO_POINTER (ALIASING_DP_ALIAS_FLAGS), NULL },
     { NULL }
   };
-  static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
-        { TP_IFACE_CONNECTION_INTERFACE_AVATARS1,
-          conn_avatars_properties_getter,
-          NULL,
-          conn_avatars_properties,
-        },
-        { TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO1,
-          conn_contact_info_properties_getter,
-          NULL,
-          conn_contact_info_properties,
-        },
-        { TP_IFACE_CONNECTION_INTERFACE_ALIASING1,
-          aliasing_get_dbus_property,
-          NULL,
-          aliasing_props,
-        },
-        { NULL }
-  };
 
   object_class->constructed = constructed;
   object_class->dispose = dispose;
@@ -560,9 +542,17 @@ tp_tests_contacts_connection_class_init (TpTestsContactsConnectionClass *klass)
   base_class->fill_contact_attributes =
     tp_tests_contacts_connection_fill_contact_attributes;
 
-  klass->properties_class.interfaces = prop_interfaces;
-  tp_dbus_properties_mixin_class_init (object_class,
-      G_STRUCT_OFFSET (TpTestsContactsConnectionClass, properties_class));
+  tp_dbus_properties_mixin_class_init (object_class, 0);
+  tp_dbus_properties_mixin_implement_interface (object_class,
+        TP_IFACE_QUARK_CONNECTION_INTERFACE_AVATARS1,
+        conn_avatars_properties_getter, NULL, conn_avatars_properties);
+  tp_dbus_properties_mixin_implement_interface (object_class,
+        TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_INFO1,
+        conn_contact_info_properties_getter, NULL,
+        conn_contact_info_properties);
+  tp_dbus_properties_mixin_implement_interface (object_class,
+        TP_IFACE_QUARK_CONNECTION_INTERFACE_ALIASING1,
+        aliasing_get_dbus_property, NULL, aliasing_props);
 }
 
 TpTestsContactListManager *
diff --git a/tests/lib/telepathy/contactlist/contacts-conn.h b/tests/lib/telepathy/contactlist/contacts-conn.h
index 2814055..7a4a7ca 100644
--- a/tests/lib/telepathy/contactlist/contacts-conn.h
+++ b/tests/lib/telepathy/contactlist/contacts-conn.h
@@ -27,8 +27,6 @@ typedef struct _TpTestsContactsConnectionPrivate TpTestsContactsConnectionPrivat
 
 struct _TpTestsContactsConnectionClass {
     TpTestsSimpleConnectionClass parent_class;
-
-    TpDBusPropertiesMixinClass properties_class;
 };
 
 struct _TpTestsContactsConnection {
diff --git a/tests/lib/telepathy/contactlist/simple-account-manager.c 
b/tests/lib/telepathy/contactlist/simple-account-manager.c
index 7b01e06..0bc9d66 100644
--- a/tests/lib/telepathy/contactlist/simple-account-manager.c
+++ b/tests/lib/telepathy/contactlist/simple-account-manager.c
@@ -162,15 +162,6 @@ tp_tests_simple_account_manager_class_init (
         { NULL }
   };
 
-  static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
-        { TP_IFACE_ACCOUNT_MANAGER,
-          tp_dbus_properties_mixin_getter_gobject_properties,
-          NULL,
-          am_props
-        },
-        { NULL },
-  };
-
   g_type_class_add_private (klass, sizeof (TpTestsSimpleAccountManagerPrivate));
   object_class->finalize = tp_tests_simple_account_manager_finalize;
   object_class->get_property = tp_tests_simple_account_manager_get_property;
@@ -191,9 +182,10 @@ tp_tests_simple_account_manager_class_init (
       G_PARAM_READABLE);
   g_object_class_install_property (object_class, PROP_UNUSABLE_ACCOUNTS, param_spec);
 
-  klass->dbus_props_class.interfaces = prop_interfaces;
-  tp_dbus_properties_mixin_class_init (object_class,
-      G_STRUCT_OFFSET (TpTestsSimpleAccountManagerClass, dbus_props_class));
+  tp_dbus_properties_mixin_class_init (object_class, 0);
+  tp_dbus_properties_mixin_implement_interface (object_class,
+        TP_IFACE_QUARK_ACCOUNT_MANAGER,
+        tp_dbus_properties_mixin_getter_gobject_properties, NULL, am_props);
 }
 
 static void
diff --git a/tests/lib/telepathy/contactlist/simple-account-manager.h 
b/tests/lib/telepathy/contactlist/simple-account-manager.h
index 0ed114d..778e11b 100644
--- a/tests/lib/telepathy/contactlist/simple-account-manager.h
+++ b/tests/lib/telepathy/contactlist/simple-account-manager.h
@@ -24,7 +24,6 @@ typedef struct _TpTestsSimpleAccountManagerPrivate TpTestsSimpleAccountManagerPr
 
 struct _TpTestsSimpleAccountManagerClass {
     GObjectClass parent_class;
-    TpDBusPropertiesMixinClass dbus_props_class;
 };
 
 struct _TpTestsSimpleAccountManager {
diff --git a/tests/lib/telepathy/contactlist/simple-account.c 
b/tests/lib/telepathy/contactlist/simple-account.c
index c56cec6..25f5a00 100644
--- a/tests/lib/telepathy/contactlist/simple-account.c
+++ b/tests/lib/telepathy/contactlist/simple-account.c
@@ -386,32 +386,6 @@ tp_tests_simple_account_class_init (TpTestsSimpleAccountClass *klass)
         { NULL },
   };
 
-  static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
-        { TP_IFACE_ACCOUNT,
-          tp_dbus_properties_mixin_getter_gobject_properties,
-          NULL,
-          a_props
-        },
-        {
-          TP_IFACE_ACCOUNT_INTERFACE_STORAGE1,
-          tp_dbus_properties_mixin_getter_gobject_properties,
-          NULL,
-          ais_props
-        },
-        {
-          TP_IFACE_ACCOUNT_INTERFACE_ADDRESSING1,
-          tp_dbus_properties_mixin_getter_gobject_properties,
-          NULL,
-          aia_props
-        },
-        { TP_IFACE_ACCOUNT_INTERFACE_AVATAR1,
-          tp_dbus_properties_mixin_getter_gobject_properties,
-          NULL,
-          avatar_props
-        },
-        { NULL },
-  };
-
   g_type_class_add_private (klass, sizeof (TpTestsSimpleAccountPrivate));
   object_class->get_property = tp_tests_simple_account_get_property;
   object_class->set_property = tp_tests_simple_account_set_property;
@@ -583,9 +557,19 @@ tp_tests_simple_account_class_init (TpTestsSimpleAccountClass *klass)
   g_object_class_install_property (object_class,
       PROP_SUPERSEDES, param_spec);
 
-  klass->dbus_props_class.interfaces = prop_interfaces;
-  tp_dbus_properties_mixin_class_init (object_class,
-      G_STRUCT_OFFSET (TpTestsSimpleAccountClass, dbus_props_class));
+  tp_dbus_properties_mixin_class_init (object_class, 0);
+  tp_dbus_properties_mixin_implement_interface (object_class,
+        TP_IFACE_QUARK_ACCOUNT,
+        tp_dbus_properties_mixin_getter_gobject_properties, NULL, a_props);
+  tp_dbus_properties_mixin_implement_interface (object_class,
+        TP_IFACE_QUARK_ACCOUNT_INTERFACE_STORAGE1,
+        tp_dbus_properties_mixin_getter_gobject_properties, NULL, ais_props);
+  tp_dbus_properties_mixin_implement_interface (object_class,
+        TP_IFACE_QUARK_ACCOUNT_INTERFACE_ADDRESSING1,
+        tp_dbus_properties_mixin_getter_gobject_properties, NULL, aia_props);
+  tp_dbus_properties_mixin_implement_interface (object_class,
+        TP_IFACE_QUARK_ACCOUNT_INTERFACE_AVATAR1,
+        tp_dbus_properties_mixin_getter_gobject_properties, NULL, avatar_props);
 }
 
 void
diff --git a/tests/lib/telepathy/contactlist/simple-account.h 
b/tests/lib/telepathy/contactlist/simple-account.h
index a7fdcf2..557a110 100644
--- a/tests/lib/telepathy/contactlist/simple-account.h
+++ b/tests/lib/telepathy/contactlist/simple-account.h
@@ -24,7 +24,6 @@ typedef struct _TpTestsSimpleAccountPrivate TpTestsSimpleAccountPrivate;
 
 struct _TpTestsSimpleAccountClass {
     GObjectClass parent_class;
-    TpDBusPropertiesMixinClass dbus_props_class;
 };
 
 struct _TpTestsSimpleAccount {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]