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_DIRECT_ADDRESS_BOOK: An #EBookCLient in direct read access mode will be created and opened for the test
64 * @E_TEST_SERVER_CALENDAR: An #ECalClient will be created and opened for the test
65 * @E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK: An #EBook will be created and opened for the test
67 * The type of service to test
70 E_TEST_SERVER_NONE = 0,
71 E_TEST_SERVER_ADDRESS_BOOK,
72 E_TEST_SERVER_DIRECT_ADDRESS_BOOK,
73 E_TEST_SERVER_CALENDAR,
74 E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK,
75 E_TEST_SERVER_DEPRECATED_CALENDAR
80 * @flags: The #ETestServiceFlags to use for this test
81 * @customize: An #ETestSourceCustomizeFunc to use to parameterize the scratch #ESource, or %NULL
82 * @calendar_source_type: An #ECalClientSourceType or #ECalSourceType; for %E_TEST_SERVER_CALENDAR
83 * and %E_TEST_SERVER_DEPRECATED_CALENDAR tests
85 * This structure provides the parameters for the #ETestServerFixture tests,
86 * it can be included as the first member of a derived structure
87 * for any tests deriving from the #ETestServerFixture test type
89 struct _ETestServerClosure {
90 ETestServiceType type;
91 ETestSourceCustomizeFunc customize;
92 gint calendar_source_type;
93 gboolean keep_work_directory;
94 GDestroyNotify destroy_closure_func;
99 * @book_client: An #EBookClient, created for %E_TEST_SERVER_ADDRESS_BOOK tests
100 * @calendar_client: An #ECalClient, created for %E_TEST_SERVER_CALENDAR tests
101 * @book: An #EBook, created for %E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK tests
102 * @calendar: An #ECal, created for %E_TEST_SERVER_DEPRECATED_CALENDAR tests
104 * A union of service types, holds the object to test in a #ETestServerFixture.
109 EBookClient *book_client;
110 ECalClient *calendar_client;
116 * ETestServerFixture:
117 * @loop: A Main loop to run traffic in
118 * @dbus: The D-Bus test scaffold
119 * @registry: An #ESourceRegistry
120 * @service: The #ETestService
121 * @timeout_source_id: A private detail, tracks the idle source which times out if the registry cannot create an ESource.
123 * A fixture for running tests on the Evolution Data Server
124 * components in an encapsulated D-Bus environment.
126 struct _ETestServerFixture {
129 ESourceRegistry *registry;
130 ETestService service;
131 guint timeout_source_id;
134 void e_test_server_utils_setup (ETestServerFixture *fixture,
135 gconstpointer user_data);
137 void e_test_server_utils_teardown (ETestServerFixture *fixture,
138 gconstpointer user_data);
140 gint e_test_server_utils_run (void);
142 #endif /* E_TEST_UTILS_H */