1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2013, Openismus GmbH
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU Lesser General Public
7 * License as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
19 * Authors: Tristan Van Berkom <tristanvb@openismus.com>
22 #ifndef DATA_TEST_UTILS_H
23 #define DATA_TEST_UTILS_H
25 #include <libebook/libebook.h>
26 #include <libedata-book/libedata-book.h>
27 #include "e-test-server-utils.h"
28 #include "e-dbus-localed.h"
30 /* This legend shows the add order, and various sort order of the sorted
31 * vcards. The UIDs of these contacts are formed as 'sorted-1', 'sorted-2' etc
32 * and the numbering of the contacts is according to the 'N' column in the
35 * The Email column indicates whether the contact has a .com email address
36 * (in order to test filtered cursor results) and corresponds to the natural
37 * order in the 'N' column.
39 * +-----------------------------------------------------------------------------------------------+
40 * | N | Email | Last Name | en_US_POSIX | en_US / de_DE | fr_CA | de_DE |
41 * | | | | | | | (phonebook) |
42 * +-----------------------------------------------------------------------------------------------+
43 * | 1 | Yes | bad | 11 | 11 | 11 | 11 |
44 * | 2 | Yes | Bad | Bad 2 | bad 1 | bad 1 | bad 1 |
45 * | 3 | Yes | Bat | Bäd 6 | Bad 2 | Bad 2 | Bad 2 |
46 * | 4 | No | bat | Bat 3 | bäd 5 | bäd 5 | bäd 5 |
47 * | 5 | Yes | bäd | Bät 8 | Bäd 6 | Bäd 6 | Bäd 6 |
48 * | 6 | No | Bäd | bad 1 | bat 4 | bat 4 | bät 7 |
49 * | 7 | No | bät | bäd 5 | Bat 3 | Bat 3 | Bät 8 |
50 * | 8 | Yes | Bät | bat 4 | bät 7 | bät 7 | bat 4 |
51 * | 9 | Yes | côté | bät 7 | Bät 8 | Bät 8 | Bat 3 |
52 * | 10 | Yes | C | black-bird 15 | black-bird 15 | black-bird 15 | black-bird 15 |
53 * | 11 | Yes | | black-birds 17 | black-birds 17 | black-birds 17 | black-birds 17 |
54 * | 12 | Yes | coté | blackbird 16 | blackbird 16 | blackbird 16 | blackbird 16 |
55 * | 13 | No | côte | blackbirds 18 | blackbirds 18 | blackbirds 18 | blackbirds 18 |
56 * | 14 | Yes | cote | C 10 | C 10 | C 10 | C 10 |
57 * | 15 | No | black-bird | cote 14 | cote 14 | cote 14 | cote 14 |
58 * | 16 | Yes | blackbird | coté 12 | coté 12 | côte 13 | coté 12 |
59 * | 17 | Yes | black-birds | côte 13 | côte 13 | coté 12 | côte 13 |
60 * | 18 | Yes | blackbirds | côté 9 | côté 9 | côté 9 | côté 9 |
61 * | 19 | No | Muffler | Muffler 19 | Muffler 19 | Muffler 19 | Müller 20 |
62 * | 20 | No | Müller | Müller 20 | Müller 20 | Müller 20 | Muffler 19 |
63 * +-----------------------------------------------------------------------------------------------+
65 * See this ICU demo to check additional sort ordering by ICU in various locales:
66 * http://demo.icu-project.org/icu-bin/locexp?_=en_US&d_=en&x=col
69 #define SQLITEDB_FOLDER_ID "folder_id"
70 #define N_SORTED_CONTACTS 20
71 #define MAX_MOVE_BY_COUNTS 5
73 /* 13 contacts in the test data have an email address ending with ".com" */
74 #define N_FILTERED_CONTACTS 13
78 ETestServerFixture parent_fixture;
80 EBookBackendSqliteDB *ebsdb;
84 ESqliteDBFixture parent_fixture;
87 EContact *contacts[N_SORTED_CONTACTS];
90 EDBusLocale1 *locale1;
95 ETestServerClosure parent;
98 EBookSortType sort_type;
102 EbSdbCursorClosure parent;
105 /* array of counts to move by, terminated with 0 or MAX_COUNTS */
106 gint counts[MAX_MOVE_BY_COUNTS];
108 /* For each move_by() command, an array of 'ABS (counts[i])' expected contacts */
109 gint expected[MAX_MOVE_BY_COUNTS][N_SORTED_CONTACTS];
111 /* Whether this is a filtered test */
118 void e_sqlitedb_fixture_setup (ESqliteDBFixture *fixture,
119 gconstpointer user_data);
120 void e_sqlitedb_fixture_teardown (ESqliteDBFixture *fixture,
121 gconstpointer user_data);
123 void e_sqlitedb_cursor_fixture_setup_book (ESource *scratch,
124 ETestServerClosure *closure);
125 void e_sqlitedb_cursor_fixture_setup (EbSdbCursorFixture *fixture,
126 gconstpointer user_data);
127 void e_sqlitedb_cursor_fixture_teardown (EbSdbCursorFixture *fixture,
128 gconstpointer user_data);
129 void e_sqlitedb_cursor_fixture_set_locale (EbSdbCursorFixture *fixture,
130 const gchar *locale);
132 /* Filters contacts with E_CONTACT_EMAIL ending with '.com' */
133 void e_sqlitedb_cursor_fixture_filtered_setup (EbSdbCursorFixture *fixture,
134 gconstpointer user_data);
137 gchar *new_vcard_from_test_case (const gchar *case_name);
138 EContact *new_contact_from_test_case (const gchar *case_name);
140 gboolean add_contact_from_test_case_verify (EBookClient *book_client,
141 const gchar *case_name,
144 void assert_contacts_order_slist (GSList *results,
146 void assert_contacts_order (GSList *results,
147 const gchar *first_uid,
148 ...) G_GNUC_NULL_TERMINATED;
150 void print_results (GSList *results);
152 /* MoveBy test helpers */
153 void move_by_test_add_assertion (MoveByData *data,
156 MoveByData *move_by_test_new (const gchar *test_path,
157 const gchar *locale);
158 MoveByData *move_by_test_new_full (const gchar *test_path,
160 EBookSortType sort_type);
161 void move_by_test_add (MoveByData *data,
164 #endif /* DATA_TEST_UTILS_H */