~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright (C) 2009 Intel Corporation
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 * Author: Travis Reitter (travis.reitter@collabora.co.uk)
 */

#include <stdlib.h>
#include <glib.h>
#include <gio/gio.h>
#include <libecal/e-cal.h>

#include "ecal-test-utils.h"

void
test_print (const gchar *format,
	    ...)
{
	va_list args;
	const gchar *debug_string;
	static gboolean debug_set = FALSE;
	static gboolean debug = FALSE;

	if (!debug_set) {
		debug_string = g_getenv ("EDS_TEST_DEBUG");
		if (debug_string) {
			debug = (g_ascii_strtoll (debug_string, NULL, 10) >= 1);
		}
		debug_set = TRUE;
	}

	if (debug) {
		va_start (args, format);
		vprintf (format, args);
		va_end (args);
	}
}

ECal*
ecal_test_utils_cal_new_from_uri (const gchar     *uri,
				  ECalSourceType  type)
{
        ECal *cal;

        test_print ("loading calendar '%s'\n", uri);
        cal = e_cal_new_from_uri (uri, type);
        if (!cal)
                g_error ("failed to create calendar: `%s'", uri);

        return cal;
}

ECal*
ecal_test_utils_cal_new_temp (gchar           **uri,
                              ECalSourceType   type)
{
        ECal *cal;
        GError *error = NULL;
        gchar *file_template;
        gchar *uri_result;

        file_template = g_build_filename (g_get_tmp_dir (),
                        "ecal-test-XXXXXX/", NULL);
        g_mkstemp (file_template);

        uri_result = g_filename_to_uri (file_template, NULL, &error);
        if (!uri_result) {
                g_error ("failed to convert %s to an URI: %s", file_template,
                                error->message);
        }
        g_free (file_template);

	cal = ecal_test_utils_cal_new_from_uri (uri_result, type);

        if (uri)
                *uri = g_strdup (uri_result);

        g_free (uri_result);

        return cal;
}

void
ecal_test_utils_cal_open (ECal     *cal,
                          gboolean  only_if_exists)
{
        GError *error = NULL;

        if (!e_cal_open (cal, only_if_exists, &error)) {
                const gchar *uri;

                uri = e_cal_get_uri (cal);

                g_warning ("failed to open calendar: `%s': %s", uri,
                                error->message);
                exit(1);
        }
}

static void
open_cb (ECal            *cal,
	 ECalendarStatus  status,
	 ECalTestClosure *closure)
{
	if (FALSE) {
	} else if (status == E_CALENDAR_STATUS_BUSY) {
		test_print ("calendar server is busy; waiting...");
		return;
	} else if (status != E_CALENDAR_STATUS_OK) {
                g_warning ("failed to asynchronously remove the calendar: "
                                "status %d", status);
                exit (1);
        }

	closure->cal = cal;

        test_print ("successfully asynchronously removed the temporary "
                        "calendar\n");
        if (closure)
                (*closure->cb) (closure);

	g_signal_handlers_disconnect_by_func (cal, open_cb, closure);
	g_free (closure);
}

void
ecal_test_utils_cal_async_open (ECal        *cal,
				gboolean     only_if_exists,
                                GSourceFunc  callback,
                                gpointer     user_data)
{
        ECalTestClosure *closure;

        closure = g_new0 (ECalTestClosure, 1);
        closure->cb = callback;
        closure->user_data = user_data;

	g_signal_connect (G_OBJECT (cal), "cal_opened", G_CALLBACK (open_cb), closure);
	e_cal_open_async (cal, only_if_exists);
}

void
ecal_test_utils_cal_remove (ECal *cal)
{
        GError *error = NULL;

        if (!e_cal_remove (cal, &error)) {
                g_warning ("failed to remove calendar; %s\n", error->message);
                exit(1);
        }
        test_print ("successfully removed the temporary calendar\n");

        g_object_unref (cal);
}

gchar *
ecal_test_utils_cal_get_alarm_email_address (ECal *cal)
{
        GError *error = NULL;
	gchar *address = NULL;

        if (!e_cal_get_alarm_email_address (cal, &address, &error)) {
                g_warning ("failed to get alarm email address; %s\n", error->message);
                exit(1);
        }
        test_print ("successfully got the alarm email address\n");

	return address;
}

gchar *
ecal_test_utils_cal_get_cal_address (ECal *cal)
{
        GError *error = NULL;
	gchar *address = NULL;

        if (!e_cal_get_cal_address (cal, &address, &error)) {
                g_warning ("failed to get calendar address; %s\n", error->message);
                exit(1);
        }
        test_print ("successfully got the calendar address\n");

	return address;
}

gchar *
ecal_test_utils_cal_get_ldap_attribute (ECal *cal)
{
        GError *error = NULL;
	gchar *attr = NULL;

        if (!e_cal_get_ldap_attribute (cal, &attr, &error)) {
                g_warning ("failed to get ldap attribute; %s\n", error->message);
                exit(1);
        }
        test_print ("successfully got the ldap attribute\n");

	return attr;
}

static const gchar *
b2s (gboolean value)
{
        return value ? "true" : "false";
}

void
ecal_test_utils_cal_get_capabilities (ECal *cal)
{
        test_print ("calendar capabilities:\n");
        test_print ("        One alarm only:                  %s\n"
                 "        Organizers must attend meetings: %s\n"
                 "        Organizers must accept meetings: %s\n"
                 "        Master object for recurrences:   %s\n"
                 "        Can save schedules:              %s\n"
                 "        No alarm repeat:                 %s\n"
                 "        No audio alarms:                 %s\n"
                 "        No display alarms:               %s\n"
                 "        No email alarms:                 %s\n"
                 "        No procedure alarms:             %s\n"
                 "        No task assignment:              %s\n"
                 "        No 'this and future':            %s\n"
                 "        No 'this and prior':             %s\n"
                 "        No transparency:                 %s\n"
                 "        Organizer not email address:     %s\n"
                 "        Remove alarms:                   %s\n"
                 "        Create messages:                 %s\n"
                 "        No conv. to assigned task:       %s\n"
                 "        No conv. to recurring:           %s\n"
                 "        No general options:              %s\n"
                 "        Requires send options:           %s\n"
                 "        Delegate supported:              %s\n"
                 "        No organizer required:           %s\n"
                 "        Delegate to many:                %s\n"
                 "        Has unaccepted meeting:          %s\n"
                 ,
		 b2s (e_cal_get_one_alarm_only (cal)),
		 b2s (e_cal_get_organizer_must_attend (cal)),
		 b2s (e_cal_get_organizer_must_accept (cal)),
		 b2s (e_cal_get_recurrences_no_master (cal)),
		 b2s (e_cal_get_save_schedules (cal)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_NO_AUDIO_ALARMS)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_NO_DISPLAY_ALARMS)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_NO_PROCEDURE_ALARMS)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_NO_THISANDFUTURE)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_NO_THISANDPRIOR)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_NO_TRANSPARENCY)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_REMOVE_ALARMS)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_CREATE_MESSAGES)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_NO_GEN_OPTIONS)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_DELEGATE_SUPPORTED)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_NO_ORGANIZER)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY)),
		 b2s (e_cal_get_static_capability (cal,
				 CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING))
		 );
}

void
ecal_test_utils_cal_assert_objects_equal_shallow (icalcomponent *a,
						  icalcomponent *b)
{
	const gchar *uid_a, *uid_b;

	if (!icalcomponent_is_valid (a) && !icalcomponent_is_valid (b)) {
		g_warning ("both components invalid");
		return;
	}

	if (!icalcomponent_is_valid (a) || !icalcomponent_is_valid (b)) {
		g_error ("exactly one of the components being compared is invalid");
	}

	uid_a = icalcomponent_get_uid (a);
	uid_b = icalcomponent_get_uid (b);
        if (g_strcmp0 (uid_a, uid_b)) {
                g_error ("icomponents not equal:\n"
			 "        uid A: '%s'\n"
			 "        uid b: '%s'\n",
			 uid_a, uid_b);
        }
}

void
ecal_test_utils_cal_assert_e_cal_components_equal (ECalComponent *a,
						   ECalComponent *b)
{
	icalcomponent *ical_a, *ical_b;
	ECalComponentTransparency transp_a, transp_b;

	ical_a = e_cal_component_get_icalcomponent (a);
	ical_b = e_cal_component_get_icalcomponent (b);
        ecal_test_utils_cal_assert_objects_equal_shallow (ical_a, ical_b);

        /* Dumping icalcomp into a string is not useful as the retrieved object
         * has some generated information like timestamps. We compare
         * member values we set during creation*/
        g_assert (e_cal_component_event_dates_match (a, b));

	e_cal_component_get_transparency (a, &transp_a);
	e_cal_component_get_transparency (b, &transp_b);
	g_assert (transp_a == transp_b);
}

icalcomponent*
ecal_test_utils_cal_get_object (ECal       *cal,
				const gchar *uid)
{
        GError *error = NULL;
	icalcomponent *component = NULL;

        if (!e_cal_get_object (cal, uid, NULL, &component, &error)) {
                g_warning ("failed to get icalcomponent object '%s'; %s\n", uid, error->message);
                exit(1);
        }
        if (!icalcomponent_is_valid (component)) {
                g_warning ("retrieved icalcomponent is invalid\n");
                exit(1);
        }
        test_print ("successfully got the icalcomponent object '%s'\n", uid);

	return component;
}

void
ecal_test_utils_cal_modify_object (ECal          *cal,
				   icalcomponent *component,
				   CalObjModType  mod_type)
{
        GError *error = NULL;

        if (!icalcomponent_is_valid (component)) {
                g_warning (G_STRLOC ": icalcomponent argument is invalid\n");
                exit(1);
        }
        if (!e_cal_modify_object (cal, component, mod_type, &error)) {
                g_warning ("failed to modify icalcomponent object; %s\n", error->message);
                exit(1);
        }
        test_print ("successfully modified the icalcomponent object\n");
}

void
ecal_test_utils_cal_remove_object (ECal       *cal,
				   const gchar *uid)
{
        GError *error = NULL;

        if (!e_cal_remove_object (cal, uid, &error)) {
                g_warning ("failed to remove icalcomponent object '%s'; %s\n", uid, error->message);
                exit(1);
        }
        test_print ("successfully remoed the icalcomponent object '%s'\n", uid);
}

icalcomponent*
ecal_test_utils_cal_get_default_object (ECal *cal)
{
        GError *error = NULL;
	icalcomponent *component = NULL;

        if (!e_cal_get_default_object (cal, &component, &error)) {
                g_warning ("failed to get default icalcomponent object; %s\n", error->message);
                exit(1);
        }
        if (!icalcomponent_is_valid (component)) {
                g_warning ("default icalcomponent is invalid\n");
                exit(1);
        }
        test_print ("successfully got the default icalcomponent object\n");

	return component;
}

GList*
ecal_test_utils_cal_get_object_list (ECal       *cal,
				     const gchar *query)
{
        GError *error = NULL;
	GList *objects = NULL;

        if (!e_cal_get_object_list (cal, query, &objects, &error)) {
                g_warning ("failed to get list of icalcomponent objects for query '%s'; %s\n", query, error->message);
                exit(1);
        }
        test_print ("successfully got list of icalcomponent objects for the query '%s'\n", query);

	return objects;
}

GList*
ecal_test_utils_cal_get_objects_for_uid (ECal       *cal,
					 const gchar *uid)
{
        GError *error = NULL;
	GList *objects = NULL;

        if (!e_cal_get_objects_for_uid (cal, uid, &objects, &error)) {
                g_warning ("failed to get icalcomponent objects for UID '%s'; %s\n", uid, error->message);
                exit(1);
        }
        test_print ("successfully got objects for the icalcomponent with UID '%s'\n", uid);

	return objects;
}

gchar *
ecal_test_utils_cal_create_object (ECal          *cal,
				   icalcomponent *component)
{
        GError *error = NULL;
	gchar *uid = NULL;
	gchar *ical_string = NULL;

        if (!icalcomponent_is_valid (component)) {
                g_warning ("supplied icalcomponent is invalid\n");
                exit(1);
        }

        if (!e_cal_create_object (cal, component, &uid, &error)) {
                g_warning ("failed to get create an icalcomponent object; %s\n", error->message);
                exit(1);
        }

	ical_string = icalcomponent_as_ical_string (component);
        test_print ("successfully created icalcomponent object '%s'\n%s\n", uid,
			ical_string);
	g_free (ical_string);

	return uid;
}

static void
cal_set_mode_cb (ECal            *cal,
		 ECalendarStatus  status,
		 CalMode          mode,
		 ECalTestClosure *closure)
{
	if (FALSE) {
	} else if (status == E_CALENDAR_STATUS_BUSY) {
		test_print ("calendar server is busy; waiting...");
		return;
	} else if (status != E_CALENDAR_STATUS_OK) {
                g_warning ("failed to asynchronously remove the calendar: "
                                "status %d", status);
                exit (1);
        }

	closure->mode = mode;

        test_print ("successfully set the calendar mode to %d\n", mode);
        if (closure)
                (*closure->cb) (closure);

	g_signal_handlers_disconnect_by_func (cal, cal_set_mode_cb, closure);
	g_free (closure);
}

void
ecal_test_utils_cal_set_mode (ECal        *cal,
			      CalMode      mode,
			      GSourceFunc  callback,
			      gpointer     user_data)
{
        ECalTestClosure *closure;

        closure = g_new0 (ECalTestClosure, 1);
        closure->cb = callback;
        closure->user_data = user_data;

	g_signal_connect (G_OBJECT (cal), "cal_set_mode", G_CALLBACK (cal_set_mode_cb), closure);
	e_cal_set_mode (cal, mode);
}

void
ecal_test_utils_create_component (ECal           *cal,
				  const gchar     *dtstart,
				  const gchar     *dtstart_tzid,
				  const gchar     *dtend,
				  const gchar     *dtend_tzid,
				  const gchar     *summary,
				  ECalComponent **comp_out,
				  gchar          **uid_out)
{
        ECalComponent *comp;
        icalcomponent *icalcomp;
        struct icaltimetype tt;
        ECalComponentText text;
        ECalComponentDateTime dt;
        gchar *uid;

        comp = e_cal_component_new ();
        /* set fields */
        e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
        text.value = summary;
        text.altrep = NULL;
        e_cal_component_set_summary (comp, &text);
        tt = icaltime_from_string (dtstart);
        dt.value = &tt;
        dt.tzid = dtstart_tzid;
        e_cal_component_set_dtstart (comp, &dt);
        tt = icaltime_from_string (dtend);
        dt.value = &tt;
        dt.tzid = dtend_tzid;
        e_cal_component_set_dtend (comp, &dt);
        e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_OPAQUE);

        e_cal_component_commit_sequence (comp);
        icalcomp = e_cal_component_get_icalcomponent (comp);

        uid = ecal_test_utils_cal_create_object (cal, icalcomp);
        e_cal_component_commit_sequence (comp);

        *comp_out = comp;
        *uid_out = uid;
}

void
ecal_test_utils_cal_component_set_icalcomponent (ECalComponent *e_component,
						 icalcomponent *component)
{
        if (!e_cal_component_set_icalcomponent (e_component, component)) {
                g_error ("Could not set icalcomponent\n");
        }
}

icaltimezone*
ecal_test_utils_cal_get_timezone (ECal       *cal,
				  const gchar *tzid)
{
        GError *error = NULL;
	icaltimezone *zone = NULL;

        if (!e_cal_get_timezone (cal, tzid, &zone, &error)) {
                g_warning ("failed to get icaltimezone* for ID '%s'; %s\n", tzid, error->message);
                exit(1);
        }
        test_print ("successfully got icaltimezone* for ID '%s'\n", tzid);

	return zone;
}

void
ecal_test_utils_cal_add_timezone (ECal         *cal,
				  icaltimezone *zone)
{
        GError *error = NULL;
	const gchar *name;

	name = icaltimezone_get_display_name (zone);

        if (!e_cal_add_timezone (cal, zone, &error)) {
                g_warning ("failed to add icaltimezone '%s'; %s\n", name, error->message);
                exit(1);
        }
        test_print ("successfully added icaltimezone '%s'\n", name);
}

void
ecal_test_utils_cal_set_default_timezone (ECal         *cal,
					  icaltimezone *zone)
{
        GError *error = NULL;
	const gchar *name;

	name = icaltimezone_get_display_name (zone);

        if (!e_cal_set_default_timezone (cal, zone, &error)) {
                g_warning ("failed to set default icaltimezone '%s'; %s\n", name, error->message);
                exit(1);
        }
        test_print ("successfully set default icaltimezone '%s'\n", name);
}

GList*
ecal_test_utils_cal_get_free_busy (ECal   *cal,
				   GList  *users,
				   time_t  start,
				   time_t  end)
{
	GList *free_busy = NULL;
	GList *l = NULL;
	GError *error = NULL;

	if (!e_cal_get_free_busy (cal, users, start, end, &free_busy, &error)) {
		g_error ("Test free/busy : Could not retrieve free busy information :  %s\n", error->message);
	}
	if (free_busy) {
		test_print ("Printing free/busy information\n");

		for (l = free_busy; l; l = l->next) {
			gchar *comp_string;
			ECalComponent *comp = E_CAL_COMPONENT (l->data);

			comp_string = e_cal_component_get_as_string (comp);
			test_print ("%s\n", comp_string);
			g_object_unref (comp);
			g_free (comp_string);
		}
	} else {
		g_error ("got empty free/busy information");
	}

	return free_busy;
}

void
ecal_test_utils_cal_send_objects (ECal           *cal,
				  icalcomponent  *component,
				  GList         **users,
				  icalcomponent **component_final)
{
	GList *l = NULL;
	GError *error = NULL;

	if (!e_cal_send_objects (cal, component, users, component_final, &error)) {
		g_error ("sending objects: %s\n", error->message);
	}

	test_print ("successfully sent the objects to the following users:\n");
	if (g_list_length (*users) <= 0) {
		test_print ("        (none)\n");
		return;
	}
	for (l = *users; l; l = l->next) {
		test_print ("        %s\n", (const gchar *) l->data);
	}
}

void
ecal_test_utils_cal_receive_objects (ECal          *cal,
				     icalcomponent *component)
{
	GError *error = NULL;

	if (!e_cal_receive_objects (cal, component, &error)) {
		g_error ("receiving objects: %s\n", error->message);
	}

	test_print ("successfully received the objects\n");
}

ECalView*
ecal_test_utils_get_query (ECal       *cal,
			   const gchar *sexp)
{
	GError *error = NULL;
	ECalView *query = NULL;

	if (!e_cal_get_query (cal, sexp, &query, &error)) {
		g_error (G_STRLOC ": Unable to obtain calendar view: %s\n",
				error->message);
	}
	test_print ("successfully retrieved calendar view for query '%s'", sexp);

	return query;
}