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



commit 17b5ec5dc70480e147d5c3fd651d401ec65eb762
Author: Travis Reitter <treitter gmail com>
Date:   Tue Dec 22 11:30:45 2009 -0800

    Add test for EDataCal method 'setDefaultTimezone'.

 calendar/tests/ecal/Makefile.am                    |    3 +
 calendar/tests/ecal/ecal-test-utils.c              |   16 ++++++
 calendar/tests/ecal/ecal-test-utils.h              |    4 ++
 .../tests/ecal/test-ecal-set-default-timezone.c    |   54 ++++++++++++++++++++
 4 files changed, 77 insertions(+), 0 deletions(-)
---
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index 738a822..fd30692 100644
--- a/calendar/tests/ecal/Makefile.am
+++ b/calendar/tests/ecal/Makefile.am
@@ -36,6 +36,7 @@ TESTS = \
         test-ecal-open				\
         test-ecal-get-timezone			\
         test-ecal-add-timezone			\
+        test-ecal-set-default-timezone		\
         test-ecal-get-alarm-email-address	\
         test-ecal-get-cal-address		\
         test-ecal-get-ldap-attribute		\
@@ -88,6 +89,8 @@ test_ecal_remove_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_remove_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_remove_object_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_remove_object_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
+test_ecal_set_default_timezone_LDADD=$(TEST_ECAL_LIBS)
+test_ecal_set_default_timezone_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_set_mode_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_set_mode_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 
diff --git a/calendar/tests/ecal/ecal-test-utils.c b/calendar/tests/ecal/ecal-test-utils.c
index 5cb96e7..4cc2597 100644
--- a/calendar/tests/ecal/ecal-test-utils.c
+++ b/calendar/tests/ecal/ecal-test-utils.c
@@ -563,3 +563,19 @@ ecal_test_utils_cal_add_timezone (ECal         *cal,
         }
         g_print ("successfully added icaltimezone '%s'\n", name);
 }
+
+void
+ecal_test_utils_cal_set_default_timezone (ECal         *cal,
+					  icaltimezone *zone)
+{
+        GError *error = NULL;
+	const char *name;
+
+	name = icaltimezone_get_display_name (zone);
+
+        if (!e_cal_set_default_timezone (cal, zone, &error)) {
+                g_warning ("failed to set default icaltimezone '%s'; %s\n", name, error->message);
+                exit(1);
+        }
+        g_print ("successfully set default icaltimezone '%s'\n", name);
+}
diff --git a/calendar/tests/ecal/ecal-test-utils.h b/calendar/tests/ecal/ecal-test-utils.h
index 77afc12..3deaf3f 100644
--- a/calendar/tests/ecal/ecal-test-utils.h
+++ b/calendar/tests/ecal/ecal-test-utils.h
@@ -124,4 +124,8 @@ void
 ecal_test_utils_cal_add_timezone (ECal         *cal,
                                   icaltimezone *zone);
 
+void
+ecal_test_utils_cal_set_default_timezone (ECal         *cal,
+					  icaltimezone *zone);
+
 #endif /* _ECAL_TEST_UTILS_H */
diff --git a/calendar/tests/ecal/test-ecal-set-default-timezone.c b/calendar/tests/ecal/test-ecal-set-default-timezone.c
new file mode 100644
index 0000000..11b04f6
--- /dev/null
+++ b/calendar/tests/ecal/test-ecal-set-default-timezone.c
@@ -0,0 +1,54 @@
+/* -*- 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"
+#define EVENT_SUMMARY "Creation of new test event in the " TZID_NEW " timezone"
+
+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);
+
+	/* 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);
+
+	/* set default; must be done before opening the calendar */
+	ecal_test_utils_cal_open (cal, FALSE);
+	ecal_test_utils_cal_add_timezone (cal, zone);
+	ecal_test_utils_cal_set_default_timezone (cal, zone);
+
+	/* verify */
+	/* FIXME: enhance the validation; confirm that the timezone was actually
+	 * set as the default */
+	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]