[evolution-data-server/sqlite-refactor: 13/13] test-client-custom-summary.c: Fix expectations for phone number matches.



commit c6ffd03df33370f2ee54dc6ce264ca99ebc1d8d3
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Sat Nov 23 22:12:28 2013 +0900

    test-client-custom-summary.c: Fix expectations for phone number matches.

 tests/libebook/client/test-client-custom-summary.c |  219 ++++++++++++++++----
 1 files changed, 176 insertions(+), 43 deletions(-)
---
diff --git a/tests/libebook/client/test-client-custom-summary.c 
b/tests/libebook/client/test-client-custom-summary.c
index ab5fc7b..f8eeb62 100644
--- a/tests/libebook/client/test-client-custom-summary.c
+++ b/tests/libebook/client/test-client-custom-summary.c
@@ -544,7 +544,7 @@ main (gint argc,
                        FALSE);
 
                /*********************************************
-                *         PHONE NUMBER QUERIES FOLLOW       *
+                *                PHONE NUMBERS              *
                 *********************************************/
 
                /* Expect E_CLIENT_ERROR_INVALID_QUERY, "ask Jenny for
@@ -564,29 +564,13 @@ main (gint argc,
                        suites[i].custom,
                        TRUE);
 
-               /* These queries will do an index lookup with a custom summary,
-                * and a full table scan matching with EBookBackendSexp when
-                * the default summary is used. */
-               add_client_test (
-                       suites[i].prefix,
-                       "/EqPhone/Exact/Common",
-                       suites[i].func,
-                       e_book_query_field_test (
-                               E_CONTACT_TEL,
-                               E_BOOK_QUERY_EQUALS_PHONE_NUMBER,
-                               "+1 221.542.3789"),
-                       1,
-                       suites[i].direct,
-                       suites[i].custom,
-                       TRUE);
-
                /* This test checks that phone number matching works when
                 * deeply nested into a query, when ENABLE_PHONENUMBER is
                 * not defined, then it ensures that the query is refused
                 * while being deeply nested. */
                add_client_test (
                        suites[i].prefix,
-                       "/EqPhone/Exact/Nested",
+                       "/EqPhone/NestedQuery",
                        suites[i].func,
                        e_book_query_orv (
                                e_book_query_field_test (
@@ -614,44 +598,97 @@ main (gint argc,
                        TRUE);
 
                /*********************************************
-                * E_BOOK_QUERY_EQUALS_NATIONAL_PHONE_NUMBER *
+                *      E_BOOK_QUERY_EQUALS_PHONE_NUMBER     *
                 *********************************************/
+               /* Only exact matches are returned.
+                *
+                * Query: +1 221.542.3789
+                * +------------------------------+--------------------+
+                * | vCard Data:   +1-221-5423789 | Matches: Exact     |
+                * | vCard Data:  +31-221-5423789 | Matches: None      |
+                * +------------------------------+--------------------+
+                */
+               add_client_test (
+                       suites[i].prefix,
+                       "/EqPhone/Exact",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_TEL,
+                               E_BOOK_QUERY_EQUALS_PHONE_NUMBER,
+                               "+1 221.542.3789"),
+                       1,
+                       suites[i].direct,
+                       suites[i].custom,
+                       TRUE);
+
 
+               /*
+                * Query: +49 408.765.5050 (one exact match)
+                * +------------------------------+--------------------+
+                * | vCard Data:     408 765-5050 | Matches: National  |
+                * | vCard Data:  +1 408 765-5050 | Matches: None      |
+                * | vCard Data: +49 408 765-5050 | Matches: Exact     |
+                * +------------------------------+--------------------+
+                */
                add_client_test (
                        suites[i].prefix,
-                       "/EqPhone/National/WithoutCountry",
+                       "/EqPhone/Exact/Another",
                        suites[i].func,
                        e_book_query_field_test (
                                E_CONTACT_TEL,
-                               E_BOOK_QUERY_EQUALS_NATIONAL_PHONE_NUMBER,
-                               "408 765-5050"),
-                       2,
+                               E_BOOK_QUERY_EQUALS_PHONE_NUMBER,
+                               "+49 408.765.5050"),
+                       1,
                        suites[i].direct,
                        suites[i].custom,
                        TRUE);
 
+               /*
+                * Query: 408.765.5050 (no exact match)
+                * +------------------------------+--------------------+
+                * | vCard Data:     408 765-5050 | Matches: National  |
+                * | vCard Data:  +1 408 765-5050 | Matches: National  |
+                * | vCard Data: +49 408 765-5050 | Matches: National  |
+                * +------------------------------+--------------------+
+                */
                add_client_test (
                        suites[i].prefix,
-                       "/EqPhone/National/en_US",
+                       "/EqPhone/Exact/MissingCountryInput",
                        suites[i].func,
                        e_book_query_field_test (
                                E_CONTACT_TEL,
-                               E_BOOK_QUERY_EQUALS_NATIONAL_PHONE_NUMBER,
-                               "+1 408 765-5050"),
-                       2,
+                               E_BOOK_QUERY_EQUALS_PHONE_NUMBER,
+                               "408.765.5050"),
+                       0,
                        suites[i].direct,
                        suites[i].custom,
                        TRUE);
 
+
+               /*********************************************
+                * E_BOOK_QUERY_EQUALS_NATIONAL_PHONE_NUMBER *
+                *********************************************/
+               /* Test that a query term with no specified country returns
+                * all vCards that have the same national number regardless
+                * of country codes (including contacts which have no
+                * national number specified)
+                *
+                * Query: 408 765-5050
+                * +------------------------------+--------------------+
+                * | vCard Data:     408 765-5050 | Matches: National  |
+                * | vCard Data:  +1 408 765-5050 | Matches: National  |
+                * | vCard Data: +49 408 765-5050 | Matches: National  |
+                * +------------------------------+--------------------+
+                */
                add_client_test (
                        suites[i].prefix,
-                       "/EqPhone/National/de_DE",
+                       "/EqPhone/National/WithoutCountry",
                        suites[i].func,
                        e_book_query_field_test (
                                E_CONTACT_TEL,
                                E_BOOK_QUERY_EQUALS_NATIONAL_PHONE_NUMBER,
-                               "+49 408 765-5050"),
-                       1,
+                               "408 765-5050"),
+                       3,
                        suites[i].direct,
                        suites[i].custom,
                        TRUE);
@@ -660,28 +697,80 @@ main (gint argc,
                 * all vCards that have the same national number regardless
                 * of country codes.
                 *
-                * | Active Country Code: +1 | Query: 221.542.3789 | vCard Data: +1-221-5423789 | Matches: 
yes |
-                * | Active Country Code: +1 | Query: 221.542.3789 | vCard Data: +31-221-5423789 | Matches: 
no  |
+                * Query: 221.542.3789
+                * +------------------------------+--------------------+
+                * | vCard Data:   +1-221-5423789 | Matches: National  |
+                * | vCard Data:  +31-221-5423789 | Matches: National  |
+                * +------------------------------+--------------------+
                 */
                add_client_test (
                        suites[i].prefix,
-                       "/EqPhone/National/Common",
+                       "/EqPhone/National/WithoutCountry2",
                        suites[i].func,
                        e_book_query_field_test (
                                E_CONTACT_TEL,
                                E_BOOK_QUERY_EQUALS_NATIONAL_PHONE_NUMBER,
                                "221.542.3789"),
-                       1,
+                       2,
+                       suites[i].direct,
+                       suites[i].custom,
+                       TRUE);
+
+               /* Test that querying with an explicit country code reports
+                * national number matches for numbers without a country
+                * code, and not for numbers with explicitly different
+                * country codes.
+                *
+                * Query: +1 408 765-5050
+                * +------------------------------+--------------------+
+                * | vCard Data:     408 765-5050 | Matches: National  |
+                * | vCard Data:  +1 408 765-5050 | Matches: Exact     |
+                * | vCard Data: +49 408 765-5050 | Matches: None      |
+                * +------------------------------+--------------------+
+                */
+               add_client_test (
+                       suites[i].prefix,
+                       "/EqPhone/National/en_US",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_TEL,
+                               E_BOOK_QUERY_EQUALS_NATIONAL_PHONE_NUMBER,
+                               "+1 408 765-5050"),
+                       2,
+                       suites[i].direct,
+                       suites[i].custom,
+                       TRUE);
+
+               /* Query: +49 408 765-5050
+                * +------------------------------+--------------------+
+                * | vCard Data:     408 765-5050 | Matches: National  |
+                * | vCard Data:  +1 408 765-5050 | Matches: None      |
+                * | vCard Data: +49 408 765-5050 | Matches: Exact     |
+                * +------------------------------+--------------------+
+                */
+               add_client_test (
+                       suites[i].prefix,
+                       "/EqPhone/National/de_DE",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_TEL,
+                               E_BOOK_QUERY_EQUALS_NATIONAL_PHONE_NUMBER,
+                               "+49 408 765-5050"),
+                       2,
                        suites[i].direct,
                        suites[i].custom,
                        TRUE);
 
+
                /* Test that a query term with a specified country returns
                 * only vCards that are specifically in the specified country
                 * code.
                 *
-                * | Active Country Code: +1 | Query: +49 221.542.3789 | vCard Data: +1-221-5423789 | 
Matches: no |
-                * | Active Country Code: +1 | Query: +49 221.542.3789 | vCard Data: +31-221-5423789 | 
Matches: no |
+                * Query: +49 221.542.3789
+                * +------------------------------+--------------------+
+                * | vCard Data:   +1-221-5423789 | Matches: None      |
+                * | vCard Data:  +31-221-5423789 | Matches: None      |
+                * +------------------------------+--------------------+
                 */
                add_client_test (
                        suites[i].prefix,
@@ -696,10 +785,13 @@ main (gint argc,
                        suites[i].custom,
                        TRUE);
 
-               /* Test that a query term with the active country code
+               /* Test that a query term with a country code
                 * specified returns a vCard with an unspecified country code.
                 *
-                * | Active Country Code: +1 | Query: +1 514-845-8436 | vCard Data: 514-845-8436 | Matches: 
yes |
+                * Query: +1 514-845-8436
+                * +------------------------------+--------------------+
+                * | vCard Data:     514-845-8436 | Matches: National  |
+                * +------------------------------+--------------------+
                 */
                add_client_test (
                        suites[i].prefix,
@@ -714,10 +806,18 @@ main (gint argc,
                        suites[i].custom,
                        TRUE);
 
-               /* Test that a query term with an arbitrary country code
-                * specified returns a vCard with an unspecified country code.
+               /* Test that a query term with another country code
+                * specified again returns a vCard with an unspecified
+                * country code.
                 *
-                * | Active Country Code: +1 | Query: +49 514-845-8436 | vCard Data: 514-845-8436 | Matches: 
yes |
+                * This test can help make sure that we are properly
+                * ignoring whatever country code is active by default
+                * in our locale.
+                *
+                * Query: +49 514-845-8436
+                * +------------------------------+--------------------+
+                * | vCard Data:     514-845-8436 | Matches: National  |
+                * +------------------------------+--------------------+
                 */
                add_client_test (
                        suites[i].prefix,
@@ -727,11 +827,23 @@ main (gint argc,
                                E_CONTACT_TEL,
                                E_BOOK_QUERY_EQUALS_NATIONAL_PHONE_NUMBER,
                                "+49 514-845-8436"),
-                       0,
+                       1,
                        suites[i].direct,
                        suites[i].custom,
                        TRUE);
 
+
+
+               /********************************************
+                *  E_BOOK_QUERY_EQUALS_SHORT_PHONE_NUMBER  *
+                ********************************************/
+               /*
+                * Query: 5423789
+                * +------------------------------+--------------------+
+                * | vCard Data:   +1-221-5423789 | Matches: Short     |
+                * | vCard Data:  +31-221-5423789 | Matches: Short     |
+                * +------------------------------+--------------------+
+                */
                add_client_test (
                        suites[i].prefix,
                        "/EqPhone/Short",
@@ -740,7 +852,28 @@ main (gint argc,
                                E_CONTACT_TEL,
                                E_BOOK_QUERY_EQUALS_SHORT_PHONE_NUMBER,
                                "5423789"),
-                       1,
+                       2,
+                       suites[i].direct,
+                       suites[i].custom,
+                       TRUE);
+
+               /*
+                * Query: 765-5050
+                * +------------------------------+--------------------+
+                * | vCard Data:     408 765-5050 | Matches: Short     |
+                * | vCard Data:  +1 408 765-5050 | Matches: Short     |
+                * | vCard Data: +49 408 765-5050 | Matches: Short     |
+                * +------------------------------+--------------------+
+                */
+               add_client_test (
+                       suites[i].prefix,
+                       "/EqPhone/Short/Another",
+                       suites[i].func,
+                       e_book_query_field_test (
+                               E_CONTACT_TEL,
+                               E_BOOK_QUERY_EQUALS_SHORT_PHONE_NUMBER,
+                               "765-5050"),
+                       3,
                        suites[i].direct,
                        suites[i].custom,
                        TRUE);


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