[next] telepathy-glib: Tests: Factor out tp_tests_add_channel_to_ptr_array
Xavier Claessens
xclaesse at kemper.freedesktop.org
Wed Dec 26 04:37:47 PST 2012
Module: telepathy-glib
Branch: next
Commit: c25eb43b838cafd7e4e8f60592b558829eebecc7
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=c25eb43b838cafd7e4e8f60592b558829eebecc7
Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date: Wed Dec 26 10:46:50 2012 +0100
Tests: Factor out tp_tests_add_channel_to_ptr_array
---
tests/dbus/account-channel-request.c | 20 +---------------
tests/dbus/base-client.c | 42 +++++++++------------------------
tests/dbus/simple-approver.c | 20 +---------------
tests/dbus/simple-handler.c | 20 +---------------
tests/dbus/simple-observer.c | 20 +---------------
tests/lib/util.c | 27 +++++++++++++++++++++
tests/lib/util.h | 3 ++
7 files changed, 46 insertions(+), 106 deletions(-)
diff --git a/tests/dbus/account-channel-request.c b/tests/dbus/account-channel-request.c
index faf1fbd..e5942f5 100644
--- a/tests/dbus/account-channel-request.c
+++ b/tests/dbus/account-channel-request.c
@@ -704,24 +704,6 @@ channel_delegated_cb (TpAccountChannelRequest *req,
}
static void
-add_channel_to_ptr_array (GPtrArray *arr,
- TpChannel *channel)
-{
- GValueArray *tmp;
-
- g_assert (arr != NULL);
- g_assert (channel != NULL);
-
- tmp = tp_value_array_build (2,
- DBUS_TYPE_G_OBJECT_PATH, tp_proxy_get_object_path (channel),
- TP_HASH_TYPE_STRING_VARIANT_MAP, tp_channel_borrow_immutable_properties (
- channel),
- G_TYPE_INVALID);
-
- g_ptr_array_add (arr, tmp);
-}
-
-static void
no_return_cb (TpClient *proxy,
const GError *error,
gpointer user_data,
@@ -799,7 +781,7 @@ test_handle_delegated (Test *test,
request_props, NULL);
channels = g_ptr_array_sized_new (1);
- add_channel_to_ptr_array (channels, test->channel);
+ tp_tests_add_channel_to_ptr_array (channels, test->channel);
base_client = _tp_account_channel_request_get_client (req);
g_assert (TP_IS_BASE_CLIENT (base_client));
diff --git a/tests/dbus/base-client.c b/tests/dbus/base-client.c
index b568b00..a76d909 100644
--- a/tests/dbus/base-client.c
+++ b/tests/dbus/base-client.c
@@ -464,24 +464,6 @@ out:
}
static void
-add_channel_to_ptr_array (GPtrArray *arr,
- TpChannel *channel)
-{
- GValueArray *tmp;
-
- g_assert (arr != NULL);
- g_assert (channel != NULL);
-
- tmp = tp_value_array_build (2,
- DBUS_TYPE_G_OBJECT_PATH, tp_proxy_get_object_path (channel),
- TP_HASH_TYPE_STRING_VARIANT_MAP, tp_channel_borrow_immutable_properties (
- channel),
- G_TYPE_INVALID);
-
- g_ptr_array_add (arr, tmp);
-}
-
-static void
free_channel_details (gpointer data,
gpointer user_data)
{
@@ -536,7 +518,7 @@ test_observer (Test *test,
/* Call ObserveChannels */
channels = g_ptr_array_sized_new (1);
- add_channel_to_ptr_array (channels, test->text_chan);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan);
requests_satisified = g_ptr_array_sized_new (0);
info = tp_asv_new (
@@ -675,8 +657,8 @@ test_approver (Test *test,
/* Call AddDispatchOperation */
channels = g_ptr_array_sized_new (2);
- add_channel_to_ptr_array (channels, test->text_chan);
- add_channel_to_ptr_array (channels, test->text_chan_2);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan_2);
properties = tp_asv_new (
TP_PROP_CHANNEL_DISPATCH_OPERATION_INTERFACES,
@@ -889,8 +871,8 @@ test_handler (Test *test,
/* Call HandleChannels */
channels = g_ptr_array_sized_new (2);
- add_channel_to_ptr_array (channels, test->text_chan);
- add_channel_to_ptr_array (channels, test->text_chan_2);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan_2);
requests_satisified = g_ptr_array_sized_new (0);
info = g_hash_table_new (NULL, NULL);
@@ -1086,7 +1068,7 @@ test_handler_requests (Test *test,
/* Call HandleChannels */
channels = g_ptr_array_sized_new (2);
- add_channel_to_ptr_array (channels, test->text_chan);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan);
requests_satisified = g_ptr_array_sized_new (1);
g_ptr_array_add (requests_satisified, "/Request");
@@ -1192,8 +1174,8 @@ test_channel_dispatch_operation_claim_with_async (Test *test,
/* Call AddDispatchOperation */
channels = g_ptr_array_sized_new (2);
- add_channel_to_ptr_array (channels, test->text_chan);
- add_channel_to_ptr_array (channels, test->text_chan_2);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan_2);
properties = tp_asv_new (
TP_PROP_CHANNEL_DISPATCH_OPERATION_INTERFACES,
@@ -1284,8 +1266,8 @@ test_delegate_channels (Test *test,
/* Call HandleChannels */
channels = g_ptr_array_sized_new (2);
- add_channel_to_ptr_array (channels, test->text_chan);
- add_channel_to_ptr_array (channels, test->text_chan_2);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan_2);
requests_satisified = g_ptr_array_sized_new (0);
info = g_hash_table_new (NULL, NULL);
@@ -1471,8 +1453,8 @@ delegate_to_preferred_handler (Test *test,
/* Call HandleChannels */
channels = g_ptr_array_sized_new (2);
- add_channel_to_ptr_array (channels, test->text_chan);
- add_channel_to_ptr_array (channels, test->text_chan_2);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan_2);
requests_satisified = g_ptr_array_sized_new (0);
info = g_hash_table_new (NULL, NULL);
diff --git a/tests/dbus/simple-approver.c b/tests/dbus/simple-approver.c
index 52be0b7..04be3fb 100644
--- a/tests/dbus/simple-approver.c
+++ b/tests/dbus/simple-approver.c
@@ -327,24 +327,6 @@ out:
}
static void
-add_channel_to_ptr_array (GPtrArray *arr,
- TpChannel *channel)
-{
- GValueArray *tmp;
-
- g_assert (arr != NULL);
- g_assert (channel != NULL);
-
- tmp = tp_value_array_build (2,
- DBUS_TYPE_G_OBJECT_PATH, tp_proxy_get_object_path (channel),
- TP_HASH_TYPE_STRING_VARIANT_MAP, tp_channel_borrow_immutable_properties (
- channel),
- G_TYPE_INVALID);
-
- g_ptr_array_add (arr, tmp);
-}
-
-static void
free_channel_details (gpointer data,
gpointer user_data)
{
@@ -361,7 +343,7 @@ call_add_dispatch (Test *test)
TP_CLIENT_BUS_NAME_BASE ".Badger", NULL, };
channels = g_ptr_array_sized_new (1);
- add_channel_to_ptr_array (channels, test->text_chan);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan);
properties = tp_asv_new (
TP_PROP_CHANNEL_DISPATCH_OPERATION_INTERFACES,
diff --git a/tests/dbus/simple-handler.c b/tests/dbus/simple-handler.c
index 40732f6..873f3a1 100644
--- a/tests/dbus/simple-handler.c
+++ b/tests/dbus/simple-handler.c
@@ -348,24 +348,6 @@ out:
}
static void
-add_channel_to_ptr_array (GPtrArray *arr,
- TpChannel *channel)
-{
- GValueArray *tmp;
-
- g_assert (arr != NULL);
- g_assert (channel != NULL);
-
- tmp = tp_value_array_build (2,
- DBUS_TYPE_G_OBJECT_PATH, tp_proxy_get_object_path (channel),
- TP_HASH_TYPE_STRING_VARIANT_MAP, tp_channel_borrow_immutable_properties (
- channel),
- G_TYPE_INVALID);
-
- g_ptr_array_add (arr, tmp);
-}
-
-static void
free_channel_details (gpointer data,
gpointer user_data)
{
@@ -380,7 +362,7 @@ call_handle_channels (Test *test)
int i;
channels = g_ptr_array_sized_new (1);
- add_channel_to_ptr_array (channels, test->text_chan);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan);
requests_satisified = g_ptr_array_sized_new (0);
info = g_hash_table_new (NULL, NULL);
diff --git a/tests/dbus/simple-observer.c b/tests/dbus/simple-observer.c
index 0a8f0d8..f45900b 100644
--- a/tests/dbus/simple-observer.c
+++ b/tests/dbus/simple-observer.c
@@ -315,24 +315,6 @@ out:
}
static void
-add_channel_to_ptr_array (GPtrArray *arr,
- TpChannel *channel)
-{
- GValueArray *tmp;
-
- g_assert (arr != NULL);
- g_assert (channel != NULL);
-
- tmp = tp_value_array_build (2,
- DBUS_TYPE_G_OBJECT_PATH, tp_proxy_get_object_path (channel),
- TP_HASH_TYPE_STRING_VARIANT_MAP, tp_channel_borrow_immutable_properties (
- channel),
- G_TYPE_INVALID);
-
- g_ptr_array_add (arr, tmp);
-}
-
-static void
free_channel_details (gpointer data,
gpointer user_data)
{
@@ -346,7 +328,7 @@ call_observe_channels (Test *test)
GHashTable *info;
channels = g_ptr_array_sized_new (1);
- add_channel_to_ptr_array (channels, test->text_chan);
+ tp_tests_add_channel_to_ptr_array (channels, test->text_chan);
requests_satisified = g_ptr_array_sized_new (0);
info = tp_asv_new (
diff --git a/tests/lib/util.c b/tests/lib/util.c
index 8694b0e..8cbc4b4 100644
--- a/tests/lib/util.c
+++ b/tests/lib/util.c
@@ -612,3 +612,30 @@ tp_tests_channel_new_from_properties (TpConnection *conn,
return tp_client_factory_ensure_channel (factory, conn,
object_path, immutable_properties, error);
}
+
+void
+tp_tests_add_channel_to_ptr_array (GPtrArray *arr,
+ TpChannel *channel)
+{
+ GValueArray *tmp;
+ GVariant *variant;
+ GValue v = G_VALUE_INIT;
+ GHashTable *asv;
+
+ g_assert (arr != NULL);
+ g_assert (channel != NULL);
+
+ variant = tp_channel_dup_immutable_properties (channel);
+ dbus_g_value_parse_g_variant (variant, &v);
+ asv = g_value_get_boxed (&v);
+
+ tmp = tp_value_array_build (2,
+ DBUS_TYPE_G_OBJECT_PATH, tp_proxy_get_object_path (channel),
+ TP_HASH_TYPE_STRING_VARIANT_MAP, asv,
+ G_TYPE_INVALID);
+
+ g_ptr_array_add (arr, tmp);
+ g_variant_unref (variant);
+ g_value_unset (&v);
+}
+
diff --git a/tests/lib/util.h b/tests/lib/util.h
index cd73183..b277efd 100644
--- a/tests/lib/util.h
+++ b/tests/lib/util.h
@@ -104,4 +104,7 @@ TpChannel *tp_tests_channel_new_from_properties (TpConnection *conn,
const GHashTable *immutable_properties,
GError **error);
+void tp_tests_add_channel_to_ptr_array (GPtrArray *arr,
+ TpChannel *channel);
+
#endif /* #ifndef __TP_TESTS_LIB_UTIL_H__ */
More information about the telepathy-commits
mailing list