diff options
| -rw-r--r-- | tests/libebook/client/test-book-client-view-operations.c | 27 | ||||
| -rw-r--r-- | tests/libebook/client/test-book-client-write-write.c | 16 | ||||
| -rw-r--r-- | tests/libedata-book/test-book-meta-backend.c | 17 | ||||
| -rw-r--r-- | tests/libedata-cal/test-cal-meta-backend.c | 17 |
4 files changed, 44 insertions, 33 deletions
diff --git a/tests/libebook/client/test-book-client-view-operations.c b/tests/libebook/client/test-book-client-view-operations.c index e126750dc..7ad3db462 100644 --- a/tests/libebook/client/test-book-client-view-operations.c +++ b/tests/libebook/client/test-book-client-view-operations.c @@ -31,6 +31,7 @@ static ETestServerClosure book_closure_direct_async = { E_TEST_SERVER_DIRECT_ADD #define N_CONTACTS 5 typedef struct { + ESourceRegistry *registry; ETestServerClosure *closure; GThread *thread; const gchar *book_uid; @@ -179,7 +180,6 @@ static gpointer test_view_thread_async (ThreadData *data) { GMainContext *context; - ESourceRegistry *registry; ESource *source; GError *error = NULL; @@ -188,18 +188,14 @@ test_view_thread_async (ThreadData *data) g_main_context_push_thread_default (context); /* Open the test book client in this thread */ - registry = e_source_registry_new_sync (NULL, &error); - if (!registry) - g_error ("Unable to create the registry: %s", error->message); - - source = e_source_registry_ref_source (registry, data->book_uid); + source = e_source_registry_ref_source (data->registry, data->book_uid); if (!source) g_error ("Unable to fetch source uid '%s' from the registry", data->book_uid); if (data->closure->type == E_TEST_SERVER_DIRECT_ADDRESS_BOOK) { /* There is no Async API to open a direct book for now, let's stick with the sync API */ - data->client = (EBookClient *) e_book_client_connect_direct_sync (registry, source, (guint32) -1, NULL, &error); + data->client = (EBookClient *) e_book_client_connect_direct_sync (data->registry, source, (guint32) -1, NULL, &error); if (!data->client) g_error ("Unable to create EBookClient for uid '%s': %s", data->book_uid, error->message); @@ -215,7 +211,6 @@ test_view_thread_async (ThreadData *data) g_main_loop_run (data->loop); g_object_unref (source); - g_object_unref (registry); g_object_unref (data->client); g_main_context_pop_thread_default (context); @@ -263,7 +258,6 @@ static gpointer test_view_thread_sync (ThreadData *data) { GMainContext *context; - ESourceRegistry *registry; ESource *source; GError *error = NULL; @@ -272,16 +266,12 @@ test_view_thread_sync (ThreadData *data) g_main_context_push_thread_default (context); /* Open the test book client in this thread */ - registry = e_source_registry_new_sync (NULL, &error); - if (!registry) - g_error ("Unable to create the registry: %s", error->message); - - source = e_source_registry_ref_source (registry, data->book_uid); + source = e_source_registry_ref_source (data->registry, data->book_uid); if (!source) g_error ("Unable to fetch source uid '%s' from the registry", data->book_uid); if (data->closure->type == E_TEST_SERVER_DIRECT_ADDRESS_BOOK) - data->client = (EBookClient *) e_book_client_connect_direct_sync (registry, source, (guint32) -1, NULL, &error); + data->client = (EBookClient *) e_book_client_connect_direct_sync (data->registry, source, (guint32) -1, NULL, &error); else data->client = (EBookClient *) e_book_client_connect_sync (source, (guint32) -1, NULL, &error); @@ -293,7 +283,6 @@ test_view_thread_sync (ThreadData *data) g_main_loop_run (data->loop); g_object_unref (source); - g_object_unref (registry); g_object_unref (data->client); g_main_context_pop_thread_default (context); @@ -305,12 +294,16 @@ test_view_thread_sync (ThreadData *data) static ThreadData * create_test_thread (const gchar *book_uid, + ESourceRegistry *registry, gconstpointer user_data, gboolean sync) { ThreadData *data = g_slice_new0 (ThreadData); + g_assert_nonnull (registry); + data->book_uid = book_uid; + data->registry = registry; data->closure = (ETestServerClosure *) user_data; g_mutex_init (&data->complete_mutex); @@ -352,7 +345,7 @@ test_concurrent_views (ETestServerFixture *fixture, /* Create all concurrent threads accessing the same addressbook */ tests = g_new0 (ThreadData *, N_THREADS); for (i = 0; i < N_THREADS; i++) - tests[i] = create_test_thread (book_uid, user_data, sync); + tests[i] = create_test_thread (book_uid, fixture->registry, user_data, sync); /* Wait for all threads to receive the complete signal */ for (i = 0; i < N_THREADS; i++) { diff --git a/tests/libebook/client/test-book-client-write-write.c b/tests/libebook/client/test-book-client-write-write.c index ee888e38a..00e6caed4 100644 --- a/tests/libebook/client/test-book-client-write-write.c +++ b/tests/libebook/client/test-book-client-write-write.c @@ -45,6 +45,7 @@ typedef struct { } TestData; typedef struct { + ESourceRegistry *registry; GThread *thread; const gchar *book_uid; const gchar *contact_uid; @@ -182,7 +183,6 @@ static gpointer test_write_thread (ThreadData *data) { GMainContext *context; - ESourceRegistry *registry; GSource *gsource; ESource *source; GError *error = NULL; @@ -192,11 +192,7 @@ test_write_thread (ThreadData *data) g_main_context_push_thread_default (context); /* Open the test book client in this thread */ - registry = e_source_registry_new_sync (NULL, &error); - if (!registry) - g_error ("Unable to create the registry: %s", error->message); - - source = e_source_registry_ref_source (registry, data->book_uid); + source = e_source_registry_ref_source (data->registry, data->book_uid); if (!source) g_error ("Unable to fetch source uid '%s' from the registry", data->book_uid); @@ -212,7 +208,6 @@ test_write_thread (ThreadData *data) g_main_loop_run (data->loop); g_object_unref (source); - g_object_unref (registry); g_object_unref (data->client); g_main_context_pop_thread_default (context); @@ -223,7 +218,8 @@ test_write_thread (ThreadData *data) } static ThreadData * -create_test_thread (const gchar *book_uid, +create_test_thread (ESourceRegistry *registry, + const gchar *book_uid, const gchar *contact_uid, EContactField field, const gchar *value) @@ -231,6 +227,9 @@ create_test_thread (const gchar *book_uid, ThreadData *data = g_slice_new0 (ThreadData); const gchar *name = e_contact_field_name (field); + g_assert_nonnull (registry); + + data->registry = registry; data->book_uid = book_uid; data->contact_uid = contact_uid; data->field = field; @@ -276,6 +275,7 @@ test_concurrent_writes (ETestServerFixture *fixture, tests = g_new0 (ThreadData *, G_N_ELEMENTS (field_tests)); for (i = 0; i < G_N_ELEMENTS (field_tests); i++) tests[i] = create_test_thread ( + fixture->registry, book_uid, contact_uid, field_tests[i].field, field_tests[i].value); diff --git a/tests/libedata-book/test-book-meta-backend.c b/tests/libedata-book/test-book-meta-backend.c index 69dedaffc..331032c3e 100644 --- a/tests/libedata-book/test-book-meta-backend.c +++ b/tests/libedata-book/test-book-meta-backend.c @@ -23,6 +23,7 @@ #include "libebook-contacts/libebook-contacts.h" +#include "e-test-server-utils.h" #include "test-book-cache-utils.h" #define REMOTE_URL "https://www.gnome.org/wp-content/themes/gnome-grass/images/gnome-logo.svg" @@ -1663,9 +1664,16 @@ gint main (gint argc, gchar **argv) { + ETestServerClosure tsclosure = { + E_TEST_SERVER_NONE, + NULL, /* Source customization function */ + 0, /* Calendar Type */ + TRUE, /* Keep the working sandbox after the test, don't remove it */ + NULL, /* Destroy Notify function */ + }; + ETestServerFixture tsfixture = { 0 }; TCUClosure closure = { 0 }; gint res; - GError *error = NULL; #if !GLIB_CHECK_VERSION (2, 35, 1) g_type_init (); @@ -1676,8 +1684,9 @@ main (gint argc, g_assert (g_setenv ("LC_ALL", "en_US.UTF-8", TRUE)); setlocale (LC_ALL, ""); - glob_registry = e_source_registry_new_sync (NULL, &error); - g_assert_no_error (error); + e_test_server_utils_setup (&tsfixture, &tsclosure); + + glob_registry = tsfixture.registry; g_assert_nonnull (glob_registry); g_test_add ("/EBookMetaBackend/Photos", TCUFixture, &closure, @@ -1703,7 +1712,7 @@ main (gint argc, res = g_test_run (); - g_clear_object (&glob_registry); + e_test_server_utils_teardown (&tsfixture, &tsclosure); return res; } diff --git a/tests/libedata-cal/test-cal-meta-backend.c b/tests/libedata-cal/test-cal-meta-backend.c index 65fa24e8e..c931f017d 100644 --- a/tests/libedata-cal/test-cal-meta-backend.c +++ b/tests/libedata-cal/test-cal-meta-backend.c @@ -23,6 +23,7 @@ #include "libecal/libecal.h" +#include "e-test-server-utils.h" #include "test-cal-cache-utils.h" void _e_cal_cache_remove_loaded_timezones (ECalCache *cal_cache); /* e-cal-cache.c, private function */ @@ -2654,9 +2655,16 @@ gint main (gint argc, gchar **argv) { + ETestServerClosure tsclosure = { + E_TEST_SERVER_NONE, + NULL, /* Source customization function */ + 0, /* Calendar Type */ + TRUE, /* Keep the working sandbox after the test, don't remove it */ + NULL, /* Destroy Notify function */ + }; + ETestServerFixture tsfixture = { 0 }; TCUClosure closure_events = { TCU_LOAD_COMPONENT_SET_EVENTS }; gint res; - GError *error = NULL; #if !GLIB_CHECK_VERSION (2, 35, 1) g_type_init (); @@ -2671,8 +2679,9 @@ main (gint argc, icaltzutil_set_exact_vtimezones_support (0); #endif - glob_registry = e_source_registry_new_sync (NULL, &error); - g_assert_no_error (error); + e_test_server_utils_setup (&tsfixture, &tsclosure); + + glob_registry = tsfixture.registry; g_assert_nonnull (glob_registry); g_test_add ("/ECalMetaBackend/MergeInstances", TCUFixture, &closure_events, @@ -2708,7 +2717,7 @@ main (gint argc, res = g_test_run (); - g_clear_object (&glob_registry); + e_test_server_utils_teardown (&tsfixture, &tsclosure); return res; } |
