ESourceRegistry: Do not mandate builtin sources.
[platform/upstream/evolution-data-server.git] / tests / libebook / test-ebook-remove-contact.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 #include <libebook/libebook.h>
4
5 #include "ebook-test-utils.h"
6
7 gint
8 main (gint argc,
9       gchar **argv)
10 {
11         EBook *book;
12         GMainLoop *loop;
13         EContact *contact_final;
14         gchar *uid;
15
16         g_type_init ();
17
18         /*
19          * Setup
20          */
21         book = ebook_test_utils_book_new_temp (NULL);
22         ebook_test_utils_book_open (book, FALSE);
23
24         /*
25          * Sync version
26          */
27         uid = ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-1", NULL);
28         ebook_test_utils_book_remove_contact (book, uid);
29         contact_final = NULL;
30         e_book_get_contact (book, uid, &contact_final, NULL);
31
32         g_assert (contact_final == NULL);
33         test_print ("successfully added and removed contact '%s'\n", uid);
34
35         g_free (uid);
36
37         /*
38          * Async version
39          */
40         book = ebook_test_utils_book_new_temp (NULL);
41         ebook_test_utils_book_open (book, FALSE);
42
43         contact_final = NULL;
44         /* contact_final has 2 refs by the end of this */
45         uid = ebook_test_utils_book_add_contact_from_test_case_verify (book, "simple-1", &contact_final);
46
47         loop = g_main_loop_new (NULL, TRUE);
48         /* contact_final is unref'd by e_book_remove_contact() here */
49         ebook_test_utils_book_async_remove_contact (
50                 book, contact_final, ebook_test_utils_callback_quit, loop);
51
52         g_main_loop_run (loop);
53
54         g_object_unref (contact_final);
55         g_free (uid);
56
57         return 0;
58 }