[evolution-data-server/openismus-work-master] test-client-custom-summary.c: Added tests for transliteration queries.



commit 105666bd26b365893510db35de100bdf24061e8b
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Tue Aug 27 13:50:55 2013 +0200

    test-client-custom-summary.c: Added tests for transliteration queries.
    
    Added new vcard 'custom-16.vcf' with chinese words in the full name as well.
    
    The new test tests that transliterated queries work on regular fields
    as well as multi valued fields, specifically we are testing it with
    E_CONTACT_EMAIL and a contact containing chinese text.

 tests/libebook/Makefile.am                         |    1 +
 tests/libebook/client/test-client-custom-summary.c |  101 +++++++++++++++++++-
 tests/libebook/data/vcards/custom-16.vcf           |    6 +
 3 files changed, 106 insertions(+), 2 deletions(-)
---
diff --git a/tests/libebook/Makefile.am b/tests/libebook/Makefile.am
index dc3663d..f6c9d6c 100644
--- a/tests/libebook/Makefile.am
+++ b/tests/libebook/Makefile.am
@@ -97,6 +97,7 @@ EXTRA_DIST = \
        $(srcdir)/data/vcards/custom-13.vcf     \
        $(srcdir)/data/vcards/custom-14.vcf     \
        $(srcdir)/data/vcards/custom-15.vcf     \
+       $(srcdir)/data/vcards/custom-16.vcf     \
        $(NULL)
 
 test_ebook_commit_contact_LDADD=$(TEST_LIBS)
diff --git a/tests/libebook/client/test-client-custom-summary.c 
b/tests/libebook/client/test-client-custom-summary.c
index 889a6dd..b19e500 100644
--- a/tests/libebook/client/test-client-custom-summary.c
+++ b/tests/libebook/client/test-client-custom-summary.c
@@ -69,8 +69,7 @@ static ETestServerClosure setup_default_closure = { E_TEST_SERVER_ADDRESS_BOOK,
 #  define CHECK_UNSUPPORTED_ERROR(data) (((ClientTestData *)(data))->phone_number_query != FALSE)
 #endif
 
-#define N_CONTACTS 15
-
+#define N_CONTACTS 16
 
 typedef struct {
        ETestServerClosure parent;
@@ -758,6 +757,104 @@ main (gint argc,
                        suites[i].direct,
                        suites[i].custom,
                        FALSE);
+
+               /*********************************************
+                *      TRANSLITERATION QUERIES FOLLOW       *
+                *********************************************/
+
+               /* We have one contact that is "Jim Morrison" and
+                * another which is "警察 懂吗" (which transliterates
+                * to "Jing cha Dong ma", which means "Police do you understand").
+                *
+                * This test tries to fetch 2 contacts beginning with '几' which
+                * transliterates to 'jǐ'.
+                *
+                * So here we assert that when searching for contacts which begin
+                * with a transliterated "几" match both "Jim Morrison" and
+                * "警察 懂吗"
+                */
+               add_client_test (
+                       suites[i].prefix,
+                       "/Transliterated/Prefix/FullName/几",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_FULL_NAME,
+                               E_BOOK_QUERY_TRANSLIT_BEGINS_WITH,
+                               "几"),
+                       2,
+                       suites[i].direct,
+                       suites[i].custom,
+                       FALSE);
+
+               /* Same results as above, only the query input is provided in Latin script */
+               add_client_test (
+                       suites[i].prefix,
+                       "/Transliterated/Prefix/FullName/Ji",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_FULL_NAME,
+                               E_BOOK_QUERY_TRANSLIT_BEGINS_WITH,
+                               "Ji"),
+                       2,
+                       suites[i].direct,
+                       suites[i].custom,
+                       FALSE);
+
+               /* Check if anything contains "Ma", this should
+                * only find one match for "警察 懂吗" */
+               add_client_test (
+                       suites[i].prefix,
+                       "/Transliterated/Contains/FullName/Ma",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_FULL_NAME,
+                               E_BOOK_QUERY_TRANSLIT_CONTAINS,
+                               "Ma"),
+                       1,
+                       suites[i].direct,
+                       suites[i].custom,
+                       FALSE);
+
+
+               add_client_test (
+                       suites[i].prefix,
+                       "/Transliterated/Contains/FullName/Ma",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_FULL_NAME,
+                               E_BOOK_QUERY_TRANSLIT_CONTAINS,
+                               "Ma"),
+                       1,
+                       suites[i].direct,
+                       suites[i].custom,
+                       FALSE);
+
+               add_client_test (
+                       suites[i].prefix,
+                       "/Transliterated/Suffix/FullName/Cha",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_FULL_NAME,
+                               E_BOOK_QUERY_TRANSLIT_ENDS_WITH,
+                               "Cha"),
+                       1,
+                       suites[i].direct,
+                       suites[i].custom,
+                       FALSE);
+
+               add_client_test (
+                       suites[i].prefix,
+                       "/Transliterated/Prefix/Email/几",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_EMAIL,
+                               E_BOOK_QUERY_TRANSLIT_BEGINS_WITH,
+                               "几"),
+                       2,
+                       suites[i].direct,
+                       suites[i].custom,
+                       FALSE);
+
        }
 
        ret = e_test_server_utils_run ();
diff --git a/tests/libebook/data/vcards/custom-16.vcf b/tests/libebook/data/vcards/custom-16.vcf
new file mode 100644
index 0000000..213b2e0
--- /dev/null
+++ b/tests/libebook/data/vcards/custom-16.vcf
@@ -0,0 +1,6 @@
+BEGIN:VCARD
+UID:custom-16
+N:警察;懂吗
+TEL;HOME:1.800 555 PONY
+EMAIL;TYPE=home,work:警察 china net
+END:VCARD


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