[evolution-data-server/openismus-work] Added test case for e_book_get_revision()



commit 3b1087e23743f10664408bf64112a5c8dcf2ca07
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sun Jul 17 18:00:04 2011 -0400

    Added test case for e_book_get_revision()
    
    Test case ensures that the revision string changes
    after having added and removed contacts in the book.

 addressbook/tests/ebook/Makefile.am               |    3 +
 addressbook/tests/ebook/test-ebook-get-revision.c |   56 +++++++++++++++++++++
 2 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/addressbook/tests/ebook/Makefile.am b/addressbook/tests/ebook/Makefile.am
index 0e4ddbd..4a562f9 100644
--- a/addressbook/tests/ebook/Makefile.am
+++ b/addressbook/tests/ebook/Makefile.am
@@ -38,6 +38,7 @@ TESTS = \
 	test-ebook-get-supported-auth-methods	     \
 	test-ebook-add-contact			     \
 	test-ebook-get-contact			     \
+	test-ebook-get-revision			     \
 	test-ebook-get-book-view		     \
 	test-ebook-get-book-view-uid-only	     \
 	test-ebook-suppress-initial-notifications    \
@@ -101,6 +102,8 @@ test_ebook_photo_is_uri_LDADD=$(TEST_LIBS)
 test_ebook_photo_is_uri_CPPFLAGS=$(TEST_CPPFLAGS)
 test_ebook_get_contact_LDADD=$(TEST_LIBS)
 test_ebook_get_contact_CPPFLAGS=$(TEST_CPPFLAGS)
+test_ebook_get_revision_LDADD=$(TEST_LIBS)
+test_ebook_get_revision_CPPFLAGS=$(TEST_CPPFLAGS)
 test_ebook_get_required_fields_LDADD=$(TEST_LIBS)
 test_ebook_get_required_fields_CPPFLAGS=$(TEST_CPPFLAGS)
 test_ebook_get_static_capabilities_LDADD=$(TEST_LIBS)
diff --git a/addressbook/tests/ebook/test-ebook-get-revision.c b/addressbook/tests/ebook/test-ebook-get-revision.c
new file mode 100644
index 0000000..e7ceecb
--- /dev/null
+++ b/addressbook/tests/ebook/test-ebook-get-revision.c
@@ -0,0 +1,56 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <string.h>
+#include <libebook/e-book.h>
+
+#include "ebook-test-utils.h"
+
+#define CYCLES 10
+
+static void
+get_revision_compare_cycle (EBook *book)
+{
+	gchar  *revision_before = NULL, *revision_after = NULL;
+	gchar  *uid;
+	GError *error = NULL;
+
+	if (!e_book_get_revision (book, &revision_before, &error))
+		g_error ("Error getting book revision: %s", error->message);
+
+	uid = ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-1", NULL);
+        ebook_test_utils_book_remove_contact (book, uid);
+
+	if (!e_book_get_revision (book, &revision_after, &error))
+		g_error ("Error getting book 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);
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+	EBook *book;
+	gint   i;
+
+	g_type_init ();
+
+	/*
+	 * Setup
+	 */
+	book = ebook_test_utils_book_new_temp (NULL);
+	ebook_test_utils_book_open (book, FALSE);
+
+	/* Test that modifications make the revisions increment */
+	for (i = 0; i < CYCLES; i++)
+		get_revision_compare_cycle (book);
+
+	ebook_test_utils_book_remove (book);
+
+	return 0;
+}



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