summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-01-24 17:07:00 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-01-24 17:34:23 +0100
commit0981825d45b7c2e665b107ab7567d989b209f62d (patch)
treea3fa6a3daa5711c4506674f0cc00b6b4e1aa740e
parent49099ed58891b860444b37b29a213013c8d8f38b (diff)
downloadtelepathy-glib-0981825d45b7c2e665b107ab7567d989b209f62d.tar.gz
add tp_tests_simple_account_manager_set_valid_accounts()
Usefull for tests wanting to run with a specific set of valid accounts.
-rw-r--r--tests/lib/simple-account-manager.c40
-rw-r--r--tests/lib/simple-account-manager.h3
2 files changed, 36 insertions, 7 deletions
diff --git a/tests/lib/simple-account-manager.c b/tests/lib/simple-account-manager.c
index e1d1611f2..12adb2662 100644
--- a/tests/lib/simple-account-manager.c
+++ b/tests/lib/simple-account-manager.c
@@ -15,6 +15,7 @@
#include <telepathy-glib/interfaces.h>
#include <telepathy-glib/svc-generic.h>
#include <telepathy-glib/svc-account-manager.h>
+#include <telepathy-glib/util.h>
static void account_manager_iface_init (gpointer, gpointer);
@@ -49,7 +50,7 @@ enum
struct _TpTestsSimpleAccountManagerPrivate
{
- int dummy;
+ GPtrArray *valid_accounts;
};
static void
@@ -80,8 +81,15 @@ account_manager_iface_init (gpointer klass,
static void
tp_tests_simple_account_manager_init (TpTestsSimpleAccountManager *self)
{
+ guint i;
+
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
TP_TESTS_TYPE_SIMPLE_ACCOUNT_MANAGER, TpTestsSimpleAccountManagerPrivate);
+
+ self->priv->valid_accounts = g_ptr_array_new_with_free_func (g_free);
+
+ for (i = 0; VALID_ACCOUNTS[i] != NULL; i++)
+ g_ptr_array_add (self->priv->valid_accounts, g_strdup (VALID_ACCOUNTS[i]));
}
static void
@@ -90,6 +98,7 @@ tp_tests_simple_account_manager_get_property (GObject *object,
GValue *value,
GParamSpec *spec)
{
+ TpTestsSimpleAccountManager *self = SIMPLE_ACCOUNT_MANAGER (object);
GPtrArray *accounts;
guint i = 0;
@@ -99,12 +108,7 @@ tp_tests_simple_account_manager_get_property (GObject *object,
break;
case PROP_VALID_ACCOUNTS:
- accounts = g_ptr_array_new ();
-
- for (i=0; VALID_ACCOUNTS[i] != NULL; i++)
- g_ptr_array_add (accounts, g_strdup (VALID_ACCOUNTS[i]));
-
- g_value_take_boxed (value, accounts);
+ g_value_set_boxed (value, self->priv->valid_accounts);
break;
case PROP_INVALID_ACCOUNTS:
@@ -122,6 +126,17 @@ tp_tests_simple_account_manager_get_property (GObject *object,
}
}
+static void
+tp_tests_simple_account_manager_dispose (GObject *object)
+{
+ TpTestsSimpleAccountManager *self = SIMPLE_ACCOUNT_MANAGER (object);
+
+ tp_clear_pointer (&self->priv->valid_accounts, g_ptr_array_unref);
+
+ G_OBJECT_CLASS (tp_tests_simple_account_manager_parent_class)->dispose (
+ object);
+}
+
/**
* This class currently only provides the minimum for
* tp_account_manager_prepare to succeed. This turns out to be only a working
@@ -157,6 +172,7 @@ tp_tests_simple_account_manager_class_init (
g_type_class_add_private (klass, sizeof (TpTestsSimpleAccountManagerPrivate));
object_class->get_property = tp_tests_simple_account_manager_get_property;
+ object_class->dispose = tp_tests_simple_account_manager_dispose;
param_spec = g_param_spec_boxed ("interfaces", "Extra D-Bus interfaces",
"In this case we only implement AccountManager, so none.",
@@ -178,3 +194,13 @@ tp_tests_simple_account_manager_class_init (
tp_dbus_properties_mixin_class_init (object_class,
G_STRUCT_OFFSET (TpTestsSimpleAccountManagerClass, dbus_props_class));
}
+
+void
+tp_tests_simple_account_manager_set_valid_accounts (
+ TpTestsSimpleAccountManager *self,
+ GPtrArray *accounts)
+{
+ tp_clear_pointer (&self->priv->valid_accounts, g_ptr_array_unref);
+
+ self->priv->valid_accounts = g_ptr_array_ref (accounts);
+}
diff --git a/tests/lib/simple-account-manager.h b/tests/lib/simple-account-manager.h
index b4f787c18..406baf307 100644
--- a/tests/lib/simple-account-manager.h
+++ b/tests/lib/simple-account-manager.h
@@ -52,6 +52,9 @@ GType tp_tests_simple_account_manager_get_type (void);
(G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_SIMPLE_ACCOUNT_MANAGER, \
TpTestsSimpleAccountManagerClass))
+void tp_tests_simple_account_manager_set_valid_accounts (
+ TpTestsSimpleAccountManager *self,
+ GPtrArray *accounts);
G_END_DECLS