-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) \
libebook_test_utils_la_LIBADD = \
$(top_builddir)/addressbook/libebook/libebook-1.2.la \
+ $(top_builddir)/tests/test-server-utils/libetestserverutils.la \
$(EVOLUTION_ADDRESSBOOK_LIBS) \
$(CAMEL_LIBS) \
$(NULL)
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 \
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)
/* -*- 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 ();
}
#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)
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 ();
}
#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)
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);
}
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);
}
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 ();
}
#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 ();
}
#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,
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 ();
}
#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 ();
}
#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,
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 ();
}
#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,
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 ();
}
#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 ();
}
#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 ();
}
#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);
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);
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 ();
}
+++ /dev/null
-/* -*- 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"
-
-gint
-main (gint argc,
- gchar **argv)
-{
- EBook *book;
- gchar *uri = NULL;
- GMainLoop *loop;
-
- g_type_init ();
-
- /* Sync version */
- book = ebook_test_utils_book_new_temp (&uri);
- ebook_test_utils_book_open (book, FALSE);
-
-#if 0 /* ebook_test_utils_book_async_remove() Not implemented */
- /* Async version */
- book = ebook_test_utils_book_new_temp (&uri);
- ebook_test_utils_book_open (book, FALSE);
-
- loop = g_main_loop_new (NULL, TRUE);
- ebook_test_utils_book_async_remove (
- book, ebook_test_utils_callback_quit, loop);
-
- g_main_loop_run (loop);
-#endif
-
- return 0;
-}