Adapt libecal to the new ESource API.
[platform/upstream/evolution-data-server.git] / tests / libecal / test-ecal-get-object-list.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 #include <libical/ical.h>
6
7 #include "ecal-test-utils.h"
8
9 #define EVENT_SUMMARY "Creation of new test event"
10
11 gint
12 main (gint argc,
13       gchar **argv)
14 {
15         ECal *cal;
16         gchar *uri = NULL;
17         ECalComponent *e_component;
18         icalcomponent *component;
19         icalcomponent *component_final;
20         gchar *uid;
21         GList *components;
22
23         g_type_init ();
24
25         cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
26         ecal_test_utils_cal_open (cal, FALSE);
27
28         ecal_test_utils_create_component (cal, "20040109T090000Z", "UTC",
29                         "20040109T103000", "UTC", EVENT_SUMMARY, &e_component,
30                         &uid);
31         component = e_cal_component_get_icalcomponent (e_component);
32
33         component_final = ecal_test_utils_cal_get_object (cal, uid);
34         ecal_test_utils_cal_assert_objects_equal_shallow (component,
35                         component_final);
36         icalcomponent_free (component_final);
37
38         components = ecal_test_utils_cal_get_object_list (cal,
39                         "(contains? \"summary\" \"" EVENT_SUMMARY "\")");
40         g_assert (g_list_length (components) == 1);
41         component_final = components->data;
42         ecal_test_utils_cal_assert_objects_equal_shallow (component,
43                         component_final);
44
45         e_cal_free_object_list (components);
46         g_free (uid);
47         icalcomponent_free (component);
48
49         return 0;
50 }