[evolution-data-server/treitter-test-suites] Add test for EDataCal method 'getFreeBusy'.



commit deca196249f752934b38394e3ddd0a31e9938395
Author: Travis Reitter <treitter gmail com>
Date:   Tue Dec 22 16:38:37 2009 -0800

    Add test for EDataCal method 'getFreeBusy'.

 calendar/tests/ecal/Makefile.am               |    3 ++
 calendar/tests/ecal/ecal-test-utils.c         |   32 ++++++++++++++++++++
 calendar/tests/ecal/ecal-test-utils.h         |    6 ++++
 calendar/tests/ecal/test-ecal-get-free-busy.c |   39 +++++++++++++++++++++++++
 4 files changed, 80 insertions(+), 0 deletions(-)
---
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index fd30692..c3c3fa8 100644
--- a/calendar/tests/ecal/Makefile.am
+++ b/calendar/tests/ecal/Makefile.am
@@ -34,6 +34,7 @@ test_scripts =                         \
 TESTS = \
         test-ecal-remove			\
         test-ecal-open				\
+        test-ecal-get-free-busy			\
         test-ecal-get-timezone			\
         test-ecal-add-timezone			\
         test-ecal-set-default-timezone		\
@@ -71,6 +72,8 @@ test_ecal_get_cal_address_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_get_cal_address_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_get_default_object_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_get_default_object_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
+test_ecal_get_free_busy_LDADD=$(TEST_ECAL_LIBS)
+test_ecal_get_free_busy_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_get_ldap_attribute_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_get_ldap_attribute_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_get_capabilities_LDADD=$(TEST_ECAL_LIBS)
diff --git a/calendar/tests/ecal/ecal-test-utils.c b/calendar/tests/ecal/ecal-test-utils.c
index 4cc2597..7b41a54 100644
--- a/calendar/tests/ecal/ecal-test-utils.c
+++ b/calendar/tests/ecal/ecal-test-utils.c
@@ -579,3 +579,35 @@ ecal_test_utils_cal_set_default_timezone (ECal         *cal,
         }
         g_print ("successfully set default icaltimezone '%s'\n", name);
 }
+
+GList*
+ecal_test_utils_cal_get_free_busy (ECal   *cal,
+				   GList  *users,
+				   time_t  start,
+				   time_t  end)
+{
+	GList *free_busy = NULL;
+	GList *l = NULL;
+	GError *error = NULL;
+
+	if (!e_cal_get_free_busy (cal, users, start, end, &free_busy, &error)) {
+		g_error ("Test free/busy : Could not retrieve free busy information :  %s\n", error->message);
+	}
+	if (free_busy) {
+		g_print ("Printing free/busy information\n");
+
+		for (l = free_busy; l; l = l->next) {
+			gchar *comp_string;
+			ECalComponent *comp = E_CAL_COMPONENT (l->data);
+
+			comp_string = e_cal_component_get_as_string (comp);
+			g_print ("%s\n", comp_string);
+			g_object_unref (comp);
+			g_free (comp_string);
+		}
+	} else {
+		g_error ("got empty free/busy information");
+	}
+
+	return free_busy;
+}
diff --git a/calendar/tests/ecal/ecal-test-utils.h b/calendar/tests/ecal/ecal-test-utils.h
index 3deaf3f..a3db11d 100644
--- a/calendar/tests/ecal/ecal-test-utils.h
+++ b/calendar/tests/ecal/ecal-test-utils.h
@@ -60,6 +60,12 @@ ecal_test_utils_cal_get_ldap_attribute (ECal *cal);
 void
 ecal_test_utils_cal_get_capabilities (ECal *cal);
 
+GList*
+ecal_test_utils_cal_get_free_busy (ECal   *cal,
+                                   GList  *users,
+                                   time_t  start,
+                                   time_t  end);
+
 void
 ecal_test_utils_cal_assert_objects_equal_shallow (icalcomponent *a,
                                                   icalcomponent *b);
diff --git a/calendar/tests/ecal/test-ecal-get-free-busy.c b/calendar/tests/ecal/test-ecal-get-free-busy.c
new file mode 100644
index 0000000..3708fe0
--- /dev/null
+++ b/calendar/tests/ecal/test-ecal-get-free-busy.c
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <libecal/e-cal.h>
+#include <libecal/e-cal-time-util.h>
+#include <libical/ical.h>
+
+#include "ecal-test-utils.h"
+
+gint
+main (gint argc, gchar **argv)
+{
+	ECal *cal;
+	char *uri = NULL;
+        GList *users = NULL;
+        icaltimezone *utc;
+        time_t start = time (NULL), end;
+	GList *free_busy;
+
+	g_type_init ();
+
+	cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
+	ecal_test_utils_cal_open (cal, FALSE);
+
+        utc = icaltimezone_get_utc_timezone ();
+        start = time_from_isodate ("20040212T000000Z");
+        end = time_add_day_with_zone (start, 2, utc);
+	/* XXX: create dummy list, which the file backend will ignore */
+	users = g_list_prepend (users, NULL);
+
+	free_busy = ecal_test_utils_cal_get_free_busy (cal, users, start, end);
+
+	ecal_test_utils_cal_remove (cal);
+
+	g_list_foreach (free_busy, (GFunc) icalcomponent_free, NULL);
+	g_list_free (free_busy);
+
+	return 0;
+}



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