[evolution-data-server/sqlite-refactor: 9/13] Added case to the book-migration test for basic cursor operation.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/sqlite-refactor: 9/13] Added case to the book-migration test for basic cursor operation.
- Date: Sat, 23 Nov 2013 15:38:10 +0000 (UTC)
commit fd4b4dbafbc08e85fefb203c23c71b42b9a0c8cd
Author: Tristan Van Berkom <tristanvb openismus com>
Date: Wed Nov 20 16:09:00 2013 +0900
Added case to the book-migration test for basic cursor operation.
tests/book-migration/test-migration.c | 55 +++++++++++++++++++++++++++++++++
1 files changed, 55 insertions(+), 0 deletions(-)
---
diff --git a/tests/book-migration/test-migration.c b/tests/book-migration/test-migration.c
index 47892fe..dfbfe90 100644
--- a/tests/book-migration/test-migration.c
+++ b/tests/book-migration/test-migration.c
@@ -265,6 +265,60 @@ test_query_phone (MigrationFixture *fixture,
g_slist_free_full (contacts, g_object_unref);
}
+static EContactField sort_fields[] = { E_CONTACT_FAMILY_NAME, E_CONTACT_GIVEN_NAME };
+static EBookCursorSortType sort_types[] = { E_BOOK_CURSOR_SORT_ASCENDING, E_BOOK_CURSOR_SORT_ASCENDING };
+
+/* For pre-cursor default summary configurations, the
+ * E_CONTACT_FAMILY_NAME and E_CONTACT_GIVEN_NAME fields should
+ * have been given an E_BOOK_INDEX_SORT_KEY during the upgrade
+ * process.
+ */
+static void
+test_cursor_step (MigrationFixture *fixture,
+ gconstpointer user_data)
+{
+ EBookClient *book_client;
+ EBookClientCursor *cursor;
+ GError *error = NULL;
+ GSList *contacts = NULL;
+ gint n_reported_results;
+
+ book_client = E_TEST_SERVER_UTILS_SERVICE (fixture, EBookClient);
+
+ if (!e_book_client_get_cursor_sync (book_client,
+ NULL,
+ sort_fields,
+ sort_types,
+ 2,
+ &cursor,
+ NULL, &error))
+ g_error ("Failed to create a cursor from a migrated book: %s", error->message);
+
+ n_reported_results = e_book_client_cursor_step_sync (cursor,
+ E_BOOK_CURSOR_STEP_MOVE |
+ E_BOOK_CURSOR_STEP_FETCH,
+ E_BOOK_CURSOR_ORIGIN_BEGIN,
+ 10,
+ &contacts,
+ NULL, &error);
+ g_assert_cmpint (n_reported_results, ==, g_slist_length (contacts));
+ g_assert_cmpint (e_book_client_cursor_get_position (cursor), ==, 10);
+ g_slist_free_full (contacts, g_object_unref);
+
+ n_reported_results = e_book_client_cursor_step_sync (cursor,
+ E_BOOK_CURSOR_STEP_MOVE |
+ E_BOOK_CURSOR_STEP_FETCH,
+ E_BOOK_CURSOR_ORIGIN_CURRENT,
+ 10,
+ &contacts,
+ NULL, &error);
+ g_assert_cmpint (n_reported_results, ==, g_slist_length (contacts));
+ g_assert_cmpint (e_book_client_cursor_get_position (cursor), ==, 20);
+ g_slist_free_full (contacts, g_object_unref);
+
+ g_object_unref (cursor);
+}
+
/***********************************************************
* Main *
***********************************************************/
@@ -371,6 +425,7 @@ main (gint argc,
add_test (version, "Query/FullName", test_query_name);
add_test (version, "Query/Phone", test_query_phone);
add_test (version, "Query/Email", test_query_email);
+ add_test (version, "Cursor/Step", test_cursor_step);
}
g_list_free_full (sandboxes, g_free);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]