telepathy-glib: tests: add simple TpFutureAccount test
Jonny Lamb
jonny at kemper.freedesktop.org
Thu May 10 07:41:17 PDT 2012
Module: telepathy-glib
Branch: master
Commit: 4e13f0c52ee32c22a69db28afc98a010c861c711
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=4e13f0c52ee32c22a69db28afc98a010c861c711
Author: Jonny Lamb <jonny.lamb at collabora.co.uk>
Date: Wed Apr 25 18:47:53 2012 +0100
tests: add simple TpFutureAccount test
Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
tests/dbus/Makefile.am | 4 ++
tests/dbus/future-account.c | 107 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 111 insertions(+), 0 deletions(-)
diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am
index b1c77a9..09d25f0 100644
--- a/tests/dbus/Makefile.am
+++ b/tests/dbus/Makefile.am
@@ -39,6 +39,7 @@ tests_list = \
test-example-no-protocols \
test-file-transfer-channel \
test-finalized-in-invalidated-handler \
+ test-future-account \
test-get-interface-after-invalidate \
test-group-mixin \
test-handle-repo \
@@ -180,6 +181,9 @@ test_file_transfer_channel_SOURCES = file-transfer-channel.c
test_finalized_in_invalidated_handler_SOURCES = \
finalized-in-invalidated-handler.c
+test_future_account_SOURCES = \
+ future-account.c
+
test_get_interface_after_invalidate_SOURCES = \
get-interface-after-invalidate.c
diff --git a/tests/dbus/future-account.c b/tests/dbus/future-account.c
new file mode 100644
index 0000000..7396ebe
--- /dev/null
+++ b/tests/dbus/future-account.c
@@ -0,0 +1,107 @@
+/* A very basic feature test for TpFutureAccount
+ *
+ * Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * Copying and distribution of this file, with or without modification,
+ * are permitted in any medium without royalty provided the copyright
+ * notice and this notice are preserved.
+ */
+
+#include "config.h"
+
+#include <telepathy-glib/future-account.h>
+
+#include "tests/lib/util.h"
+
+typedef struct {
+ GMainLoop *mainloop;
+ TpDBusDaemon *dbus;
+
+ TpAccountManager *account_manager;
+ TpFutureAccount *account;
+
+ GAsyncResult *result;
+ GError *error /* initialized where needed */;
+} Test;
+
+static void
+setup (Test *test,
+ gconstpointer data G_GNUC_UNUSED)
+{
+ test->mainloop = g_main_loop_new (NULL, FALSE);
+ test->dbus = tp_tests_dbus_daemon_dup_or_die ();
+ g_assert (test->dbus != NULL);
+
+ test->account_manager = tp_account_manager_dup ();
+ g_assert (test->account_manager != NULL);
+
+ test->account = NULL;
+}
+
+static void
+teardown (Test *test,
+ gconstpointer data G_GNUC_UNUSED)
+{
+ g_clear_object (&test->account);
+
+ /* make sure any pending calls on the account have happened, so it can die */
+ tp_tests_proxy_run_until_dbus_queue_processed (test->dbus);
+
+ g_clear_object (&test->dbus);
+ tp_clear_pointer (&test->mainloop, g_main_loop_unref);
+
+ g_clear_error (&test->error);
+ tp_clear_object (&test->result);
+}
+
+static void
+test_new (Test *test,
+ gconstpointer data G_GNUC_UNUSED)
+{
+ test->account = tp_future_account_new (test->account_manager,
+ "gabble", "jabber");
+ g_assert (TP_IS_FUTURE_ACCOUNT (test->account));
+}
+
+static void
+test_properties (Test *test,
+ gconstpointer data G_GNUC_UNUSED)
+{
+ TpAccountManager *am;
+ gchar *manager, *protocol;
+
+ test->account = tp_future_account_new (test->account_manager,
+ "gabble", "jabber");
+
+ g_object_get (test->account,
+ "account-manager", &am,
+ "connection-manager", &manager,
+ "protocol", &protocol,
+ NULL);
+
+ g_assert (am == test->account_manager);
+ g_assert_cmpstr (manager, ==, "gabble");
+ g_assert_cmpstr (protocol, ==, "jabber");
+
+ g_object_unref (am);
+ g_free (manager);
+ g_free (protocol);
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ g_type_init ();
+ tp_tests_abort_after (10);
+ tp_debug_set_flags ("all");
+
+ g_test_init (&argc, &argv, NULL);
+ g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
+
+ g_test_add ("/future-account/new", Test, NULL, setup, test_new, teardown);
+ g_test_add ("/future-account/properties", Test, NULL, setup,
+ test_properties, teardown);
+
+ return g_test_run ();
+}
More information about the telepathy-commits
mailing list