diff options
author | Dmitri Plotnikov <dplotnikov@google.com> | 2010-07-16 16:51:22 -0700 |
---|---|---|
committer | Dmitri Plotnikov <dplotnikov@google.com> | 2010-07-16 16:51:22 -0700 |
commit | 97fd30388bd6530f86679510cd7b43b9c518bcef (patch) | |
tree | a17ebb879e6d7c3be9b88aa4666c7c01a68e0311 /tests | |
parent | 16103e8a0391a0381d73464e4405fbc935e4878b (diff) | |
download | packages_providers_ContactsProvider-97fd30388bd6530f86679510cd7b43b9c518bcef.zip packages_providers_ContactsProvider-97fd30388bd6530f86679510cd7b43b9c518bcef.tar.gz packages_providers_ContactsProvider-97fd30388bd6530f86679510cd7b43b9c518bcef.tar.bz2 |
Implementation for new ContactsContract API
Change-Id: I91eb0bc2184f65185a342aa3761afe8549b9e640
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/providers/contacts/ContactsProvider2Test.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java index f6b4708..139824f 100644 --- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java +++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java @@ -2725,6 +2725,62 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test { assertNoRowsAndClose(queryGroupMemberships(mAccountTwo)); } + public void testReadOnlyRawContact() { + long rawContactId = createRawContact(); + Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); + storeValue(rawContactUri, RawContacts.CUSTOM_RINGTONE, "first"); + storeValue(rawContactUri, RawContacts.RAW_CONTACT_IS_READ_ONLY, 1); + + storeValue(rawContactUri, RawContacts.CUSTOM_RINGTONE, "second"); + assertStoredValue(rawContactUri, RawContacts.CUSTOM_RINGTONE, "first"); + + Uri syncAdapterUri = rawContactUri.buildUpon() + .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "1") + .build(); + storeValue(syncAdapterUri, RawContacts.CUSTOM_RINGTONE, "third"); + assertStoredValue(rawContactUri, RawContacts.CUSTOM_RINGTONE, "third"); + } + + public void testReadOnlyDataRow() { + long rawContactId = createRawContact(); + Uri emailUri = insertEmail(rawContactId, "email"); + Uri phoneUri = insertPhoneNumber(rawContactId, "555-1111"); + + storeValue(emailUri, Data.IS_READ_ONLY, "1"); + storeValue(emailUri, Email.ADDRESS, "changed"); + storeValue(phoneUri, Phone.NUMBER, "555-2222"); + assertStoredValue(emailUri, Email.ADDRESS, "email"); + assertStoredValue(phoneUri, Phone.NUMBER, "555-2222"); + + Uri syncAdapterUri = emailUri.buildUpon() + .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "1") + .build(); + storeValue(syncAdapterUri, Email.ADDRESS, "changed"); + assertStoredValue(emailUri, Email.ADDRESS, "changed"); + } + + public void testContactWithReadOnlyRawContact() { + long rawContactId1 = createRawContact(); + Uri rawContactUri1 = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId1); + storeValue(rawContactUri1, RawContacts.CUSTOM_RINGTONE, "first"); + + long rawContactId2 = createRawContact(); + Uri rawContactUri2 = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId2); + storeValue(rawContactUri2, RawContacts.CUSTOM_RINGTONE, "second"); + storeValue(rawContactUri2, RawContacts.RAW_CONTACT_IS_READ_ONLY, 1); + + setAggregationException(AggregationExceptions.TYPE_KEEP_TOGETHER, + rawContactId1, rawContactId2); + + long contactId = queryContactId(rawContactId1); + + Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); + storeValue(contactUri, Contacts.CUSTOM_RINGTONE, "rt"); + assertStoredValue(contactUri, Contacts.CUSTOM_RINGTONE, "rt"); + assertStoredValue(rawContactUri1, RawContacts.CUSTOM_RINGTONE, "rt"); + assertStoredValue(rawContactUri2, RawContacts.CUSTOM_RINGTONE, "second"); + } + private Cursor queryGroupMemberships(Account account) { Cursor c = mResolver.query(maybeAddAccountQueryParameters(Data.CONTENT_URI, account), new String[]{GroupMembership.GROUP_ROW_ID, GroupMembership.RAW_CONTACT_ID}, |