diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2013-09-26 16:46:50 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2013-09-27 13:39:12 +0200 |
commit | 56bdbb0183c507acefd2c673d14509a54ebfddd2 (patch) | |
tree | 5ef88a83ba806ada5ac3349903a4d84a05c59e06 | |
parent | f8b26736c19748d33fe23cc474e61b88434844c6 (diff) |
add logger-test-helper.c
Introduce a new helper file to contain logger test specific helper functions.
Add helper function to register and prepare accounts.
https://bugs.freedesktop.org/show_bug.cgi?id=69814
-rw-r--r-- | tests/lib/Makefile.am | 4 | ||||
-rw-r--r-- | tests/lib/logger-test-helper.c | 64 | ||||
-rw-r--r-- | tests/lib/logger-test-helper.h | 38 |
3 files changed, 105 insertions, 1 deletions
diff --git a/tests/lib/Makefile.am b/tests/lib/Makefile.am index 0f7fc28..5a3b35d 100644 --- a/tests/lib/Makefile.am +++ b/tests/lib/Makefile.am @@ -16,7 +16,9 @@ libtp_logger_tests_la_SOURCES = \ textchan-null.c \ textchan-null.h \ util.c \ - util.h + util.h \ + logger-test-helper.c \ + logger-test-helper.h check_c_sources = *.c include $(top_srcdir)/tools/check-coding-style.mk diff --git a/tests/lib/logger-test-helper.c b/tests/lib/logger-test-helper.c new file mode 100644 index 0000000..ecba2ef --- /dev/null +++ b/tests/lib/logger-test-helper.c @@ -0,0 +1,64 @@ +/* + * logger-test-helper.c + * + * Copyright (C) 2013 Collabora Ltd. <http://www.collabora.co.uk/> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <config.h> + +#include "logger-test-helper.h" + +#include "util.h" + +void +tpl_test_create_and_prepare_account (TpDBusDaemon *dbus, + TpSimpleClientFactory *factory, + const gchar *path, + TpAccount **account, + TpTestsSimpleAccount **account_service) +{ + GError *error = NULL; + GArray *features; + GQuark zero = 0; + + *account_service = g_object_new (TP_TESTS_TYPE_SIMPLE_ACCOUNT, + NULL); + g_assert (*account_service != NULL); + + tp_dbus_daemon_register_object (dbus, path, *account_service); + + *account = tp_simple_client_factory_ensure_account (factory, path, NULL, + &error); + g_assert_no_error (error); + g_assert (*account != NULL); + + features = tp_simple_client_factory_dup_account_features (factory, *account); + g_array_append_val (features, zero); + + tp_tests_proxy_run_until_prepared (*account, (GQuark *) features->data); + g_array_free (features, FALSE); +} + +void +tpl_test_release_account (TpDBusDaemon *dbus, + TpAccount *account, + TpTestsSimpleAccount *account_service) +{ + tp_dbus_daemon_unregister_object (dbus, account_service); + g_object_unref (account_service); + g_object_unref (account); +} diff --git a/tests/lib/logger-test-helper.h b/tests/lib/logger-test-helper.h new file mode 100644 index 0000000..8464e13 --- /dev/null +++ b/tests/lib/logger-test-helper.h @@ -0,0 +1,38 @@ +/* + * logger-test-helper.h + * + * Copyright (C) 2013 Collabora Ltd. <http://www.collabora.co.uk/> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __LOGGER_TEST_HELPER_H__ +#define __LOGGER_TEST_HELPER_H__ + +#include <telepathy-glib/telepathy-glib.h> + +#include "simple-account.h" + +void tpl_test_create_and_prepare_account (TpDBusDaemon *dbus, + TpSimpleClientFactory *factory, + const gchar *path, + TpAccount **account, + TpTestsSimpleAccount **account_service); + +void tpl_test_release_account (TpDBusDaemon *dbus, + TpAccount *account, + TpTestsSimpleAccount *account_service); + +#endif |