[evolution-data-server/rbradford-wip-ecal-async-api: 5/5] ecal (tests): Test e_cal_remove_object_async



commit e8a2302d1285d87d39cbb84553d442a35f14a8ed
Author: Rob Bradford <rob linux intel com>
Date:   Tue Aug 3 15:08:04 2010 +0100

    ecal (tests): Test e_cal_remove_object_async

 calendar/tests/ecal/Makefile.am                    |    3 +
 calendar/tests/ecal/ecal-test-utils.c              |   17 ++++++
 calendar/tests/ecal/ecal-test-utils.h              |    6 ++
 .../tests/ecal/test-ecal-remove-object-async.c     |   59 ++++++++++++++++++++
 4 files changed, 85 insertions(+), 0 deletions(-)
---
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index f549c2e..ab7b809 100644
--- a/calendar/tests/ecal/Makefile.am
+++ b/calendar/tests/ecal/Makefile.am
@@ -48,6 +48,7 @@ TESTS = \
 	test-ecal-create-object--2		\
 	test-ecal-get-objects-for-uid		\
 	test-ecal-remove-object			\
+	test-ecal-remove-object-async		\
 	test-ecal-get-object-list		\
 	test-ecal-modify-object			\
 	test-ecal-modify-object-async		\
@@ -106,6 +107,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_remove_object_async_LDADD=$(TEST_ECAL_LIBS)
+test_ecal_remove_object_async_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)
diff --git a/calendar/tests/ecal/ecal-test-utils.c b/calendar/tests/ecal/ecal-test-utils.c
index 0fda56d..2d08e7a 100644
--- a/calendar/tests/ecal/ecal-test-utils.c
+++ b/calendar/tests/ecal/ecal-test-utils.c
@@ -411,6 +411,23 @@ ecal_test_utils_cal_remove_object (ECal       *cal,
         test_print ("successfully remoed the icalcomponent object '%s'\n", uid);
 }
 
+
+void
+ecal_test_utils_cal_remove_object_async (ECal              *cal,
+					 const gchar       *uid,
+					 ECalAsyncCallback  cb,
+					 gpointer           userdata)
+{
+        GError *error = NULL;
+
+        if (!e_cal_remove_object_async (cal, uid, cb, userdata, &error)) {
+                g_warning ("failed to remove icalcomponent object '%s'; %s\n", uid, error->message);
+                exit(1);
+        }
+}
+
+
+
 icalcomponent*
 ecal_test_utils_cal_get_default_object (ECal *cal)
 {
diff --git a/calendar/tests/ecal/ecal-test-utils.h b/calendar/tests/ecal/ecal-test-utils.h
index b7fa4a5..f0ba8a7 100644
--- a/calendar/tests/ecal/ecal-test-utils.h
+++ b/calendar/tests/ecal/ecal-test-utils.h
@@ -103,6 +103,12 @@ void
 ecal_test_utils_cal_remove_object (ECal       *cal,
 				   const gchar *uid);
 
+void
+ecal_test_utils_cal_remove_object_async (ECal              *cal,
+					 const gchar       *uid,
+					 ECalAsyncCallback  cb,
+					 gpointer           userdata);
+
 icalcomponent*
 ecal_test_utils_cal_get_default_object (ECal *cal);
 
diff --git a/calendar/tests/ecal/test-ecal-remove-object-async.c b/calendar/tests/ecal/test-ecal-remove-object-async.c
new file mode 100644
index 0000000..5e1bf61
--- /dev/null
+++ b/calendar/tests/ecal/test-ecal-remove-object-async.c
@@ -0,0 +1,59 @@
+/* -*- 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"
+
+static void
+_remove_object_cb (ECal         *cal,
+		   const GError *error,
+		   gpointer      userdata)
+{
+	GMainLoop *loop = (GMainLoop *)userdata;
+
+	if (error)
+	{
+		g_warning ("failed to remove icalcomponent object; %s\n", error->message);
+		exit(1);
+	}
+
+	test_print ("successfully removed the icalcomponent object\n");
+	g_main_loop_quit (loop);
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+	ECal *cal;
+	gchar *uri = NULL;
+	icalcomponent *component;
+	icalcomponent *component_final;
+	gchar *uid;
+	GMainLoop *loop;
+
+	g_type_init ();
+
+	loop = g_main_loop_new (NULL, FALSE);
+
+	cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
+	ecal_test_utils_cal_open (cal, FALSE);
+
+	component = icalcomponent_new (ICAL_VEVENT_COMPONENT);
+	uid = ecal_test_utils_cal_create_object (cal, component);
+
+	component_final = ecal_test_utils_cal_get_object (cal, uid);
+	ecal_test_utils_cal_assert_objects_equal_shallow (component, component_final);
+	ecal_test_utils_cal_remove_object_async (cal, uid, _remove_object_cb, loop);
+
+	g_main_loop_run (loop);
+	
+	ecal_test_utils_cal_remove (cal);
+
+	g_free (uid);
+	icalcomponent_free (component);
+	icalcomponent_free (component_final);
+
+	return 0;
+}



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