[evolution-data-server/openismus-work: 7/7] Adding test case for e_cal_get_revision()
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work: 7/7] Adding test case for e_cal_get_revision()
- Date: Thu, 4 Aug 2011 21:41:52 +0000 (UTC)
commit dc9a4e0a9fd75e5a1a9828b3581dc50e80623901
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Thu Aug 4 17:33:48 2011 -0400
Adding test case for e_cal_get_revision()
Add a test case that makes some modifications to the
calendar and asserts that the revision string changes between
each modification.
calendar/tests/ecal/Makefile.am | 3 +
calendar/tests/ecal/test-ecal-get-revision.c | 71 ++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 0 deletions(-)
---
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index e1fbff0..20d67b8 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-get-revision \
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_get_revision_LDADD=$(TEST_ECAL_LIBS)
+test_ecal_get_revision_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/test-ecal-get-revision.c b/calendar/tests/ecal/test-ecal-get-revision.c
new file mode 100644
index 0000000..bc51743
--- /dev/null
+++ b/calendar/tests/ecal/test-ecal-get-revision.c
@@ -0,0 +1,71 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <string.h>
+#include <libecal/e-cal.h>
+#include <libical/ical.h>
+
+#include "ecal-test-utils.h"
+
+#define CYCLES 10
+
+static void
+get_revision_compare_cycle (ECal *cal)
+{
+ gchar *revision_before = NULL, *revision_after = NULL;
+ icalcomponent *component = NULL;
+ icalcomponent *component_final;
+ gchar *uid;
+ GError *error = NULL;
+
+ g_assert (E_IS_CAL (cal));
+
+ if (!e_cal_get_revision (cal, &revision_before, &error))
+ g_error ("Error getting calendar revision (1): %s", error->message);
+
+ 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);
+
+ g_free (uid);
+ icalcomponent_free (component);
+ icalcomponent_free (component_final);
+ uid = NULL;
+
+ if (!e_cal_get_revision (cal, &revision_after, &error))
+ g_error ("Error getting calendar revision (2): %s", error->message);
+
+ g_assert (revision_before);
+ g_assert (revision_after);
+ g_assert (strcmp (revision_before, revision_after) != 0);
+
+ g_message ("Passed cycle, revision before '%s' revision after '%s'",
+ revision_before, revision_after);
+
+ g_free (revision_before);
+ g_free (revision_after);
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+ ECal *cal;
+ gchar *uri = NULL;
+ gint i;
+
+ g_type_init ();
+
+ cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
+ ecal_test_utils_cal_open (cal, FALSE);
+
+
+ /* Test that modifications make the revisions increment */
+ for (i = 0; i < CYCLES; i++)
+ get_revision_compare_cycle (cal);
+
+ ecal_test_utils_cal_remove (cal);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]