~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to addressbook/tests/ebook/test-ebook-get-supported-fields.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 
2
 
 
3
#include <stdlib.h>
 
4
#include <libebook/e-book.h>
 
5
 
 
6
#include "ebook-test-utils.h"
 
7
 
 
8
static void
 
9
list_member_print_and_free (gchar     *member,
 
10
                            gpointer  user_data)
 
11
{
 
12
        test_print ("    %s\n", member);
 
13
        g_free (member);
 
14
}
 
15
 
 
16
static void
 
17
get_supported_fields_cb (EBookTestClosure *closure)
 
18
{
 
19
        /* XXX: assuming an empty list is valid, we'll just print out anything
 
20
         * we do get */
 
21
        if (closure->list) {
 
22
                EIterator *iter;
 
23
                const gchar *field;
 
24
 
 
25
                test_print ("supported fields:\n");
 
26
                iter = e_list_get_iterator (closure->list);
 
27
                while ((field = e_iterator_get (iter))) {
 
28
                        test_print ("    %s\n", field);
 
29
                        e_iterator_next (iter);
 
30
                }
 
31
                test_print ("----------------\n");
 
32
        }
 
33
 
 
34
        g_object_unref (closure->list);
 
35
 
 
36
        g_main_loop_quit ((GMainLoop*) (closure->user_data));
 
37
}
 
38
 
 
39
gint
 
40
main (gint argc, gchar **argv)
 
41
{
 
42
        EBook *book;
 
43
        GMainLoop *loop;
 
44
        GList *fields;
 
45
 
 
46
        g_type_init ();
 
47
 
 
48
        /*
 
49
         * Setup
 
50
         */
 
51
        book = ebook_test_utils_book_new_temp (NULL);
 
52
        ebook_test_utils_book_open (book, FALSE);
 
53
 
 
54
        /*
 
55
         * Sync version
 
56
         */
 
57
        fields = ebook_test_utils_book_get_supported_fields (book);
 
58
 
 
59
        test_print ("successfully retrieved supported fields:\n");
 
60
        g_list_foreach (fields, (GFunc) list_member_print_and_free, NULL);
 
61
        test_print ("----------------\n");
 
62
        g_list_free (fields);
 
63
 
 
64
        /*
 
65
         * Async version
 
66
         */
 
67
        loop = g_main_loop_new (NULL, TRUE);
 
68
        ebook_test_utils_book_async_get_supported_fields (book,
 
69
                        (GSourceFunc) get_supported_fields_cb, loop);
 
70
 
 
71
        g_main_loop_run (loop);
 
72
 
 
73
        ebook_test_utils_book_remove (book);
 
74
 
 
75
        return 0;
 
76
}