From dd8c765c0dbc080e408cadaf1de1cccafd938948 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 23 Oct 2013 11:12:35 +0200 Subject: [PATCH 1/3] simple-account: add test API to change the avatar --- tests/lib/simple-account.c | 29 ++++++++++++++++++++++------- tests/lib/simple-account.h | 3 +++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/tests/lib/simple-account.c b/tests/lib/simple-account.c index 79673d9..eeed423 100644 --- a/tests/lib/simple-account.c +++ b/tests/lib/simple-account.c @@ -10,6 +10,8 @@ #include "config.h" +#include + #include "simple-account.h" #include @@ -76,6 +78,7 @@ struct _TpTestsSimpleAccountPrivate gboolean enabled; GPtrArray *uri_schemes; GHashTable *parameters; + GArray *avatar; }; static void @@ -140,6 +143,10 @@ tp_tests_simple_account_init (TpTestsSimpleAccount *self) g_ptr_array_add (self->priv->uri_schemes, g_strdup (uri_schemes[i])); self->priv->parameters = g_hash_table_new (NULL, NULL); + + self->priv->avatar = g_array_new (FALSE, FALSE, sizeof (char)); + + tp_tests_simple_account_set_avatar (self, ":-)"); } static void @@ -250,17 +257,11 @@ tp_tests_simple_account_get_property (GObject *object, break; case PROP_AVATAR: { - GArray *arr = g_array_new (FALSE, FALSE, sizeof (char)); - - /* includes NUL for simplicity */ - g_array_append_vals (arr, ":-)", 4); - g_value_take_boxed (value, tp_value_array_build (2, - TP_TYPE_UCHAR_ARRAY, arr, + TP_TYPE_UCHAR_ARRAY, self->priv->avatar, G_TYPE_STRING, "text/plain", G_TYPE_INVALID)); - g_array_unref (arr); } break; case PROP_SUPERSEDES: @@ -311,6 +312,7 @@ tp_tests_simple_account_finalize (GObject *object) g_ptr_array_unref (self->priv->uri_schemes); g_hash_table_unref (self->priv->parameters); + g_array_unref (self->priv->avatar); G_OBJECT_CLASS (tp_tests_simple_account_parent_class)->finalize (object); } @@ -639,3 +641,16 @@ tp_tests_simple_account_add_uri_scheme (TpTestsSimpleAccount *self, g_strfreev (schemes); g_hash_table_unref (changed); } + +void +tp_tests_simple_account_set_avatar (TpTestsSimpleAccount *self, + const gchar *avatar) +{ + g_return_if_fail (avatar != NULL); + + g_array_set_size (self->priv->avatar, 0); + /* includes NULL for simplicity */ + g_array_append_vals (self->priv->avatar, avatar, strlen (avatar) +1); + + tp_svc_account_interface_avatar_emit_avatar_changed (self); +} diff --git a/tests/lib/simple-account.h b/tests/lib/simple-account.h index 351c6cc..bfe9961 100644 --- a/tests/lib/simple-account.h +++ b/tests/lib/simple-account.h @@ -66,6 +66,9 @@ void tp_tests_simple_account_set_enabled (TpTestsSimpleAccount *self, void tp_tests_simple_account_add_uri_scheme (TpTestsSimpleAccount *self, const gchar * uri_scheme); +void tp_tests_simple_account_set_avatar (TpTestsSimpleAccount *self, + const gchar *avatar); + G_END_DECLS #endif /* #ifndef __TP_TESTS_SIMPLE_ACCOUNT_H__ */ -- 1.8.3.1