[telepathy-glib/master] Add a trivial test for TpAccount, TpAccountManager

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Jun 8 09:36:39 PDT 2009


These just test that nothing actually crashes when we make a TpAccount
and a TpAccountManager.
---
 tests/dbus/Makefile.am       |    6 +++
 tests/dbus/account-manager.c |   69 ++++++++++++++++++++++++++++++++++++
 tests/dbus/account.c         |   79 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 154 insertions(+), 0 deletions(-)
 create mode 100644 tests/dbus/account-manager.c
 create mode 100644 tests/dbus/account.c

diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am
index 049d550..41bcbb0 100644
--- a/tests/dbus/Makefile.am
+++ b/tests/dbus/Makefile.am
@@ -1,6 +1,8 @@
 include $(top_srcdir)/tools/shave.mk
 
 noinst_PROGRAMS = \
+    test-account \
+    test-account-manager \
     test-call-cancellation \
     test-callable-example \
     test-channel-introspect \
@@ -39,6 +41,10 @@ LDADD = \
     $(top_builddir)/telepathy-glib/libtelepathy-glib.la \
     $(top_builddir)/tests/lib/libtp-glib-tests.la
 
+test_account_SOURCES = account.c
+
+test_account_manager_SOURCES = account-manager.c
+
 test_call_cancellation_SOURCES = call-cancellation.c
 
 test_channel_introspect_SOURCES = channel-introspect.c
diff --git a/tests/dbus/account-manager.c b/tests/dbus/account-manager.c
new file mode 100644
index 0000000..7aa373a
--- /dev/null
+++ b/tests/dbus/account-manager.c
@@ -0,0 +1,69 @@
+/* A very basic feature test for TpAccountManager
+ *
+ * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * 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 <telepathy-glib/account-manager.h>
+#include <telepathy-glib/debug.h>
+
+typedef struct {
+    GMainLoop *mainloop;
+    TpDBusDaemon *dbus;
+
+    TpAccountManager *am;
+    GError *error /* initialized where needed */;
+} Test;
+
+static void
+setup (Test *test,
+       gconstpointer data)
+{
+  g_type_init ();
+  tp_debug_set_flags ("all");
+
+  test->mainloop = g_main_loop_new (NULL, FALSE);
+  test->dbus = tp_dbus_daemon_dup (NULL);
+  g_assert (test->dbus != NULL);
+
+  test->am = NULL;
+}
+
+static void
+teardown (Test *test,
+          gconstpointer data)
+{
+  if (test->am != NULL)
+    {
+      g_object_unref (test->am);
+      test->am = NULL;
+    }
+
+  g_object_unref (test->dbus);
+  test->dbus = NULL;
+  g_main_loop_unref (test->mainloop);
+  test->mainloop = NULL;
+}
+
+static void
+test_new (Test *test,
+          gconstpointer data G_GNUC_UNUSED)
+{
+  test->am = tp_account_manager_new (test->dbus);
+}
+
+int
+main (int argc,
+      char **argv)
+{
+  g_test_init (&argc, &argv, NULL);
+  g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
+
+  g_test_add ("/am/new", Test, NULL, setup, test_new, teardown);
+
+  return g_test_run ();
+}
diff --git a/tests/dbus/account.c b/tests/dbus/account.c
new file mode 100644
index 0000000..aeb8762
--- /dev/null
+++ b/tests/dbus/account.c
@@ -0,0 +1,79 @@
+/* A very basic feature test for TpAccount
+ *
+ * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * 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 <telepathy-glib/account.h>
+#include <telepathy-glib/debug.h>
+
+typedef struct {
+    GMainLoop *mainloop;
+    TpDBusDaemon *dbus;
+
+    TpAccount *account;
+    GError *error /* initialized where needed */;
+} Test;
+
+static void
+setup (Test *test,
+       gconstpointer data)
+{
+  g_type_init ();
+  tp_debug_set_flags ("all");
+
+  test->mainloop = g_main_loop_new (NULL, FALSE);
+  test->dbus = tp_dbus_daemon_dup (NULL);
+  g_assert (test->dbus != NULL);
+
+  test->account = NULL;
+}
+
+static void
+teardown (Test *test,
+          gconstpointer data)
+{
+  if (test->account != NULL)
+    {
+      g_object_unref (test->account);
+      test->account = NULL;
+    }
+
+  g_object_unref (test->dbus);
+  test->dbus = NULL;
+  g_main_loop_unref (test->mainloop);
+  test->mainloop = NULL;
+}
+
+static void
+test_new (Test *test,
+          gconstpointer data G_GNUC_UNUSED)
+{
+  test->account = tp_account_new (test->dbus,
+      "/secretly/not/an/object", NULL);
+  g_assert (test->account == NULL);
+
+  test->account = tp_account_new (test->dbus,
+      "not even syntactically valid", NULL);
+  g_assert (test->account == NULL);
+
+  test->account = tp_account_new (test->dbus,
+      "/org/freedesktop/Telepathy/Account/whatever", NULL);
+  g_assert (test->account != NULL);
+}
+
+int
+main (int argc,
+      char **argv)
+{
+  g_test_init (&argc, &argv, NULL);
+  g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
+
+  g_test_add ("/account/new", Test, NULL, setup, test_new, teardown);
+
+  return g_test_run ();
+}
-- 
1.5.6.5




More information about the telepathy-commits mailing list