[next] telepathy-glib: Tpl D-Bus tests: run under tp_tests_run_with_bus() or equivalent
Simon McVittie
smcv at kemper.freedesktop.org
Tue Mar 18 07:03:27 PDT 2014
Module: telepathy-glib
Branch: next
Commit: 2fb2fc0da1afb9fe1cde4183eb5512124734232b
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=2fb2fc0da1afb9fe1cde4183eb5512124734232b
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Tue Mar 18 13:02:53 2014 +0000
Tpl D-Bus tests: run under tp_tests_run_with_bus() or equivalent
Reviewed-by: Guillaume Desmottes
---
tests/logger/dbus/test-entity.c | 4 +--
tests/logger/dbus/test-log-manager.c | 14 ++++++++--
tests/logger/dbus/test-tpl-log-iter-pidgin.c | 4 +--
tests/logger/dbus/test-tpl-log-iter-xml.c | 4 +--
tests/logger/dbus/test-tpl-log-store-pidgin.c | 12 ++++++++-
tests/logger/dbus/test-tpl-log-store-sqlite.c | 34 +++++++++++++++++++++++--
tests/logger/dbus/test-tpl-log-store-xml.c | 4 +--
tests/logger/dbus/test-tpl-log-walker.c | 4 +--
tests/logger/dbus/test-tpl-observer.c | 33 +++++++++++++++++++++---
9 files changed, 95 insertions(+), 18 deletions(-)
diff --git a/tests/logger/dbus/test-entity.c b/tests/logger/dbus/test-entity.c
index ba87722..ab9c9a2 100644
--- a/tests/logger/dbus/test-entity.c
+++ b/tests/logger/dbus/test-entity.c
@@ -154,7 +154,7 @@ test_entity_instantiation_from_tp_contact (void)
int main (int argc,
char **argv)
{
- g_test_init (&argc, &argv, NULL);
+ tp_tests_init (&argc, &argv);
g_test_add_func ("/entity/instantiation",
test_entity_instantiation);
@@ -165,5 +165,5 @@ int main (int argc,
g_test_add_func ("/entity/instantiation-from-tp-contact",
test_entity_instantiation_from_tp_contact);
- return g_test_run ();
+ return tp_tests_run_with_bus ();
}
diff --git a/tests/logger/dbus/test-log-manager.c b/tests/logger/dbus/test-log-manager.c
index fce3079..76455e5 100644
--- a/tests/logger/dbus/test-log-manager.c
+++ b/tests/logger/dbus/test-log-manager.c
@@ -742,11 +742,18 @@ main (int argc, char **argv)
GHashTable *params = NULL;
GList *l = NULL;
int retval;
+ GTestDBus *test_dbus;
+
+ /* FIXME: this stuff should be part of the fixture, but setup_debug()
+ * uses tp_dbus_daemon_dup() */
+ g_test_dbus_unset ();
+ test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
+ g_test_dbus_up (test_dbus);
setup_debug ();
/* no account tests */
- g_test_init (&argc, &argv, NULL);
+ tp_tests_init (&argc, &argv);
g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
/* account related tests */
@@ -793,9 +800,12 @@ main (int argc, char **argv)
TestCaseFixture, params,
setup_for_writing, test_ignorelist, teardown);
- retval = g_test_run ();
+ retval = tp_tests_run_with_bus ();
g_list_foreach (l, (GFunc) g_hash_table_unref, NULL);
+ g_test_dbus_down (test_dbus);
+ g_clear_object (&test_dbus);
+
return retval;
}
diff --git a/tests/logger/dbus/test-tpl-log-iter-pidgin.c b/tests/logger/dbus/test-tpl-log-iter-pidgin.c
index 36286a8..9d8cf72 100644
--- a/tests/logger/dbus/test-tpl-log-iter-pidgin.c
+++ b/tests/logger/dbus/test-tpl-log-iter-pidgin.c
@@ -825,7 +825,7 @@ main (gint argc, gchar **argv)
gint retval;
GVariant *params;
- g_test_init (&argc, &argv, NULL);
+ tp_tests_init (&argc, &argv);
g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
params = create_params ();
@@ -838,7 +838,7 @@ main (gint argc, gchar **argv)
PidginTestCaseFixture, params,
setup, test_rewind, teardown);
- retval = g_test_run ();
+ retval = tp_tests_run_with_bus ();
g_variant_unref (params);
return retval;
diff --git a/tests/logger/dbus/test-tpl-log-iter-xml.c b/tests/logger/dbus/test-tpl-log-iter-xml.c
index dcbaa1d..4ffd3fe 100644
--- a/tests/logger/dbus/test-tpl-log-iter-xml.c
+++ b/tests/logger/dbus/test-tpl-log-iter-xml.c
@@ -427,7 +427,7 @@ test_rewind (XmlTestCaseFixture *fixture,
gint main (gint argc, gchar **argv)
{
- g_test_init (&argc, &argv, NULL);
+ tp_tests_init (&argc, &argv);
g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
g_test_add ("/log-iter-xml/get-events",
@@ -438,5 +438,5 @@ gint main (gint argc, gchar **argv)
XmlTestCaseFixture, NULL,
setup, test_rewind, teardown);
- return g_test_run ();
+ return tp_tests_run_with_bus ();
}
diff --git a/tests/logger/dbus/test-tpl-log-store-pidgin.c b/tests/logger/dbus/test-tpl-log-store-pidgin.c
index f3aea90..c4bb7fd 100644
--- a/tests/logger/dbus/test-tpl-log-store-pidgin.c
+++ b/tests/logger/dbus/test-tpl-log-store-pidgin.c
@@ -526,11 +526,18 @@ main (int argc, char **argv)
GHashTable *params = NULL;
GList *l = NULL;
int retval;
+ GTestDBus *test_dbus;
+
+ /* FIXME: this stuff should be part of the fixture, but setup_debug()
+ * uses tp_dbus_daemon_dup() */
+ g_test_dbus_unset ();
+ test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
+ g_test_dbus_up (test_dbus);
setup_debug ();
/* no account tests */
- g_test_init (&argc, &argv, NULL);
+ tp_tests_init (&argc, &argv);
g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
g_test_add ("/log-store-pidgin/get-name",
@@ -612,5 +619,8 @@ main (int argc, char **argv)
g_list_foreach (l, (GFunc) g_hash_table_unref, NULL);
+ g_test_dbus_down (test_dbus);
+ g_clear_object (&test_dbus);
+
return retval;
}
diff --git a/tests/logger/dbus/test-tpl-log-store-sqlite.c b/tests/logger/dbus/test-tpl-log-store-sqlite.c
index 8c538e2..5d26168 100644
--- a/tests/logger/dbus/test-tpl-log-store-sqlite.c
+++ b/tests/logger/dbus/test-tpl-log-store-sqlite.c
@@ -4,8 +4,21 @@
#include <telepathy-logger/debug-internal.h>
#include <telepathy-logger/client-factory-internal.h>
-int
-main (int argc, char **argv)
+#include "tests/lib/util.h"
+
+typedef struct {
+ int dummy;
+} Fixture;
+
+static void
+setup (Fixture *fixture,
+ gconstpointer data)
+{
+}
+
+static void
+test (Fixture *fixture,
+ gconstpointer data)
{
TplLogStore *store;
TpDBusDaemon *bus;
@@ -36,3 +49,20 @@ main (int argc, char **argv)
g_object_unref (bus);
g_object_unref (factory);
}
+
+static void
+teardown (Fixture *fixture,
+ gconstpointer data)
+{
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ tp_tests_init (&argc, &argv);
+
+ g_test_add ("/log-store-sqlite", Fixture, NULL, setup, test, teardown);
+
+ return tp_tests_run_with_bus ();
+}
diff --git a/tests/logger/dbus/test-tpl-log-store-xml.c b/tests/logger/dbus/test-tpl-log-store-xml.c
index 7b6f91e..ed5f845 100644
--- a/tests/logger/dbus/test-tpl-log-store-xml.c
+++ b/tests/logger/dbus/test-tpl-log-store-xml.c
@@ -1073,7 +1073,7 @@ test_get_events_for_date (XmlTestCaseFixture *fixture,
gint main (gint argc, gchar **argv)
{
- g_test_init (&argc, &argv, NULL);
+ tp_tests_init (&argc, &argv);
g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
g_test_add ("/log-store-xml/clear",
@@ -1112,5 +1112,5 @@ gint main (gint argc, gchar **argv)
XmlTestCaseFixture, NULL,
setup, test_get_events_for_date, teardown);
- return g_test_run ();
+ return tp_tests_run_with_bus ();
}
diff --git a/tests/logger/dbus/test-tpl-log-walker.c b/tests/logger/dbus/test-tpl-log-walker.c
index 91778ef..496539d 100644
--- a/tests/logger/dbus/test-tpl-log-walker.c
+++ b/tests/logger/dbus/test-tpl-log-walker.c
@@ -439,7 +439,7 @@ gint main (gint argc, gchar **argv)
gint retval;
GVariant *params;
- g_test_init (&argc, &argv, NULL);
+ tp_tests_init (&argc, &argv);
g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
params = create_params ();
@@ -452,7 +452,7 @@ gint main (gint argc, gchar **argv)
WalkerTestCaseFixture, params,
setup, test_rewind, teardown);
- retval = g_test_run ();
+ retval = tp_tests_run_with_bus ();
g_variant_unref (params);
return retval;
diff --git a/tests/logger/dbus/test-tpl-observer.c b/tests/logger/dbus/test-tpl-observer.c
index f747d92..0ecf052 100644
--- a/tests/logger/dbus/test-tpl-observer.c
+++ b/tests/logger/dbus/test-tpl-observer.c
@@ -2,8 +2,21 @@
#include <telepathy-logger/observer-internal.h>
-int
-main (int argc, char **argv)
+#include "tests/lib/util.h"
+
+typedef struct {
+ int dummy;
+} Fixture;
+
+static void
+setup (Fixture *fixture,
+ gconstpointer data)
+{
+}
+
+static void
+test (Fixture *fixture,
+ gconstpointer data)
{
TplObserver *obs, *obs2;
@@ -27,7 +40,21 @@ main (int argc, char **argv)
/* proper disposal for the singleton when no references are present */
g_object_unref (obs);
+}
- return 0;
+static void
+teardown (Fixture *fixture,
+ gconstpointer data)
+{
}
+int
+main (int argc,
+ char **argv)
+{
+ tp_tests_init (&argc, &argv);
+
+ g_test_add ("/log-store-sqlite", Fixture, NULL, setup, test, teardown);
+
+ return tp_tests_run_with_bus ();
+}
More information about the telepathy-commits
mailing list