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



commit 6942277c084d0336e0606e489ab9804dd203c941
Author: Travis Reitter <treitter gmail com>
Date:   Tue Dec 22 10:02:04 2009 -0800

    Add test for EDataCal method 'addTimezone'.

 calendar/tests/ecal/Makefile.am              |    3 ++
 calendar/tests/ecal/ecal-test-utils.c        |   16 ++++++++
 calendar/tests/ecal/ecal-test-utils.h        |    4 ++
 calendar/tests/ecal/test-ecal-add-timezone.c |   50 ++++++++++++++++++++++++++
 4 files changed, 73 insertions(+), 0 deletions(-)
---
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index 812701d..738a822 100644
--- a/calendar/tests/ecal/Makefile.am
+++ b/calendar/tests/ecal/Makefile.am
@@ -35,6 +35,7 @@ TESTS = \
         test-ecal-remove			\
         test-ecal-open				\
         test-ecal-get-timezone			\
+        test-ecal-add-timezone			\
         test-ecal-get-alarm-email-address	\
         test-ecal-get-cal-address		\
         test-ecal-get-ldap-attribute		\
@@ -57,6 +58,8 @@ TEST_ECAL_CPPFLAGS= \
 	$(NULL)
 
 # ordered alphanumerically
+test_ecal_add_timezone_LDADD=$(TEST_ECAL_LIBS)
+test_ecal_add_timezone_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_create_object_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_create_object_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_create_object__2_LDADD=$(TEST_ECAL_LIBS)
diff --git a/calendar/tests/ecal/ecal-test-utils.c b/calendar/tests/ecal/ecal-test-utils.c
index 5c959e1..5cb96e7 100644
--- a/calendar/tests/ecal/ecal-test-utils.c
+++ b/calendar/tests/ecal/ecal-test-utils.c
@@ -547,3 +547,19 @@ ecal_test_utils_cal_get_timezone (ECal       *cal,
 
 	return zone;
 }
+
+void
+ecal_test_utils_cal_add_timezone (ECal         *cal,
+				  icaltimezone *zone)
+{
+        GError *error = NULL;
+	const char *name;
+
+	name = icaltimezone_get_display_name (zone);
+
+        if (!e_cal_add_timezone (cal, zone, &error)) {
+                g_warning ("failed to add icaltimezone '%s'; %s\n", name, error->message);
+                exit(1);
+        }
+        g_print ("successfully added icaltimezone '%s'\n", name);
+}
diff --git a/calendar/tests/ecal/ecal-test-utils.h b/calendar/tests/ecal/ecal-test-utils.h
index aea710f..77afc12 100644
--- a/calendar/tests/ecal/ecal-test-utils.h
+++ b/calendar/tests/ecal/ecal-test-utils.h
@@ -120,4 +120,8 @@ icaltimezone*
 ecal_test_utils_cal_get_timezone (ECal       *cal,
                                   const char *tzid);
 
+void
+ecal_test_utils_cal_add_timezone (ECal         *cal,
+                                  icaltimezone *zone);
+
 #endif /* _ECAL_TEST_UTILS_H */
diff --git a/calendar/tests/ecal/test-ecal-add-timezone.c b/calendar/tests/ecal/test-ecal-add-timezone.c
new file mode 100644
index 0000000..eeb4413
--- /dev/null
+++ b/calendar/tests/ecal/test-ecal-add-timezone.c
@@ -0,0 +1,50 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <libecal/e-cal.h>
+#include <libical/ical.h>
+
+#include "ecal-test-utils.h"
+
+#define TZID_NEW "XYZ"
+#define TZNAME_NEW "Ex Wye Zee"
+
+gint
+main (gint argc, gchar **argv)
+{
+	ECal *cal;
+	char *uri = NULL;
+	icalproperty *property;
+	icalcomponent *component;
+	icaltimezone *zone;
+	icaltimezone *zone_final;
+
+	g_type_init ();
+
+	cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
+	ecal_test_utils_cal_open (cal, FALSE);
+
+	/* 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);
+	
+	/* add */
+	ecal_test_utils_cal_add_timezone (cal, zone);
+
+	/* verify */
+	zone_final = ecal_test_utils_cal_get_timezone (cal, TZID_NEW);
+	g_assert (!g_strcmp0 (icaltimezone_get_tzid (zone),
+			icaltimezone_get_tzid (zone_final)));
+	g_assert (!g_strcmp0 (icaltimezone_get_tznames (zone),
+			icaltimezone_get_tznames (zone_final)));
+
+	ecal_test_utils_cal_remove (cal);
+	icaltimezone_free (zone, TRUE);
+
+	return 0;
+}



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