[evolution-data-server/openismus-work: 6/7] Added test case showing e_book_get_revisioned_contact_uid_list() at work.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work: 6/7] Added test case showing e_book_get_revisioned_contact_uid_list() at work.
- Date: Wed, 3 Aug 2011 19:36:43 +0000 (UTC)
commit c2601814bd8594cd476f99f2a05f9bff40e68194
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Wed Jul 20 22:49:46 2011 -0400
Added test case showing e_book_get_revisioned_contact_uid_list() at work.
Test case simply asserts that both Sync and Async apis work.
addressbook/tests/ebook/Makefile.am | 3 +
.../tests/ebook/test-ebook-get-card-revisions.c | 97 ++++++++++++++++++++
2 files changed, 100 insertions(+), 0 deletions(-)
---
diff --git a/addressbook/tests/ebook/Makefile.am b/addressbook/tests/ebook/Makefile.am
index 4a562f9..12ac4d4 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-card-revisions \
test-ebook-get-revision \
test-ebook-get-book-view \
test-ebook-get-book-view-uid-only \
@@ -102,6 +103,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_card_revisions_LDADD=$(TEST_LIBS)
+test_ebook_get_card_revisions_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)
diff --git a/addressbook/tests/ebook/test-ebook-get-card-revisions.c b/addressbook/tests/ebook/test-ebook-get-card-revisions.c
new file mode 100644
index 0000000..234b5f5
--- /dev/null
+++ b/addressbook/tests/ebook/test-ebook-get-card-revisions.c
@@ -0,0 +1,97 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <libebook/e-book.h>
+
+#include "ebook-test-utils.h"
+
+static void
+setup_book (EBook **book_out)
+{
+ EBook *book;
+
+ book = ebook_test_utils_book_new_temp (NULL);
+ ebook_test_utils_book_open (book, FALSE);
+
+ ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-1", NULL);
+ ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-2", NULL);
+ ebook_test_utils_book_add_contact_from_test_case_verify (book, "name-only", NULL);
+
+ *book_out = book;
+}
+
+static void
+revisioned_uids_cb (EBook *book,
+ const GError *error,
+ GList *uids,
+ GList *revs,
+ gpointer closure)
+{
+ GList *l, *ll;
+ GMainLoop *loop = (GMainLoop *)closure;
+
+ if (error) {
+ g_warning ("failed to asynchronously get the contact revisions: "
+ "status %d (%s)", error->code, error->message);
+ exit (1);
+ }
+
+ for (l = uids, ll = revs; l && ll; l = l->next, ll = ll->next) {
+ const gchar *uid = l->data, *rev = ll->data;
+ g_print ("UID:%s REV:%s\n", uid, rev);
+ }
+
+ g_main_loop_quit (loop);
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+ EBook *book;
+ GMainLoop *loop;
+ GError *error = NULL;
+ GList *uids = NULL, *revs = NULL;
+ GList *l, *ll;
+
+
+ g_type_init ();
+
+ /*
+ * Setup
+ */
+ setup_book (&book);
+
+ /*
+ * Sync version
+ */
+ if (!e_book_get_revisioned_contact_uids (book,
+ e_book_query_any_field_contains (""),
+ &uids, &revs, &error))
+ g_error ("Failed to get revisioned contact ids: %s", error->message);
+
+ for (l = uids, ll = revs; l && ll; l = l->next, ll = ll->next) {
+ const gchar *uid = l->data, *rev = ll->data;
+ g_print ("UID:%s REV:%s\n", uid, rev);
+ }
+ g_list_foreach (uids, (GFunc) g_free, NULL);
+ g_list_foreach (revs, (GFunc) g_free, NULL);
+ g_list_free (uids);
+ g_list_free (revs);
+
+ /*
+ * Async version
+ */
+ loop = g_main_loop_new (NULL, TRUE);
+
+
+ if (!e_book_get_revisioned_contact_uids_async (book,
+ e_book_query_any_field_contains (""),
+ revisioned_uids_cb, loop))
+ g_error ("Failed to get revisioned contact ids: %s", error->message);
+
+ g_main_loop_run (loop);
+
+ ebook_test_utils_book_remove (book);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]