Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / calendar / tests / ecal / test-ecal.c
1 /* Evolution calendar client - test program
2  *
3  * Copyright (C) 2000 Ximian, Inc.
4  * Copyright (C) 2000 Ximian, Inc.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2 of the GNU Lesser General Public
8  * License as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23
24 #include <stdlib.h>
25 #include <string.h>
26 #include <glib.h>
27 #include <glib/gi18n.h>
28 #include <libecal/e-cal.h>
29 #include <libecal/e-cal-component.h>
30 #include <libecal/e-cal-time-util.h>
31 #include <libical/ical.h>
32
33 /* start_testing_scaffold */
34 #define mu_assert(message, test) do { if (!(test)) return message; else { tests_passed++; return NULL;}} while (0)
35 #define mu_run_test(test) do { char *message = test; tests_run++; \
36                                 if (message) { cl_printf (client, "***Error***\n%s\n", message); break;} } while (0)
37
38 static int tests_run = 0;
39 static int tests_passed = 0;
40 /* end_testing_scaffold */
41
42 static ECal *client1;
43 static ECal *client2;
44
45 static GMainLoop *loop;
46
47 /* Prints a message with a client identifier */
48 static void
49 cl_printf (ECal *client, const char *format, ...)
50 {
51         va_list args;
52
53         va_start (args, format);
54         if ( client != client1)
55                 return;
56         printf ("Client %s: ", "Test");
57         vprintf (format, args);
58         va_end (args);
59 }
60
61 static void
62 objects_added_cb (GObject *object, GList *objects, gpointer data)
63 {
64         GList *l;
65         
66         for (l = objects; l; l = l->next)
67                 cl_printf (data, "Object added %s\n", icalcomponent_get_uid (l->data));
68 }
69
70 static void
71 objects_modified_cb (GObject *object, GList *objects, gpointer data)
72 {
73         GList *l;
74         
75         for (l = objects; l; l = l->next)
76                 cl_printf (data, "Object modified %s\n", icalcomponent_get_uid (l->data));
77 }
78
79 static void
80 objects_removed_cb (GObject *object, GList *objects, gpointer data)
81 {
82         GList *l;
83         
84         for (l = objects; l; l = l->next)
85                 cl_printf (data, "Object removed %s\n", icalcomponent_get_uid (l->data));
86 }
87
88 static void
89 view_done_cb (GObject *object, ECalendarStatus status, gpointer data)
90 {
91         cl_printf (data, "View done\n");
92 }
93
94 static gboolean
95 list_uids (ECal *client)
96 {
97         GList *objects = NULL;
98         GList *l;
99         
100         if (!e_cal_get_object_list (client, "(contains? \"any\" \"test\")", &objects, NULL))
101                 return FALSE;
102         
103         cl_printf (client, "UIDS: ");
104
105         cl_printf (client, "\nGot %d objects\n", g_list_length (objects));
106         if (!objects)
107                 printf ("none\n");
108         else {
109                 for (l = objects; l; l = l->next) {
110                         const char *uid;
111
112                         uid = icalcomponent_get_uid (l->data);
113                         printf ("`%s' ", uid);
114                 }
115
116                 printf ("\n");
117
118                 for (l = objects; l; l = l->next) {
119                         printf ("------------------------------\n");
120                         printf ("%s", icalcomponent_as_ical_string (l->data));
121                         printf ("------------------------------\n");
122                 }
123         }
124
125         e_cal_free_object_list (objects);
126
127         return FALSE;
128 }
129
130 /* Callback used when a client is destroyed */
131 static void
132 client_destroy_cb (gpointer data, GObject *object)
133 {
134         if (E_CAL (object) == client1)
135                 client1 = NULL;
136         else if (E_CAL (object) == client2)
137                 client2 = NULL;
138         else
139                 g_assert_not_reached ();
140
141         if (!client1 && !client2)
142                 g_main_loop_quit (loop);
143 }
144
145 static char * 
146 test_object_creation (ECal *client,  char **uid)
147 {
148         ECalComponent *comp, *comp_retrieved;
149         icalcomponent *icalcomp, *icalcomp_retrieved;
150         struct icaltimetype tt;
151         ECalComponentText text;
152         ECalComponentDateTime dt;
153         ECalComponentTransparency transp;
154         gboolean compare;
155         GError *error = NULL;
156         
157         comp = e_cal_component_new ();
158         /* set fields */
159         e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
160         text.value = "Creation of new test event";
161         text.altrep = NULL;
162         e_cal_component_set_summary (comp, &text);
163         tt = icaltime_from_string ("20040109T090000Z");
164         dt.value = &tt;
165         dt.tzid ="UTC";
166         e_cal_component_set_dtstart (comp, &dt);
167         tt = icaltime_from_string ("20040109T103000");
168         dt.value = &tt;
169         dt.tzid ="UTC";
170         e_cal_component_set_dtend (comp, &dt);
171         e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_OPAQUE);
172         
173
174         e_cal_component_commit_sequence (comp);
175         icalcomp = e_cal_component_get_icalcomponent (comp); 
176         if (!e_cal_create_object (client, icalcomp, uid, &error)) {
177                 cl_printf (client, "Object creation:  %s\n", error->message);
178                 g_free (comp);
179                 g_free (icalcomp);
180                 return "Test Object Creation failed";
181         }
182         e_cal_component_commit_sequence (comp);
183         if (!e_cal_get_object (client, *uid, NULL, &icalcomp_retrieved, &error)) {
184                 cl_printf (client, "Object retrieval:  %s\n", error->message);
185                 g_free (uid);
186                 g_free (comp);
187                 g_free (icalcomp);
188                 return "Test Object Creation failed";
189
190         }
191
192         comp_retrieved = e_cal_component_new ();
193         if (!e_cal_component_set_icalcomponent (comp_retrieved, icalcomp_retrieved)) {
194                 cl_printf (client, "Could not set icalcomponent\n");
195                 g_free (uid);
196                 g_free (comp);
197                 g_free (icalcomp);
198                 g_free (icalcomp_retrieved);
199                 return "Test Object Creation failed";
200
201         }       
202         /* Dumping icalcomp into a string is not useful as the retrieved object
203          * has some generated information like timestamps. We compare 
204          * member values we set during creation*/
205         compare = e_cal_component_event_dates_match (comp, comp_retrieved);
206         
207         if (compare) {
208                 e_cal_component_get_transparency (comp_retrieved, &transp);
209                 compare = (transp == E_CAL_COMPONENT_TRANSP_OPAQUE); 
210         }
211         
212         g_free (comp_retrieved);
213         g_free (comp);
214         g_free (icalcomp);
215         g_free (icalcomp_retrieved);
216         
217         mu_assert ("Test Object creation : Created object does not match retrieved data\n", compare);
218         return NULL;
219 }
220         
221 static char *
222 test_object_modification (ECal *client, char *uid)
223 {
224         const char *summary = "This summary was modified";
225         icalcomponent *icalcomp, *icalcomp_modified;
226         gboolean compare;
227         GError *error = NULL;
228         
229         if (!e_cal_get_object (client, uid, NULL, &icalcomp, &error)) {
230                 cl_printf (client, "Test Modify object : Could not get the object: %s\n", error->message);
231                 g_free (uid);
232                 return error->message;
233         }
234
235         // modify one property of the icalcomp and save it. Now retrieve it and
236         // check the field.
237         icalcomponent_set_summary (icalcomp, summary);
238         if (!e_cal_modify_object  (client, icalcomp, CALOBJ_MOD_THIS, &error)) {
239                 cl_printf (client, "Test Modify object : Could not modify the object: %s\n", error->message);
240                 g_free (uid);
241                 g_free (icalcomp);
242                 return error->message;
243         }
244
245         if (!e_cal_get_object (client, uid, NULL, &icalcomp_modified, &error)) {
246                 cl_printf (client, "Test Modify object : Could not get the modified object: %s\n", error->message);
247                 g_free (uid);
248                 g_free (icalcomp);
249                 return "Test Object Creation failed";
250         }
251
252         compare = !strcmp ( icalcomponent_get_summary (icalcomp_modified), summary);
253
254         g_free (uid);
255         g_free (icalcomp);
256         g_free (icalcomp_modified);
257
258         mu_assert ("Test Modify object : Modification failed\n", compare);
259         return NULL;
260 }
261
262 #if 0
263 static char *
264 test_object_removal (ECal *client)
265 {
266         
267         char *uid;
268         ECalComponent *comp;
269         icalcomponent *icalcomp;
270         gboolean compare = 1;
271         GError *error = NULL;
272         
273         comp = e_cal_component_new ();
274         e_cal_component_commit_sequence (comp);
275         icalcomp = e_cal_component_get_icalcomponent (comp); 
276         if (!e_cal_create_object (client, icalcomp, &uid, &error)) {
277                 cl_printf (client, "Test object removal - Object creation:  %s\n", error->message);
278                 g_object_unref (comp);
279                 g_object_unref(icalcomp);
280                 return "Test Object Removal failed\n";
281         }
282         
283         if (!e_cal_remove_object (client, uid, &error)) {
284                 cl_printf (client, "Test object removal - Could not remove the object\n");
285                 g_free (uid);
286                 g_object_unref (comp);
287                 g_object_unref (icalcomp);
288                 return "Test Object Removal failed\n";
289                 
290         }       
291
292         compare =  e_cal_get_object (client, uid, NULL, &icalcomp, &error);
293
294         g_free (uid);
295         g_object_unref (comp);
296         g_object_unref (icalcomp);
297         
298         mu_assert ("Test object removal - Failed\n", compare);  
299         return NULL;
300 }
301 #endif
302
303 static char *
304 test_get_alarms_in_range (ECal *client)
305 {
306         GSList *alarms;
307         icaltimezone *utc;
308         time_t start = time (NULL), end;
309         gboolean compare;
310         
311         utc = icaltimezone_get_utc_timezone ();
312         start = time_from_isodate ("20040212T000000Z");
313         end = time_add_day_with_zone (start, 2, utc);
314
315         alarms = e_cal_get_alarms_in_range (client, start, end);
316         compare = (g_slist_length (alarms) == 3); 
317         
318         e_cal_free_alarms (alarms);
319         mu_assert ("Test getting alarms in range\n", compare);
320         
321         return NULL;
322 }
323
324 static char *
325 test_set_uri (ECal *client, const gchar *uri) 
326 {
327         /* The uri is set as part of create_client call. This method merely
328          * verifies it was done correctly.
329          */
330         char *cal_uri;
331         gboolean compare = 0;
332         cal_uri = g_strconcat ("file://", uri, NULL);
333         compare = !strcmp (e_cal_get_uri (client), cal_uri);
334         
335         g_free (cal_uri);
336         mu_assert ("Test set_uri : uri was not set correctly\n", compare);  
337         
338         return NULL;
339 }
340
341 static char *
342 test_cal_loaded (ECal *client)
343 {
344         /* Test one loaded calendar and another that is not loaded. */
345         mu_assert ("Test get_cal_load_state : Failed \n",
346                         (E_CAL_LOAD_LOADED == e_cal_get_load_state (client)) && 
347                         (E_CAL_LOAD_NOT_LOADED == e_cal_get_load_state (NULL)));
348
349         return NULL;
350 }
351
352 static char *
353 test_get_source (ECal *client, const gchar *expected)
354 {
355         ESource *source;
356         char *uri;
357         char *cal_uri;
358         gboolean compare = 0;
359         
360         source = e_cal_get_source (client);
361         uri = e_source_get_uri (source);
362         cal_uri = g_strconcat ("file://", expected, NULL);
363         compare = !strcmp (expected, uri);
364
365         g_free (cal_uri);
366         mu_assert ("Test get_source : Failed\n", compare);
367                         
368         return NULL;
369 }
370
371 static char *
372 test_query (ECal *client, const char *query, int expected)
373 {
374         /* This uses pre-loaded data. Hence its results are valid only
375          * when called before any write operation is performed.
376          */ 
377         int i = 0;
378         GList *objects = NULL;
379
380         if (!e_cal_get_object_list (client, query, &objects, NULL))
381                 return "Could not get the list of objects";
382         i = g_list_length (objects);
383         e_cal_free_object_list (objects);
384         
385         mu_assert ("Test get_object_list : Expected number of objects not found", i == expected);
386
387         return NULL;
388 }
389
390 #if 0
391 static char *
392 test_e_cal_new (ECal **cal, const char *uri)
393 {
394         GError *error = NULL;
395         char *cal_uri, *cal_file;
396         gboolean created = 0;
397         
398         cal_uri = g_strconcat ("file://", uri, NULL);
399         *cal = e_cal_new_from_uri (cal_uri, E_CAL_SOURCE_TYPE_EVENT);
400         if (!*cal) {
401                 g_message (G_STRLOC ": could not create the client");
402                 g_free (cal_uri);
403                 return "Test Creation of new calendar : Failed";
404         }
405         g_object_weak_ref (G_OBJECT (*cal), client_destroy_cb, NULL);
406
407         cl_printf (*cal, "Calendar loading `%s'...\n", uri);
408
409         if (!e_cal_open (*cal, FALSE, &error)) {
410                 cl_printf (*cal, "Load/create %s\n", error->message);
411                 g_free (cal_uri);
412                 return "Test creation of new calendar : Failed";
413         }
414
415         cal_file = g_strconcat (uri, "/calendar.ics", NULL);
416
417         created = g_file_test (cal_file, G_FILE_TEST_EXISTS);
418         g_free (cal_uri);
419         g_free (cal_file);
420
421         mu_assert ("Test creation of new calendar : Failed", created);
422         
423         return NULL;
424 }
425
426 static char *
427 test_e_cal_remove (ECal *ecal, const char *uri)
428 {
429         char *cal_uri;
430         GError *error = NULL;
431         gboolean removed = 0;
432         
433         cal_uri = g_strconcat (uri, "/calendar.ics", NULL);
434         if (!e_cal_remove (ecal, &error)) {
435                 cl_printf (ecal, "Test Calendar removal : Could not remove the Calendar : %s\n", error->message);
436         }
437         
438         removed = !g_file_test (uri, G_FILE_TEST_EXISTS);
439         g_free (cal_uri);
440         
441         mu_assert ("Test Remove calendar : Failed ", removed);
442         
443         return NULL;
444
445 #endif
446
447 static char *
448 test_new_system_calendar(void)
449 {
450         ECal *cal;
451         char *uri;
452         gboolean created;
453         
454         cal = e_cal_new_system_calendar ();
455         uri = g_build_filename (g_get_home_dir (), ".evolution", "calendar", "local", "system", "calendar.ics", NULL);
456         created = g_file_test (uri, G_FILE_TEST_EXISTS);
457         g_free (uri);
458         
459         mu_assert ("Test creation of default system calendar : Failed", created);
460         
461         return NULL;
462 }
463
464 static char *
465 test_new_system_tasks(void)
466 {
467         ECal *cal;
468         char *uri;
469         gboolean created;
470         
471         cal = e_cal_new_system_tasks ();
472         uri = g_build_filename (g_get_home_dir (), ".evolution", "tasks", "local", "system", "tasks.ics", NULL);
473         created = g_file_test (uri, G_FILE_TEST_EXISTS);
474         g_free (uri);
475         
476         mu_assert ("Test creation of default system tasks : Failed", created);
477         
478         return NULL;
479 }
480
481 static char *
482 test_new_system_memos(void)
483 {
484         ECal *cal;
485         char *uri;
486         gboolean created;
487         
488         cal = e_cal_new_system_memos ();
489         uri = g_build_filename (g_get_home_dir (), ".evolution", "memos", "local", "system", "journal.ics", NULL);
490         created = g_file_test (uri, G_FILE_TEST_EXISTS);
491         g_free (uri);
492         
493         mu_assert ("Test creation of default system memos : Failed", created);
494         
495         return NULL;
496 }
497
498 static char *
499 test_get_free_busy (ECal *client)
500 {
501         // TODO uses NULL for users and currently specific to file backend.
502         GList *l, *freebusy = NULL;
503         GError *error = NULL;
504         icaltimezone *utc;
505         time_t start = time (NULL), end;
506         
507         utc = icaltimezone_get_utc_timezone ();
508         start = time_from_isodate ("20040212T000000Z");
509         end = time_add_day_with_zone (start, 2, utc);
510
511         if (!e_cal_get_free_busy (client, NULL, start, end, &freebusy, &error)) {
512                 cl_printf (client, "Test free/busy : Could not retrieve free busy information :  %s\n", error->message);
513                 return error->message;
514         }
515         if (freebusy) {
516                 cl_printf (client, "Printing free busy information\n");
517                 for (l = freebusy; l; l = l->next) {
518                         char *comp_string;
519                         ECalComponent *comp = E_CAL_COMPONENT (l->data);
520                         
521                         comp_string = e_cal_component_get_as_string (comp);
522                         cl_printf (client, "%s\n\n", comp_string);
523                         g_object_unref (comp);
524                         g_free (comp_string);
525                 }       
526         }       
527         else {
528                 cl_printf (client, "free_busy was returned but NULL");
529         }       
530         return NULL;    
531 }
532
533
534 static char *
535 test_get_default_object (ECal *client)
536 {
537         icalcomponent *icalcomp;
538         GError *error = NULL;
539         char *ical_string;
540         if (e_cal_get_default_object (client, &icalcomp, &error)) {
541                 ical_string = icalcomponent_as_ical_string (icalcomp);
542                 cl_printf (client, "Obtained default object: %s\n", ical_string);
543                 g_free (ical_string);
544                 tests_passed++;
545                 return NULL;
546                 
547         } else 
548                 cl_printf (client, "Test Get default object : Could not get the default object: %s\n", error->message); 
549         return error->message;
550 }
551
552
553 /* XXX The string pasted below is *really* ugly. Alternatively, it could be
554  * read from a file at run-time. Not sure if it is an elegant solution when
555  * multiple clients try to load the same file during stress testing. 
556  * how can this be done better ?
557  */
558 #define EXPECTED \
559 "BEGIN:VEVENT\
560 UID:20040213T055519Z-15802-500-1-3@testcal\
561 DTSTAMP:20040213T055519Z\
562 DTSTART;TZID=/softwarestudio.org/Olson_20011030_5/Asia/Calcutta:\
563  20040213T130000\
564 DTEND;TZID=/softwarestudio.org/Olson_20011030_5/Asia/Calcutta:\
565  20040213T133000\
566 TRANSP:OPAQUE\
567 SEQUENCE:3\
568 SUMMARY:Test - Travel plans to Kansas\
569 LOCATION:Yellow Brick road\
570 CLASS:PUBLIC\
571 ORGANIZER;CN=dorothy:MAILTO:dorothy@oz\
572 DESCRIPTION: Discuss way to home\
573 ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;\
574  RSVP=TRUE;CN=dorothy;LANGUAGE=en:MAILTO:dorothy@oz\
575 ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;\
576  RSVP=TRUE;CN=tinman;LANGUAGE=en:MAILTO:tinman@oz\
577 ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;\
578  RSVP=TRUE;CN=toto;LANGUAGE=en:MAILTO:toto@oz\
579 ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=OPT-PARTICIPANT;PARTSTAT=NEEDS-ACTION;\
580  RSVP=TRUE;CN=scarecrow;LANGUAGE=en:MAILTO:scarecrow@oz\
581 LAST-MODIFIED:20040213T055647Z\
582 END:VEVENT"
583
584 static char *
585 test_get_object (ECal *client) 
586 {
587         const char *uid = "20040213T055519Z-15802-500-1-3@testcal";
588         char *actual;
589         icalcomponent *icalcomp;
590         gboolean compare;
591         GError *error = NULL;
592         
593         if (!e_cal_get_object (client, uid, NULL, &icalcomp, &error)) {
594                 cl_printf (client, "Test Get object : Could not get the object: %s\n", error->message);
595                 return error->message;
596         }
597
598         actual = icalcomponent_as_ical_string (icalcomp);
599         compare = !strcmp (actual, EXPECTED);
600         
601         g_free (actual);
602
603         mu_assert ("Test : get_object does not match the expected output", compare);
604         return NULL;
605 }       
606
607 static char *
608 test_timezones (ECal *client)
609 {
610         icaltimezone *zone;
611         GError *error = NULL;
612         if (!e_cal_get_timezone (client, "UTC", &zone, &error))
613         {
614                 cl_printf (client, "Could not get the timezone\n");
615         }
616
617         printf ("\n\nTime Zones : \n%s *** %s", icaltimezone_get_display_name (zone), icaltimezone_get_tzid (zone));
618         printf ("\n\nTime Zones : \n%s", icaltimezone_get_location (zone));
619         
620         
621         return NULL;
622 }
623
624 static char *
625 all_tests(ECal *client, const gchar *uri) 
626 {
627         char *uid;
628                 
629         mu_run_test (test_new_system_calendar ());
630         mu_run_test (test_new_system_tasks ());
631         mu_run_test (test_new_system_memos ());
632         mu_run_test (test_set_uri (client, uri));
633         mu_run_test (test_get_source (client, uri));
634         mu_run_test (test_cal_loaded (client));
635         
636         /* test_query acts on pre-loaded data. Hence it must executed before
637          * any writes are made */
638         mu_run_test (test_query (client, "(contains? \"any\" \"test\")", 2));
639         mu_run_test (test_query (client, "(contains? \"summary\" \"Kansas\")", 1));
640         mu_run_test (test_query (client, "(contains? \"any\" \"gibberish\")", 0));
641
642         
643         mu_run_test (test_get_default_object (client));
644         mu_run_test (test_get_object (client));
645         mu_run_test (test_get_free_busy (client));
646         mu_run_test (test_object_creation (client, &uid));
647         mu_run_test (test_object_modification (client, uid));
648 //      mu_run_test (test_object_removal (client));
649         mu_run_test (test_get_alarms_in_range (client));
650
651 //      tmp = g_strconcat (uri, "_tmp", NULL);
652 //      mu_run_test (test_e_cal_new (&ecal, tmp));
653 //      mu_run_test (test_e_cal_remove (ecal, tmp));
654 //      g_free (tmp);
655         
656         test_timezones (client);
657         
658         return NULL;
659 }
660
661 /* Creates a calendar client and tries to load the specified URI into it */
662 static void
663 create_client (ECal **client, const gchar *uri, ECalSourceType type, gboolean only_if_exists)
664 {
665         char *results;
666         ECalView *query;
667         char *cal_uri;
668         GError *error = NULL;
669         
670         cal_uri = g_strconcat ("file://", uri, NULL);
671         *client = e_cal_new_from_uri (cal_uri, type);
672         if (!*client) {
673                 g_message (G_STRLOC ": could not create the client");
674                 exit (1);
675         }
676
677         g_object_weak_ref (G_OBJECT (*client), client_destroy_cb, NULL);
678
679         cl_printf (*client, "Calendar loading `%s'...\n", uri);
680
681         if (!e_cal_open (*client, only_if_exists, &error)) {
682                 cl_printf (*client, "Load/create %s\n", error->message);
683                 exit (1);
684         }
685         g_clear_error (&error);
686         
687         if (!e_cal_get_query (*client, "(contains? \"any\" \"Event\")", &query, NULL)) {
688                 cl_printf (*client, G_STRLOC ": Unable to obtain query");
689                 exit (1);               
690         }
691
692         g_signal_connect (G_OBJECT (query), "objects_added", 
693                           G_CALLBACK (objects_added_cb), client);
694         g_signal_connect (G_OBJECT (query), "objects_modified", 
695                           G_CALLBACK (objects_modified_cb), client);
696         g_signal_connect (G_OBJECT (query), "objects_removed", 
697                           G_CALLBACK (objects_removed_cb), client);
698         g_signal_connect (G_OBJECT (query), "view_done",
699                           G_CALLBACK (view_done_cb), client);
700         
701         e_cal_view_start (query);
702         
703         results = all_tests (*client, uri);
704         cl_printf (*client, "\n\n\n*************Tests run: %d****************\n\n", tests_run); 
705         cl_printf (*client, "*************Tests passed: %d*************\n\n\n", tests_passed);
706         if (results != 0) 
707                 cl_printf (*client, "***Failures********%s\n", results);
708
709         
710         cl_printf (*client, "dump of the test calendar data");
711         list_uids (*client);
712         g_free (cal_uri);
713
714 }
715
716 int
717 main (int argc, char **argv)
718 {
719         char *uri;
720         bindtextdomain (GETTEXT_PACKAGE, EVOLUTION_LOCALEDIR);
721         textdomain (GETTEXT_PACKAGE);
722
723         g_type_init ();
724         loop = g_main_loop_new (NULL, TRUE);
725
726         /* arg1- file name; arg2- client suffix */
727         uri = g_strconcat (argv[1], argv[2], NULL);
728         create_client (&client1, uri, E_CAL_SOURCE_TYPE_EVENT, FALSE);
729         
730         g_free (uri);   
731         g_main_loop_run (loop);
732         return 0;
733 }