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

« back to all changes in this revision

Viewing changes to addressbook/tests/ebook/test-changes.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:
3
3
#include <stdlib.h>
4
4
#include <libebook/e-book.h>
5
5
 
 
6
#include "ebook-test-utils.h"
 
7
 
6
8
#define NEW_VCARD "BEGIN:VCARD\n\
7
9
X-EVOLUTION-FILE-AS:Toshok, Chris\n\
8
10
FN:Chris Toshok\n\
18
20
        GList *changes;
19
21
        GError *error = NULL;
20
22
        EBookChange *change;
21
 
        gchar *file_template;
22
23
        gchar *uri;
23
24
 
24
25
        g_type_init ();
25
26
 
26
 
        file_template = g_build_filename (g_get_tmp_dir (),
27
 
                                          "change-test-XXXXXX",
28
 
                                          NULL);
29
 
        g_mkstemp (file_template);
30
 
 
31
 
        uri = g_filename_to_uri (file_template, NULL, &error);
32
 
        if (!uri) {
33
 
                printf ("failed to convert %s to an URI: %s\n",
34
 
                        file_template, error->message);
35
 
                exit (0);
36
 
        }
37
 
        g_free (file_template);
38
 
 
39
 
        /* create a temp addressbook in /tmp */
40
 
        printf ("loading addressbook\n");
41
 
        book = e_book_new_from_uri (uri, &error);
42
 
        if (!book) {
43
 
                printf ("failed to create addressbook: `%s': %s\n",
44
 
                        uri, error->message);
45
 
                exit(0);
46
 
        }
47
 
 
48
 
        if (!e_book_open (book, FALSE, &error)) {
49
 
                printf ("failed to open addressbook: `%s': %s\n",
50
 
                        uri, error->message);
51
 
                exit(0);
52
 
        }
 
27
        book = ebook_test_utils_book_new_temp (&uri);
 
28
        ebook_test_utils_book_open (book, FALSE);
53
29
 
54
30
        /* get an initial change set */
55
31
        if (!e_book_get_changes (book, "changeidtest", &changes, &error)) {
59
35
 
60
36
        /* make a change to the book */
61
37
        contact = e_contact_new_from_vcard (NEW_VCARD);
62
 
        if (!e_book_add_contact (book, contact, &error)) {
63
 
                printf ("failed to add new contact: %s\n", error->message);
64
 
                exit(0);
65
 
        }
 
38
        ebook_test_utils_book_add_contact (book, contact);
66
39
 
67
40
        /* get another change set */
68
41
        if (!e_book_get_changes (book, "changeidtest", &changes, &error)) {
86
59
 
87
60
        e_book_free_change_list (changes);
88
61
 
89
 
        if (!e_book_remove (book, &error)) {
90
 
                printf ("failed to remove book; %s\n", error->message);
91
 
                exit(0);
92
 
        }
93
 
 
94
 
        g_object_unref (book);
 
62
        g_object_unref (contact);
 
63
        ebook_test_utils_book_remove (book);
95
64
 
96
65
        return 0;
97
66
}