[evolution-data-server/treitter-test-suites] Add a test for the e-book 'getStaticCapabilities' method.



commit 4414e5ec4116eaaf49888bc952cb5d45660eaeaa
Author: Travis Reitter <treitter gmail com>
Date:   Wed Dec 9 11:40:22 2009 -0800

    Add a test for the e-book 'getStaticCapabilities' method.

 addressbook/tests/ebook/Makefile.am                |    3 ++
 addressbook/tests/ebook/ebook-test-utils.c         |   18 +++++++++++
 addressbook/tests/ebook/ebook-test-utils.h         |    3 ++
 .../ebook/test-ebook-get-static-capabilities.c     |   32 ++++++++++++++++++++
 .../tests/ebook/test-ebook-remove-contact-by-id.c  |    6 ----
 5 files changed, 56 insertions(+), 6 deletions(-)
---
diff --git a/addressbook/tests/ebook/Makefile.am b/addressbook/tests/ebook/Makefile.am
index 171b5f3..cc892a2 100644
--- a/addressbook/tests/ebook/Makefile.am
+++ b/addressbook/tests/ebook/Makefile.am
@@ -30,6 +30,7 @@ noinst_PROGRAMS = \
 	test-ebook-add-contact               \
 	test-ebook-commit-contact            \
 	test-ebook-get-contact               \
+	test-ebook-get-static-capabilities   \
 	test-ebook-remove                    \
 	test-ebook-remove-contact            \
 	test-ebook-remove-contact-by-id      \
@@ -64,6 +65,8 @@ test_ebook_commit_contact_LDADD=$(TEST_LIBS)
 test_ebook_commit_contact_CPPFLAGS=$(TEST_CPPFLAGS)
 test_ebook_get_contact_LDADD=$(TEST_LIBS)
 test_ebook_get_contact_CPPFLAGS=$(TEST_CPPFLAGS)
+test_ebook_get_static_capabilities_LDADD=$(TEST_LIBS)
+test_ebook_get_static_capabilities_CPPFLAGS=$(TEST_CPPFLAGS)
 test_ebook_remove_LDADD=$(TEST_LIBS)
 test_ebook_remove_CPPFLAGS=$(TEST_CPPFLAGS)
 test_ebook_remove_contact_LDADD=$(TEST_LIBS)
diff --git a/addressbook/tests/ebook/ebook-test-utils.c b/addressbook/tests/ebook/ebook-test-utils.c
index 1385c7b..634396a 100644
--- a/addressbook/tests/ebook/ebook-test-utils.c
+++ b/addressbook/tests/ebook/ebook-test-utils.c
@@ -260,6 +260,24 @@ ebook_test_utils_book_async_get_contact (EBook       *book,
         }
 }
 
+const char*
+ebook_test_utils_book_get_static_capabilities (EBook *book)
+{
+        GError *error = NULL;
+        const char *caps;
+
+        if (!(caps = e_book_get_static_capabilities (book, &error))) {
+                const char *uri;
+
+                uri = e_book_get_uri (book);
+                g_warning ("failed to get capabilities for addressbook: `%s': "
+                                "%s", uri, error->message);
+                exit(1);
+        }
+
+        return caps;
+}
+
 void
 ebook_test_utils_book_remove_contact (EBook      *book,
                                       const char *uid)
diff --git a/addressbook/tests/ebook/ebook-test-utils.h b/addressbook/tests/ebook/ebook-test-utils.h
index d76d126..3b0b963 100644
--- a/addressbook/tests/ebook/ebook-test-utils.h
+++ b/addressbook/tests/ebook/ebook-test-utils.h
@@ -78,6 +78,9 @@ ebook_test_utils_book_async_get_contact (EBook       *book,
                                          GSourceFunc  callback,
                                          gpointer     user_data);
 
+const char*
+ebook_test_utils_book_get_static_capabilities (EBook *book);
+
 void
 ebook_test_utils_book_remove_contact (EBook      *book,
                                       const char *uid);
diff --git a/addressbook/tests/ebook/test-ebook-get-static-capabilities.c b/addressbook/tests/ebook/test-ebook-get-static-capabilities.c
new file mode 100644
index 0000000..ccc0ea6
--- /dev/null
+++ b/addressbook/tests/ebook/test-ebook-get-static-capabilities.c
@@ -0,0 +1,32 @@
+/* -*- 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"
+
+gint
+main (gint argc, gchar **argv)
+{
+	EBook *book;
+	const char *caps;
+
+	g_type_init ();
+
+	/*
+	 * Setup
+	 */
+	book = ebook_test_utils_book_new_temp (NULL);
+	ebook_test_utils_book_open (book, FALSE);
+
+	/*
+	 * Sync version
+	 */
+	caps = ebook_test_utils_book_get_static_capabilities (book);
+
+	g_print ("successfully retrieved static capabilities: '%s'\n", caps);
+
+	ebook_test_utils_book_remove (book);
+
+	return 0;
+}
diff --git a/addressbook/tests/ebook/test-ebook-remove-contact-by-id.c b/addressbook/tests/ebook/test-ebook-remove-contact-by-id.c
index 7f5a497..d6c9ac2 100644
--- a/addressbook/tests/ebook/test-ebook-remove-contact-by-id.c
+++ b/addressbook/tests/ebook/test-ebook-remove-contact-by-id.c
@@ -14,12 +14,6 @@ main (gint argc, gchar **argv)
         g_type_init ();
         
         /*
-         * Setup
-         */
-        book = ebook_test_utils_book_new_temp (NULL);
-        ebook_test_utils_book_open (book, FALSE);
-
-        /*
          * Async version
          */
         book = ebook_test_utils_book_new_temp (NULL);



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