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



commit 7ab4750a2706b59c9d445a8a18086d373028ada3
Author: Travis Reitter <treitter gmail com>
Date:   Tue Dec 22 18:21:10 2009 -0800

    Add a test for EDataCal method 'sendObjects'.

 calendar/tests/ecal/Makefile.am              |    3 ++
 calendar/tests/ecal/ecal-test-utils.c        |   23 ++++++++++++++
 calendar/tests/ecal/ecal-test-utils.h        |    7 ++++
 calendar/tests/ecal/test-ecal-send-objects.c |   41 ++++++++++++++++++++++++++
 4 files changed, 74 insertions(+), 0 deletions(-)
---
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index c3c3fa8..74e082b 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 7b41a54..0b1be76 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 a3db11d..641d6f1 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 0000000..fcd7c95
--- /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;
+}



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