[evolution-data-server/openismus-work-master: 14/15] Ported EBook (deprecated) test cases to use the new test-server-utils scaffold.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work-master: 14/15] Ported EBook (deprecated) test cases to use the new test-server-utils scaffold.
- Date: Thu, 13 Dec 2012 08:30:01 +0000 (UTC)
commit 63f1c42ebdcc841c3373b4dfefe6d5daca3f2b05
Author: Tristan Van Berkom <tristanvb openismus com>
Date: Wed Dec 12 16:34:32 2012 +0900
Ported EBook (deprecated) test cases to use the new test-server-utils scaffold.
Note that test-ebook-remove is removed, this is executed in every test case
implicitly and asserted by the test scaffold
tests/libebook/Makefile.am | 10 ++-
tests/libebook/test-ebook-add-contact.c | 70 +++++++++-------
tests/libebook/test-ebook-commit-contact.c | 72 ++++++++++------
tests/libebook/test-ebook-get-book-view.c | 88 ++++++++++++-------
tests/libebook/test-ebook-get-contact.c | 68 ++++++++++------
tests/libebook/test-ebook-get-required-fields.c | 57 ++++++++-----
.../libebook/test-ebook-get-static-capabilities.c | 37 +++++----
.../test-ebook-get-supported-auth-methods.c | 65 ++++++++++-----
tests/libebook/test-ebook-get-supported-fields.c | 55 ++++++++-----
tests/libebook/test-ebook-remove-contact-by-id.c | 41 ++++++----
tests/libebook/test-ebook-remove-contact.c | 64 ++++++++------
tests/libebook/test-ebook-remove-contacts.c | 61 ++++++++------
tests/libebook/test-ebook-remove.c | 35 --------
13 files changed, 420 insertions(+), 303 deletions(-)
---
diff --git a/tests/libebook/Makefile.am b/tests/libebook/Makefile.am
index ba8e9b8..3dd07bb 100644
--- a/tests/libebook/Makefile.am
+++ b/tests/libebook/Makefile.am
@@ -11,6 +11,10 @@ libebook_test_utils_la_CPPFLAGS = \
-I$(top_builddir) \
-I$(top_srcdir)/addressbook \
-I$(top_builddir)/addressbook \
+ -I$(top_srcdir)/calendar \
+ -I$(top_builddir)/calendar \
+ -I$(top_srcdir)/tests/test-server-utils \
+ -I$(top_builddir)/tests/test-server-utils \
-DSRCDIR=\""$(abs_srcdir)"\" \
$(EVOLUTION_ADDRESSBOOK_CFLAGS) \
$(CAMEL_CFLAGS) \
@@ -19,6 +23,7 @@ libebook_test_utils_la_CPPFLAGS = \
libebook_test_utils_la_LIBADD = \
$(top_builddir)/addressbook/libebook-contacts/libebook-contacts-1.2.la \
$(top_builddir)/addressbook/libebook/libebook-1.2.la \
+ $(top_builddir)/tests/test-server-utils/libetestserverutils.la \
$(EVOLUTION_ADDRESSBOOK_LIBS) \
$(CAMEL_LIBS) \
$(NULL)
@@ -55,8 +60,7 @@ TESTS = \
test-ebook-get-supported-auth-methods \
test-ebook-remove-contact-by-id \
test-ebook-remove-contacts \
- test-ebook-get-book-view \
- test-ebook-remove
+ test-ebook-get-book-view
# test-ebook-stress-factory--serial \
# test-ebook-stress-factory--fifo \
@@ -123,8 +127,6 @@ test_ebook_get_supported_fields_LDADD=$(TEST_LIBS)
test_ebook_get_supported_fields_CPPFLAGS=$(TEST_CPPFLAGS)
test_ebook_add_contact_LDADD=$(TEST_LIBS)
test_ebook_add_contact_CPPFLAGS=$(TEST_CPPFLAGS)
-test_ebook_remove_LDADD=$(TEST_LIBS)
-test_ebook_remove_CPPFLAGS=$(TEST_CPPFLAGS)
test_ebook_remove_contact_LDADD=$(TEST_LIBS)
test_ebook_remove_contact_CPPFLAGS=$(TEST_CPPFLAGS)
test_ebook_remove_contact_by_id_LDADD=$(TEST_LIBS)
diff --git a/tests/libebook/test-ebook-add-contact.c b/tests/libebook/test-ebook-add-contact.c
index 96eaf12..2921d1c 100644
--- a/tests/libebook/test-ebook-add-contact.c
+++ b/tests/libebook/test-ebook-add-contact.c
@@ -1,54 +1,62 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#include <stdlib.h>
-#include <libebook/libebook.h>
#include "ebook-test-utils.h"
+#include "e-test-server-utils.h"
-gint
-main (gint argc,
- gchar **argv)
+static ETestServerClosure book_closure =
+ { E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK, NULL, 0 };
+
+static void
+test_add_contact_sync (ETestServerFixture *fixture,
+ gconstpointer user_data)
{
EBook *book;
- GMainLoop *loop;
- gchar *vcard;
EContact *contact;
- EContact *contact_final;
gchar *uid;
- g_type_init ();
-
- /*
- * Setup
- */
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
-
- /*
- * Sync version
- */
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
uid = ebook_test_utils_book_add_contact_from_test_case_verify (
- book, "simple-1", &contact_final);
+ book, "simple-1", &contact);
test_print ("successfully added and retrieved contact '%s'\n", uid);
- g_object_unref (contact_final);
+ g_object_unref (contact);
+}
+
+static void
+test_add_contact_async (ETestServerFixture *fixture,
+ gconstpointer user_data)
+{
+ EBook *book;
+ gchar *vcard;
+ EContact *contact;
+
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
- /*
- * Async version
- */
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
vcard = ebook_test_utils_new_vcard_from_test_case ("simple-1");
contact = e_contact_new_from_vcard (vcard);
+ g_free (vcard);
- loop = g_main_loop_new (NULL, TRUE);
ebook_test_utils_book_async_add_contact (
- book, contact, ebook_test_utils_callback_quit, loop);
+ book, contact, ebook_test_utils_callback_quit, fixture->loop);
- g_free (uid);
- g_main_loop_run (loop);
+ g_main_loop_run (fixture->loop);
+}
- g_free (vcard);
+gint
+main (gint argc,
+ gchar **argv)
+{
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+ g_type_init ();
+#endif
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add ("/EBook/AddContact/Sync", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_add_contact_sync, e_test_server_utils_teardown);
+ g_test_add ("/EBook/AddContact/Async", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_add_contact_async, e_test_server_utils_teardown);
- return 0;
+ return e_test_server_utils_run ();
}
diff --git a/tests/libebook/test-ebook-commit-contact.c b/tests/libebook/test-ebook-commit-contact.c
index ede5e99..1d5f9b1 100644
--- a/tests/libebook/test-ebook-commit-contact.c
+++ b/tests/libebook/test-ebook-commit-contact.c
@@ -4,11 +4,17 @@
#include <libebook/libebook.h>
#include "ebook-test-utils.h"
+#include "e-test-server-utils.h"
+
+static ETestServerClosure book_closure =
+ { E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK, NULL, 0 };
#define EMAIL_ADD "foo bar com"
-static EBook *book;
-static gchar *uid;
+
+/* Global data */
+static EBook *book = NULL;
+static gchar *uid = NULL;
static void
verify_precommit_and_prepare_contact (EContact *contact)
@@ -46,50 +52,62 @@ commit_verify_cb (EBookTestClosure *closure)
return FALSE;
}
-gint
-main (gint argc,
- gchar **argv)
+static void
+test_commit_contact_sync (ETestServerFixture *fixture,
+ gconstpointer user_data)
{
- GMainLoop *loop;
EContact *contact;
- g_type_init ();
-
- /*
- * Setup
- */
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
-
- /*
- * Sync version
- */
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
uid = ebook_test_utils_book_add_contact_from_test_case_verify (book, "name-only", &contact);
+
verify_precommit_and_prepare_contact (contact);
ebook_test_utils_book_commit_contact (book, contact);
-
verify_commit (contact);
test_print ("successfully committed changes to contact contact '%s'\n", uid);
g_object_unref (contact);
g_free (uid);
- /*
- * Async version
- */
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
+ contact = NULL;
+ uid = NULL;
+}
+
+static void
+test_commit_contact_async (ETestServerFixture *fixture,
+ gconstpointer user_data)
+{
+ EContact *contact;
+
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
uid = ebook_test_utils_book_add_contact_from_test_case_verify (book, "name-only", &contact);
verify_precommit_and_prepare_contact (contact);
- loop = g_main_loop_new (NULL, TRUE);
ebook_test_utils_book_async_commit_contact (
- book, contact, (GSourceFunc) commit_verify_cb, loop);
+ book, contact, (GSourceFunc) commit_verify_cb, fixture->loop);
- g_main_loop_run (loop);
+ g_main_loop_run (fixture->loop);
+ g_object_unref (contact);
g_free (uid);
+ contact = NULL;
+ uid = NULL;
+}
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+ g_type_init ();
+#endif
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add ("/EBook/CommitContact/Sync", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_commit_contact_sync, e_test_server_utils_teardown);
+ g_test_add ("/EBook/CommitContact/Async", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_commit_contact_async, e_test_server_utils_teardown);
- return 0;
+ return e_test_server_utils_run ();
}
diff --git a/tests/libebook/test-ebook-get-book-view.c b/tests/libebook/test-ebook-get-book-view.c
index 4e345c5..4ae4ed9 100644
--- a/tests/libebook/test-ebook-get-book-view.c
+++ b/tests/libebook/test-ebook-get-book-view.c
@@ -4,8 +4,10 @@
#include <libebook/libebook.h>
#include "ebook-test-utils.h"
+#include "e-test-server-utils.h"
-static GMainLoop *loop;
+static ETestServerClosure book_closure =
+ { E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK, NULL, 0 };
static void
print_contact (EContact *contact)
@@ -51,7 +53,8 @@ contacts_removed (EBookView *book_view,
static void
view_complete (EBookView *book_view,
EBookViewStatus status,
- const gchar *error_msg)
+ const gchar *error_msg,
+ GMainLoop *loop)
{
e_book_view_stop (book_view);
g_object_unref (book_view);
@@ -59,11 +62,12 @@ view_complete (EBookView *book_view,
}
static void
-setup_and_start_view (EBookView *view)
+setup_and_start_view (EBookView *view,
+ GMainLoop *loop)
{
g_signal_connect (view, "contacts_added", G_CALLBACK (contacts_added), NULL);
g_signal_connect (view, "contacts_removed", G_CALLBACK (contacts_removed), NULL);
- g_signal_connect (view, "view_complete", G_CALLBACK (view_complete), NULL);
+ g_signal_connect (view, "view_complete", G_CALLBACK (view_complete), loop);
e_book_view_start (view);
}
@@ -71,65 +75,83 @@ setup_and_start_view (EBookView *view)
static void
get_book_view_cb (EBookTestClosure *closure)
{
+ GMainLoop *loop = closure->user_data;
g_assert (closure->view);
- setup_and_start_view (closure->view);
+ setup_and_start_view (closure->view, loop);
}
static void
-setup_book (EBook **book_out)
+setup_book (EBook *book)
{
- EBook *book;
-
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
-
ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-1", NULL);
ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-2", NULL);
ebook_test_utils_book_add_contact_from_test_case_verify (book, "name-only", NULL);
-
- *book_out = book;
}
-gint
-main (gint argc,
- gchar **argv)
+static void
+test_get_book_view_sync (ETestServerFixture *fixture,
+ gconstpointer user_data)
{
EBook *book;
EBookQuery *query;
EBookView *view;
- g_type_init ();
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
+ setup_book (book);
- /*
- * Sync version
- */
- setup_book (&book);
query = e_book_query_any_field_contains ("");
ebook_test_utils_book_get_book_view (book, query, &view);
- setup_and_start_view (view);
+ setup_and_start_view (view, fixture->loop);
test_print ("successfully set up the book view\n");
- loop = g_main_loop_new (NULL, TRUE);
- g_main_loop_run (loop);
+ g_main_loop_run (fixture->loop);
e_book_query_unref (query);
+}
+
+static gboolean
+main_loop_fail_timeout (gpointer unused)
+{
+ g_error ("Failed to get book view, async call timed out");
+ return FALSE;
+}
+
+static void
+test_get_book_view_async (ETestServerFixture *fixture,
+ gconstpointer user_data)
+{
+ EBook *book;
+ EBookQuery *query;
+
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
+ setup_book (book);
- /*
- * Async version
- */
- setup_book (&book);
query = e_book_query_any_field_contains ("");
- loop = g_main_loop_new (NULL, TRUE);
ebook_test_utils_book_async_get_book_view (
book, query,
- (GSourceFunc) get_book_view_cb, loop);
-
- g_main_loop_run (loop);
+ (GSourceFunc) get_book_view_cb, fixture->loop);
+ g_timeout_add (5 * 1000, (GSourceFunc)main_loop_fail_timeout, NULL);
+ g_main_loop_run (fixture->loop);
e_book_query_unref (query);
+}
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+ g_type_init ();
+#endif
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add ("/EBook/GetBookView/Sync", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_get_book_view_sync, e_test_server_utils_teardown);
+ g_test_add ("/EBook/GetBookView/Async", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_get_book_view_async, e_test_server_utils_teardown);
- return 0;
+ return e_test_server_utils_run ();
}
diff --git a/tests/libebook/test-ebook-get-contact.c b/tests/libebook/test-ebook-get-contact.c
index f49c2db..e8e8dfc 100644
--- a/tests/libebook/test-ebook-get-contact.c
+++ b/tests/libebook/test-ebook-get-contact.c
@@ -4,40 +4,58 @@
#include <libebook/libebook.h>
#include "ebook-test-utils.h"
+#include "e-test-server-utils.h"
-gint
-main (gint argc,
- gchar **argv)
+static ETestServerClosure book_closure =
+ { E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK, NULL, 0 };
+
+static void
+test_get_contact_sync (ETestServerFixture *fixture,
+ gconstpointer user_data)
{
EBook *book;
- GMainLoop *loop;
- EContact *contact_final;
- const gchar *uid;
+ gchar *uid;
- g_type_init ();
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
+ uid = ebook_test_utils_book_add_contact_from_test_case_verify (
+ book, "simple-1", NULL);
- /*
- * Setup
- */
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
+ test_print ("successfully added and retrieved contact '%s'\n", uid);
+ g_free (uid);
+}
- /*
- * Sync version
- */
- uid = ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-1", &contact_final);
+static void
+test_get_contact_async (ETestServerFixture *fixture,
+ gconstpointer user_data)
+{
+ EBook *book;
+ gchar *uid;
- test_print ("successfully added and retrieved contact '%s'\n", uid);
- g_object_unref (contact_final);
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
+ uid = ebook_test_utils_book_add_contact_from_test_case_verify (
+ book, "simple-1", NULL);
- /*
- * Async version
- */
- loop = g_main_loop_new (NULL, TRUE);
ebook_test_utils_book_async_get_contact (
- book, uid, ebook_test_utils_callback_quit, loop);
+ book, uid, ebook_test_utils_callback_quit, fixture->loop);
+
+ g_free (uid);
+ g_main_loop_run (fixture->loop);
+}
+
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+ g_type_init ();
+#endif
+ g_test_init (&argc, &argv, NULL);
- g_main_loop_run (loop);
+ g_test_add ("/EBook/GetContact/Sync", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_get_contact_sync, e_test_server_utils_teardown);
+ g_test_add ("/EBook/GetContact/Async", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_get_contact_async, e_test_server_utils_teardown);
- return 0;
+ return e_test_server_utils_run ();
}
diff --git a/tests/libebook/test-ebook-get-required-fields.c b/tests/libebook/test-ebook-get-required-fields.c
index 8d4ea3e..9ed46f5 100644
--- a/tests/libebook/test-ebook-get-required-fields.c
+++ b/tests/libebook/test-ebook-get-required-fields.c
@@ -4,6 +4,10 @@
#include <libebook/libebook.h>
#include "ebook-test-utils.h"
+#include "e-test-server-utils.h"
+
+static ETestServerClosure book_closure =
+ { E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK, NULL, 0 };
static void
list_member_print_and_free (gchar *member,
@@ -36,41 +40,48 @@ get_required_fields_cb (EBookTestClosure *closure)
g_main_loop_quit ((GMainLoop *) (closure->user_data));
}
-gint
-main (gint argc,
- gchar **argv)
+
+static void
+test_get_required_fields_sync (ETestServerFixture *fixture,
+ gconstpointer user_data)
{
EBook *book;
- GMainLoop *loop;
GList *fields;
- g_type_init ();
-
- /*
- * Setup
- */
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
-
- /*
- * Sync version
- */
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
fields = ebook_test_utils_book_get_required_fields (book);
test_print ("successfully retrieved required fields:\n");
g_list_foreach (fields, (GFunc) list_member_print_and_free, NULL);
test_print ("----------------\n");
g_list_free (fields);
+}
- /*
- * Async version
- */
- loop = g_main_loop_new (NULL, TRUE);
+static void
+test_get_required_fields_async (ETestServerFixture *fixture,
+ gconstpointer user_data)
+{
+ EBook *book;
+
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
ebook_test_utils_book_async_get_required_fields (
- book,
- (GSourceFunc) get_required_fields_cb, loop);
+ book, (GSourceFunc) get_required_fields_cb, fixture->loop);
+ g_main_loop_run (fixture->loop);
+}
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+ g_type_init ();
+#endif
+ g_test_init (&argc, &argv, NULL);
- g_main_loop_run (loop);
+ g_test_add ("/EBook/GetRequiredFields/Sync", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_get_required_fields_sync, e_test_server_utils_teardown);
+ g_test_add ("/EBook/GetRequiredFields/Async", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_get_required_fields_async, e_test_server_utils_teardown);
- return 0;
+ return e_test_server_utils_run ();
}
diff --git a/tests/libebook/test-ebook-get-static-capabilities.c b/tests/libebook/test-ebook-get-static-capabilities.c
index 42cce08..dd39d73 100644
--- a/tests/libebook/test-ebook-get-static-capabilities.c
+++ b/tests/libebook/test-ebook-get-static-capabilities.c
@@ -4,28 +4,35 @@
#include <libebook/libebook.h>
#include "ebook-test-utils.h"
+#include "e-test-server-utils.h"
-gint
-main (gint argc,
- gchar **argv)
+static ETestServerClosure book_closure =
+ { E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK, NULL, 0 };
+
+static void
+test_get_static_capabilities_sync (ETestServerFixture *fixture,
+ gconstpointer user_data)
{
EBook *book;
const gchar *caps;
- g_type_init ();
-
- /*
- * Setup
- */
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
- /*
- * Sync version
- */
caps = ebook_test_utils_book_get_static_capabilities (book);
-
test_print ("successfully retrieved static capabilities: '%s'\n", caps);
+}
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+ g_type_init ();
+#endif
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add ("/EBook/GetStaticCapabilities/Sync", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_get_static_capabilities_sync, e_test_server_utils_teardown);
- return 0;
+ return e_test_server_utils_run ();
}
diff --git a/tests/libebook/test-ebook-get-supported-auth-methods.c b/tests/libebook/test-ebook-get-supported-auth-methods.c
index 262ebd0..82f708b 100644
--- a/tests/libebook/test-ebook-get-supported-auth-methods.c
+++ b/tests/libebook/test-ebook-get-supported-auth-methods.c
@@ -4,6 +4,10 @@
#include <libebook/libebook.h>
#include "ebook-test-utils.h"
+#include "e-test-server-utils.h"
+
+static ETestServerClosure book_closure =
+ { E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK, NULL, 0 };
static void
list_member_print_and_free (gchar *member,
@@ -36,40 +40,59 @@ get_supported_auth_methods_cb (EBookTestClosure *closure)
g_main_loop_quit ((GMainLoop *) (closure->user_data));
}
-gint
-main (gint argc,
- gchar **argv)
+
+static void
+test_get_supported_auth_methods_sync (ETestServerFixture *fixture,
+ gconstpointer user_data)
{
EBook *book;
- GMainLoop *loop;
GList *auth_methods;
- g_type_init ();
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
- /*
- * Setup
- */
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
-
- /*
- * Sync version
- */
auth_methods = ebook_test_utils_book_get_supported_auth_methods (book);
test_print ("successfully retrieved supported auth methods:\n");
g_list_foreach (auth_methods, (GFunc) list_member_print_and_free, NULL);
test_print ("----------------\n");
g_list_free (auth_methods);
+}
+
+static gboolean
+main_loop_fail_timeout (gpointer unused)
+{
+ g_error ("Failed to get supported auth methods, async call timed out");
+ return FALSE;
+}
+
+static void
+test_get_supported_auth_methods_async (ETestServerFixture *fixture,
+ gconstpointer user_data)
+{
+ EBook *book;
+
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
- /*
- * Async version
- */
- loop = g_main_loop_new (NULL, TRUE);
ebook_test_utils_book_async_get_supported_auth_methods (
- book, (GSourceFunc) get_supported_auth_methods_cb, loop);
+ book, (GSourceFunc) get_supported_auth_methods_cb, fixture->loop);
+
+ g_timeout_add (5 * 1000, (GSourceFunc)main_loop_fail_timeout, NULL);
+ g_main_loop_run (fixture->loop);
+}
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+ g_type_init ();
+#endif
+ g_test_init (&argc, &argv, NULL);
- g_main_loop_run (loop);
+ g_test_add ("/EBook/GetSupportedAuthMethods/Sync", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_get_supported_auth_methods_sync, e_test_server_utils_teardown);
+ g_test_add ("/EBook/GetSupportedAuthMethods/Async", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_get_supported_auth_methods_async, e_test_server_utils_teardown);
- return 0;
+ return e_test_server_utils_run ();
}
diff --git a/tests/libebook/test-ebook-get-supported-fields.c b/tests/libebook/test-ebook-get-supported-fields.c
index a5e8831..7e10d1b 100644
--- a/tests/libebook/test-ebook-get-supported-fields.c
+++ b/tests/libebook/test-ebook-get-supported-fields.c
@@ -4,6 +4,10 @@
#include <libebook/libebook.h>
#include "ebook-test-utils.h"
+#include "e-test-server-utils.h"
+
+static ETestServerClosure book_closure =
+ { E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK, NULL, 0 };
static void
list_member_print_and_free (gchar *member,
@@ -36,40 +40,49 @@ get_supported_fields_cb (EBookTestClosure *closure)
g_main_loop_quit ((GMainLoop *) (closure->user_data));
}
-gint
-main (gint argc,
- gchar **argv)
+static void
+test_get_supported_fields_sync (ETestServerFixture *fixture,
+ gconstpointer user_data)
{
EBook *book;
- GMainLoop *loop;
GList *fields;
- g_type_init ();
-
- /*
- * Setup
- */
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
- /*
- * Sync version
- */
fields = ebook_test_utils_book_get_supported_fields (book);
test_print ("successfully retrieved supported fields:\n");
g_list_foreach (fields, (GFunc) list_member_print_and_free, NULL);
test_print ("----------------\n");
g_list_free (fields);
+}
+
+static void
+test_get_supported_fields_async (ETestServerFixture *fixture,
+ gconstpointer user_data)
+{
+ EBook *book;
+
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
- /*
- * Async version
- */
- loop = g_main_loop_new (NULL, TRUE);
ebook_test_utils_book_async_get_supported_fields (
- book, (GSourceFunc) get_supported_fields_cb, loop);
+ book, (GSourceFunc) get_supported_fields_cb, fixture->loop);
+ g_main_loop_run (fixture->loop);
+}
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+ g_type_init ();
+#endif
+ g_test_init (&argc, &argv, NULL);
- g_main_loop_run (loop);
+ g_test_add ("/EBook/GetSupportedFields/Sync", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_get_supported_fields_sync, e_test_server_utils_teardown);
+ g_test_add ("/EBook/GetSupportedFields/Async", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_get_supported_fields_async, e_test_server_utils_teardown);
- return 0;
+ return e_test_server_utils_run ();
}
diff --git a/tests/libebook/test-ebook-remove-contact-by-id.c b/tests/libebook/test-ebook-remove-contact-by-id.c
index 74b78d6..c76a498 100644
--- a/tests/libebook/test-ebook-remove-contact-by-id.c
+++ b/tests/libebook/test-ebook-remove-contact-by-id.c
@@ -3,32 +3,39 @@
#include <libebook/libebook.h>
#include "ebook-test-utils.h"
+#include "e-test-server-utils.h"
-gint
-main (gint argc,
- gchar **argv)
+static ETestServerClosure book_closure =
+ { E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK, NULL, 0 };
+
+static void
+test_remove_contact_by_id_async (ETestServerFixture *fixture,
+ gconstpointer user_data)
{
EBook *book;
- GMainLoop *loop;
gchar *uid;
- g_type_init ();
-
- /*
- * Async version
- */
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
-
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
uid = ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-1", NULL);
- loop = g_main_loop_new (NULL, TRUE);
ebook_test_utils_book_async_remove_contact_by_id (
- book, uid, ebook_test_utils_callback_quit, loop);
-
- g_main_loop_run (loop);
+ book, uid, ebook_test_utils_callback_quit, fixture->loop);
+ g_main_loop_run (fixture->loop);
g_free (uid);
+}
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+ g_type_init ();
+#endif
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add ("/EBook/RemoveContactById/Async", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_remove_contact_by_id_async, e_test_server_utils_teardown);
- return 0;
+ return e_test_server_utils_run ();
}
diff --git a/tests/libebook/test-ebook-remove-contact.c b/tests/libebook/test-ebook-remove-contact.c
index a54c825..609a9b3 100644
--- a/tests/libebook/test-ebook-remove-contact.c
+++ b/tests/libebook/test-ebook-remove-contact.c
@@ -3,56 +3,66 @@
#include <libebook/libebook.h>
#include "ebook-test-utils.h"
+#include "e-test-server-utils.h"
-gint
-main (gint argc,
- gchar **argv)
+static ETestServerClosure book_closure =
+ { E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK, NULL, 0 };
+
+static void
+test_remove_contact_sync (ETestServerFixture *fixture,
+ gconstpointer user_data)
{
EBook *book;
- GMainLoop *loop;
- EContact *contact_final;
+ EContact *contact_final = NULL;
gchar *uid;
- g_type_init ();
-
- /*
- * Setup
- */
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
- /*
- * Sync version
- */
uid = ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-1", NULL);
ebook_test_utils_book_remove_contact (book, uid);
- contact_final = NULL;
e_book_get_contact (book, uid, &contact_final, NULL);
g_assert (contact_final == NULL);
test_print ("successfully added and removed contact '%s'\n", uid);
g_free (uid);
+}
+
+static void
+test_remove_contact_async (ETestServerFixture *fixture,
+ gconstpointer user_data)
+{
+ EBook *book;
+ EContact *contact_final = NULL;
+ gchar *uid;
- /*
- * Async version
- */
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
- contact_final = NULL;
/* contact_final has 2 refs by the end of this */
uid = ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-1", &contact_final);
- loop = g_main_loop_new (NULL, TRUE);
/* contact_final is unref'd by e_book_remove_contact() here */
ebook_test_utils_book_async_remove_contact (
- book, contact_final, ebook_test_utils_callback_quit, loop);
-
- g_main_loop_run (loop);
+ book, contact_final, ebook_test_utils_callback_quit, fixture->loop);
+ g_main_loop_run (fixture->loop);
g_object_unref (contact_final);
g_free (uid);
+}
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+ g_type_init ();
+#endif
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add ("/EBook/RemoveContact/Sync", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_remove_contact_sync, e_test_server_utils_teardown);
+ g_test_add ("/EBook/RemoveContact/Async", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_remove_contact_async, e_test_server_utils_teardown);
- return 0;
+ return e_test_server_utils_run ();
}
diff --git a/tests/libebook/test-ebook-remove-contacts.c b/tests/libebook/test-ebook-remove-contacts.c
index 20ab401..c34d452 100644
--- a/tests/libebook/test-ebook-remove-contacts.c
+++ b/tests/libebook/test-ebook-remove-contacts.c
@@ -3,28 +3,22 @@
#include <libebook/libebook.h>
#include "ebook-test-utils.h"
+#include "e-test-server-utils.h"
-gint
-main (gint argc,
- gchar **argv)
+static ETestServerClosure book_closure =
+ { E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK, NULL, 0 };
+
+static void
+test_remove_contacts_sync (ETestServerFixture *fixture,
+ gconstpointer user_data)
{
EBook *book;
- GMainLoop *loop;
- EContact *contact_final;
+ EContact *contact_final = NULL;
gchar *uid_1, *uid_2;
GList *uids = NULL;
- g_type_init ();
-
- /*
- * Setup
- */
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
- /*
- * Sync version
- */
uid_1 = ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-1", NULL);
uid_2 = ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-2", NULL);
uids = g_list_prepend (uids, uid_1);
@@ -43,12 +37,17 @@ main (gint argc,
g_free (uid_1);
g_free (uid_2);
g_list_free (uids);
+}
+
+static void
+test_remove_contacts_async (ETestServerFixture *fixture,
+ gconstpointer user_data)
+{
+ EBook *book;
+ gchar *uid_1, *uid_2;
+ GList *uids = NULL;
- /*
- * Async version
- */
- book = ebook_test_utils_book_new_temp (NULL);
- ebook_test_utils_book_open (book, FALSE);
+ book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook);
uid_1 = ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-1", NULL);
uid_2 = ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-2", NULL);
@@ -56,16 +55,30 @@ main (gint argc,
uids = g_list_prepend (uids, uid_1);
uids = g_list_prepend (uids, uid_2);
- loop = g_main_loop_new (NULL, TRUE);
ebook_test_utils_book_async_remove_contacts (
book, uids,
- ebook_test_utils_callback_quit, loop);
+ ebook_test_utils_callback_quit, fixture->loop);
- g_main_loop_run (loop);
+ g_main_loop_run (fixture->loop);
g_free (uid_1);
g_free (uid_2);
g_list_free (uids);
+}
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+ g_type_init ();
+#endif
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add ("/EBook/RemoveContacts/Sync", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_remove_contacts_sync, e_test_server_utils_teardown);
+ g_test_add ("/EBook/RemoveContacts/Async", ETestServerFixture, &book_closure,
+ e_test_server_utils_setup, test_remove_contacts_async, e_test_server_utils_teardown);
- return 0;
+ return e_test_server_utils_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]