summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2013-10-23 11:12:35 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2013-10-23 11:12:35 +0200
commitdd8c765c0dbc080e408cadaf1de1cccafd938948 (patch)
tree7bf6a199490bde0fc8004b6c0d73ad2684348841
parent69be1c1cc0a328905a7df44f44f3e56d213db5af (diff)
simple-account: add test API to change the avatar
-rw-r--r--tests/lib/simple-account.c29
-rw-r--r--tests/lib/simple-account.h3
2 files changed, 25 insertions, 7 deletions
diff --git a/tests/lib/simple-account.c b/tests/lib/simple-account.c
index 79673d9ee..eeed423cd 100644
--- a/tests/lib/simple-account.c
+++ b/tests/lib/simple-account.c
@@ -10,6 +10,8 @@
#include "config.h"
+#include <string.h>
+
#include "simple-account.h"
#include <telepathy-glib/telepathy-glib.h>
@@ -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 351c6cc22..bfe996108 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__ */