updated changelog
[platform/upstream/evolution-data-server.git] / tests / test-server-utils / test-fixture.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 /* test-fixture.c - Test to ensure the server test fixture works.
4  *
5  * Copyright (C) 2012 Intel Corporation
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, see <http://www.gnu.org/licenses/>.
18  *
19  * Authors: Tristan Van Berkom <tristanvb@openismus.com>
20  */
21
22 #include "e-test-server-utils.h"
23
24 #define N_CYCLES 10
25
26 static ETestServerClosure registry_closure = { E_TEST_SERVER_NONE, NULL, 0 };
27 static ETestServerClosure book_closure = { E_TEST_SERVER_ADDRESS_BOOK, NULL, 0 };
28 static ETestServerClosure calendar_closure = { E_TEST_SERVER_CALENDAR, NULL, E_CAL_CLIENT_SOURCE_TYPE_EVENTS };
29 static ETestServerClosure deprecated_book_closure = { E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK, NULL, 0 };
30 static ETestServerClosure deprecated_calendar_closure = { E_TEST_SERVER_DEPRECATED_CALENDAR, NULL, E_CAL_SOURCE_TYPE_EVENT };
31
32 static void
33 empty_test (ETestServerFixture *fixture,
34             gconstpointer user_data)
35 {
36         /* Basic Empty case just to run the fixture */
37 }
38
39 gint
40 main (gint argc,
41       gchar *argv[])
42 {
43         gchar **registry_keys;
44         gchar **book_keys;
45         gchar **calendar_keys;
46         gchar **deprecated_book_keys;
47         gchar **deprecated_calendar_keys;
48         gint i;
49         gint ret;
50
51         g_test_init (&argc, &argv, NULL);
52         g_test_bug_base ("http://bugzilla.gnome.org/");
53
54         registry_keys = g_new0 (gchar *, N_CYCLES);
55         book_keys = g_new0 (gchar *, N_CYCLES);
56         calendar_keys = g_new0 (gchar *, N_CYCLES);
57         deprecated_book_keys = g_new0 (gchar *, N_CYCLES);
58         deprecated_calendar_keys = g_new0 (gchar *, N_CYCLES);
59
60         for (i = 0; i < N_CYCLES; i++) {
61                 registry_keys[i] = g_strdup_printf ("/Fixture/Registry%d", i);
62                 g_test_add (
63                         registry_keys[i],
64                         ETestServerFixture,
65                         &registry_closure,
66                         e_test_server_utils_setup,
67                         empty_test,
68                         e_test_server_utils_teardown);
69         }
70
71         for (i = 0; i < N_CYCLES; i++) {
72                 book_keys[i] = g_strdup_printf ("/Fixture/Book%d", i);
73                 g_test_add (
74                         book_keys[i],
75                         ETestServerFixture,
76                         &book_closure,
77                         e_test_server_utils_setup,
78                         empty_test,
79                         e_test_server_utils_teardown);
80         }
81
82         for (i = 0; i < N_CYCLES; i++) {
83                 calendar_keys[i] = g_strdup_printf ("/Fixture/Calendar%d", i);
84                 g_test_add (
85                         calendar_keys[i],
86                         ETestServerFixture,
87                         &calendar_closure,
88                         e_test_server_utils_setup,
89                         empty_test,
90                         e_test_server_utils_teardown);
91         }
92
93         for (i = 0; i < N_CYCLES; i++) {
94                 deprecated_book_keys[i] = g_strdup_printf ("/Fixture/Deprecated/Book%d", i);
95                 g_test_add (
96                         deprecated_book_keys[i],
97                         ETestServerFixture,
98                         &deprecated_book_closure,
99                         e_test_server_utils_setup,
100                         empty_test,
101                         e_test_server_utils_teardown);
102         }
103
104         for (i = 0; i < N_CYCLES; i++) {
105                 deprecated_calendar_keys[i] = g_strdup_printf ("/Fixture/Deprecated/Calendar%d", i);
106                 g_test_add (
107                         deprecated_calendar_keys[i],
108                         ETestServerFixture,
109                         &deprecated_calendar_closure,
110                         e_test_server_utils_setup,
111                         empty_test,
112                         e_test_server_utils_teardown);
113         }
114
115         ret = e_test_server_utils_run ();
116
117         for (i = 0; i < N_CYCLES; i++) {
118                 g_free (registry_keys[i]);
119                 g_free (book_keys[i]);
120                 g_free (calendar_keys[i]);
121                 g_free (deprecated_book_keys[i]);
122                 g_free (deprecated_calendar_keys[i]);
123         }
124
125         g_free (registry_keys);
126         g_free (book_keys);
127         g_free (calendar_keys);
128         g_free (deprecated_book_keys);
129         g_free (deprecated_calendar_keys);
130
131         return ret;
132 }