1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
4 #include <libecal/e-cal.h>
6 #include "ecal-test-utils.h"
8 #define OPEN_ASYNC_TIMEOUT 200
11 static void open_timeout_cb (gpointer user_data) __attribute__ ((noreturn));
13 static guint open_timeout_id = 0;
14 static ECal *cals[NUM_CALS];
15 static gint cals_processed = 0;
18 open_complete_cb (ECalTestClosure *closure)
20 g_source_remove (open_timeout_id);
24 if (cals_processed == NUM_CALS) {
25 test_print ("asynchronously opened all calendars successfully\n");
26 g_main_loop_quit ((GMainLoop *) closure->user_data);
31 open_timeout_cb (gpointer user_data)
33 g_error ("failed to get a response for the async 'open' within a "
34 "reasonable time frame");
47 open_timeout_id = g_timeout_add_seconds (OPEN_ASYNC_TIMEOUT,
48 (GSourceFunc) open_timeout_cb, NULL);
50 loop = g_main_loop_new (NULL, TRUE);
52 /* open and close many calendars in parallel */
53 for (i = 0; i < NUM_CALS; i++) {
54 cals[i] = ecal_test_utils_cal_new_temp (&uri,
55 E_CAL_SOURCE_TYPE_EVENT);
56 ecal_test_utils_cal_async_open (cals[i], FALSE,
57 (GSourceFunc) open_complete_cb, loop);
62 g_main_loop_run (loop);