summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-03-18 16:12:10 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-03-19 17:30:19 +0000
commit35103e5332e88046cb1fb9c4e9c5e1cc06852ef3 (patch)
treec25cff93cde937e0861dbd78ca6c2d2409d3de4a
parent306f3175fb7facf4ce4e06cd96752e35ac5d0943 (diff)
downloadtelepathy-glib-35103e5332e88046cb1fb9c4e9c5e1cc06852ef3.tar.gz
logger tests: wait for objects to be torn down between test cases
We need to avoid carrying over the same singleton between one test-case and the next, because we drop and reacquire the AccountManager name. There's no point in keeping a global singleton object if it gets invalidated. Reviewed-by: Xavier Claessens
-rw-r--r--tests/lib/logger-test-helper.c4
-rw-r--r--tests/logger/dbus/test-tpl-log-store-pidgin.c28
-rw-r--r--tests/logger/dbus/test-tpl-log-store-xml.c67
3 files changed, 63 insertions, 36 deletions
diff --git a/tests/lib/logger-test-helper.c b/tests/lib/logger-test-helper.c
index 0468a90eb..64c72a29a 100644
--- a/tests/lib/logger-test-helper.c
+++ b/tests/lib/logger-test-helper.c
@@ -61,8 +61,8 @@ tpl_test_release_account (TpDBusDaemon *dbus,
TpTestsSimpleAccount *account_service)
{
tp_dbus_daemon_unregister_object (dbus, account_service);
- g_object_unref (account_service);
- g_object_unref (account);
+ tp_tests_assert_last_unref (&account_service);
+ tp_tests_await_last_unref (&account);
}
void
diff --git a/tests/logger/dbus/test-tpl-log-store-pidgin.c b/tests/logger/dbus/test-tpl-log-store-pidgin.c
index 5727f0142..147ecb2b6 100644
--- a/tests/logger/dbus/test-tpl-log-store-pidgin.c
+++ b/tests/logger/dbus/test-tpl-log-store-pidgin.c
@@ -33,6 +33,7 @@ typedef struct
GMainLoop *main_loop;
TpDBusDaemon *dbus;
+ TpAccountManager *account_manager;
TpAccount *account;
TpTestsSimpleAccount *account_service;
TpClientFactory *factory;
@@ -149,6 +150,8 @@ setup_service (PidginTestCaseFixture* fixture,
fixture->factory = _tpl_client_factory_dup (fixture->dbus);
+ fixture->account_manager = tp_account_manager_dup ();
+
fixture->account = tp_client_factory_ensure_account (fixture->factory,
account_path, NULL, NULL);
g_assert (fixture->account != NULL);
@@ -201,18 +204,23 @@ teardown_service (PidginTestCaseFixture* fixture,
g_assert (user_data != NULL);
+ if (fixture->store != NULL)
+ tp_tests_assert_last_unref (&fixture->store);
+
if (fixture->account != NULL)
{
/* FIXME is it useful in this suite */
tp_tests_proxy_run_until_dbus_queue_processed (fixture->account);
- g_object_unref (fixture->account);
- fixture->account = NULL;
+ tp_tests_assert_last_unref (&fixture->account);
}
+ /* wait for pending call if any */
+ if (fixture->account_manager != NULL)
+ tp_tests_await_last_unref (&fixture->account_manager);
+
tp_dbus_daemon_unregister_object (fixture->dbus, fixture->account_service);
- g_object_unref (fixture->account_service);
- fixture->account_service = NULL;
+ tp_tests_await_last_unref (&fixture->account_service);
tp_dbus_daemon_release_name (fixture->dbus, TP_ACCOUNT_MANAGER_BUS_NAME,
&error);
@@ -221,7 +229,7 @@ teardown_service (PidginTestCaseFixture* fixture,
g_object_unref (fixture->dbus);
fixture->dbus = NULL;
- g_clear_object (&fixture->factory);
+ tp_tests_assert_last_unref (&fixture->factory);
}
static void
@@ -231,12 +239,10 @@ teardown (PidginTestCaseFixture* fixture,
g_free (fixture->basedir);
fixture->basedir = NULL;
- g_object_unref (fixture->store);
- fixture->store = NULL;
-
- g_object_unref (fixture->room);
- g_object_unref (fixture->irc_room);
- g_object_unref (fixture->contact);
+ tp_tests_assert_last_unref (&fixture->store);
+ tp_tests_assert_last_unref (&fixture->room);
+ tp_tests_assert_last_unref (&fixture->irc_room);
+ tp_tests_assert_last_unref (&fixture->contact);
if (user_data != NULL)
teardown_service (fixture, user_data);
diff --git a/tests/logger/dbus/test-tpl-log-store-xml.c b/tests/logger/dbus/test-tpl-log-store-xml.c
index 4906f0040..3dcd89e1c 100644
--- a/tests/logger/dbus/test-tpl-log-store-xml.c
+++ b/tests/logger/dbus/test-tpl-log-store-xml.c
@@ -25,6 +25,7 @@ typedef struct
TplLogStore *store;
TpDBusDaemon *bus;
TpClientFactory *factory;
+ TpAccountManager *account_manager;
} XmlTestCaseFixture;
@@ -55,6 +56,8 @@ setup (XmlTestCaseFixture* fixture,
fixture->factory = _tpl_client_factory_dup (fixture->bus);
+ fixture->account_manager = tp_account_manager_dup ();
+
tp_debug_divert_messages (g_getenv ("TPL_LOGFILE"));
_tpl_debug_set_flags_from_env ();
@@ -88,6 +91,15 @@ teardown (XmlTestCaseFixture *fixture,
{
GError *error = NULL;
+ if (fixture->store != NULL)
+ tp_tests_assert_last_unref (&fixture->store);
+
+ /* wait for pending call if any */
+ if (fixture->account_manager != NULL)
+ tp_tests_await_last_unref (&fixture->account_manager);
+
+ tp_tests_assert_last_unref (&fixture->factory);
+
tp_dbus_daemon_release_name (fixture->bus, TP_ACCOUNT_MANAGER_BUS_NAME,
&error);
g_assert_no_error (error);
@@ -104,10 +116,6 @@ teardown (XmlTestCaseFixture *fixture,
g_free (command);
}
- if (fixture->store == NULL)
- g_object_unref (fixture->store);
-
- g_clear_object (&fixture->factory);
g_main_loop_unref (fixture->main_loop);
}
@@ -168,7 +176,7 @@ test_clear_account (XmlTestCaseFixture *fixture,
g_assert (account != NULL);
_tpl_log_store_clear_account (fixture->store, account);
- g_object_unref (account);
+ tp_tests_await_last_unref (&account);
hits = _tpl_log_store_search_new (fixture->store, kept, TPL_EVENT_MASK_TEXT);
@@ -241,8 +249,8 @@ test_clear_entity (XmlTestCaseFixture *fixture,
TP_ENTITY_TYPE_CONTACT, NULL, NULL);
_tpl_log_store_clear_entity (fixture->store, account, entity);
- g_object_unref (account);
g_object_unref (entity);
+ tp_tests_await_last_unref (&account);
hits = _tpl_log_store_search_new (fixture->store,
always_kept, TPL_EVENT_MASK_TEXT);
@@ -465,10 +473,15 @@ test_add_text_event (XmlTestCaseFixture *fixture,
* this assertion, as long as you don't break message edits). */
assert_cmp_text_event (event, events->data);
+ tp_tests_assert_last_unref (&event);
+
+ while (events != NULL)
+ {
+ tp_tests_assert_last_unref (&events->data);
+ events = g_list_delete_link (events, events);
+ }
+
tpl_test_release_account (fixture->bus, account, account_service);
- g_object_unref (event);
- g_list_foreach (events, (GFunc) g_object_unref, NULL);
- g_list_free (events);
}
static void
@@ -668,16 +681,19 @@ test_add_superseding_event (XmlTestCaseFixture *fixture,
assert_cmp_text_event (TPL_EVENT (new_new_event), events->next->data);
assert_cmp_text_event (TPL_EVENT (late_event), g_list_last (events)->data);
- tpl_test_release_account (fixture->bus, account, account_service);
+ tp_tests_assert_last_unref (&event);
+ tp_tests_assert_last_unref (&new_event);
+ tp_tests_assert_last_unref (&new_new_event);
+ tp_tests_assert_last_unref (&late_event);
+ tp_tests_assert_last_unref (&early_event);
- g_list_foreach (events, (GFunc) g_object_unref, NULL);
- g_list_free (events);
+ while (events != NULL)
+ {
+ tp_tests_assert_last_unref (&events->data);
+ events = g_list_delete_link (events, events);
+ }
- g_object_unref (event);
- g_object_unref (new_event);
- g_object_unref (new_new_event);
- g_object_unref (late_event);
- g_object_unref (early_event);
+ tpl_test_release_account (fixture->bus, account, account_service);
}
static void
@@ -863,10 +879,15 @@ test_add_call_event (XmlTestCaseFixture *fixture,
assert_cmp_call_event (event, events->data);
- tpl_test_release_account (fixture->bus, account, account_service);
- g_object_unref (event);
- g_object_unref (events->data);
- g_list_free (events);
+ tp_tests_assert_last_unref (&event);
+
+ while (events != NULL)
+ {
+ tp_tests_assert_last_unref (&events->data);
+ events = g_list_delete_link (events, events);
+ }
+
+ tpl_test_release_account (fixture->bus, account, account_service);
}
static void
@@ -916,8 +937,8 @@ test_exists (XmlTestCaseFixture *fixture,
g_assert (!_tpl_log_store_exists (fixture->store, account2, user3, TPL_EVENT_MASK_TEXT));
g_assert (_tpl_log_store_exists (fixture->store, account2, user3, TPL_EVENT_MASK_CALL));
- g_object_unref (account1);
- g_object_unref (account2);
+ tp_tests_await_last_unref (&account1);
+ tp_tests_await_last_unref (&account2);
g_object_unref (user2);
g_object_unref (user3);
}