[evolution-data-server/openismus-work-master: 6/9] Added test case for e_cal_get_revision()



commit 227213f528fc7a58f10f7b50e6db1e77e83d2a36
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Thu Aug 4 21:32:09 2011 -0400

    Added test case for e_cal_get_revision()
    
    Test case modifies the calendar in a loop and ensures that
    every modification results in a new revision string.

 tests/libecal/client/Makefile.am                |    3 +
 tests/libecal/client/test-client-get-revision.c |   84 +++++++++++++++++++++++
 2 files changed, 87 insertions(+), 0 deletions(-)
---
diff --git a/tests/libecal/client/Makefile.am b/tests/libecal/client/Makefile.am
index 9b9d08c..93672d6 100644
--- a/tests/libecal/client/Makefile.am
+++ b/tests/libecal/client/Makefile.am
@@ -28,6 +28,7 @@ TESTS = 					\
 	test-client-remove-object		\
 	test-client-get-object-list		\
 	test-client-modify-object		\
+	test-client-get-revision		\
 	test-client-send-objects		\
 	test-client-receive-objects		\
 	test-client-get-attachment-uris		\
@@ -67,6 +68,8 @@ test_client_get_view_LDADD=$(TEST_LIBS)
 test_client_get_view_CPPFLAGS=$(TEST_CPPFLAGS)
 test_client_modify_object_LDADD=$(TEST_LIBS)
 test_client_modify_object_CPPFLAGS=$(TEST_CPPFLAGS)
+test_client_get_revision_LDADD=$(TEST_LIBS)
+test_client_get_revision_CPPFLAGS=$(TEST_CPPFLAGS)
 test_client_open_LDADD=$(TEST_LIBS)
 test_client_open_CPPFLAGS=$(TEST_CPPFLAGS)
 test_client_receive_objects_LDADD=$(TEST_LIBS)
diff --git a/tests/libecal/client/test-client-get-revision.c b/tests/libecal/client/test-client-get-revision.c
new file mode 100644
index 0000000..69b996d
--- /dev/null
+++ b/tests/libecal/client/test-client-get-revision.c
@@ -0,0 +1,84 @@
+/* -*- 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 "client-test-utils.h"
+
+#define CYCLES 10
+
+static void
+get_revision_compare_cycle (ECalClient *client)
+{
+       icalcomponent *icalcomp;
+       struct icaltimetype now;
+       gchar    *revision_before = NULL, *revision_after = NULL, *uid = NULL;
+       GError   *error = NULL;
+
+       /* Build up new component */
+       now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
+       icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT);
+       icalcomponent_set_summary (icalcomp, "Test event summary");
+       icalcomponent_set_dtstart (icalcomp, now);
+       icalcomponent_set_dtend   (icalcomp, icaltime_from_timet (icaltime_as_timet (now) + 60 * 60 * 60, 0));
+
+       if (!e_cal_client_get_revision_sync (client, &revision_before, NULL, &error))
+               g_error ("Error getting cal revision: %s", error->message);
+
+       if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, &error))
+	       g_error ("Error creating object: %s", error->message);
+
+       if (!e_cal_client_get_revision_sync (client, &revision_after, NULL, &error))
+               g_error ("Error getting cal revision: %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);
+       g_free (uid);
+
+       icalcomponent_free (icalcomp);
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+	ECalClient *cal_client;
+	GError      *error = NULL;
+	gint         i;
+
+	main_initialize ();
+
+	/*
+	 * Setup
+	 */
+	cal_client = new_temp_client (E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL);
+
+	g_return_val_if_fail (cal_client != NULL, 1);
+
+	if (!e_client_open_sync (E_CLIENT (cal_client), FALSE, NULL, &error)) {
+		report_error ("client open sync", &error);
+		g_object_unref (cal_client);
+		return 1;
+	}
+
+	/* Test that modifications make the revisions increment */
+	for (i = 0; i < CYCLES; i++)
+		get_revision_compare_cycle (cal_client);
+
+	if (!e_client_remove_sync (E_CLIENT (cal_client), NULL, &error)) {
+		report_error ("client remove sync", &error);
+		g_object_unref (cal_client);
+		return 1;
+	}
+
+	g_object_unref (cal_client);
+
+	return 0;
+}



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