[evolution-data-server/openismus-work-master: 12/14] Adding test-server-utils



commit 3f69ac8b26119548845aab2f1ccd6ebebfa3e9a6
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Tue Dec 11 18:22:49 2012 +0900

    Adding test-server-utils
    
    A library with text fixtures for testing ESourceRegistry, EBookClient and
    ECalClient in a self contained fashion.

 configure.ac                                       |    5 +
 data/Makefile.am                                   |    7 +-
 tests/Makefile.am                                  |    2 +-
 tests/test-server-utils/Makefile.am                |   54 +++
 tests/test-server-utils/e-test-server-utils.c      |  347 ++++++++++++++++++++
 tests/test-server-utils/e-test-server-utils.h      |  117 +++++++
 tests/test-server-utils/services/Makefile.am       |    4 +
 ...ome.evolution.dataserver.AddressBook.service.in |    3 +
 ....gnome.evolution.dataserver.Calendar.service.in |    3 +
 ...g.gnome.evolution.dataserver.Sources.service.in |    3 +
 tests/test-server-utils/test-fixture.c             |   73 ++++
 11 files changed, 616 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index eed24c1..8c57745 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1637,6 +1637,11 @@ tests/libecal/Makefile
 tests/libecal/client/Makefile
 tests/libedata-cal/Makefile
 tests/libedataserver/Makefile
+tests/test-server-utils/Makefile
+tests/test-server-utils/services/Makefile
+tests/test-server-utils/services/org.gnome.evolution.dataserver.AddressBook.service
+tests/test-server-utils/services/org.gnome.evolution.dataserver.Calendar.service
+tests/test-server-utils/services/org.gnome.evolution.dataserver.Sources.service
 tests/tools/Makefile
 docs/Makefile
 docs/reference/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index f209552..654369f 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -9,12 +9,17 @@ gsettings_SCHEMAS =						\
 
 @GSETTINGS_RULES@
 
+# Compile the schemas locally, this is
+# required for running sandboxed test cases
+all-am:
+	$(GLIB_COMPILE_SCHEMAS) .
+
 convertdir = $(datadir)/GConf/gsettings
 convert_DATA = evolution-data-server.convert
 
 EXTRA_DIST = $(gsettings_SCHEMAS:.xml=.xml.in) \
 	     $(convert_DATA)
 
-CLEANFILES = $(gsettings_SCHEMAS)
+CLEANFILES = $(gsettings_SCHEMAS) gschemas.compiled
 
 -include $(top_srcdir)/git.mk
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6c5f457..388ea42 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = libedataserver libebook libecal libedata-cal tools
+SUBDIRS = test-server-utils libedataserver libebook libecal libedata-cal tools
 
 @GNOME_CODE_COVERAGE_RULES@
 
diff --git a/tests/test-server-utils/Makefile.am b/tests/test-server-utils/Makefile.am
new file mode 100644
index 0000000..34fe539
--- /dev/null
+++ b/tests/test-server-utils/Makefile.am
@@ -0,0 +1,54 @@
+NULL =
+
+ GNOME_CODE_COVERAGE_RULES@
+
+common_cflags = \
+	$(AM_CPPFLAGS) \
+	-I$(top_srcdir) \
+	-I$(top_builddir) \
+	-I$(top_srcdir)/addressbook \
+	-I$(top_builddir)/addressbook \
+	-I$(top_srcdir)/calendar \
+	-I$(top_builddir)/calendar \
+	-DG_LOG_DOMAIN=\"e-test-server-utils\" \
+	-DEDS_TEST_DBUS_SERVICE_DIR=\""$(abs_top_builddir)/tests/test-server-utils/services"\" \
+	-DEDS_TEST_WORK_DIR=\""$(abs_top_builddir)/tests/test-server-utils/cache"\" \
+	-DEDS_TEST_SCHEMA_DIR=\""$(abs_top_builddir)/data"\" \
+	-DEDS_TEST_ADDRESS_BOOK_DIR=\""$(abs_top_builddir)/addressbook/backends/file/.libs"\" \
+	-DEDS_TEST_CALENDAR_DIR=\""$(abs_top_builddir)/calendar/backends/file/.libs"\" \
+	$(E_DATA_SERVER_CFLAGS) \
+	$(GIO_UNIX_CFLAGS) \
+	$(NULL)
+
+common_libs = \
+	$(top_builddir)/libedataserver/libedataserver-1.2.la \
+	$(top_builddir)/addressbook/libebook/libebook-1.2.la \
+	$(top_builddir)/calendar/libecal/libecal-1.2.la \
+	$(E_DATA_SERVER_LIBS) \
+	$(GIO_UNIX_LIBS) \
+	$(NULL)
+
+######################################
+#         Utility Library            #
+######################################
+noinst_LTLIBRARIES = libetestserverutils.la
+
+libetestserverutils_la_CPPFLAGS = $(common_cflags)
+libetestserverutils_la_LIBADD = $(common_libs)
+libetestserverutils_la_SOURCES = \
+	e-test-server-utils.c \
+	e-test-server-utils.h \
+	$(NULL)
+
+######################################
+#         Local Unit Tests           #
+######################################
+noinst_PROGRAMS = $(TESTS)
+
+TESTS = test-fixture
+
+test_fixture_CPPFLAGS = $(common_cflags)
+test_fixture_LDADD    = $(common_libs) libetestserverutils.la
+test_fixture_SOURCES  = test-fixture.c
+
+-include $(top_srcdir)/git.mk
diff --git a/tests/test-server-utils/e-test-server-utils.c b/tests/test-server-utils/e-test-server-utils.c
new file mode 100644
index 0000000..8c573af
--- /dev/null
+++ b/tests/test-server-utils/e-test-server-utils.c
@@ -0,0 +1,347 @@
+#include "e-test-server-utils.h"
+
+#define ADDRESS_BOOK_SOURCE_UID "test-address-book"
+#define CALENDAR_SOURCE_UID     "test-calendar"
+
+/* FIXME, currently we are unable to achieve server activation
+ * twice in a single test case, so we're using one D-Bus server
+ * throughout an entire test suite.
+ *
+ * When this is fixed we can migrate the D-Bus initialization
+ * and teardown from e_test_server_utils_run() to
+ * e_test_server_utils_setup() and e_test_server_utils_teardown()
+ * and this will transparantly change the way tests run using
+ * this test framework.
+ */
+#define GLOBAL_DBUS_DAEMON 1
+
+#if GLOBAL_DBUS_DAEMON
+static GTestDBus *global_test_dbus = NULL;
+#endif
+
+typedef struct {
+	ETestServerFixture *fixture;
+	ETestServerClosure *closure;
+} FixturePair;
+
+static void
+setup_environment (void)
+{
+	g_assert (g_setenv ("XDG_DATA_HOME", EDS_TEST_WORK_DIR, TRUE));
+	g_assert (g_setenv ("XDG_CACHE_HOME", EDS_TEST_WORK_DIR, TRUE));
+	g_assert (g_setenv ("XDG_CONFIG_HOME", EDS_TEST_WORK_DIR, TRUE));
+	g_assert (g_setenv ("GSETTINGS_SCHEMA_DIR", EDS_TEST_SCHEMA_DIR, TRUE));
+	g_assert (g_setenv ("EDS_CALENDAR_MODULES", EDS_TEST_CALENDAR_DIR, TRUE));
+	g_assert (g_setenv ("EDS_ADDRESS_BOOK_MODULES", EDS_TEST_ADDRESS_BOOK_DIR, TRUE));
+}
+
+static void
+delete_work_directory (void)
+{
+	gchar *command_line;
+
+	/* XXX Instead of complex error checking here, we should ideally use
+	 * a recursive GDir / g_unlink() function.
+	 *
+	 * We cannot use GFile and the recursive delete function without
+	 * corrupting our contained D-Bus environment with service files
+	 * from the OS.
+	 */
+	command_line = g_strdup_printf ("/bin/rm -rf %s", EDS_TEST_WORK_DIR);
+	g_spawn_command_line_sync (command_line, NULL, NULL, NULL, NULL);
+	g_free (command_line);
+}
+
+static gboolean
+e_test_server_utils_bootstrap_timeout (FixturePair *pair)
+{
+	ESource *source = NULL;
+	GError  *error = NULL;
+
+	switch (pair->closure->type) {
+	case E_TEST_SERVER_ADDRESS_BOOK:
+		source = e_source_registry_ref_source (pair->fixture->registry, ADDRESS_BOOK_SOURCE_UID);
+		if (!source)
+			g_error ("Unable to fetch newly created addressbook source from the registry");
+
+		pair->fixture->service.book_client = e_book_client_new (source, &error);
+		if (!pair->fixture->service.book_client)
+			g_error ("Unable to create the test book: %s", error->message);
+
+		if (!e_client_open_sync (E_CLIENT (pair->fixture->service.book_client), FALSE, NULL, &error))
+			g_error ("Unable to open book client: %s", error->message);
+
+		break;
+
+	case E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK:
+		source = e_source_registry_ref_source (pair->fixture->registry, ADDRESS_BOOK_SOURCE_UID);
+		if (!source)
+			g_error ("Unable to fetch newly created addressbook source from the registry");
+
+		pair->fixture->service.book = e_book_new (source, &error);
+		if (!pair->fixture->service.book)
+			g_error ("Unable to create the test book: %s", error->message);
+
+		if (!e_book_open (pair->fixture->service.book, FALSE, &error))
+			g_error ("Unable to open book: %s", error->message);
+
+		break;
+
+	case E_TEST_SERVER_CALENDAR:
+		source = e_source_registry_ref_source (pair->fixture->registry, CALENDAR_SOURCE_UID);
+		if (!source)
+			g_error ("Unable to fetch newly created addressbook source from the registry");
+
+		pair->fixture->service.calendar_client = e_cal_client_new (source, 
+									   pair->closure->calendar_source_type,
+									   &error);
+		if (!pair->fixture->service.calendar_client)
+			g_error ("Unable to create the test calendar: %s", error->message);
+
+		if (!e_client_open_sync (E_CLIENT (pair->fixture->service.calendar_client), FALSE, NULL, &error))
+			g_error ("Unable to open calendar client: %s", error->message);
+
+		break;
+
+	case E_TEST_SERVER_DEPRECATED_CALENDAR:
+		source = e_source_registry_ref_source (pair->fixture->registry, CALENDAR_SOURCE_UID);
+		if (!source)
+			g_error ("Unable to fetch newly created addressbook source from the registry");
+
+		pair->fixture->service.calendar = e_cal_new (source, pair->closure->calendar_source_type);
+		if (!pair->fixture->service.calendar)
+			g_error ("Unable to create the test calendar");
+
+		if (!e_cal_open (pair->fixture->service.calendar, FALSE, &error))
+			g_error ("Unable to open calendar: %s", error->message);
+
+		break;
+
+	case E_TEST_SERVER_NONE:
+		break;
+	}
+
+	if (source)
+		g_object_unref (source);
+
+	g_main_loop_quit (pair->fixture->loop);
+
+	return FALSE;
+}
+
+static gboolean
+e_test_server_utils_bootstrap_idle (FixturePair *pair)
+{
+	ESourceBackend *backend = NULL;
+	ESource *scratch = NULL;
+	GError  *error = NULL;
+
+	pair->fixture->registry = e_source_registry_new_sync (NULL, &error);
+
+	if (!pair->fixture->registry)
+		g_error ("Unable to create the test registry: %s", error->message);
+
+	/* Create an address book */
+	switch (pair->closure->type) {
+	case E_TEST_SERVER_ADDRESS_BOOK:
+	case E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK:
+
+		scratch = e_source_new_with_uid (ADDRESS_BOOK_SOURCE_UID, NULL, &error);
+		if (!scratch)
+			g_error ("Failed to create scratch source for an addressbook: %s", error->message);
+
+		/* Ensure Book type */
+		backend = e_source_get_extension (scratch, E_SOURCE_EXTENSION_ADDRESS_BOOK);
+		e_source_backend_set_backend_name (backend, "local");
+
+		break;
+	case E_TEST_SERVER_CALENDAR:
+	case E_TEST_SERVER_DEPRECATED_CALENDAR:
+
+		scratch = e_source_new_with_uid (CALENDAR_SOURCE_UID, NULL, &error);
+		if (!scratch)
+			g_error ("Failed to create scratch source for a calendar: %s", error->message);
+
+		/* Ensure Calendar type source (how to specify the backend here ?? */
+		backend = e_source_get_extension (scratch, E_SOURCE_EXTENSION_CALENDAR);
+		e_source_backend_set_backend_name (backend, "local");
+
+		break;
+
+	case E_TEST_SERVER_NONE:
+		break;
+	}
+
+	if (scratch) {
+		if (pair->closure->customize)
+			pair->closure->customize (scratch, pair->closure);
+
+		if (!e_source_registry_commit_source_sync (pair->fixture->registry, scratch, NULL, &error))
+			g_error ("Unable to add new addressbook source to the registry: %s", error->message);
+
+
+		g_object_unref (scratch);
+	}
+
+	if (pair->closure->type != E_TEST_SERVER_NONE)
+		g_timeout_add (20, (GSourceFunc)e_test_server_utils_bootstrap_timeout, pair);
+	else
+		g_main_loop_quit (pair->fixture->loop);
+
+	return FALSE;
+}
+
+/**
+ * e_test_server_utils_setup:
+ * @fixture: A #ETestServerFixture
+ * @user_data: A #ETestServerClosure or derived structure provided by the test.
+ *
+ * A setup function for the #ETestServerFixture fixture
+ */
+void
+e_test_server_utils_setup (ETestServerFixture *fixture,
+			   gconstpointer       user_data)
+{
+	ETestServerClosure *closure = (ETestServerClosure *)user_data;
+	FixturePair         pair    = { fixture, closure };
+
+	/* Create work directory */
+	g_assert (g_mkdir_with_parents (EDS_TEST_WORK_DIR, 0755) == 0);
+
+	fixture->loop = g_main_loop_new (NULL, FALSE);
+
+#if !GLOBAL_DBUS_DAEMON
+	/* Create the global dbus-daemon for this test suite */
+	fixture->dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
+
+	/* Add the private directory with our in-tree service files */
+	g_test_dbus_add_service_dir (fixture->dbus, EDS_TEST_DBUS_SERVICE_DIR);
+
+	/* Start the private D-Bus daemon */
+	g_test_dbus_up (fixture->dbus);
+#else
+	fixture->dbus = global_test_dbus;
+#endif
+
+	g_idle_add ((GSourceFunc)e_test_server_utils_bootstrap_idle, &pair);
+	g_main_loop_run (fixture->loop);
+}
+
+/**
+ * e_test_server_utils_teardown:
+ * @fixture: A #ETestServerFixture
+ * @user_data: A #ETestServerClosure or derived structure provided by the test.
+ *
+ * A teardown function for the #ETestServerFixture fixture
+ */
+void
+e_test_server_utils_teardown (ETestServerFixture *fixture,
+			      gconstpointer       user_data)
+{
+	ETestServerClosure *closure = (ETestServerClosure *)user_data;
+	GError             *error = NULL;
+
+	switch (closure->type) {
+	case E_TEST_SERVER_ADDRESS_BOOK:
+		if (!e_client_remove_sync (E_CLIENT (fixture->service.book_client), NULL, &error)) {
+			g_message ("Failed to remove test book: %s (ignoring)", error->message);
+			g_clear_error (&error);
+		}
+		g_object_unref (fixture->service.book_client);
+		fixture->service.book_client = NULL;
+		break;
+
+	case E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK:
+		if (!e_book_remove (fixture->service.book, &error)) {
+			g_message ("Failed to remove test book: %s (ignoring)", error->message);
+			g_clear_error (&error);
+		}
+		g_object_unref (fixture->service.book);
+		fixture->service.book = NULL;
+		break;
+
+	case E_TEST_SERVER_CALENDAR:
+		if (!e_client_remove_sync (E_CLIENT (fixture->service.calendar_client), NULL, &error)) {
+			g_message ("Failed to remove test calendar: %s (ignoring)", error->message);
+			g_clear_error (&error);
+		}
+		g_object_unref (fixture->service.calendar_client);
+		fixture->service.calendar_client = NULL;
+		break;
+
+	case E_TEST_SERVER_DEPRECATED_CALENDAR:
+		if (!e_cal_remove (fixture->service.calendar, &error)) {
+			g_message ("Failed to remove test calendar: %s (ignoring)", error->message);
+			g_clear_error (&error);
+		}
+		g_object_unref (fixture->service.calendar);
+		fixture->service.calendar = NULL;
+
+	case E_TEST_SERVER_NONE:
+		break;
+	}
+
+	g_object_run_dispose (G_OBJECT (fixture->registry));
+	g_object_unref (fixture->registry);
+	fixture->registry = NULL;
+
+	g_main_loop_unref (fixture->loop);
+	fixture->loop = NULL;
+
+#if !GLOBAL_DBUS_DAEMON
+	/* Teardown the D-Bus Daemon
+	 *
+	 * Note that we intentionally leak the TestDBus daemon
+	 * in this case, presumably this is due to some leaked
+	 * GDBusConnection reference counting
+	 */
+	g_test_dbus_down (fixture->dbus);
+	g_object_unref (fixture->dbus);
+	fixture->dbus = NULL;
+#else
+	fixture->dbus = NULL;
+#endif
+
+	/* Cleanup work directory */
+	delete_work_directory ();
+}
+
+gint
+e_test_server_utils_run (void)
+{
+	gint tests_ret;
+
+	/* Cleanup work directory */
+	delete_work_directory ();
+
+	setup_environment ();
+
+#if GLOBAL_DBUS_DAEMON
+
+	/* Create the global dbus-daemon for this test suite */
+	global_test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
+
+	/* Add the private directory with our in-tree service files */
+	g_test_dbus_add_service_dir (global_test_dbus, EDS_TEST_DBUS_SERVICE_DIR);
+
+	/* Start the private D-Bus daemon */
+	g_test_dbus_up (global_test_dbus);
+#endif
+
+	/* Run the GTest suite */
+	tests_ret = g_test_run ();
+
+#if GLOBAL_DBUS_DAEMON
+	/* Teardown the D-Bus Daemon
+	 *
+	 * Note that we intentionally leak the TestDBus daemon
+	 * in this case, presumably this is due to some leaked
+	 * GDBusConnection reference counting
+	 */
+	g_test_dbus_stop (global_test_dbus);
+	/* g_object_unref (global_test_dbus); */
+	global_test_dbus = NULL;
+#endif
+  
+  return tests_ret;
+}
diff --git a/tests/test-server-utils/e-test-server-utils.h b/tests/test-server-utils/e-test-server-utils.h
new file mode 100644
index 0000000..34c153b
--- /dev/null
+++ b/tests/test-server-utils/e-test-server-utils.h
@@ -0,0 +1,117 @@
+#ifndef E_TEST_UTILS_H
+#define E_TEST_UTILS_H
+
+#include <libedataserver/libedataserver.h>
+#include <libebook/libebook.h>
+#include <libecal/libecal.h>
+
+typedef struct _ETestServerFixture ETestServerFixture;
+typedef struct _ETestServerClosure ETestServerClosure;
+
+
+/**
+ * E_TEST_SERVER_UTILS_SERVICE:
+ * @fixture: An #ETestServerFixture
+ * @service_type: The type to cast for the service in use
+ *
+ * A convenience macro to fetch the service for a given test case:
+ *
+ * |[
+ *    EBookClient *book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBookClient);
+ * ]|
+ *
+ */
+#define E_TEST_SERVER_UTILS_SERVICE(fixture, service_type) \
+	((service_type *)((ETestServerFixture *)fixture)->service.generic)
+
+/**
+ * ETestSourceCustomizeFunc:
+ * @scratch: The scratch #ESource template being used to create an addressbook or calendar
+ * @closure: The #ETestServerClosure for this test case
+ *
+ * This can be used to parameterize the addressbook or calendar @scratch #ESource
+ * before creating/committing it.
+ */
+typedef void (* ETestSourceCustomizeFunc) (ESource            *scratch,
+					   ETestServerClosure *closure);
+
+/**
+ * ETestServiceType:
+ * @E_TEST_SERVER_NONE: Only the #ESourceRegistry will be created
+ * @E_TEST_SERVER_ADDRESS_BOOK: An #EBookCLient will be created and opened for the test
+ * @E_TEST_SERVER_CALENDAR: An #ECalClient will be created and opened for the test
+ * @E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK: An #EBook will be created and opened for the test
+ *
+ * The type of service to test
+ */
+typedef enum {
+	E_TEST_SERVER_NONE = 0,
+	E_TEST_SERVER_ADDRESS_BOOK,
+	E_TEST_SERVER_CALENDAR,
+	E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK,
+	E_TEST_SERVER_DEPRECATED_CALENDAR
+} ETestServiceType;
+
+/**
+ * ETestServerClosure:
+ * @flags:                The #ETestServiceFlags to use for this test
+ * @customize:            An #ETestSourceCustomizeFunc to use to parameterize the scratch #ESource, or %NULL
+ * @calendar_source_type: An #ECalClientSourceType or #ECalSourceType; for %E_TEST_SERVER_CALENDAR
+ *                        and %E_TEST_SERVER_DEPRECATED_CALENDAR tests
+ *
+ * This structure provides the parameters for the #ETestServerFixture tests,
+ * it can be included as the first member of a derived structure
+ * for any tests deriving from the #ETestServerFixture test type
+ */
+struct _ETestServerClosure {
+	ETestServiceType         type;
+	ETestSourceCustomizeFunc customize;
+	gint                     calendar_source_type;
+};
+
+/**
+ * ETestService:
+ * @book_client: An #EBookClient, created for %E_TEST_SERVER_ADDRESS_BOOK tests
+ * @calendar_client: An #ECalClient, created for %E_TEST_SERVER_CALENDAR tests
+ * @book: An #EBook, created for %E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK tests
+ * @calendar: An #ECal, created for %E_TEST_SERVER_DEPRECATED_CALENDAR tests
+ *
+ * A union of service types, holds the object to test in a #ETestServerFixture.
+ *
+ */
+typedef union {
+	gpointer     generic;
+	EBookClient *book_client;
+	ECalClient  *calendar_client;
+	EBook       *book;
+	ECal        *calendar;
+} ETestService;
+
+/**
+ * ETestServerFixture:
+ * @loop: A Main loop to run traffic in
+ * @dbus: The D-Bus test scaffold
+ * @registry: An #ESourceRegistry
+ * @service: The #ETestService
+ *
+ * A fixture for running tests on the Evolution Data Server
+ * components in an encapsulated D-Bus environment.
+ */
+struct _ETestServerFixture {
+	GMainLoop       *loop;
+	GTestDBus       *dbus;
+	ESourceRegistry *registry;
+	ETestService     service;
+};
+
+
+void e_test_server_utils_setup    (ETestServerFixture *fixture,
+				   gconstpointer       user_data);
+
+void e_test_server_utils_teardown (ETestServerFixture *fixture,
+				   gconstpointer       user_data);
+
+gint e_test_server_utils_run      (void);
+
+
+#endif /* E_TEST_UTILS_H */
diff --git a/tests/test-server-utils/services/Makefile.am b/tests/test-server-utils/services/Makefile.am
new file mode 100644
index 0000000..0ffe1db
--- /dev/null
+++ b/tests/test-server-utils/services/Makefile.am
@@ -0,0 +1,4 @@
+EXTRA_DIST = \
+	org.gnome.evolution.dataserver.AddressBook.service.in	\
+	org.gnome.evolution.dataserver.Calendar.service.in	\
+	org.gnome.evolution.dataserver.Sources.service.in
diff --git a/tests/test-server-utils/services/org.gnome.evolution.dataserver.AddressBook.service.in b/tests/test-server-utils/services/org.gnome.evolution.dataserver.AddressBook.service.in
new file mode 100644
index 0000000..b32af72
--- /dev/null
+++ b/tests/test-server-utils/services/org.gnome.evolution.dataserver.AddressBook.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name= ADDRESS_BOOK_DBUS_SERVICE_NAME@
+Exec= abs_top_builddir@/services/evolution-addressbook-factory/evolution-addressbook-factory
diff --git a/tests/test-server-utils/services/org.gnome.evolution.dataserver.Calendar.service.in b/tests/test-server-utils/services/org.gnome.evolution.dataserver.Calendar.service.in
new file mode 100644
index 0000000..aa148e3
--- /dev/null
+++ b/tests/test-server-utils/services/org.gnome.evolution.dataserver.Calendar.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name= CALENDAR_DBUS_SERVICE_NAME@
+Exec= abs_top_builddir@/services/evolution-calendar-factory/evolution-calendar-factory
diff --git a/tests/test-server-utils/services/org.gnome.evolution.dataserver.Sources.service.in b/tests/test-server-utils/services/org.gnome.evolution.dataserver.Sources.service.in
new file mode 100644
index 0000000..cd88998
--- /dev/null
+++ b/tests/test-server-utils/services/org.gnome.evolution.dataserver.Sources.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name= SOURCES_DBUS_SERVICE_NAME@
+Exec= abs_top_builddir@/services/evolution-source-registry/evolution-source-registry
diff --git a/tests/test-server-utils/test-fixture.c b/tests/test-server-utils/test-fixture.c
new file mode 100644
index 0000000..875e37d
--- /dev/null
+++ b/tests/test-server-utils/test-fixture.c
@@ -0,0 +1,73 @@
+#include "e-test-server-utils.h"
+
+
+static ETestServerClosure registry_closure = { E_TEST_SERVER_NONE, NULL, 0 };
+static ETestServerClosure book_closure     = { E_TEST_SERVER_ADDRESS_BOOK, NULL, 0 };
+static ETestServerClosure calendar_closure = { E_TEST_SERVER_CALENDAR, NULL, E_CAL_CLIENT_SOURCE_TYPE_EVENTS };
+static ETestServerClosure deprecated_book_closure     = { E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK, NULL, 0 };
+static ETestServerClosure deprecated_calendar_closure = { E_TEST_SERVER_DEPRECATED_CALENDAR, NULL, E_CAL_SOURCE_TYPE_EVENT };
+
+static void
+empty_test (ETestServerFixture *fixture,
+	    gconstpointer       user_data)
+{
+	/* Basic Empty case just to run the fixture */
+}
+
+int
+main (int   argc,
+      char *argv[])
+{
+#if !GLIB_CHECK_VERSION (2, 35, 1)
+  g_type_init ();
+#endif
+  g_test_init (&argc, &argv, NULL);
+
+  /* Test that internal implementations can return all kinds of type through its api */
+  g_test_add ("/Fixture/Registry1", ETestServerFixture, &registry_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Registry2", ETestServerFixture, &registry_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Registry3", ETestServerFixture, &registry_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Registry4", ETestServerFixture, &registry_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+
+  g_test_add ("/Fixture/Book1", ETestServerFixture, &book_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Book2", ETestServerFixture, &book_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Book3", ETestServerFixture, &book_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Book4", ETestServerFixture, &book_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+
+  g_test_add ("/Fixture/Calendar1", ETestServerFixture, &calendar_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Calendar2", ETestServerFixture, &calendar_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Calendar3", ETestServerFixture, &calendar_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Calendar4", ETestServerFixture, &calendar_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+
+  g_test_add ("/Fixture/Deprecated/Book1", ETestServerFixture, &deprecated_book_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Deprecated/Book2", ETestServerFixture, &deprecated_book_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Deprecated/Book3", ETestServerFixture, &deprecated_book_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Deprecated/Book4", ETestServerFixture, &deprecated_book_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+
+  g_test_add ("/Fixture/Deprecated/Calendar1", ETestServerFixture, &deprecated_calendar_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Deprecated/Calendar2", ETestServerFixture, &deprecated_calendar_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Deprecated/Calendar3", ETestServerFixture, &deprecated_calendar_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  g_test_add ("/Fixture/Deprecated/Calendar4", ETestServerFixture, &deprecated_calendar_closure,
+  	      e_test_server_utils_setup, empty_test, e_test_server_utils_teardown);
+  
+  return e_test_server_utils_run ();
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]