[evolution-data-server/rbradford-wip-ecal-async-api: 3/5] ecal (tests): Test e_cal_modify_object_async
- From: Rob Bradford <rbradford src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/rbradford-wip-ecal-async-api: 3/5] ecal (tests): Test e_cal_modify_object_async
- Date: Tue, 3 Aug 2010 14:31:17 +0000 (UTC)
commit de473d2325e9de0123ccc40259ca5c8713b1c2fb
Author: Rob Bradford <rob linux intel com>
Date: Tue Aug 3 14:25:31 2010 +0100
ecal (tests): Test e_cal_modify_object_async
calendar/tests/ecal/Makefile.am | 3 +
calendar/tests/ecal/ecal-test-utils.c | 20 +++++
calendar/tests/ecal/ecal-test-utils.h | 7 ++
.../tests/ecal/test-ecal-modify-object-async.c | 87 ++++++++++++++++++++
4 files changed, 117 insertions(+), 0 deletions(-)
---
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index e1fbff0..f549c2e 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-modify-object-async \
test-ecal-send-objects \
test-ecal-receive-objects \
test-ecal-get-query \
@@ -95,6 +96,8 @@ 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_modify_object_async_LDADD=$(TEST_ECAL_LIBS)
+test_ecal_modify_object_async_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
test_ecal_open_LDADD=$(TEST_ECAL_LIBS)
test_ecal_open_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
test_ecal_receive_objects_LDADD=$(TEST_ECAL_LIBS)
diff --git a/calendar/tests/ecal/ecal-test-utils.c b/calendar/tests/ecal/ecal-test-utils.c
index bae6a6e..0fda56d 100644
--- a/calendar/tests/ecal/ecal-test-utils.c
+++ b/calendar/tests/ecal/ecal-test-utils.c
@@ -378,6 +378,26 @@ ecal_test_utils_cal_modify_object (ECal *cal,
test_print ("successfully modified the icalcomponent object\n");
}
+
+void
+ecal_test_utils_cal_modify_object_async (ECal *cal,
+ icalcomponent *component,
+ CalObjModType mod_type,
+ ECalAsyncCallback cb,
+ gpointer closure)
+{
+ GError *error = NULL;
+
+ if (!icalcomponent_is_valid (component)) {
+ g_warning (G_STRLOC ": icalcomponent argument is invalid\n");
+ exit(1);
+ }
+ if (!e_cal_modify_object_async (cal, component, mod_type, cb, closure, &error)) {
+ g_warning ("failed to modify icalcomponent object (async); %s\n", error->message);
+ exit(1);
+ }
+}
+
void
ecal_test_utils_cal_remove_object (ECal *cal,
const gchar *uid)
diff --git a/calendar/tests/ecal/ecal-test-utils.h b/calendar/tests/ecal/ecal-test-utils.h
index 60760e7..b7fa4a5 100644
--- a/calendar/tests/ecal/ecal-test-utils.h
+++ b/calendar/tests/ecal/ecal-test-utils.h
@@ -93,6 +93,13 @@ ecal_test_utils_cal_modify_object (ECal *cal,
CalObjModType mod_type);
void
+ecal_test_utils_cal_modify_object_async (ECal *cal,
+ icalcomponent *component,
+ CalObjModType mod_type,
+ ECalAsyncCallback cb,
+ gpointer closure);
+
+void
ecal_test_utils_cal_remove_object (ECal *cal,
const gchar *uid);
diff --git a/calendar/tests/ecal/test-ecal-modify-object-async.c b/calendar/tests/ecal/test-ecal-modify-object-async.c
new file mode 100644
index 0000000..20ec195
--- /dev/null
+++ b/calendar/tests/ecal/test-ecal-modify-object-async.c
@@ -0,0 +1,87 @@
+/* -*- 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 EVENT_SUMMARY "Creation of new test event"
+#define INITIAL_BEGIN_TIME "20040109T090000Z"
+#define INITIAL_BEGIN_TIMEZONE "UTC"
+#define INITIAL_END_TIME "20040109T103000"
+#define INITIAL_END_TIMEZONE "UTC"
+#define FINAL_BEGIN_TIME "20091221T090000Z"
+#define FINAL_BEGIN_TIMEZONE "UTC"
+
+static gchar *uid;
+static ECalComponent *e_component;
+static icalcomponent *component;
+static ECalComponent *e_component_final;
+static icalcomponent *component_final;
+
+static void
+_modify_object_cb (ECal *cal,
+ const GError *error,
+ gpointer userdata)
+{
+ GMainLoop *loop = (GMainLoop *)userdata;
+
+
+ /* verify */
+ component_final = ecal_test_utils_cal_get_object (cal, uid);
+ e_component_final = e_cal_component_new ();
+ ecal_test_utils_cal_component_set_icalcomponent (e_component_final,
+ component_final);
+
+ ecal_test_utils_cal_assert_e_cal_components_equal (e_component,
+ e_component_final);
+ g_object_unref (e_component_final);
+
+ g_main_loop_quit (loop);
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+ ECal *cal;
+ gchar *uri = NULL;
+
+ struct icaltimetype icaltime;
+ 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);
+
+ ecal_test_utils_create_component (cal, INITIAL_BEGIN_TIME,
+ INITIAL_BEGIN_TIMEZONE, INITIAL_END_TIME,
+ INITIAL_END_TIMEZONE, EVENT_SUMMARY, &e_component,
+ &uid);
+ component = e_cal_component_get_icalcomponent (e_component);
+
+ component_final = ecal_test_utils_cal_get_object (cal, uid);
+ ecal_test_utils_cal_assert_objects_equal_shallow (component,
+ component_final);
+ icalcomponent_free (component_final);
+
+ /* make and commit changes */
+ icaltime = icaltime_from_string (FINAL_BEGIN_TIME);
+ icalcomponent_set_dtstart (component, icaltime);
+ ecal_test_utils_cal_component_set_icalcomponent (e_component,
+ component);
+ ecal_test_utils_cal_modify_object_async (cal, component, CALOBJ_MOD_ALL, _modify_object_cb, loop);
+
+ g_main_loop_run (loop);
+
+ /* Clean-up */
+ ecal_test_utils_cal_remove (cal);
+
+ g_free (uid);
+ icalcomponent_free (component);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]