diff options
| author | Tristan Van Berkom <tristanvb@openismus.com> | 2012-12-12 14:23:30 +0900 |
|---|---|---|
| committer | Tristan Van Berkom <tristanvb@openismus.com> | 2012-12-15 14:12:14 +0900 |
| commit | 8028e303a98db4c3fb9a6da6f33c9d311c00f54d (patch) | |
| tree | e1135ed86aa6b58abfeb885337265160a2028633 /tests/libedataserver | |
| parent | c155d7e1fb57bde5e90a056306b4e257b72e1264 (diff) | |
| download | evolution-data-server-8028e303a98db4c3fb9a6da6f33c9d311c00f54d.tar.gz | |
Removing e-source-registry-test.c and e-test-dbus-utils.[ch]
The source registry test checks if sources can be created in the
registry, this is already asserted by e-test-server-utils in
the fixture test. Removing the e-test-dbus-utils.[ch] and
tests/tools directory in favour of new testing framework added in
test-server-utils directory.
Diffstat (limited to 'tests/libedataserver')
| -rw-r--r-- | tests/libedataserver/Makefile.am | 10 | ||||
| -rw-r--r-- | tests/libedataserver/e-source-registry-test.c | 152 | ||||
| -rw-r--r-- | tests/libedataserver/e-source-test.c | 2 | ||||
| -rw-r--r-- | tests/libedataserver/e-test-dbus-utils.c | 184 | ||||
| -rw-r--r-- | tests/libedataserver/e-test-dbus-utils.h | 34 |
5 files changed, 2 insertions, 380 deletions
diff --git a/tests/libedataserver/Makefile.am b/tests/libedataserver/Makefile.am index efc7d9aac..7dc05e3bc 100644 --- a/tests/libedataserver/Makefile.am +++ b/tests/libedataserver/Makefile.am @@ -4,7 +4,6 @@ NULL = TESTS = \ e-source-test \ - e-source-registry-test \ e-user-prompter-test \ $(NULL) @@ -29,12 +28,6 @@ e_source_test_SOURCES = \ e-source-test.c \ $(NULL) -e_source_registry_test_SOURCES = \ - e-source-registry-test.c \ - e-test-dbus-utils.c \ - e-test-dbus-utils.h \ - $(NULL) - e_user_prompter_test_SOURCES = \ e-user-prompter-test.c \ $(NULL) @@ -42,9 +35,6 @@ e_user_prompter_test_SOURCES = \ e_source_test_CPPFLAGS = $(test_CPPFLAGS) e_source_test_LDADD = $(test_LDADD) -e_source_registry_test_CPPFLAGS = $(test_CPPFLAGS) -e_source_registry_test_LDADD = $(test_LDADD) - e_user_prompter_test_CPPFLAGS = $(test_CPPFLAGS) e_user_prompter_test_LDADD = $(top_builddir)/libebackend/libebackend-1.2.la $(test_LDADD) diff --git a/tests/libedataserver/e-source-registry-test.c b/tests/libedataserver/e-source-registry-test.c deleted file mode 100644 index d5111f765..000000000 --- a/tests/libedataserver/e-source-registry-test.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * e-source-registry-test.c - * - * This program 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 of the License, or (at your option) version 3. - * - * This program 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 the program; if not, see <http://www.gnu.org/licenses/> - * - */ - -#include "e-test-dbus-utils.h" - -#include <libedataserver/libedataserver.h> - -typedef struct _TestClosure TestClosure; -typedef struct _TestFixture TestFixture; - -struct _TestClosure { - GTestDBus *test_dbus; - const gchar *base_directory; -}; - -struct _TestFixture { - ESourceRegistry *registry; - GMainLoop *main_loop; -}; - -static void -test_fixture_setup_session (TestFixture *fixture, - gconstpointer user_data) -{ - const TestClosure *closure = user_data; - GError *error = NULL; - - g_assert (fixture->registry == NULL); - g_assert (fixture->main_loop == NULL); - - g_test_dbus_up (closure->test_dbus); - - fixture->registry = e_source_registry_new_sync (NULL, &error); - g_assert_no_error (error); - - fixture->main_loop = g_main_loop_new (NULL, FALSE); -} - -static void -test_fixture_teardown_session (TestFixture *fixture, - gconstpointer user_data) -{ - const TestClosure *closure = user_data; - GError *error = NULL; - - g_object_unref (fixture->registry); - fixture->registry = NULL; - - g_main_loop_unref (fixture->main_loop); - fixture->main_loop = NULL; - - g_test_dbus_stop (closure->test_dbus); - - e_test_clean_base_directories (&error); - g_assert_no_error (error); -} - -static gboolean -test_commit_source_idle_cb (gpointer user_data) -{ - TestFixture *fixture = user_data; - ESource *source; - gchar *uid; - GError *error = NULL; - - /* Configure a minimal scratch source. */ - source = e_source_new (NULL, NULL, &error); - g_assert_no_error (error); - e_source_set_parent (source, "local-stub"); - e_source_set_display_name (source, "Test Commit Source"); - - /* Note the ESource UID. */ - uid = e_source_dup_uid (source); - - /* Submit the scratch source. */ - e_source_registry_commit_source_sync ( - fixture->registry, source, NULL, &error); - g_assert_no_error (error); - - /* Discard the scratch source. */ - g_object_unref (source); - - /* Verify the registry has an ESource with the same UID. */ - source = e_source_registry_ref_source (fixture->registry, uid); - - g_free (uid); - - if (source != NULL) { - g_object_unref (source); - } else { - g_test_fail (); - } - - g_main_loop_quit (fixture->main_loop); - - return FALSE; -} - -static void -test_commit_source (TestFixture *fixture, - gconstpointer user_data) -{ - g_test_bug ("685986"); - g_idle_add (test_commit_source_idle_cb, fixture); - g_main_loop_run (fixture->main_loop); -} - -gint -main (gint argc, - gchar **argv) -{ - TestClosure closure; - gint retval; - - g_type_init (); - - g_test_init (&argc, &argv, NULL); - g_test_bug_base ("http://bugzilla.gnome.org/"); - - closure.base_directory = e_test_setup_base_directories (); - closure.test_dbus = e_test_setup_dbus_session (); - - g_test_add ( - "/e-source-registry-test/CommitSource", - TestFixture, &closure, - test_fixture_setup_session, - test_commit_source, - test_fixture_teardown_session); - - retval = g_test_run (); - - /* XXX Something is leaking a GDBusConnection reference. - * Leave this disabled until I can track it down. */ - /* g_object_unref (closure.test_dbus); */ - - return retval; -} diff --git a/tests/libedataserver/e-source-test.c b/tests/libedataserver/e-source-test.c index bb14f5d54..d6b6da060 100644 --- a/tests/libedataserver/e-source-test.c +++ b/tests/libedataserver/e-source-test.c @@ -124,7 +124,9 @@ static void test_fixture_teardown_key_file (TestFixture *fixture, gconstpointer test_data) { +#if 0 /* ACCOUNT_MGMT */ teardown_test_source (&fixture->test); +#endif } static void diff --git a/tests/libedataserver/e-test-dbus-utils.c b/tests/libedataserver/e-test-dbus-utils.c deleted file mode 100644 index 7bc592e4e..000000000 --- a/tests/libedataserver/e-test-dbus-utils.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * e-test-dbus-utils.c - * - * This program 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 of the License, or (at your option) version 3. - * - * This program 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 the program; if not, see <http://www.gnu.org/licenses/> - * - */ - -#include <errno.h> -#include <stdlib.h> -#include <string.h> - -#include "e-test-dbus-utils.h" - -#include <libedataserver/libedataserver.h> - -static GOnce base_directories_once = G_ONCE_INIT; - -static void -test_setup_xdg_data_home (const gchar *base_directory) -{ - gchar *filename; - - g_assert (base_directory != NULL); - - filename = g_build_filename (base_directory, "share", NULL); - - g_print ("XDG_DATA_HOME=%s\n", filename); - g_assert (g_setenv ("XDG_DATA_HOME", filename, TRUE)); - g_assert_cmpstr (g_get_user_data_dir (), ==, filename); - - g_free (filename); -} - -static void -test_setup_xdg_cache_home (const gchar *base_directory) -{ - gchar *filename; - - g_assert (base_directory != NULL); - - filename = g_build_filename (base_directory, "cache", NULL); - - g_print ("XDG_CACHE_HOME=%s\n", filename); - g_assert (g_setenv ("XDG_CACHE_HOME", filename, TRUE)); - g_assert_cmpstr (g_get_user_cache_dir (), ==, filename); - - g_free (filename); -} - -static void -test_setup_xdg_config_home (const gchar *base_directory) -{ - gchar *filename; - - g_assert (base_directory != NULL); - - filename = g_build_filename (base_directory, "config", NULL); - - g_print ("XDG_CONFIG_HOME=%s\n", filename); - g_assert (g_setenv ("XDG_CONFIG_HOME", filename, TRUE)); - g_assert_cmpstr (g_get_user_config_dir (), ==, filename); - - g_free (filename); -} - -static gpointer -test_setup_base_directories_once (gpointer unused) -{ - gchar *base_directory; - - /* Do not invoke g_get_user_cache_dir() here because that will - * permanently set the cache directory result and we won't be - * able to override it with an environment variable. */ - base_directory = g_build_filename ( - g_get_home_dir (), - ".cache", "evolution", - "tmp", "test-home-XXXXXX", NULL); - - mkdtemp (base_directory); - - test_setup_xdg_data_home (base_directory); - test_setup_xdg_cache_home (base_directory); - test_setup_xdg_config_home (base_directory); - - return base_directory; -} - -const gchar * -e_test_setup_base_directories (void) -{ - g_once ( - &base_directories_once, - test_setup_base_directories_once, NULL); - - return base_directories_once.retval; -} - -gboolean -e_test_clean_base_directories (GError **error) -{ - GFile *file; - gboolean success = TRUE; - const gchar *user_data_dir; - const gchar *user_cache_dir; - const gchar *user_config_dir; - - e_test_setup_base_directories (); - - user_data_dir = g_get_user_data_dir (); - g_assert (strstr (user_data_dir, "test-home") != NULL); - - user_cache_dir = g_get_user_cache_dir (); - g_assert (strstr (user_cache_dir, "test-home") != NULL); - - user_config_dir = g_get_user_config_dir (); - g_assert (strstr (user_config_dir, "test-home") != NULL); - - if (success) { - file = g_file_new_for_path (user_data_dir); - success = e_file_recursive_delete_sync (file, NULL, error); - g_object_unref (file); - } - - if (success) { - file = g_file_new_for_path (user_cache_dir); - success = e_file_recursive_delete_sync (file, NULL, error); - g_object_unref (file); - } - - if (success) { - file = g_file_new_for_path (user_config_dir); - success = e_file_recursive_delete_sync (file, NULL, error); - g_object_unref (file); - } - - return success; -} - -static void -register_dbus_service_dir (GTestDBus *test_dbus, - const gchar *data_dir) -{ - gchar *service_dir; - - service_dir = g_build_filename (data_dir, "dbus-1", "services", NULL); - - g_print ("Adding service dir: %s\n", service_dir); - g_test_dbus_add_service_dir (test_dbus, service_dir); - - g_free (service_dir); -} - -GTestDBus * -e_test_setup_dbus_session (void) -{ - GTestDBus *test_dbus; - const gchar * const *system_data_dirs; - gint ii; - - e_test_setup_base_directories (); - - system_data_dirs = g_get_system_data_dirs (); - g_assert (system_data_dirs != NULL); - - test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE); - register_dbus_service_dir (test_dbus, DATADIR); - - for (ii = 0; system_data_dirs[ii] != NULL; ii++) { - register_dbus_service_dir (test_dbus, system_data_dirs[ii]); - } - - return test_dbus; -} diff --git a/tests/libedataserver/e-test-dbus-utils.h b/tests/libedataserver/e-test-dbus-utils.h deleted file mode 100644 index f12b7d5b2..000000000 --- a/tests/libedataserver/e-test-dbus-utils.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * e-test-dbus-utils.h - * - * This program 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 of the License, or (at your option) version 3. - * - * This program 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 the program; if not, see <http://www.gnu.org/licenses/> - * - */ - -#ifndef E_TEST_DBUS_UTILS_H -#define E_TEST_DBUS_UTILS_H - -#include <gio/gio.h> - -G_BEGIN_DECLS - -const gchar * e_test_setup_base_directories (void); -gboolean e_test_clean_base_directories (GError **error); - -GTestDBus * e_test_setup_dbus_session (void); - -G_END_DECLS - -#endif /* E_TEST_DBUS_UTILS_H */ - |
