summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Reitter <treitter@gmail.com>2009-12-22 18:21:10 -0800
committerTravis Reitter <treitter@gmail.com>2010-01-15 13:30:00 -0800
commita2a65721a71394dae3e80397662fa8e15e85519a (patch)
tree2f2f9951a18c4fba83510cd7ed4e28de5a8dac46
parent1ce3f3f2718b84155a9a49670167577083f6160b (diff)
downloadevolution-data-server-a2a65721a71394dae3e80397662fa8e15e85519a.tar.gz
Add a test for EDataCal method 'sendObjects'.
-rw-r--r--calendar/tests/ecal/Makefile.am3
-rw-r--r--calendar/tests/ecal/ecal-test-utils.c23
-rw-r--r--calendar/tests/ecal/ecal-test-utils.h7
-rw-r--r--calendar/tests/ecal/test-ecal-send-objects.c41
4 files changed, 74 insertions, 0 deletions
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index c3c3fa86b..74e082bd8 100644
--- a/calendar/tests/ecal/Makefile.am
+++ b/calendar/tests/ecal/Makefile.am
@@ -50,6 +50,7 @@ TESTS = \
test-ecal-remove-object \
test-ecal-get-object-list \
test-ecal-modify-object \
+ test-ecal-send-objects \
$(NULL)
# The test program
@@ -92,6 +93,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_send_objects_LDADD=$(TEST_ECAL_LIBS)
+test_ecal_send_objects_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)
diff --git a/calendar/tests/ecal/ecal-test-utils.c b/calendar/tests/ecal/ecal-test-utils.c
index 7b41a547c..0b1be7682 100644
--- a/calendar/tests/ecal/ecal-test-utils.c
+++ b/calendar/tests/ecal/ecal-test-utils.c
@@ -611,3 +611,26 @@ ecal_test_utils_cal_get_free_busy (ECal *cal,
return free_busy;
}
+
+void
+ecal_test_utils_cal_send_objects (ECal *cal,
+ icalcomponent *component,
+ GList **users,
+ icalcomponent **component_final)
+{
+ GList *l = NULL;
+ GError *error = NULL;
+
+ if (!e_cal_send_objects (cal, component, users, component_final, &error)) {
+ g_error ("sending objects: %s\n", error->message);
+ }
+
+ g_print ("successfully sent the objects to the following users:\n");
+ if (g_list_length (*users) <= 0) {
+ g_print (" (none)\n");
+ return;
+ }
+ for (l = *users; l; l = l->next) {
+ g_print (" %s\n", (const char*) l->data);
+ }
+}
diff --git a/calendar/tests/ecal/ecal-test-utils.h b/calendar/tests/ecal/ecal-test-utils.h
index a3db11d75..641d6f1c1 100644
--- a/calendar/tests/ecal/ecal-test-utils.h
+++ b/calendar/tests/ecal/ecal-test-utils.h
@@ -134,4 +134,11 @@ void
ecal_test_utils_cal_set_default_timezone (ECal *cal,
icaltimezone *zone);
+void
+ecal_test_utils_cal_send_objects (ECal *cal,
+ icalcomponent *component,
+ GList **users,
+ icalcomponent **component_final);
+
+
#endif /* _ECAL_TEST_UTILS_H */
diff --git a/calendar/tests/ecal/test-ecal-send-objects.c b/calendar/tests/ecal/test-ecal-send-objects.c
new file mode 100644
index 000000000..fcd7c953e
--- /dev/null
+++ b/calendar/tests/ecal/test-ecal-send-objects.c
@@ -0,0 +1,41 @@
+/* -*- 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;
+ GList *users = NULL;
+ ECalComponent *e_component = NULL;
+ icalcomponent *component = NULL;
+ icalcomponent *modified_component = NULL;
+ char *uid = NULL;
+
+ g_type_init ();
+
+ cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
+ ecal_test_utils_cal_open (cal, FALSE);
+
+ ecal_test_utils_create_component (cal, "20040109T090000Z", "UTC",
+ "20040109T103000", "UTC", "new event", &e_component,
+ &uid);
+
+ component = e_cal_component_get_icalcomponent (e_component);
+ ecal_test_utils_cal_send_objects (cal, component, &users, &modified_component);
+
+ ecal_test_utils_cal_remove (cal);
+
+ g_list_foreach (users, (GFunc) g_free, NULL);
+ g_list_free (users);
+
+ g_object_unref (e_component);
+ g_free (uid);
+
+ return 0;
+}