[evolution-data-server/treitter-client-gdbus] Port EDataCal method 'setDefaultTimezone' and add a basic regression test.
- From: Travis Reitter <treitter src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server/treitter-client-gdbus] Port EDataCal method 'setDefaultTimezone' and add a basic regression test.
- Date: Wed, 23 Dec 2009 20:04:36 +0000 (UTC)
commit 193477b2a2c8ad7d6ecfc290f5bfbcc8d52524b5
Author: Travis Reitter <treitter gmail com>
Date: Tue Dec 22 11:30:45 2009 -0800
Port EDataCal method 'setDefaultTimezone' and add a basic regression test.
calendar/libecal/e-cal.c | 4 +-
calendar/libecal/e-data-cal-gdbus-bindings.h | 14 +++++
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 ++++++++++++++++++++
6 files changed, 93 insertions(+), 2 deletions(-)
---
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index 1468a2c..cd71cce 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -3907,7 +3907,7 @@ e_cal_set_default_timezone (ECal *ecal, icaltimezone *zone, GError **error)
e_return_error_if_fail (E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
e_return_error_if_fail (zone, E_CALENDAR_STATUS_INVALID_ARG);
priv = ecal->priv;
- e_return_error_if_fail (priv->proxy, E_CALENDAR_STATUS_REPOSITORY_OFFLINE);
+ e_return_error_if_fail (priv->gdbus_proxy, E_CALENDAR_STATUS_REPOSITORY_OFFLINE);
/* Don't set the same timezone multiple times */
if (priv->default_zone == zone)
@@ -3928,7 +3928,7 @@ e_cal_set_default_timezone (ECal *ecal, icaltimezone *zone, GError **error)
/* call the backend */
LOCK_CONN ();
- if (!org_gnome_evolution_dataserver_calendar_Cal_set_default_timezone (priv->proxy, tzobj, error)) {
+ if (!e_data_cal_gdbus_set_default_timezone_sync (priv->gdbus_proxy, tzobj, error)) {
UNLOCK_CONN ();
g_free (tzobj);
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
diff --git a/calendar/libecal/e-data-cal-gdbus-bindings.h b/calendar/libecal/e-data-cal-gdbus-bindings.h
index 5c88b15..36286b9 100644
--- a/calendar/libecal/e-data-cal-gdbus-bindings.h
+++ b/calendar/libecal/e-data-cal-gdbus-bindings.h
@@ -320,4 +320,18 @@ e_data_cal_gdbus_add_timezone_sync (GDBusProxy *proxy,
return demarshal_retvals__VOID (retvals);
}
+static gboolean
+e_data_cal_gdbus_set_default_timezone_sync (GDBusProxy *proxy,
+ const char *IN_zone,
+ GError **error)
+{
+ GVariant *parameters;
+ GVariant *retvals;
+
+ parameters = g_variant_new ("(s)", IN_zone);
+ retvals = g_dbus_proxy_invoke_method_sync (proxy, "setDefaultTimezone", parameters, -1, NULL, error);
+
+ return demarshal_retvals__VOID (retvals);
+}
+
G_END_DECLS
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]