1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 /* e-test-server-utils.h - Test scaffolding to run tests with in-tree data server.
5 * Copyright (C) 2012 Intel Corporation
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) version 3.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with the program; if not, see <http://www.gnu.org/licenses/>
20 * Authors: Tristan Van Berkom <tristanvb@openismus.com>
23 #ifndef E_TEST_UTILS_H
24 #define E_TEST_UTILS_H
26 #include <libedataserver/libedataserver.h>
27 #include <libebook/libebook.h>
28 #include <libecal/libecal.h>
30 typedef struct _ETestServerFixture ETestServerFixture;
31 typedef struct _ETestServerClosure ETestServerClosure;
34 * E_TEST_SERVER_UTILS_SERVICE:
35 * @fixture: An #ETestServerFixture
36 * @service_type: The type to cast for the service in use
38 * A convenience macro to fetch the service for a given test case:
41 * EBookClient *book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBookClient);
45 #define E_TEST_SERVER_UTILS_SERVICE(fixture, service_type) \
46 ((service_type *)((ETestServerFixture *) fixture)->service.generic)
49 * ETestSourceCustomizeFunc:
50 * @scratch: The scratch #ESource template being used to create an addressbook or calendar
51 * @closure: The #ETestServerClosure for this test case
53 * This can be used to parameterize the addressbook or calendar @scratch #ESource
54 * before creating/committing it.
56 typedef void (* ETestSourceCustomizeFunc) (ESource *scratch,
57 ETestServerClosure *closure);
61 * @E_TEST_SERVER_NONE: Only the #ESourceRegistry will be created
62 * @E_TEST_SERVER_ADDRESS_BOOK: An #EBookCLient will be created and opened for the test
63 * @E_TEST_SERVER_CALENDAR: An #ECalClient will be created and opened for the test
64 * @E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK: An #EBook will be created and opened for the test
66 * The type of service to test
69 E_TEST_SERVER_NONE = 0,
70 E_TEST_SERVER_ADDRESS_BOOK,
71 E_TEST_SERVER_CALENDAR,
72 E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK,
73 E_TEST_SERVER_DEPRECATED_CALENDAR
78 * @flags: The #ETestServiceFlags to use for this test
79 * @customize: An #ETestSourceCustomizeFunc to use to parameterize the scratch #ESource, or %NULL
80 * @calendar_source_type: An #ECalClientSourceType or #ECalSourceType; for %E_TEST_SERVER_CALENDAR
81 * and %E_TEST_SERVER_DEPRECATED_CALENDAR tests
83 * This structure provides the parameters for the #ETestServerFixture tests,
84 * it can be included as the first member of a derived structure
85 * for any tests deriving from the #ETestServerFixture test type
87 struct _ETestServerClosure {
88 ETestServiceType type;
89 ETestSourceCustomizeFunc customize;
90 gint calendar_source_type;
91 gboolean keep_work_directory;
92 GDestroyNotify destroy_closure_func;
97 * @book_client: An #EBookClient, created for %E_TEST_SERVER_ADDRESS_BOOK tests
98 * @calendar_client: An #ECalClient, created for %E_TEST_SERVER_CALENDAR tests
99 * @book: An #EBook, created for %E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK tests
100 * @calendar: An #ECal, created for %E_TEST_SERVER_DEPRECATED_CALENDAR tests
102 * A union of service types, holds the object to test in a #ETestServerFixture.
107 EBookClient *book_client;
108 ECalClient *calendar_client;
114 * ETestServerFixture:
115 * @loop: A Main loop to run traffic in
116 * @dbus: The D-Bus test scaffold
117 * @registry: An #ESourceRegistry
118 * @service: The #ETestService
120 * A fixture for running tests on the Evolution Data Server
121 * components in an encapsulated D-Bus environment.
123 struct _ETestServerFixture {
126 ESourceRegistry *registry;
127 ETestService service;
130 void e_test_server_utils_setup (ETestServerFixture *fixture,
131 gconstpointer user_data);
133 void e_test_server_utils_teardown (ETestServerFixture *fixture,
134 gconstpointer user_data);
136 gint e_test_server_utils_run (void);
138 #endif /* E_TEST_UTILS_H */