diff options
author | Dmitri Plotnikov <dplotnikov@google.com> | 2010-08-11 16:57:00 -0700 |
---|---|---|
committer | Dmitri Plotnikov <dplotnikov@google.com> | 2010-08-11 16:57:00 -0700 |
commit | 5b3634b24d3c21618f96860e969fd5c9ba7d9ca8 (patch) | |
tree | 7f990e816d0d25282c4db802f4d018c172585416 /tests | |
parent | b0c9a8a175ca1d3fea593062081b838b6e758339 (diff) | |
download | packages_providers_ContactsProvider-5b3634b24d3c21618f96860e969fd5c9ba7d9ca8.zip packages_providers_ContactsProvider-5b3634b24d3c21618f96860e969fd5c9ba7d9ca8.tar.gz packages_providers_ContactsProvider-5b3634b24d3c21618f96860e969fd5c9ba7d9ca8.tar.bz2 |
Adding support for query-based aggregation suggestions.
For now exact name match is required.
Will add other types of search later.
Change-Id: Ibc7bca3a7f418da349b318e0e31861268af5f827
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/providers/contacts/ContactAggregatorTest.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/src/com/android/providers/contacts/ContactAggregatorTest.java b/tests/src/com/android/providers/contacts/ContactAggregatorTest.java index 6113856..38cd4bb 100644 --- a/tests/src/com/android/providers/contacts/ContactAggregatorTest.java +++ b/tests/src/com/android/providers/contacts/ContactAggregatorTest.java @@ -28,6 +28,7 @@ import android.net.Uri; import android.provider.ContactsContract; import android.provider.ContactsContract.AggregationExceptions; import android.provider.ContactsContract.Contacts; +import android.provider.ContactsContract.Contacts.AggregationSuggestions; import android.provider.ContactsContract.Data; import android.provider.ContactsContract.RawContacts; import android.provider.ContactsContract.CommonDataKinds.Organization; @@ -893,6 +894,54 @@ public class ContactAggregatorTest extends BaseContactsProvider2Test { assertAggregated(rawContactId1, rawContactId2); } + public void testAggregationSuggestionsQueryBuilderWithContactId() throws Exception { + Uri uri = AggregationSuggestions.builder().setContactId(12).setLimit(7).build(); + assertEquals("content://com.android.contacts/contacts/12/suggestions?limit=7", + uri.toString()); + } + + public void testAggregationSuggestionsQueryBuilderWithValues() throws Exception { + Uri uri = AggregationSuggestions.builder() + .addParameter(AggregationSuggestions.MATCH_NAME, "name1") + .addParameter(AggregationSuggestions.MATCH_NAME, "name2") + .addParameter(AggregationSuggestions.MATCH_EMAIL, "email1") + .addParameter(AggregationSuggestions.MATCH_EMAIL, "email2") + .addParameter(AggregationSuggestions.MATCH_PHONE, "phone1") + .addParameter(AggregationSuggestions.MATCH_NICKNAME, "nickname1") + .setLimit(7) + .build(); + assertEquals("content://com.android.contacts/contacts/-1/suggestions?" + + "limit=7" + + "&query=name%3Aname1" + + "&query=name%3Aname2" + + "&query=email%3Aemail1" + + "&query=email%3Aemail2" + + "&query=phone%3Aphone1" + + "&query=nickname%3Anickname1", uri.toString()); + } + + public void testAggregationSuggestionsByName() throws Exception { + long rawContactId1 = createRawContactWithName("first1", "last1"); + long rawContactId2 = createRawContactWithName("first2", "last2"); + + Uri uri = AggregationSuggestions.builder() + .addParameter(AggregationSuggestions.MATCH_NAME, "last1 first1") + .build(); + + Cursor cursor = mResolver.query( + uri, new String[] { Contacts._ID, Contacts.DISPLAY_NAME }, null, null, null); + + assertEquals(1, cursor.getCount()); + + cursor.moveToFirst(); + + ContentValues values = new ContentValues(); + values.put(Contacts._ID, queryContactId(rawContactId1)); + values.put(Contacts.DISPLAY_NAME, "first1 last1"); + assertCursorValues(cursor, values); + cursor.close(); + } + private void assertSuggestions(long contactId, long... suggestions) { final Uri aggregateUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); Uri uri = Uri.withAppendedPath(aggregateUri, |