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



commit 570ac245ce662ced2f75ad69fe17329d2e1b4d18
Author: Travis Reitter <treitter gmail com>
Date:   Mon Dec 21 22:57:12 2009 -0800

    Add test for EDataCal method 'getTimezone'.

 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-get-timezone.c |   31 ++++++++++++++++++++++++++
 4 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index 815e38c..812701d 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-timezone			\
         test-ecal-get-alarm-email-address	\
         test-ecal-get-cal-address		\
         test-ecal-get-ldap-attribute		\
@@ -74,6 +75,8 @@ test_ecal_get_object_list_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_get_object_list_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_get_objects_for_uid_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_get_objects_for_uid_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
+test_ecal_get_timezone_LDADD=$(TEST_ECAL_LIBS)
+test_ecal_get_timezone_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_modify_object_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_modify_object_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_open_LDADD=$(TEST_ECAL_LIBS)
diff --git a/calendar/tests/ecal/ecal-test-utils.c b/calendar/tests/ecal/ecal-test-utils.c
index 49c4b08..5c959e1 100644
--- a/calendar/tests/ecal/ecal-test-utils.c
+++ b/calendar/tests/ecal/ecal-test-utils.c
@@ -531,3 +531,19 @@ ecal_test_utils_cal_component_set_icalcomponent (ECalComponent *e_component,
                 g_error ("Could not set icalcomponent\n");
         }
 }
+
+icaltimezone*
+ecal_test_utils_cal_get_timezone (ECal       *cal,
+				  const char *tzid)
+{
+        GError *error = NULL;
+	icaltimezone *zone = NULL;
+
+        if (!e_cal_get_timezone (cal, tzid, &zone, &error)) {
+                g_warning ("failed to get icaltimezone* for ID '%s'; %s\n", tzid, error->message);
+                exit(1);
+        }
+        g_print ("successfully got icaltimezone* for ID '%s'\n", tzid);
+
+	return zone;
+}
diff --git a/calendar/tests/ecal/ecal-test-utils.h b/calendar/tests/ecal/ecal-test-utils.h
index 77918f8..aea710f 100644
--- a/calendar/tests/ecal/ecal-test-utils.h
+++ b/calendar/tests/ecal/ecal-test-utils.h
@@ -116,4 +116,8 @@ void
 ecal_test_utils_cal_component_set_icalcomponent (ECalComponent *e_component,
 						 icalcomponent *component);
 
+icaltimezone*
+ecal_test_utils_cal_get_timezone (ECal       *cal,
+                                  const char *tzid);
+
 #endif /* _ECAL_TEST_UTILS_H */
diff --git a/calendar/tests/ecal/test-ecal-get-timezone.c b/calendar/tests/ecal/test-ecal-get-timezone.c
new file mode 100644
index 0000000..3f6961b
--- /dev/null
+++ b/calendar/tests/ecal/test-ecal-get-timezone.c
@@ -0,0 +1,31 @@
+/* -*- 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"
+
+gint
+main (gint argc, gchar **argv)
+{
+	ECal *cal;
+	char *uri = NULL;
+	icaltimezone *zone;
+	icaltimezone *utc_zone;
+
+	g_type_init ();
+
+	cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
+	ecal_test_utils_cal_open (cal, FALSE);
+
+	zone = ecal_test_utils_cal_get_timezone (cal, "UTC");
+	utc_zone = icaltimezone_get_utc_timezone ();
+
+	g_assert (!g_strcmp0 (icaltimezone_get_tzid (zone),
+			icaltimezone_get_tzid (utc_zone)));
+
+	ecal_test_utils_cal_remove (cal);
+
+	return 0;
+}



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