Coding style and whitespace cleanups.
[platform/upstream/evolution-data-server.git] / tests / libecal / test-ecal-open.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 #include <stdlib.h>
4 #include <libecal/e-cal.h>
5
6 #include "ecal-test-utils.h"
7
8 #define OPEN_ASYNC_TIMEOUT 30
9
10 static void open_timeout_cb (gpointer user_data) __attribute__ ((noreturn));
11
12 static guint open_timeout_id = 0;
13
14 static void
15 open_complete_cb (ECalTestClosure *closure)
16 {
17         g_source_remove (open_timeout_id);
18
19         g_main_loop_quit ((GMainLoop*) closure->user_data);
20 }
21
22 static void
23 open_timeout_cb (gpointer user_data)
24 {
25         g_warning ("failed to get a response for the async 'open' within a "
26                         "reasonable time frame");
27         exit (1);
28 }
29
30 gint
31 main (gint argc, gchar **argv)
32 {
33         ECal *cal;
34         gchar *uri = NULL;
35         GMainLoop *loop;
36
37         g_type_init ();
38
39         /* Sync version */
40         cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
41         ecal_test_utils_cal_open (cal, FALSE);
42         ecal_test_utils_cal_remove (cal);
43
44         /* Async version */
45         cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
46         open_timeout_id = g_timeout_add_seconds (OPEN_ASYNC_TIMEOUT,
47                         (GSourceFunc) open_timeout_cb, cal);
48
49         loop = g_main_loop_new (NULL, TRUE);
50         ecal_test_utils_cal_async_open (cal, FALSE,
51                         (GSourceFunc) open_complete_cb, loop);
52         g_main_loop_run (loop);
53
54         ecal_test_utils_cal_remove (cal);
55
56         return 0;
57 }