telepathy-glib: Add unit test for tp_capabilities_supports_audio(_video) _call()
Xavier Claessens
xclaesse at kemper.freedesktop.org
Tue Apr 17 03:57:57 PDT 2012
Module: telepathy-glib
Branch: master
Commit: ded205c7dd94ee87c03e5fc55e7955a6c2b570d9
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=ded205c7dd94ee87c03e5fc55e7955a6c2b570d9
Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date: Mon Apr 16 22:12:53 2012 +0200
Add unit test for tp_capabilities_supports_audio(_video)_call()
---
tests/capabilities.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 168 insertions(+), 0 deletions(-)
diff --git a/tests/capabilities.c b/tests/capabilities.c
index f05964c..7b82195 100644
--- a/tests/capabilities.c
+++ b/tests/capabilities.c
@@ -754,6 +754,172 @@ test_supports_sms (Test *test,
g_object_unref (caps);
}
+static void
+add_call_class (GPtrArray *classes,
+ TpHandleType handle_type,
+ gboolean initial_audio,
+ gboolean initial_video,
+ gboolean use_allowed,
+ gboolean add_extra_fixed)
+{
+ GHashTable *fixed;
+ GPtrArray *allowed;
+ GValueArray *arr;
+
+ fixed = tp_asv_new (
+ TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
+ TP_IFACE_CHANNEL_TYPE_CALL,
+ TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
+ handle_type,
+ NULL);
+
+ allowed = g_ptr_array_new ();
+
+ if (initial_audio)
+ {
+ if (use_allowed)
+ {
+ g_ptr_array_add (allowed, TP_PROP_CHANNEL_TYPE_CALL_INITIAL_AUDIO);
+ }
+ else
+ {
+ tp_asv_set_boolean (fixed, TP_PROP_CHANNEL_TYPE_CALL_INITIAL_AUDIO,
+ TRUE);
+ }
+ }
+
+ if (initial_video)
+ {
+ if (use_allowed)
+ {
+ g_ptr_array_add (allowed, TP_PROP_CHANNEL_TYPE_CALL_INITIAL_VIDEO);
+ }
+ else
+ {
+ tp_asv_set_boolean (fixed, TP_PROP_CHANNEL_TYPE_CALL_INITIAL_VIDEO,
+ TRUE);
+ }
+ }
+
+ g_ptr_array_add (allowed, NULL);
+
+ if (add_extra_fixed)
+ tp_asv_set_boolean (fixed, "ExtraBadgersRequired", TRUE);
+
+ arr = tp_value_array_build (2,
+ TP_HASH_TYPE_STRING_VARIANT_MAP, fixed,
+ G_TYPE_STRV, allowed->pdata,
+ G_TYPE_INVALID);
+
+ g_hash_table_unref (fixed);
+ g_ptr_array_unref (allowed);
+
+ g_ptr_array_add (classes, arr);
+}
+
+static void
+test_supports_call (Test *test,
+ gconstpointer data G_GNUC_UNUSED)
+{
+ TpCapabilities *caps;
+ GPtrArray *classes;
+
+ /* A class with no audio/video can't do anything */
+ classes = g_ptr_array_sized_new (1);
+ add_call_class (classes, TP_HANDLE_TYPE_CONTACT, FALSE, FALSE, FALSE, FALSE);
+
+ caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
+ "channel-classes", classes,
+ "contact-specific", FALSE,
+ NULL);
+
+ g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
+ classes);
+
+ g_assert (!tp_capabilities_supports_audio_call (caps,
+ TP_HANDLE_TYPE_CONTACT));
+ g_assert (!tp_capabilities_supports_audio_video_call (caps,
+ TP_HANDLE_TYPE_CONTACT));
+
+ g_object_unref (caps);
+
+ /* A class with only audio can't do audio_video */
+ classes = g_ptr_array_sized_new (1);
+ add_call_class (classes, TP_HANDLE_TYPE_CONTACT, TRUE, FALSE, FALSE, FALSE);
+
+ caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
+ "channel-classes", classes,
+ "contact-specific", FALSE,
+ NULL);
+
+ g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
+ classes);
+
+ g_assert (tp_capabilities_supports_audio_call (caps,
+ TP_HANDLE_TYPE_CONTACT));
+ g_assert (!tp_capabilities_supports_audio_video_call (caps,
+ TP_HANDLE_TYPE_CONTACT));
+
+ g_object_unref (caps);
+
+ /* A class with audio and video in fixed can't do audio only */
+ classes = g_ptr_array_sized_new (1);
+ add_call_class (classes, TP_HANDLE_TYPE_CONTACT, TRUE, TRUE, FALSE, FALSE);
+
+ caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
+ "channel-classes", classes,
+ "contact-specific", FALSE,
+ NULL);
+
+ g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
+ classes);
+
+ g_assert (!tp_capabilities_supports_audio_call (caps,
+ TP_HANDLE_TYPE_CONTACT));
+ g_assert (tp_capabilities_supports_audio_video_call (caps,
+ TP_HANDLE_TYPE_CONTACT));
+
+ g_object_unref (caps);
+
+ /* A class with audio and video in allowed can do audio only */
+ classes = g_ptr_array_sized_new (1);
+ add_call_class (classes, TP_HANDLE_TYPE_CONTACT, TRUE, TRUE, TRUE, FALSE);
+
+ caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
+ "channel-classes", classes,
+ "contact-specific", FALSE,
+ NULL);
+
+ g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
+ classes);
+
+ g_assert (tp_capabilities_supports_audio_call (caps,
+ TP_HANDLE_TYPE_CONTACT));
+ g_assert (tp_capabilities_supports_audio_video_call (caps,
+ TP_HANDLE_TYPE_CONTACT));
+
+ g_object_unref (caps);
+
+ /* A class with unknown extra fixed can't do anything */
+ classes = g_ptr_array_sized_new (1);
+ add_call_class (classes, TP_HANDLE_TYPE_CONTACT, TRUE, TRUE, TRUE, TRUE);
+
+ caps = tp_tests_object_new_static_class (TP_TYPE_CAPABILITIES,
+ "channel-classes", classes,
+ "contact-specific", FALSE,
+ NULL);
+
+ g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
+ classes);
+
+ g_assert (!tp_capabilities_supports_audio_call (caps,
+ TP_HANDLE_TYPE_CONTACT));
+ g_assert (!tp_capabilities_supports_audio_video_call (caps,
+ TP_HANDLE_TYPE_CONTACT));
+
+ g_object_unref (caps);
+}
+
int
main (int argc,
char **argv)
@@ -773,6 +939,8 @@ main (int argc,
test_supports_room_list, NULL);
g_test_add (TEST_PREFIX "supports/sms", Test, NULL, setup,
test_supports_sms, NULL);
+ g_test_add (TEST_PREFIX "supports/call", Test, NULL, setup,
+ test_supports_call, NULL);
return g_test_run ();
}
More information about the telepathy-commits
mailing list