diff options
author | Dmitri Plotnikov <dplotnikov@google.com> | 2010-08-18 19:25:19 -0700 |
---|---|---|
committer | Dmitri Plotnikov <dplotnikov@google.com> | 2010-08-18 19:25:19 -0700 |
commit | 7a3c645fa7db38449d34eb04d4e032fd079c3244 (patch) | |
tree | b070c9dbe75006a3f2673599f3e9241826aa1575 /tests | |
parent | ac13ddd04d665442de846b59234bdc936a6699b4 (diff) | |
download | packages_providers_ContactsProvider-7a3c645fa7db38449d34eb04d4e032fd079c3244.zip packages_providers_ContactsProvider-7a3c645fa7db38449d34eb04d4e032fd079c3244.tar.gz packages_providers_ContactsProvider-7a3c645fa7db38449d34eb04d4e032fd079c3244.tar.bz2 |
New ContactsProvider query: complete_name
We want to allow the UI to switch freely
between a single field name and multi-field name.
For that we need to expose the name parsing/concatenation
machinery we have in the contacts provider.
Change-Id: I51586e309e11a90c719d747862b646de7fb8f326
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/providers/contacts/ContactsProvider2Test.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java index ec8522e..4c293e1 100644 --- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java +++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java @@ -47,6 +47,7 @@ import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Data; import android.provider.ContactsContract.Directory; import android.provider.ContactsContract.DisplayNameSources; +import android.provider.ContactsContract.FullNameStyle; import android.provider.ContactsContract.Groups; import android.provider.ContactsContract.PhoneLookup; import android.provider.ContactsContract.PhoneticNameStyle; @@ -3492,6 +3493,45 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test { assertStoredValue(rawContactUri2, RawContacts.CUSTOM_RINGTONE, "second"); } + public void testNameParsingQuery() { + Uri uri = ContactsContract.AUTHORITY_URI.buildUpon().appendPath("complete_name") + .appendQueryParameter(StructuredName.DISPLAY_NAME, "Mr. John Q. Doe Jr.").build(); + Cursor cursor = mResolver.query(uri, null, null, null, null); + ContentValues values = new ContentValues(); + values.put(StructuredName.DISPLAY_NAME, "Mr. John Q. Doe Jr."); + values.put(StructuredName.PREFIX, "Mr"); + values.put(StructuredName.GIVEN_NAME, "John"); + values.put(StructuredName.MIDDLE_NAME, "Q."); + values.put(StructuredName.FAMILY_NAME, "Doe"); + values.put(StructuredName.SUFFIX, "Jr."); + values.put(StructuredName.FULL_NAME_STYLE, FullNameStyle.WESTERN); + assertTrue(cursor.moveToFirst()); + assertCursorValues(cursor, values); + cursor.close(); + } + + public void testNameConcatenationQuery() { + Uri uri = ContactsContract.AUTHORITY_URI.buildUpon().appendPath("complete_name") + .appendQueryParameter(StructuredName.PREFIX, "Mr") + .appendQueryParameter(StructuredName.GIVEN_NAME, "John") + .appendQueryParameter(StructuredName.MIDDLE_NAME, "Q.") + .appendQueryParameter(StructuredName.FAMILY_NAME, "Doe") + .appendQueryParameter(StructuredName.SUFFIX, "Jr.") + .build(); + Cursor cursor = mResolver.query(uri, null, null, null, null); + ContentValues values = new ContentValues(); + values.put(StructuredName.DISPLAY_NAME, "John Q. Doe, Jr."); + values.put(StructuredName.PREFIX, "Mr"); + values.put(StructuredName.GIVEN_NAME, "John"); + values.put(StructuredName.MIDDLE_NAME, "Q."); + values.put(StructuredName.FAMILY_NAME, "Doe"); + values.put(StructuredName.SUFFIX, "Jr."); + values.put(StructuredName.FULL_NAME_STYLE, FullNameStyle.WESTERN); + assertTrue(cursor.moveToFirst()); + assertCursorValues(cursor, values); + cursor.close(); + } + private Cursor queryGroupMemberships(Account account) { Cursor c = mResolver.query(maybeAddAccountQueryParameters(Data.CONTENT_URI, account), new String[]{GroupMembership.GROUP_ROW_ID, GroupMembership.RAW_CONTACT_ID}, |