[evolution-data-server/wip/mcrha/libical-glib] tests/libecal changes



commit b1a750c913691e902e8bb584591e8755aedbb77e
Author: Milan Crha <mcrha redhat com>
Date:   Wed Feb 13 16:18:43 2019 +0100

    tests/libecal changes

 tests/libecal/test-cal-client-add-timezone.c       |  60 ++++----
 tests/libecal/test-cal-client-bulk-methods.c       | 150 +++++++++++--------
 tests/libecal/test-cal-client-create-object.c      | 158 +++++++++++++--------
 .../libecal/test-cal-client-get-attachment-uris.c  |  53 +++----
 tests/libecal/test-cal-client-get-free-busy.c      |  18 +--
 tests/libecal/test-cal-client-get-object-list.c    |  54 +++----
 tests/libecal/test-cal-client-get-revision.c       |  26 ++--
 tests/libecal/test-cal-client-get-view.c           |  32 +++--
 tests/libecal/test-cal-client-modify-object.c      |  64 +++++----
 tests/libecal/test-cal-client-receive-objects.c    |  44 +++---
 tests/libecal/test-cal-client-refresh.c            |  25 ++--
 tests/libecal/test-cal-client-remove-object.c      |  24 ++--
 tests/libecal/test-cal-client-revision-view.c      |  28 ++--
 tests/libecal/test-cal-client-send-objects.c       |  77 +++++-----
 14 files changed, 459 insertions(+), 354 deletions(-)
---
diff --git a/tests/libecal/test-cal-client-add-timezone.c b/tests/libecal/test-cal-client-add-timezone.c
index 6ae44745b..b05bbbd57 100644
--- a/tests/libecal/test-cal-client-add-timezone.c
+++ b/tests/libecal/test-cal-client-add-timezone.c
@@ -32,20 +32,21 @@ test_add_timezone_sync (ETestServerFixture *fixture,
                         gconstpointer user_data)
 {
        ECalClient *cal_client;
-       icalproperty *property;
-       icalcomponent *component;
-       icaltimezone *zone;
-       icaltimezone *zone2 = NULL;
+       ICalProperty *property;
+       ICalComponent *component;
+       ICalTimezone *zone;
+       ICalTimezone *zone2 = NULL;
        GError *error = NULL;
 
        /* Build up new timezone */
-       component = icalcomponent_new_vtimezone ();
-       property = icalproperty_new_tzid (TZID_NEW);
-       icalcomponent_add_property (component, property);
-       property = icalproperty_new_tzname (TZNAME_NEW);
-       icalcomponent_add_property (component, property);
-       zone = icaltimezone_new ();
-       icaltimezone_set_component (zone, component);
+       component = i_cal_component_new_vtimezone ();
+       property = i_cal_property_new_tzid (TZID_NEW);
+       i_cal_component_take_property (component, property);
+       property = i_cal_property_new_tzname (TZNAME_NEW);
+       i_cal_component_take_property (component, property);
+       zone = i_cal_timezone_new ();
+       g_assert (i_cal_timezone_set_component (zone, component));
+       g_object_unref (component);
 
        cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
 
@@ -58,14 +59,14 @@ test_add_timezone_sync (ETestServerFixture *fixture,
        if (!zone2)
                g_error ("Failure: get timezone returned NULL");
 
-       g_assert_cmpstr (icaltimezone_get_tzid (zone), ==, icaltimezone_get_tzid (zone2));
-       g_assert_cmpstr (icaltimezone_get_tznames (zone), ==, icaltimezone_get_tznames (zone2));
+       g_assert_cmpstr (i_cal_timezone_get_tzid (zone), ==, i_cal_timezone_get_tzid (zone2));
+       g_assert_cmpstr (i_cal_timezone_get_tznames (zone), ==, i_cal_timezone_get_tznames (zone2));
 
-       icaltimezone_free (zone, TRUE);
+       g_object_unref (zone);
 }
 
 typedef struct {
-       icaltimezone *zone;
+       ICalTimezone *zone;
        GMainLoop *loop;
 } AsyncData;
 
@@ -77,7 +78,7 @@ async_read_result_ready (GObject *source_object,
        ECalClient *cal_client;
        GError *error = NULL;
        AsyncData *data = (AsyncData *) user_data;
-       icaltimezone *zone1 = data->zone, *zone2 = NULL;
+       ICalTimezone *zone1 = data->zone, *zone2 = NULL;
 
        cal_client = E_CAL_CLIENT (source_object);
 
@@ -87,8 +88,8 @@ async_read_result_ready (GObject *source_object,
        if (!zone2)
                g_error ("Failure: get timezone returned NULL");
 
-       g_assert_cmpstr (icaltimezone_get_tzid (zone1), ==, icaltimezone_get_tzid (zone2));
-       g_assert_cmpstr (icaltimezone_get_tznames (zone1), ==, icaltimezone_get_tznames (zone2));
+       g_assert_cmpstr (i_cal_timezone_get_tzid (zone1), ==, i_cal_timezone_get_tzid (zone2));
+       g_assert_cmpstr (i_cal_timezone_get_tznames (zone1), ==, i_cal_timezone_get_tznames (zone2));
 
        g_main_loop_quit (data->loop);
 }
@@ -115,19 +116,20 @@ test_add_timezone_async (ETestServerFixture *fixture,
                          gconstpointer user_data)
 {
        ECalClient *cal_client;
-       icalproperty *property;
-       icalcomponent *component;
-       icaltimezone *zone;
+       ICalProperty *property;
+       ICalComponent *component;
+       ICalTimezone *zone;
        AsyncData data;
 
        /* Build up new timezone */
-       component = icalcomponent_new_vtimezone ();
-       property = icalproperty_new_tzid (TZID_NEW);
-       icalcomponent_add_property (component, property);
-       property = icalproperty_new_tzname (TZNAME_NEW);
-       icalcomponent_add_property (component, property);
-       zone = icaltimezone_new ();
-       icaltimezone_set_component (zone, component);
+       component = i_cal_component_new_vtimezone ();
+       property = i_cal_property_new_tzid (TZID_NEW);
+       i_cal_component_take_property (component, property);
+       property = i_cal_property_new_tzname (TZNAME_NEW);
+       i_cal_component_take_property (component, property);
+       zone = i_cal_timezone_new ();
+       i_cal_timezone_set_component (zone, component);
+       g_object_unref (component);
 
        cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
 
@@ -136,7 +138,7 @@ test_add_timezone_async (ETestServerFixture *fixture,
        e_cal_client_add_timezone (cal_client, zone, NULL, async_write_result_ready, &data);
        g_main_loop_run (fixture->loop);
 
-       icaltimezone_free (zone, TRUE);
+       g_object_unref (zone);
 }
 
 gint
diff --git a/tests/libecal/test-cal-client-bulk-methods.c b/tests/libecal/test-cal-client-bulk-methods.c
index c481f8ab2..bc6bc23ee 100644
--- a/tests/libecal/test-cal-client-bulk-methods.c
+++ b/tests/libecal/test-cal-client-bulk-methods.c
@@ -25,32 +25,52 @@ static ETestServerClosure cal_closure =
 #define NB_COMPONENTS 5
 
 static void
-test_icalcomps (icalcomponent *icalcomp1,
-                icalcomponent *icalcomp2)
+test_icomps (ICalComponent *icomp1,
+            ICalComponent *icomp2)
 {
-       struct icaltimetype t1, t2;
+       ICalTimetype *t1, *t2;
 
-       if (!icalcomp2)
+       if (!icomp2)
                g_error ("Failure: get object returned NULL");
 
-       g_assert_cmpstr (icalcomponent_get_uid (icalcomp1), ==, icalcomponent_get_uid (icalcomp2));
-       g_assert_cmpstr (icalcomponent_get_summary (icalcomp1), ==, icalcomponent_get_summary (icalcomp2));
+       g_assert_cmpstr (i_cal_component_get_uid (icomp1), ==, i_cal_component_get_uid (icomp2));
+       g_assert_cmpstr (i_cal_component_get_summary (icomp1), ==, i_cal_component_get_summary (icomp2));
 
-       t1 = icalcomponent_get_dtstart (icalcomp1);
-       t2 = icalcomponent_get_dtstart (icalcomp2);
+       t1 = i_cal_component_get_dtstart (icomp1);
+       t2 = i_cal_component_get_dtstart (icomp2);
 
-       if (icaltime_compare (t1, t2) != 0)
-               g_error (
-                       "Failure: dtend doesn't match, expected '%s', got '%s'\n",
-                       icaltime_as_ical_string (t1), icaltime_as_ical_string (t2));
+       if (i_cal_time_compare (t1, t2) != 0) {
+               gchar *str1, *str2;
 
-       t1 = icalcomponent_get_dtend (icalcomp1);
-       t2 = icalcomponent_get_dtend (icalcomp2);
+               str1 = i_cal_time_as_ical_string_r (t1);
+               str2 = i_cal_time_as_ical_string_r (t2);
 
-       if (icaltime_compare (t1, t2) != 0)
-               g_error (
-                       "Failure: dtend doesn't match, expected '%s', got '%s'\n",
-                       icaltime_as_ical_string (t1), icaltime_as_ical_string (t2));
+               g_error ("Failure: dtend doesn't match, expected '%s', got '%s'\n", str1, str2);
+
+               g_free (str1);
+               g_free (str2);
+       }
+
+       g_clear_object (&t1);
+       g_clear_object (&t2);
+
+       t1 = i_cal_component_get_dtend (icomp1);
+       t2 = i_cal_component_get_dtend (icomp2);
+
+       if (i_cal_time_compare (t1, t2) != 0) {
+               gchar *str1, *str2;
+
+               str1 = i_cal_time_as_ical_string_r (t1);
+               str2 = i_cal_time_as_ical_string_r (t2);
+
+               g_error ("Failure: dtend doesn't match, expected '%s', got '%s'\n", str1, str2);
+
+               g_free (str1);
+               g_free (str2);
+       }
+
+       g_clear_object (&t1);
+       g_clear_object (&t2);
 }
 
 static void
@@ -62,13 +82,19 @@ check_removed (ECalClient *cal_client,
 
        while (uids) {
                GError *error = NULL;
-               icalcomponent *icalcomp = NULL;
+               ICalComponent *icomp = NULL;
 
-               if (!e_cal_client_get_object_sync (cal_client, uids->data, NULL, &icalcomp, NULL, &error) &&
-                               g_error_matches (error, E_CAL_CLIENT_ERROR, 
E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) {
+               if (!e_cal_client_get_object_sync (cal_client, uids->data, NULL, &icomp, NULL, &error) &&
+                   g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) {
                        g_clear_error (&error);
-               } else
+               } else if (error) {
                        g_error ("check objects removed sync: %s", error->message);
+                       g_clear_error (&error);
+               } else {
+                       g_clear_object (&icomp);
+
+                       g_error ("check objects removed sync: object found in the backend");
+               }
 
                uids = uids->next;
        }
@@ -88,75 +114,76 @@ uid_slist_to_ecalcomponentid_slist (GSList *uids)
 }
 
 static void
-check_icalcomps_exist (ECalClient *cal_client,
-                       GSList *icalcomps)
+check_icomps_exist (ECalClient *cal_client,
+                   GSList *icomps)
 {
-       const GSList *l;
+       GSList *link;
 
-       for (l = icalcomps; l; l = l->next) {
+       for (link = icomps; link; link = g_slist_next (link)) {
                GError *error = NULL;
-               icalcomponent *icalcomp = l->data;
-               icalcomponent *icalcomp2 = NULL;
-               const gchar *uid = icalcomponent_get_uid (icalcomp);
+               ICalComponent *icomp = link->data;
+               ICalComponent *icomp2 = NULL;
+               const gchar *uid = i_cal_component_get_uid (icomp);
 
-               if (!e_cal_client_get_object_sync (cal_client, uid, NULL, &icalcomp2, NULL, &error))
+               if (!e_cal_client_get_object_sync (cal_client, uid, NULL, &icomp2, NULL, &error))
                        g_error ("get object sync: %s", error->message);
 
-               g_assert (icalcomp2 != NULL);
+               g_assert_nonnull (icomp2);
+
+               test_icomps (icomp, icomp2);
 
-               test_icalcomps (icalcomp, icalcomp2);
-               icalcomponent_free (icalcomp2);
+               g_object_unref (icomp2);
        }
 }
 
 static void
 test_bulk_methods (ECalClient *cal_client,
-                   GSList *icalcomps)
+                  GSList *icomps)
 {
        GError *error = NULL;
        GSList *uids = NULL, *ids = NULL;
        const GSList *lcomp, *luid;
        gint i = 0;
 
-       g_assert (icalcomps != NULL);
+       g_assert_nonnull (icomps);
 
        /* Create all the objects in bulk */
-       if (!e_cal_client_create_objects_sync (cal_client, icalcomps, &uids, NULL, &error))
+       if (!e_cal_client_create_objects_sync (cal_client, icomps, &uids, NULL, &error))
                g_error ("create objects sync: %s", error->message);
 
        g_assert (uids != NULL);
        g_assert_cmpint (g_slist_length (uids), ==, NB_COMPONENTS);
 
-       /* Update icalcomponents uids */
+       /* Update ICalComponents uids */
        luid = uids;
-       lcomp = icalcomps;
+       lcomp = icomps;
        while (luid && lcomp) {
-               icalcomponent_set_uid (lcomp->data, luid->data);
+               i_cal_component_set_uid (lcomp->data, luid->data);
                luid = luid->next;
                lcomp = lcomp->next;
        }
 
        /* Retrieve all the objects and check that they are the same */
-       check_icalcomps_exist (cal_client, icalcomps);
+       check_icomps_exist (cal_client, icomps);
 
        /* Modify the objects */
-       for (lcomp = icalcomps; lcomp; lcomp = lcomp->next) {
+       for (lcomp = icomps; lcomp; lcomp = lcomp->next) {
                gchar *summary;
-               icalcomponent *icalcomp = lcomp->data;
+               ICalComponent *icomp = lcomp->data;
 
                summary = g_strdup_printf ("Edited test summary %d", i);
-               icalcomponent_set_summary (icalcomp, summary);
+               i_cal_component_set_summary (icomp, summary);
 
                g_free (summary);
                ++i;
        }
 
        /* Save the modified objects in bulk */
-       if (!e_cal_client_modify_objects_sync (cal_client, icalcomps, E_CAL_OBJ_MOD_ALL, NULL, &error))
+       if (!e_cal_client_modify_objects_sync (cal_client, icomps, E_CAL_OBJ_MOD_ALL, NULL, &error))
                g_error ("modify objects sync: %s", error->message);
 
        /* Retrieve all the objects and check that they have been modified */
-       check_icalcomps_exist (cal_client, icalcomps);
+       check_icomps_exist (cal_client, icomps);
 
        /* Remove all the objects in bulk */
        ids = uid_slist_to_ecalcomponentid_slist (uids);
@@ -177,33 +204,38 @@ run_test_bulk_methods (ETestServerFixture *fixture,
                        gconstpointer user_data)
 {
        ECalClient *cal_client;
-       GSList *icalcomps = NULL;
-       struct icaltimetype now;
-       gint i;
+       GSList *icomps = NULL;
+       ICalTimetype *dtstart, *dtend;
+       gint ii;
 
        cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
 
-       now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
+       dtstart = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+       dtend = i_cal_timetype_new_clone (dtstart);
+       i_cal_time_adjust (dtend, 0, 1, 0, 0);
 
        /* Build up new components */
-       for (i = 0; i < NB_COMPONENTS; ++i) {
-               icalcomponent *icalcomp;
+       for (ii = 0; ii < NB_COMPONENTS; ++ii) {
+               ICalComponent *icomp;
                gchar *summary;
 
-               icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-               summary = g_strdup_printf ("Test summary %d", i);
-               icalcomponent_set_summary (icalcomp, summary);
-               icalcomponent_set_dtstart (icalcomp, now);
-               icalcomponent_set_dtend   (icalcomp, icaltime_from_timet_with_zone (icaltime_as_timet (now) + 
60 * 60 * 60, 0, NULL));
+               icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+               summary = g_strdup_printf ("Test summary %d", ii);
+               i_cal_component_set_summary (icomp, summary);
+               i_cal_component_set_dtstart (icomp, dtstart);
+               i_cal_component_set_dtend (icomp, dtend);
 
-               icalcomps = g_slist_append (icalcomps, icalcomp);
+               icomps = g_slist_append (icomps, icomp);
                g_free (summary);
        }
 
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
+
        /* Test synchronous bulk methods */
-       test_bulk_methods (cal_client, icalcomps);
+       test_bulk_methods (cal_client, icomps);
 
-       g_slist_free_full (icalcomps, (GDestroyNotify) icalcomponent_free);
+       g_slist_free_full (icomps, g_object_unref);
 }
 
 gint
diff --git a/tests/libecal/test-cal-client-create-object.c b/tests/libecal/test-cal-client-create-object.c
index 0d5bbd8f3..4d297fb47 100644
--- a/tests/libecal/test-cal-client-create-object.c
+++ b/tests/libecal/test-cal-client-create-object.c
@@ -25,32 +25,52 @@ static ETestServerClosure cal_closure_async =
        { E_TEST_SERVER_CALENDAR, NULL, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, FALSE, NULL, TRUE };
 
 static void
-test_icalcomps (icalcomponent *icalcomp1,
-                icalcomponent *icalcomp2)
+test_icomps (ICalComponent *icomp1,
+            ICalComponent *icomp2)
 {
-       struct icaltimetype t1, t2;
+       ICalTimetype *t1, *t2;
 
-       if (!icalcomp2)
+       if (!icomp2)
                g_error ("Failure: get object returned NULL");
 
-       g_assert_cmpstr (icalcomponent_get_uid (icalcomp1), ==, icalcomponent_get_uid (icalcomp2));
-       g_assert_cmpstr (icalcomponent_get_summary (icalcomp1), ==, icalcomponent_get_summary (icalcomp2));
+       g_assert_cmpstr (i_cal_component_get_uid (icomp1), ==, i_cal_component_get_uid (icomp2));
+       g_assert_cmpstr (i_cal_component_get_summary (icomp1), ==, i_cal_component_get_summary (icomp2));
 
-       t1 = icalcomponent_get_dtstart (icalcomp1);
-       t2 = icalcomponent_get_dtstart (icalcomp2);
+       t1 = i_cal_component_get_dtstart (icomp1);
+       t2 = i_cal_component_get_dtstart (icomp2);
 
-       if (icaltime_compare (t1, t2) != 0)
-               g_error (
-                       "Failure: dtend doesn't match, expected '%s', got '%s'\n",
-                       icaltime_as_ical_string (t1), icaltime_as_ical_string (t2));
+       if (i_cal_time_compare (t1, t2) != 0) {
+               gchar *str1, *str2;
 
-       t1 = icalcomponent_get_dtend (icalcomp1);
-       t2 = icalcomponent_get_dtend (icalcomp2);
+               str1 = i_cal_time_as_ical_string_r (t1);
+               str2 = i_cal_time_as_ical_string_r (t2);
 
-       if (icaltime_compare (t1, t2) != 0)
-               g_error (
-                       "Failure: dtend doesn't match, expected '%s', got '%s'\n",
-                       icaltime_as_ical_string (t1), icaltime_as_ical_string (t2));
+               g_error ("Failure: dtend doesn't match, expected '%s', got '%s'\n", str1, str2);
+
+               g_free (str1);
+               g_free (str2);
+       }
+
+       g_clear_object (&t1);
+       g_clear_object (&t2);
+
+       t1 = i_cal_component_get_dtend (icomp1);
+       t2 = i_cal_component_get_dtend (icomp2);
+
+       if (i_cal_time_compare (t1, t2) != 0) {
+               gchar *str1, *str2;
+
+               str1 = i_cal_time_as_ical_string_r (t1);
+               str2 = i_cal_time_as_ical_string_r (t2);
+
+               g_error ("Failure: dtend doesn't match, expected '%s', got '%s'\n", str1, str2);
+
+               g_free (str1);
+               g_free (str2);
+       }
+
+       g_clear_object (&t1);
+       g_clear_object (&t2);
 }
 
 static void
@@ -58,9 +78,9 @@ test_create_object_sync (ETestServerFixture *fixture,
                          gconstpointer user_data)
 {
        ECalClient *cal_client;
-       icalcomponent *icalcomp;
-       icalcomponent *icalcomp2 = NULL, *clone;
-       struct icaltimetype now;
+       ICalComponent *icomp;
+       ICalComponent *icomp2 = NULL, *clone;
+       ICalTimetype *dtstart, *dtend;
        GError *error = NULL;
        GSList *ecalcomps = NULL;
        gchar *uid = NULL;
@@ -68,24 +88,30 @@ test_create_object_sync (ETestServerFixture *fixture,
        cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
 
        /* Build up new component */
-       now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-       icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-       icalcomponent_set_summary (icalcomp, "Test event summary");
-       icalcomponent_set_dtstart (icalcomp, now);
-       icalcomponent_set_dtend   (icalcomp, icaltime_from_timet_with_zone (icaltime_as_timet (now) + 60 * 60 
* 60, 0, NULL));
+       dtstart = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+       dtend = i_cal_timetype_new_clone (dtstart);
+       i_cal_time_adjust (dtend, 0, 1, 0, 0);
+
+       icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       i_cal_component_set_summary (icomp, "Test event summary");
+       i_cal_component_set_dtstart (icomp, dtstart);
+       i_cal_component_set_dtend (icomp, dtend);
 
-       if (!e_cal_client_create_object_sync (cal_client, icalcomp, &uid, NULL, &error))
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
+
+       if (!e_cal_client_create_object_sync (cal_client, icomp, &uid, NULL, &error))
                g_error ("create object sync: %s", error->message);
 
-       if (!e_cal_client_get_object_sync (cal_client, uid, NULL, &icalcomp2, NULL, &error))
+       if (!e_cal_client_get_object_sync (cal_client, uid, NULL, &icomp2, NULL, &error))
                g_error ("get object sync: %s", error->message);
 
-       clone = icalcomponent_new_clone (icalcomp);
-       icalcomponent_set_uid (clone, uid);
+       clone = i_cal_component_new_clone (icomp);
+       i_cal_component_set_uid (clone, uid);
 
-       test_icalcomps (clone, icalcomp2);
+       test_icomps (clone, icomp2);
 
-       icalcomponent_free (icalcomp2);
+       g_object_unref (icomp2);
 
        if (!e_cal_client_get_objects_for_uid_sync (cal_client, uid, &ecalcomps, NULL, &error))
                g_error ("get objects for uid sync: %s", error->message);
@@ -95,18 +121,18 @@ test_create_object_sync (ETestServerFixture *fixture,
        else {
                ECalComponent *ecalcomp = ecalcomps->data;
 
-               test_icalcomps (clone, e_cal_component_get_icalcomponent (ecalcomp));
+               test_icomps (clone, e_cal_component_get_icalcomponent (ecalcomp));
        }
-       e_cal_client_free_ecalcomp_slist (ecalcomps);
+       e_util_free_nullable_object_slist (ecalcomps);
 
-       icalcomponent_free (clone);
+       g_object_unref (clone);
+       g_object_unref (icomp);
        g_free (uid);
-       icalcomponent_free (icalcomp);
 }
 
 typedef struct {
-       icalcomponent *icalcomp;
-       icalcomponent *clone;
+       ICalComponent *icomp;
+       ICalComponent *clone;
        GMainLoop *loop;
 } AsyncData;
 
@@ -118,10 +144,10 @@ async_read2_result_ready (GObject *source_object,
        ECalClient *cal_client;
        GError *error = NULL;
        AsyncData *data = (AsyncData *) user_data;
-       icalcomponent *icalcomp1 = data->clone;
+       ICalComponent *icomp1 = data->clone;
        GSList *ecalcomps = NULL;
 
-       g_return_if_fail (icalcomp1 != NULL);
+       g_return_if_fail (icomp1 != NULL);
 
        cal_client = E_CAL_CLIENT (source_object);
 
@@ -133,11 +159,11 @@ async_read2_result_ready (GObject *source_object,
        else {
                ECalComponent *ecalcomp = ecalcomps->data;
 
-               test_icalcomps (icalcomp1, e_cal_component_get_icalcomponent (ecalcomp));
+               test_icomps (icomp1, e_cal_component_get_icalcomponent (ecalcomp));
        }
-       e_cal_client_free_ecalcomp_slist (ecalcomps);
+       e_util_free_nullable_object_slist (ecalcomps);
 
-       icalcomponent_free (icalcomp1);
+       g_object_unref (icomp1);
        g_main_loop_quit (data->loop);
 }
 
@@ -149,19 +175,19 @@ async_read_result_ready (GObject *source_object,
        ECalClient *cal_client;
        GError *error = NULL;
        AsyncData *data = (AsyncData *) user_data;
-       icalcomponent *icalcomp1 = data->clone, *icalcomp2 = NULL;
+       ICalComponent *icomp1 = data->clone, *icomp2 = NULL;
 
-       g_return_if_fail (icalcomp1 != NULL);
+       g_return_if_fail (icomp1 != NULL);
 
        cal_client = E_CAL_CLIENT (source_object);
-       if (!e_cal_client_get_object_finish (cal_client, result, &icalcomp2, &error))
+       if (!e_cal_client_get_object_finish (cal_client, result, &icomp2, &error))
                g_error ("get object finish: %s", error->message);
 
-       test_icalcomps (icalcomp1, icalcomp2);
-       icalcomponent_free (icalcomp2);
+       test_icomps (icomp1, icomp2);
+       g_object_unref (icomp2);
 
        e_cal_client_get_objects_for_uid (cal_client,
-                                         icalcomponent_get_uid (icalcomp1), NULL,
+                                         i_cal_component_get_uid (icomp1), NULL,
                                          async_read2_result_ready, data);
 }
 
@@ -174,17 +200,17 @@ async_write_result_ready (GObject *source_object,
        GError *error = NULL;
        gchar *uid = NULL;
        AsyncData *data = (AsyncData *) user_data;
-       icalcomponent *clone, *icalcomp = data->icalcomp;
+       ICalComponent *clone, *icomp = data->icomp;
 
-       g_return_if_fail (icalcomp != NULL);
+       g_return_if_fail (icomp != NULL);
 
        cal_client = E_CAL_CLIENT (source_object);
 
        if (!e_cal_client_create_object_finish (cal_client, result, &uid, &error))
                g_error ("create object finish: %s", error->message);
 
-       clone = icalcomponent_new_clone (icalcomp);
-       icalcomponent_set_uid (clone, uid);
+       clone = i_cal_component_new_clone (icomp);
+       i_cal_component_set_uid (clone, uid);
 
        data->clone = clone;
        e_cal_client_get_object (cal_client, uid, NULL, NULL, async_read_result_ready, data);
@@ -196,25 +222,31 @@ test_create_object_async (ETestServerFixture *fixture,
                           gconstpointer user_data)
 {
        ECalClient *cal_client;
-       icalcomponent *icalcomp;
-       struct icaltimetype now;
+       ICalComponent *icomp;
+       ICalTimetype *dtstart, *dtend;
        AsyncData data = { 0, };
 
        cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
 
        /* Build up new component */
-       now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-       icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-       icalcomponent_set_summary (icalcomp, "Test event summary");
-       icalcomponent_set_dtstart (icalcomp, now);
-       icalcomponent_set_dtend   (icalcomp, icaltime_from_timet_with_zone (icaltime_as_timet (now) + 60 * 60 
* 60, 0, NULL));
+       dtstart = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+       dtend = i_cal_timetype_new_clone (dtstart);
+       i_cal_time_adjust (dtend, 0, 1, 0, 0);
+
+       icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       i_cal_component_set_summary (icomp, "Test event summary");
+       i_cal_component_set_dtstart (icomp, dtstart);
+       i_cal_component_set_dtend (icomp, dtend);
+
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
 
-       data.icalcomp = icalcomp;
+       data.icomp = icomp;
        data.loop = fixture->loop;
-       e_cal_client_create_object (cal_client, icalcomp, NULL, async_write_result_ready, &data);
+       e_cal_client_create_object (cal_client, icomp, NULL, async_write_result_ready, &data);
        g_main_loop_run (fixture->loop);
 
-       icalcomponent_free (icalcomp);
+       g_object_unref (icomp);
 }
 
 gint
diff --git a/tests/libecal/test-cal-client-get-attachment-uris.c 
b/tests/libecal/test-cal-client-get-attachment-uris.c
index 48dd415f3..815f2bfa7 100644
--- a/tests/libecal/test-cal-client-get-attachment-uris.c
+++ b/tests/libecal/test-cal-client-get-attachment-uris.c
@@ -30,48 +30,53 @@ static ETestServerClosure cal_closure_async =
        { E_TEST_SERVER_CALENDAR, NULL, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, FALSE, NULL, TRUE };
 
 static void
-add_attach (icalcomponent *icalcomp,
+add_attach (ICalComponent *icomp,
             const gchar *uri)
 {
-       gsize buf_size;
        gchar *buf;
-       icalproperty *prop;
-       icalattach *attach;
+       ICalProperty *prop;
+       ICalAttach *attach;
 
-       g_return_if_fail (icalcomp != NULL);
+       g_return_if_fail (icomp != NULL);
        g_return_if_fail (uri != NULL);
 
-       buf_size = 2 * strlen (uri);
-       buf = g_malloc0 (buf_size);
-       icalvalue_encode_ical_string (uri, buf, buf_size);
-       attach = icalattach_new_from_url (uri);
-       prop = icalproperty_new_attach (attach);
-       icalcomponent_add_property (icalcomp, prop);
-       icalattach_unref (attach);
+       buf = i_cal_value_encode_ical_string (uri);
+       attach = i_cal_attach_new_from_url (buf);
+       prop = i_cal_property_new_attach (attach);
+       i_cal_component_take_property (icomp, prop);
+       g_object_unref (attach);
        g_free (buf);
 }
 
 static const gchar *
 setup_cal (ECalClient *cal_client)
 {
-       icalcomponent *icalcomp;
-       struct icaltimetype now;
+       ICalComponent *icomp;
+       ICalTimetype *dtstart, *dtend;
        gchar *uid = NULL;
        GError *error = NULL;
 
-       now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-       icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-       icalcomponent_set_summary (icalcomp, "Test event summary");
-       icalcomponent_set_dtstart (icalcomp, now);
-       icalcomponent_set_dtend   (icalcomp, icaltime_from_timet_with_zone (icaltime_as_timet (now) + 60 * 60 
* 60, 0, NULL));
-       add_attach (icalcomp, ATTACH1);
-       add_attach (icalcomp, ATTACH2);
-       add_attach (icalcomp, ATTACH3);
+       dtstart = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+       dtend = i_cal_timetype_new_clone (dtstart);
+       i_cal_time_adjust (dtend, 0, 1, 0, 0);
 
-       if (!e_cal_client_create_object_sync (cal_client, icalcomp, &uid, NULL, &error))
+       icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       i_cal_component_set_summary (icomp, "Test event summary");
+       i_cal_component_set_dtstart (icomp, dtstart);
+       i_cal_component_set_dtend (icomp, dtend);
+
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
+
+       add_attach (icomp, ATTACH1);
+       add_attach (icomp, ATTACH2);
+       add_attach (icomp, ATTACH3);
+
+       if (!e_cal_client_create_object_sync (cal_client, icomp, &uid, NULL, &error))
                g_error ("create object sync: %s", error->message);
 
-       icalcomponent_free (icalcomp);
+       g_object_unref (icomp);
+
        g_object_set_data_full (G_OBJECT (cal_client), "use-uid", uid, g_free);
 
        return uid;
diff --git a/tests/libecal/test-cal-client-get-free-busy.c b/tests/libecal/test-cal-client-get-free-busy.c
index 12ebbc610..41abd46b3 100644
--- a/tests/libecal/test-cal-client-get-free-busy.c
+++ b/tests/libecal/test-cal-client-get-free-busy.c
@@ -107,16 +107,16 @@ add_component_sync (ECalClient *cal_client)
                "CREATED:20040211T080000Z\r\n"
                "LAST-MODIFIED:20040211T080000Z\r\n"
                "END:VEVENT\r\n";
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
        GError *error = NULL;
 
-       icalcomp = icalcomponent_new_from_string (comp_str);
-       g_assert_nonnull (icalcomp);
+       icomp = i_cal_component_new_from_string (comp_str);
+       g_assert_nonnull (icomp);
 
-       if (!e_cal_client_create_object_sync (cal_client, icalcomp, NULL, NULL, &error))
+       if (!e_cal_client_create_object_sync (cal_client, icomp, NULL, NULL, &error))
                g_error ("Failed to add component: %s", error ? error->message : "Unknown error");
 
-       icalcomponent_free (icalcomp);
+       g_object_unref (icomp);
        g_clear_error (&error);
 }
 
@@ -150,7 +150,7 @@ test_get_free_busy_sync (ETestServerFixture *fixture,
 {
        ECalClient *cal_client;
        GError *error = NULL;
-       icaltimezone *utc;
+       ICalTimezone *utc;
        GSList *users = NULL, *freebusy_data = NULL;
        time_t start, end;
 
@@ -163,7 +163,7 @@ test_get_free_busy_sync (ETestServerFixture *fixture,
 
        g_signal_connect (cal_client, "free-busy-data", G_CALLBACK (free_busy_data_cb), (gpointer) G_STRFUNC);
 
-       utc = icaltimezone_get_utc_timezone ();
+       utc = i_cal_timezone_get_utc_timezone ();
        start = time_from_isodate ("20040212T000000Z");
        end = time_add_day_with_zone (start, 2, utc);
        users = g_slist_append (users, (gpointer) USER_EMAIL);
@@ -211,7 +211,7 @@ test_get_free_busy_async (ETestServerFixture *fixture,
                           gconstpointer user_data)
 {
        ECalClient *cal_client;
-       icaltimezone *utc;
+       ICalTimezone *utc;
        GSList *users = NULL;
        time_t start, end;
 
@@ -222,7 +222,7 @@ test_get_free_busy_async (ETestServerFixture *fixture,
        /* This is set by the free-busy-data callback */
        received_free_busy_data = FALSE;
 
-       utc = icaltimezone_get_utc_timezone ();
+       utc = i_cal_timezone_get_utc_timezone ();
        start = time_from_isodate ("20040212T000000Z");
        end = time_add_day_with_zone (start, 2, utc);
        users = g_slist_append (users, (gpointer) USER_EMAIL);
diff --git a/tests/libecal/test-cal-client-get-object-list.c b/tests/libecal/test-cal-client-get-object-list.c
index 45e333ae5..0e19c7925 100644
--- a/tests/libecal/test-cal-client-get-object-list.c
+++ b/tests/libecal/test-cal-client-get-object-list.c
@@ -30,29 +30,35 @@ static ETestServerClosure cal_closure_async =
 static void
 setup_cal (ECalClient *cal_client)
 {
-       struct icaltimetype now;
-       icalcomponent *icalcomp;
+       ICalTimetype *dtstart, *dtend;
+       ICalComponent *icomp;
        gchar *uid = NULL;
        GError *error = NULL;
 
-       now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-       icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-       icalcomponent_set_summary (icalcomp, EVENT_SUMMARY);
-       icalcomponent_set_dtstart (icalcomp, now);
-       icalcomponent_set_dtend   (icalcomp, icaltime_from_timet_with_zone (icaltime_as_timet (now) + 60 * 60 
* 60, 0, NULL));
+       dtstart = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+       dtend = i_cal_timetype_new_clone (dtstart);
+       i_cal_time_adjust (dtend, 0, 1, 0, 0);
 
-       if (!e_cal_client_create_object_sync (cal_client, icalcomp, &uid, NULL, &error))
+       icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       i_cal_component_set_summary (icomp, EVENT_SUMMARY);
+       i_cal_component_set_dtstart (icomp, dtstart);
+       i_cal_component_set_dtend (icomp, dtend);
+
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
+
+       if (!e_cal_client_create_object_sync (cal_client, icomp, &uid, NULL, &error))
                g_error ("create object sync: %s", error->message);
 
-       icalcomponent_free (icalcomp);
+       g_object_unref (icomp);
        g_free (uid);
 }
 
 static void
-test_result (icalcomponent *icalcomp)
+test_result (ICalComponent *icomp)
 {
-       g_assert (icalcomp != NULL);
-       g_assert_cmpstr (icalcomponent_get_summary (icalcomp), ==, EVENT_SUMMARY);
+       g_assert_nonnull (icomp);
+       g_assert_cmpstr (i_cal_component_get_summary (icomp), ==, EVENT_SUMMARY);
 }
 
 static void
@@ -60,19 +66,19 @@ test_get_object_list_sync (ETestServerFixture *fixture,
                            gconstpointer user_data)
 {
        ECalClient *cal_client;
-       GSList *icalcomps = NULL, *ecalcomps = NULL;
+       GSList *icomps = NULL, *ecalcomps = NULL;
        GError *error = NULL;
 
        cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
        setup_cal (cal_client);
 
-       if (!e_cal_client_get_object_list_sync (cal_client, EVENT_QUERY, &icalcomps, NULL, &error))
+       if (!e_cal_client_get_object_list_sync (cal_client, EVENT_QUERY, &icomps, NULL, &error))
                g_error ("get object list sync: %s", error->message);
 
-       g_assert_cmpint (g_slist_length (icalcomps), ==, 1);
-       test_result (icalcomps->data);
+       g_assert_cmpint (g_slist_length (icomps), ==, 1);
+       test_result (icomps->data);
 
-       e_cal_client_free_icalcomp_slist (icalcomps);
+       e_util_free_nullable_object_slist (icomps);
 
        if (!e_cal_client_get_object_list_as_comps_sync (cal_client, EVENT_QUERY, &ecalcomps, NULL, &error))
                g_error ("get object list as comps sync: %s", error->message);
@@ -80,7 +86,7 @@ test_get_object_list_sync (ETestServerFixture *fixture,
        g_assert_cmpint (g_slist_length (ecalcomps), ==, 1);
        test_result (e_cal_component_get_icalcomponent (ecalcomps->data));
 
-       e_cal_client_free_ecalcomp_slist (ecalcomps);
+       e_util_free_nullable_object_slist (ecalcomps);
 }
 
 static void
@@ -101,7 +107,7 @@ async_get_object_list_as_comps_result_ready (GObject *source_object,
        g_assert_cmpint (g_slist_length (ecalcomps), ==, 1);
        test_result (e_cal_component_get_icalcomponent (ecalcomps->data));
 
-       e_cal_client_free_ecalcomp_slist (ecalcomps);
+       e_util_free_nullable_object_slist (ecalcomps);
        g_main_loop_quit (loop);
 }
 
@@ -112,16 +118,16 @@ async_get_object_list_result_ready (GObject *source_object,
 {
        ECalClient *cal_client;
        GError *error = NULL;
-       GSList *icalcomps = NULL;
+       GSList *icomps = NULL;
 
        cal_client = E_CAL_CLIENT (source_object);
 
-       if (!e_cal_client_get_object_list_finish (cal_client, result, &icalcomps, &error))
+       if (!e_cal_client_get_object_list_finish (cal_client, result, &icomps, &error))
                g_error ("get object list finish: %s", error->message);
 
-       g_assert_cmpint (g_slist_length (icalcomps), ==, 1);
-       test_result (icalcomps->data);
-       e_cal_client_free_icalcomp_slist (icalcomps);
+       g_assert_cmpint (g_slist_length (icomps), ==, 1);
+       test_result (icomps->data);
+       e_util_free_nullable_object_slist (icomps);
 
        e_cal_client_get_object_list_as_comps (
                cal_client, EVENT_QUERY, NULL,
diff --git a/tests/libecal/test-cal-client-get-revision.c b/tests/libecal/test-cal-client-get-revision.c
index 96887a360..5b99ccf3b 100644
--- a/tests/libecal/test-cal-client-get-revision.c
+++ b/tests/libecal/test-cal-client-get-revision.c
@@ -28,23 +28,29 @@ static ETestServerClosure cal_closure =
 static void
 get_revision_compare_cycle (ECalClient *client)
 {
-       icalcomponent *icalcomp;
-       struct icaltimetype now;
-       gchar    *revision_before = NULL, *revision_after = NULL, *uid = NULL;
+       ICalComponent *icomp;
+       ICalTimetype *dtstart, *dtend;
+       gchar *revision_before = NULL, *revision_after = NULL, *uid = NULL;
        GError   *error = NULL;
 
        /* Build up new component */
-       now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-       icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-       icalcomponent_set_summary (icalcomp, "Test event summary");
-       icalcomponent_set_dtstart (icalcomp, now);
-       icalcomponent_set_dtend   (icalcomp, icaltime_from_timet_with_zone (icaltime_as_timet (now) + 60 * 60 
* 60, 0, NULL));
+       dtstart = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+       dtend = i_cal_timetype_new_clone (dtstart);
+       i_cal_time_adjust (dtend, 0, 1, 0, 0);
+
+       icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       i_cal_component_set_summary (icomp, "Test event summary");
+       i_cal_component_set_dtstart (icomp, dtstart);
+       i_cal_component_set_dtend (icomp, dtend);
+
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
 
        if (!e_client_get_backend_property_sync (E_CLIENT (client), CLIENT_BACKEND_PROPERTY_REVISION,
                                                &revision_before, NULL, &error))
                g_error ("Error getting calendar revision: %s", error->message);
 
-       if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, &error))
+       if (!e_cal_client_create_object_sync (client, icomp, &uid, NULL, &error))
                g_error ("Error creating object: %s", error->message);
 
        if (!e_cal_client_remove_object_sync (client, uid, NULL, E_CAL_OBJ_MOD_ALL, NULL, &error))
@@ -66,7 +72,7 @@ get_revision_compare_cycle (ECalClient *client)
        g_free (revision_after);
        g_free (uid);
 
-       icalcomponent_free (icalcomp);
+       g_object_unref (icomp);
 }
 
 static void
diff --git a/tests/libecal/test-cal-client-get-view.c b/tests/libecal/test-cal-client-get-view.c
index 220dcd32b..4af213c59 100644
--- a/tests/libecal/test-cal-client-get-view.c
+++ b/tests/libecal/test-cal-client-get-view.c
@@ -112,35 +112,37 @@ alter_cal_client (gpointer user_data)
 {
        ECalClient *cal_client = user_data;
        GError *error = NULL;
-       ICalComponent *comp;
-       ICalTimetype *now, *itt;
+       ICalComponent *icomp;
+       ICalTimetype *dtstart, *dtend;
        gchar *uid = NULL;
 
        g_return_val_if_fail (cal_client != NULL, NULL);
 
-       now = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
-       itt = i_cal_time_from_timet_with_zone (i_cal_time_as_timet (now) + 60 * 60 * 60, 0, NULL);
+       dtstart = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+       dtend = i_cal_timetype_new_clone (dtstart);
+       i_cal_time_adjust (dtend, 0, 1, 0, 0);
 
-       comp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
-       i_cal_component_set_summary (comp, "Initial event summary");
-       i_cal_component_set_dtstart (comp, now);
-       i_cal_component_set_dtend (comp, itt);
+       icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       i_cal_component_set_summary (icomp, "Initial event summary");
+       i_cal_component_set_dtstart (icomp, dtstart);
+       i_cal_component_set_dtend (icomp, dtend);
 
-       if (!e_cal_client_create_object_sync (cal_client, comp, &uid, NULL, &error))
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
+
+       if (!e_cal_client_create_object_sync (cal_client, icomp, &uid, NULL, &error))
                g_error ("create object sync: %s", error->message);
 
-       i_cal_component_set_uid (comp, uid);
-       i_cal_component_set_summary (comp, "Modified event summary");
+       i_cal_component_set_uid (icomp, uid);
+       i_cal_component_set_summary (icomp, "Modified event summary");
 
-       if (!e_cal_client_modify_object_sync (cal_client, comp, E_CAL_OBJ_MOD_ALL, NULL, &error))
+       if (!e_cal_client_modify_object_sync (cal_client, icomp, E_CAL_OBJ_MOD_ALL, NULL, &error))
                g_error ("modify object sync: %s", error->message);
 
        if (!e_cal_client_remove_object_sync (cal_client, uid, NULL, E_CAL_OBJ_MOD_ALL, NULL, &error))
                g_error ("remove object sync: %s", error->message);
 
-       g_object_unref (comp);
-       g_object_unref (itt);
-       g_object_unref (now);
+       g_object_unref (icomp);
        g_free (uid);
 
        return FALSE;
diff --git a/tests/libecal/test-cal-client-modify-object.c b/tests/libecal/test-cal-client-modify-object.c
index 7bc0ef579..09218a248 100644
--- a/tests/libecal/test-cal-client-modify-object.c
+++ b/tests/libecal/test-cal-client-modify-object.c
@@ -29,29 +29,35 @@ static ETestServerClosure cal_closure_async =
 static void
 setup_cal (ECalClient *cal_client)
 {
-       struct icaltimetype now;
-       icalcomponent *icalcomp;
+       ICalTimetype *dtstart, *dtend;
+       ICalComponent *icomp;
        gchar *uid = NULL;
        GError *error = NULL;
 
-       now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-       icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-       icalcomponent_set_summary (icalcomp, "Initial" EVENT_SUMMARY);
-       icalcomponent_set_dtstart (icalcomp, now);
-       icalcomponent_set_dtend   (icalcomp, icaltime_from_timet_with_zone (icaltime_as_timet (now) + 60 * 60 
* 60, 0, NULL));
+       dtstart = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+       dtend = i_cal_timetype_new_clone (dtstart);
+       i_cal_time_adjust (dtend, 0, 1, 0, 0);
 
-       if (!e_cal_client_create_object_sync (cal_client, icalcomp, &uid, NULL, &error))
+       icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       i_cal_component_set_summary (icomp, "Initial" EVENT_SUMMARY);
+       i_cal_component_set_dtstart (icomp, dtstart);
+       i_cal_component_set_dtend (icomp, dtend);
+
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
+
+       if (!e_cal_client_create_object_sync (cal_client, icomp, &uid, NULL, &error))
                g_error ("create object sync: %s", error->message);
 
-       icalcomponent_free (icalcomp);
+       g_object_unref (icomp);
        g_object_set_data_full (G_OBJECT (cal_client), "use-uid", uid, g_free);
 }
 
 static void
-test_result (icalcomponent *icalcomp)
+test_result (ICalComponent *icomp)
 {
-       g_assert (icalcomp != NULL);
-       g_assert_cmpstr (icalcomponent_get_summary (icalcomp), ==, EVENT_SUMMARY);
+       g_assert_nonnull (icomp);
+       g_assert_cmpstr (i_cal_component_get_summary (icomp), ==, EVENT_SUMMARY);
 }
 
 static void
@@ -60,7 +66,7 @@ test_modify_object_sync (ETestServerFixture *fixture,
 {
        ECalClient *cal_client;
        GError *error = NULL;
-       icalcomponent *icalcomp = NULL;
+       ICalComponent *icomp = NULL;
        const gchar *uid;
 
        cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
@@ -69,21 +75,21 @@ test_modify_object_sync (ETestServerFixture *fixture,
        uid = g_object_get_data (G_OBJECT (cal_client), "use-uid");
        g_assert (uid != NULL);
 
-       if (!e_cal_client_get_object_sync (cal_client, uid, NULL, &icalcomp, NULL, &error))
+       if (!e_cal_client_get_object_sync (cal_client, uid, NULL, &icomp, NULL, &error))
                g_error ("get object sync: %s", error->message);
 
-       icalcomponent_set_summary (icalcomp, EVENT_SUMMARY);
+       i_cal_component_set_summary (icomp, EVENT_SUMMARY);
 
-       if (!e_cal_client_modify_object_sync (cal_client, icalcomp, E_CAL_OBJ_MOD_ALL, NULL, &error))
+       if (!e_cal_client_modify_object_sync (cal_client, icomp, E_CAL_OBJ_MOD_ALL, NULL, &error))
                g_error ("modify object sync: %s", error->message);
 
-       icalcomponent_free (icalcomp);
+       g_object_unref (icomp);
 
-       if (!e_cal_client_get_object_sync (cal_client, uid, NULL, &icalcomp, NULL, &error))
+       if (!e_cal_client_get_object_sync (cal_client, uid, NULL, &icomp, NULL, &error))
                g_error ("get object sync after modification: %s", error->message);
 
-       test_result (icalcomp);
-       icalcomponent_free (icalcomp);
+       test_result (icomp);
+       g_object_unref (icomp);
 }
 
 static void
@@ -93,7 +99,7 @@ async_modify_result_ready (GObject *source_object,
 {
        ECalClient *cal_client;
        GError *error = NULL;
-       icalcomponent *icalcomp = NULL;
+       ICalComponent *icomp = NULL;
        const gchar *uid;
        GMainLoop *loop = (GMainLoop *) user_data;
 
@@ -103,11 +109,11 @@ async_modify_result_ready (GObject *source_object,
        if (!e_cal_client_modify_object_finish (cal_client, result, &error))
                g_error ("modify object finish: %s", error->message);
 
-       if (!e_cal_client_get_object_sync (cal_client, uid, NULL, &icalcomp, NULL, &error))
+       if (!e_cal_client_get_object_sync (cal_client, uid, NULL, &icomp, NULL, &error))
                g_error ("get object sync after async modification: %s", error->message);
 
-       test_result (icalcomp);
-       icalcomponent_free (icalcomp);
+       test_result (icomp);
+       g_object_unref (icomp);
 
        g_main_loop_quit (loop);
 }
@@ -118,7 +124,7 @@ test_modify_object_async (ETestServerFixture *fixture,
 {
        ECalClient *cal_client;
        GError *error = NULL;
-       icalcomponent *icalcomp = NULL;
+       ICalComponent *icomp = NULL;
        const gchar *uid;
 
        cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
@@ -127,13 +133,13 @@ test_modify_object_async (ETestServerFixture *fixture,
        uid = g_object_get_data (G_OBJECT (cal_client), "use-uid");
        g_assert (uid != NULL);
 
-       if (!e_cal_client_get_object_sync (cal_client, uid, NULL, &icalcomp, NULL, &error))
+       if (!e_cal_client_get_object_sync (cal_client, uid, NULL, &icomp, NULL, &error))
                g_error ("get object sync: %s", error->message);
 
-       icalcomponent_set_summary (icalcomp, EVENT_SUMMARY);
+       i_cal_component_set_summary (icomp, EVENT_SUMMARY);
 
-       e_cal_client_modify_object (cal_client, icalcomp, E_CAL_OBJ_MOD_ALL, NULL, async_modify_result_ready, 
fixture->loop);
-       icalcomponent_free (icalcomp);
+       e_cal_client_modify_object (cal_client, icomp, E_CAL_OBJ_MOD_ALL, NULL, async_modify_result_ready, 
fixture->loop);
+       g_object_unref (icomp);
 
        g_main_loop_run (fixture->loop);
 }
diff --git a/tests/libecal/test-cal-client-receive-objects.c b/tests/libecal/test-cal-client-receive-objects.c
index afc656a19..074e4be99 100644
--- a/tests/libecal/test-cal-client-receive-objects.c
+++ b/tests/libecal/test-cal-client-receive-objects.c
@@ -24,19 +24,25 @@ static ETestServerClosure cal_closure_sync =
 static ETestServerClosure cal_closure_async =
        { E_TEST_SERVER_CALENDAR, NULL, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, FALSE, NULL, TRUE };
 
-static icalcomponent *
+static ICalComponent *
 create_object (void)
 {
-       icalcomponent *icalcomp;
-       struct icaltimetype now;
+       ICalTimetype *dtstart, *dtend;
+       ICalComponent *icomp;
 
-       now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-       icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-       icalcomponent_set_summary (icalcomp, "To-be-received event summary");
-       icalcomponent_set_dtstart (icalcomp, now);
-       icalcomponent_set_dtend   (icalcomp, icaltime_from_timet_with_zone (icaltime_as_timet (now) + 60 * 60 
* 60, 0, NULL));
+       dtstart = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+       dtend = i_cal_timetype_new_clone (dtstart);
+       i_cal_time_adjust (dtend, 0, 1, 0, 0);
 
-       return icalcomp;
+       icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       i_cal_component_set_summary (icomp, "To-be-received event summary");
+       i_cal_component_set_dtstart (icomp, dtstart);
+       i_cal_component_set_dtend (icomp, dtend);
+
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
+
+       return icomp;
 }
 
 static void
@@ -45,17 +51,17 @@ test_receive_objects_sync (ETestServerFixture *fixture,
 {
        ECalClient *cal_client;
        GError *error = NULL;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
 
        cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
 
-       icalcomp = create_object ();
-       g_assert (icalcomp != NULL);
+       icomp = create_object ();
+       g_assert_nonnull (icomp);
 
-       if (!e_cal_client_receive_objects_sync (cal_client, icalcomp, NULL, &error))
+       if (!e_cal_client_receive_objects_sync (cal_client, icomp, NULL, &error))
                g_error ("receive objects sync: %s", error->message);
 
-       icalcomponent_free (icalcomp);
+       g_object_unref (icomp);
 }
 
 static void
@@ -80,15 +86,15 @@ test_receive_objects_async (ETestServerFixture *fixture,
                             gconstpointer user_data)
 {
        ECalClient *cal_client;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
 
        cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
 
-       icalcomp = create_object ();
-       g_assert (icalcomp != NULL);
+       icomp = create_object ();
+       g_assert_nonnull (icomp);
 
-       e_cal_client_receive_objects (cal_client, icalcomp, NULL, async_receive_result_ready, fixture->loop);
-       icalcomponent_free (icalcomp);
+       e_cal_client_receive_objects (cal_client, icomp, NULL, async_receive_result_ready, fixture->loop);
+       g_object_unref (icomp);
 
        g_main_loop_run (fixture->loop);
 }
diff --git a/tests/libecal/test-cal-client-refresh.c b/tests/libecal/test-cal-client-refresh.c
index a17892cd8..3da09fe7b 100644
--- a/tests/libecal/test-cal-client-refresh.c
+++ b/tests/libecal/test-cal-client-refresh.c
@@ -29,20 +29,26 @@ static void
 setup_cal (ECalClient *cal_client)
 {
        GError *error = NULL;
-       icalcomponent *icalcomp;
-       struct icaltimetype now;
+       ICalComponent *icomp;
+       ICalTimetype *dtstart, *dtend;
        gchar *uid = NULL;
 
-       now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-       icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-       icalcomponent_set_summary (icalcomp, "Test event summary");
-       icalcomponent_set_dtstart (icalcomp, now);
-       icalcomponent_set_dtend   (icalcomp, icaltime_from_timet_with_zone (icaltime_as_timet (now) + 60 * 60 
* 60, 0, NULL));
+       dtstart = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+       dtend = i_cal_timetype_new_clone (dtstart);
+       i_cal_time_adjust (dtend, 0, 1, 0, 0);
 
-       if (!e_cal_client_create_object_sync (cal_client, icalcomp, &uid, NULL, &error))
+       icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       i_cal_component_set_summary (icomp, "Test event summary");
+       i_cal_component_set_dtstart (icomp, dtstart);
+       i_cal_component_set_dtend (icomp, dtend);
+
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
+
+       if (!e_cal_client_create_object_sync (cal_client, icomp, &uid, NULL, &error))
                g_error ("create object sync: %s", error->message);
 
-       icalcomponent_free (icalcomp);
+       g_object_unref (icomp);
        g_free (uid);
 }
 
@@ -126,4 +132,3 @@ main (gint argc,
 
        return e_test_server_utils_run ();
 }
-
diff --git a/tests/libecal/test-cal-client-remove-object.c b/tests/libecal/test-cal-client-remove-object.c
index 200eaad2d..98902b0f0 100644
--- a/tests/libecal/test-cal-client-remove-object.c
+++ b/tests/libecal/test-cal-client-remove-object.c
@@ -27,23 +27,29 @@ static ETestServerClosure cal_closure_async =
 static gchar *
 create_object (ECalClient *cal_client)
 {
-       icalcomponent *icalcomp;
-       struct icaltimetype now;
+       ICalComponent *icomp;
+       ICalTimetype *dtstart, *dtend;
        gchar *uid = NULL;
        GError *error = NULL;
 
        g_return_val_if_fail (cal_client != NULL, NULL);
 
-       now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-       icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-       icalcomponent_set_summary (icalcomp, "To-be-removed event summary");
-       icalcomponent_set_dtstart (icalcomp, now);
-       icalcomponent_set_dtend   (icalcomp, icaltime_from_timet_with_zone (icaltime_as_timet (now) + 60 * 60 
* 60, 0, NULL));
+       dtstart = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+       dtend = i_cal_timetype_new_clone (dtstart);
+       i_cal_time_adjust (dtend, 0, 1, 0, 0);
 
-       if (!e_cal_client_create_object_sync (cal_client, icalcomp, &uid, NULL, &error))
+       icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       i_cal_component_set_summary (icomp, "To-be-removed event summary");
+       i_cal_component_set_dtstart (icomp, dtstart);
+       i_cal_component_set_dtend (icomp, dtend);
+
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
+
+       if (!e_cal_client_create_object_sync (cal_client, icomp, &uid, NULL, &error))
                g_error ("create object sync: %s", error->message);
 
-       icalcomponent_free (icalcomp);
+       g_object_unref (icomp);
 
        return uid;
 }
diff --git a/tests/libecal/test-cal-client-revision-view.c b/tests/libecal/test-cal-client-revision-view.c
index a108d3221..804fe3528 100644
--- a/tests/libecal/test-cal-client-revision-view.c
+++ b/tests/libecal/test-cal-client-revision-view.c
@@ -69,7 +69,7 @@ get_last_modified (ICalComponent *component)
                res = i_cal_time_null_time ();
        }
 
-       g_clear_object (&innter);
+       g_clear_object (&inner);
 
        return res;
 }
@@ -88,7 +88,7 @@ objects_added_cb (GObject *object,
                ICalTimetype *last_modified = get_last_modified (component);
                gchar *str_recurrence, *str_last_modified;
 
-               str_recurrence = i_cal_time_as_ical_string (recurrence);
+               str_recurrence = i_cal_time_as_ical_string_r (recurrence);
                str_last_modified = i_cal_time_as_ical_string_r (last_modified);
 
                g_print (
@@ -122,7 +122,7 @@ objects_modified_cb (GObject *object,
                ICalTimetype *last_modified = get_last_modified (component);
                gchar *str_recurrence, *str_last_modified;
 
-               str_recurrence = i_cal_time_as_ical_string (recurrence);
+               str_recurrence = i_cal_time_as_ical_string_r (recurrence);
                str_last_modified = i_cal_time_as_ical_string_r (last_modified);
 
                g_print (
@@ -136,7 +136,7 @@ objects_modified_cb (GObject *object,
                g_free (str_recurrence);
                g_free (str_last_modified);
 
-               g_assert (icalcomponent_get_summary (component) == NULL);
+               g_assert (i_cal_component_get_summary (component) == NULL);
        }
 
        subtest_passed (SUBTEST_OBJECTS_MODIFIED, loop);
@@ -176,7 +176,7 @@ alter_cal_client (gpointer user_data)
 {
        ECalClient *cal_client = user_data;
        GError *error = NULL;
-       ICalComponent *comp;
+       ICalComponent *icomp;
        ICalTimetype *now, *itt;
        gchar *uid = NULL;
 
@@ -185,24 +185,24 @@ alter_cal_client (gpointer user_data)
        now = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
        itt = i_cal_time_from_timet_with_zone (i_cal_time_as_timet (now) + 60 * 60 * 60, 0, NULL);
 
-       comp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
-       i_cal_component_set_summary (comp, "Initial event summary");
-       i_cal_component_set_dtstart (comp, now);
-       i_cal_component_set_dtend   (comp, itt);
+       icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       i_cal_component_set_summary (icomp, "Initial event summary");
+       i_cal_component_set_dtstart (icomp, now);
+       i_cal_component_set_dtend   (icomp, itt);
 
-       if (!e_cal_client_create_object_sync (cal_client, comp, &uid, NULL, &error))
+       if (!e_cal_client_create_object_sync (cal_client, icomp, &uid, NULL, &error))
                g_error ("create object sync: %s", error->message);
 
-       i_cal_component_set_uid (comp, uid);
-       i_cal_component_set_summary (comp, "Modified event summary");
+       i_cal_component_set_uid (icomp, uid);
+       i_cal_component_set_summary (icomp, "Modified event summary");
 
-       if (!e_cal_client_modify_object_sync (cal_client, comp, E_CAL_OBJ_MOD_ALL, NULL, &error))
+       if (!e_cal_client_modify_object_sync (cal_client, icomp, E_CAL_OBJ_MOD_ALL, NULL, &error))
                g_error ("modify object sync: %s", error->message);
 
        if (!e_cal_client_remove_object_sync (cal_client, uid, NULL, E_CAL_OBJ_MOD_ALL, NULL, &error))
                g_error ("remove object sync: %s", error->message);
 
-       g_object_urnef (comp);
+       g_object_unref (icomp);
        g_object_unref (now);
        g_object_unref (itt);
        g_free (uid);
diff --git a/tests/libecal/test-cal-client-send-objects.c b/tests/libecal/test-cal-client-send-objects.c
index b7bd98d83..0ece68ad6 100644
--- a/tests/libecal/test-cal-client-send-objects.c
+++ b/tests/libecal/test-cal-client-send-objects.c
@@ -43,46 +43,44 @@ print_ecomp (ECalComponent *ecalcomp)
 }
 
 static void
-print_icomp (icalcomponent *icalcomp)
+print_icomp (ICalComponent *icomp)
 {
        ECalComponent *ecomp;
 
-       g_return_if_fail (icalcomp != NULL);
+       g_assert_nonnull (icomp);
 
-       ecomp = e_cal_component_new ();
-       icalcomp = icalcomponent_new_clone (icalcomp);
-
-       if (!e_cal_component_set_icalcomponent (ecomp, icalcomp)) {
-               icalcomponent_free (icalcomp);
-               g_object_unref (ecomp);
-               g_printerr ("%s: Failed to assing icalcomp to ECalComponent\n", G_STRFUNC);
-               g_print ("\n");
-               return;
-       }
+       ecomp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (icomp));
+       g_assert_nonnull (ecomp);
 
        print_ecomp (ecomp);
 
        g_object_unref (ecomp);
 }
 
-static icalcomponent *
+static ICalComponent *
 create_object (void)
 {
-       icalcomponent *icalcomp;
-       struct icaltimetype now;
+       ICalComponent *icomp;
+       ICalTimetype *dtstart, *dtend;
+
+       dtstart = i_cal_time_current_time_with_zone (i_cal_timezone_get_utc_timezone ());
+       dtend = i_cal_timetype_new_clone (dtstart);
+       i_cal_time_adjust (dtend, 0, 1, 0, 0);
+
+       icomp = i_cal_component_new (I_CAL_VEVENT_COMPONENT);
+       i_cal_component_set_summary (icomp, "To-be-sent event summary");
+       i_cal_component_set_dtstart (icomp, dtstart);
+       i_cal_component_set_dtend (icomp, dtend);
 
-       now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
-       icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
-       icalcomponent_set_summary (icalcomp, "To-be-sent event summary");
-       icalcomponent_set_dtstart (icalcomp, now);
-       icalcomponent_set_dtend   (icalcomp, icaltime_from_timet_with_zone (icaltime_as_timet (now) + 60 * 60 
* 60, 0, NULL));
+       g_clear_object (&dtstart);
+       g_clear_object (&dtend);
 
-       return icalcomp;
+       return icomp;
 }
 
 static void
 manage_result (GSList *users,
-               icalcomponent *modified_icalcomp)
+              ICalComponent *modified_icomp)
 {
        g_print ("Wishes to send to %d users", g_slist_length (users));
        if (users) {
@@ -95,14 +93,13 @@ manage_result (GSList *users,
        }
        g_print ("\n");
 
-       if (!modified_icalcomp)
-               g_print ("No modified icalcomp, would send the same\n");
+       if (!modified_icomp)
+               g_print ("No modified iCalendar component, would send the same\n");
        else
-               print_icomp (modified_icalcomp);
+               print_icomp (modified_icomp);
 
        e_client_util_free_string_slist (users);
-       if (modified_icalcomp)
-               icalcomponent_free (modified_icalcomp);
+       g_clear_object (&modified_icomp);
 }
 
 static void
@@ -111,17 +108,17 @@ test_send_objects_sync (ETestServerFixture *fixture,
 {
        ECalClient *cal_client;
        GError *error = NULL;
-       icalcomponent *icalcomp, *modified_icalcomp = NULL;
+       ICalComponent *icomp, *modified_icomp = NULL;
        GSList *users = NULL;
 
        cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
 
-       icalcomp = create_object ();
-       if (!e_cal_client_send_objects_sync (cal_client, icalcomp, &users, &modified_icalcomp, NULL, &error))
+       icomp = create_object ();
+       if (!e_cal_client_send_objects_sync (cal_client, icomp, &users, &modified_icomp, NULL, &error))
                g_error ("send objects sync: %s", error->message);
 
-       icalcomponent_free (icalcomp);
-       manage_result (users, modified_icalcomp);
+       g_object_unref (icomp);
+       manage_result (users, modified_icomp);
 }
 
 static void
@@ -132,15 +129,15 @@ async_send_result_ready (GObject *source_object,
        ECalClient *cal_client;
        GError *error = NULL;
        GSList *users = NULL;
-       icalcomponent *modified_icalcomp = NULL;
+       ICalComponent *modified_icomp = NULL;
        GMainLoop *loop = (GMainLoop *) user_data;
 
        cal_client = E_CAL_CLIENT (source_object);
 
-       if (!e_cal_client_send_objects_finish (cal_client, result, &users, &modified_icalcomp, &error))
+       if (!e_cal_client_send_objects_finish (cal_client, result, &users, &modified_icomp, &error))
                g_error ("send objects finish: %s", error->message);
 
-       manage_result (users, modified_icalcomp);
+       manage_result (users, modified_icomp);
        g_main_loop_quit (loop);
 }
 
@@ -149,15 +146,15 @@ test_send_objects_async (ETestServerFixture *fixture,
                         gconstpointer user_data)
 {
        ECalClient *cal_client;
-       icalcomponent *icalcomp;
+       ICalComponent *icomp;
 
        cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
 
-       icalcomp = create_object ();
-       g_assert (icalcomp);
+       icomp = create_object ();
+       g_assert_nonnull (icomp);
 
-       e_cal_client_send_objects (cal_client, icalcomp, NULL, async_send_result_ready, fixture->loop);
-       icalcomponent_free (icalcomp);
+       e_cal_client_send_objects (cal_client, icomp, NULL, async_send_result_ready, fixture->loop);
+       g_object_unref (icomp);
 
        g_main_loop_run (fixture->loop);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]