diff options
author | Dmitri Plotnikov <dplotnikov@google.com> | 2011-02-16 15:41:44 -0800 |
---|---|---|
committer | Dmitri Plotnikov <dplotnikov@google.com> | 2011-02-16 15:41:44 -0800 |
commit | 0db2cea4e4a8082ca8dd7d2023b9f3025c2768d8 (patch) | |
tree | 5a5c74cb2f093ccf538cefe91525916f8bea91ec /tests | |
parent | 2352cf62c46e1caaad64c7b3dbcc601951018eb3 (diff) | |
download | packages_providers_ContactsProvider-0db2cea4e4a8082ca8dd7d2023b9f3025c2768d8.zip packages_providers_ContactsProvider-0db2cea4e4a8082ca8dd7d2023b9f3025c2768d8.tar.gz packages_providers_ContactsProvider-0db2cea4e4a8082ca8dd7d2023b9f3025c2768d8.tar.bz2 |
Added a couple of regression tests
Bug: 3423385
Change-Id: I6d8ab5c8669b61d69152a3b2d3ba88ffa3fc6ce0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/providers/contacts/ContactLookupKeyTest.java | 7 | ||||
-rw-r--r-- | tests/src/com/android/providers/contacts/ContactsProvider2Test.java | 32 |
2 files changed, 38 insertions, 1 deletions
diff --git a/tests/src/com/android/providers/contacts/ContactLookupKeyTest.java b/tests/src/com/android/providers/contacts/ContactLookupKeyTest.java index ebadc55..225b00c 100644 --- a/tests/src/com/android/providers/contacts/ContactLookupKeyTest.java +++ b/tests/src/com/android/providers/contacts/ContactLookupKeyTest.java @@ -74,11 +74,16 @@ public class ContactLookupKeyTest extends BaseContactsProvider2Test { long rawContactId2 = createRawContactWithName("johndoe", null); storeValue(RawContacts.CONTENT_URI, rawContactId2, RawContacts.SOURCE_ID, "4.5.6"); + long rawContactId3 = createRawContactWithName("john", "dough"); + storeValue(RawContacts.CONTENT_URI, rawContactId3, RawContacts.SOURCE_ID, "http://foo?bar"); + setAggregationException( AggregationExceptions.TYPE_KEEP_TOGETHER, rawContactId1, rawContactId2); + setAggregationException( + AggregationExceptions.TYPE_KEEP_TOGETHER, rawContactId1, rawContactId3); // Two source ids, of them escaped - String expectedLookupKey = "0i123.0e4..5..6"; + String expectedLookupKey = "0i123.0e4..5..6.0ihttp%3A%2F%2Ffoo%3Fbar"; long contactId = queryContactId(rawContactId1); assertStoredValue(ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId), diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java index 790d294..557f228 100644 --- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java +++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java @@ -2400,6 +2400,38 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test { null, Contacts.IN_VISIBLE_GROUP, expectedValue); } + public void testSupplyingBothValuesAndParameters() throws Exception { + Account account = new Account("account 1", "type%/:1"); + Uri uri = ContactsContract.Groups.CONTENT_URI.buildUpon() + .appendQueryParameter(ContactsContract.Groups.ACCOUNT_NAME, account.name) + .appendQueryParameter(ContactsContract.Groups.ACCOUNT_TYPE, account.type) + .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true") + .build(); + + ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(uri); + builder.withValue(ContactsContract.Groups.ACCOUNT_TYPE, account.type); + builder.withValue(ContactsContract.Groups.ACCOUNT_NAME, account.name); + builder.withValue(ContactsContract.Groups.SYSTEM_ID, "some id"); + builder.withValue(ContactsContract.Groups.TITLE, "some name"); + builder.withValue(ContactsContract.Groups.GROUP_VISIBLE, 1); + + mResolver.applyBatch(ContactsContract.AUTHORITY, Lists.newArrayList(builder.build())); + + builder = ContentProviderOperation.newInsert(uri); + builder.withValue(ContactsContract.Groups.ACCOUNT_TYPE, account.type + "diff"); + builder.withValue(ContactsContract.Groups.ACCOUNT_NAME, account.name); + builder.withValue(ContactsContract.Groups.SYSTEM_ID, "some other id"); + builder.withValue(ContactsContract.Groups.TITLE, "some other name"); + builder.withValue(ContactsContract.Groups.GROUP_VISIBLE, 1); + + try { + mResolver.applyBatch(ContactsContract.AUTHORITY, Lists.newArrayList(builder.build())); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException ex) { + // Expected + } + } + public void testContentEntityIterator() { // create multiple contacts and check that the selected ones are returned long id; |