[evolution-data-server/openismus-work-master: 48/82] Fixed test cases to use the new API for setting alphabetic index targets.



commit dd75d8ef51574ed81124847b950285cfda28bbd2
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Sun Jun 9 18:13:43 2013 +0900

    Fixed test cases to use the new API for setting alphabetic index targets.
    
    Use e_book_backend_sqlitedb_cursor_set_target_alphabetic_index() instead
    of e_book_backend_sqlitedb_cursor_set_target() (which is now removed).

 tests/libedata-book/test-sqlite-cursor-calculate.c |   32 +++++++++++++++----
 .../libedata-book/test-sqlite-cursor-set-target.c  |   32 +++++++++++++++----
 2 files changed, 50 insertions(+), 14 deletions(-)
---
diff --git a/tests/libedata-book/test-sqlite-cursor-calculate.c 
b/tests/libedata-book/test-sqlite-cursor-calculate.c
index 029a768..c71823e 100644
--- a/tests/libedata-book/test-sqlite-cursor-calculate.c
+++ b/tests/libedata-book/test-sqlite-cursor-calculate.c
@@ -193,10 +193,19 @@ test_cursor_calculate_partial_target (EbSdbCursorFixture *fixture,
 {
        GError *error = NULL;
        gint    position = 0, total = 0;
+       ECollator *collator;
+       gint n_labels;
+       const gchar *const *labels;
 
-       /* Set the cursor to point to the beginning of "C" */
-       e_book_backend_sqlitedb_cursor_set_target (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                  fixture->cursor, "C", NULL);
+       /* First verify our test... in en_US locale the label 'C' should exist with the index 3 */
+       collator = e_book_backend_sqlitedb_ref_collator (((ESqliteDBFixture *) fixture)->ebsdb);
+       labels = e_collator_get_index_labels (collator, &n_labels, NULL, NULL, NULL);
+       g_assert_cmpstr (labels[3], ==, "C");
+       e_collator_unref (collator);
+
+       /* Set the cursor at the start of family names beginning with 'C' */
+       e_book_backend_sqlitedb_cursor_set_target_alphabetic_index (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                                   fixture->cursor, 3);
 
        /* Check new position */
        if (!e_book_backend_sqlitedb_cursor_calculate (((ESqliteDBFixture *) fixture)->ebsdb,
@@ -353,10 +362,19 @@ test_cursor_calculate_filtered_partial_target (EbSdbCursorFixture *fixture,
 {
        GError *error = NULL;
        gint    position = 0, total = 0;
-
-       /* Set the cursor to point to the beginning of "C" */
-       e_book_backend_sqlitedb_cursor_set_target (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                  fixture->cursor, "C", NULL);
+       ECollator *collator;
+       gint n_labels;
+       const gchar *const *labels;
+
+       /* First verify our test... in en_US locale the label 'C' should exist with the index 3 */
+       collator = e_book_backend_sqlitedb_ref_collator (((ESqliteDBFixture *) fixture)->ebsdb);
+       labels = e_collator_get_index_labels (collator, &n_labels, NULL, NULL, NULL);
+       g_assert_cmpstr (labels[3], ==, "C");
+       e_collator_unref (collator);
+
+       /* Set the cursor at the start of family names beginning with 'C' */
+       e_book_backend_sqlitedb_cursor_set_target_alphabetic_index (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                                   fixture->cursor, 3);
 
        /* Check new position */
        if (!e_book_backend_sqlitedb_cursor_calculate (((ESqliteDBFixture *) fixture)->ebsdb,
diff --git a/tests/libedata-book/test-sqlite-cursor-set-target.c 
b/tests/libedata-book/test-sqlite-cursor-set-target.c
index d0ad7e6..4f240ef 100644
--- a/tests/libedata-book/test-sqlite-cursor-set-target.c
+++ b/tests/libedata-book/test-sqlite-cursor-set-target.c
@@ -41,8 +41,8 @@ test_cursor_set_target_reset_cursor (EbSdbCursorFixture *fixture,
        g_slist_free (results);
 
        /* Reset cursor */
-       e_book_backend_sqlitedb_cursor_set_target (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                  fixture->cursor, NULL);
+       e_book_backend_sqlitedb_cursor_set_target_contact (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                          fixture->cursor, NULL);
 
        /* Second batch */
        results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
@@ -76,10 +76,19 @@ test_cursor_set_target_c_next_results (EbSdbCursorFixture *fixture,
 {
        GSList *results;
        GError *error = NULL;
+       ECollator *collator;
+       gint n_labels;
+       const gchar *const *labels;
+
+       /* First verify our test... in en_US locale the label 'C' should exist with the index 3 */
+       collator = e_book_backend_sqlitedb_ref_collator (((ESqliteDBFixture *) fixture)->ebsdb);
+       labels = e_collator_get_index_labels (collator, &n_labels, NULL, NULL, NULL);
+       g_assert_cmpstr (labels[3], ==, "C");
+       e_collator_unref (collator);
 
        /* Set the cursor at the start of family names beginning with 'C' */
-       e_book_backend_sqlitedb_cursor_set_target (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                  fixture->cursor, "C", NULL);
+       e_book_backend_sqlitedb_cursor_set_target_alphabetic_index (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                                   fixture->cursor, 3);
 
        results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
                                                          fixture->cursor, 5, &error);
@@ -112,10 +121,19 @@ test_cursor_set_target_c_prev_results (EbSdbCursorFixture *fixture,
 {
        GSList *results;
        GError *error = NULL;
+       ECollator *collator;
+       gint n_labels;
+       const gchar *const *labels;
 
-       /* Set the cursor at the start of family names beginning with 'J' */
-       e_book_backend_sqlitedb_cursor_set_target (((ESqliteDBFixture *) fixture)->ebsdb,
-                                                  fixture->cursor, "C", NULL);
+       /* First verify our test... in en_US locale the label 'C' should exist with the index 3 */
+       collator = e_book_backend_sqlitedb_ref_collator (((ESqliteDBFixture *) fixture)->ebsdb);
+       labels = e_collator_get_index_labels (collator, &n_labels, NULL, NULL, NULL);
+       g_assert_cmpstr (labels[3], ==, "C");
+       e_collator_unref (collator);
+
+       /* Set the cursor at the start of family names beginning with 'C' */
+       e_book_backend_sqlitedb_cursor_set_target_alphabetic_index (((ESqliteDBFixture *) fixture)->ebsdb,
+                                                                   fixture->cursor, 3);
 
        results = e_book_backend_sqlitedb_cursor_move_by (((ESqliteDBFixture *) fixture)->ebsdb,
                                                          fixture->cursor, -5, &error);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]