diff options
author | Dmitri Plotnikov <dplotnikov@google.com> | 2010-11-10 18:19:01 -0800 |
---|---|---|
committer | Dmitri Plotnikov <dplotnikov@google.com> | 2010-11-10 18:19:01 -0800 |
commit | f4015ab9ab7c26b766b5331fbf6655b8c54877ea (patch) | |
tree | cae5677e303e11bee998cff9b1fa3a1c12174dc3 /tests | |
parent | 08550a37f085339f88b7047d1911110d81e70d00 (diff) | |
download | packages_providers_ContactsProvider-f4015ab9ab7c26b766b5331fbf6655b8c54877ea.zip packages_providers_ContactsProvider-f4015ab9ab7c26b766b5331fbf6655b8c54877ea.tar.gz packages_providers_ContactsProvider-f4015ab9ab7c26b766b5331fbf6655b8c54877ea.tar.bz2 |
Fixing an issue with social status updates after a contact split
Bug: 3172848
Change-Id: Iea102c2751d48f6d0f0d78474ad664a24dc46602
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java | 16 | ||||
-rw-r--r-- | tests/src/com/android/providers/contacts/ContactAggregatorTest.java | 27 |
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java b/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java index d96c24e..717c2ed 100644 --- a/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java +++ b/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java @@ -368,6 +368,18 @@ public abstract class BaseContactsProvider2Test extends AndroidTestCase { values.put(StatusUpdates.PROTOCOL, protocol); values.put(StatusUpdates.CUSTOM_PROTOCOL, customProtocol); values.put(StatusUpdates.IM_HANDLE, handle); + return insertStatusUpdate(values, presence, status, timestamp, chatMode); + } + + protected Uri insertStatusUpdate( + long dataId, int presence, String status, long timestamp, int chatMode) { + ContentValues values = new ContentValues(); + values.put(StatusUpdates.DATA_ID, dataId); + return insertStatusUpdate(values, presence, status, timestamp, chatMode); + } + + private Uri insertStatusUpdate( + ContentValues values, int presence, String status, long timestamp, int chatMode) { if (presence != 0) { values.put(StatusUpdates.PRESENCE, presence); values.put(StatusUpdates.CHAT_CAPABILITY, chatMode); @@ -429,6 +441,10 @@ public abstract class BaseContactsProvider2Test extends AndroidTestCase { projection, null, null, null); } + protected Uri getContactUriForRawContact(long rawContactId) { + return ContentUris.withAppendedId(Contacts.CONTENT_URI, queryContactId(rawContactId)); + } + protected long queryContactId(long rawContactId) { Cursor c = queryRawContact(rawContactId); assertTrue(c.moveToFirst()); diff --git a/tests/src/com/android/providers/contacts/ContactAggregatorTest.java b/tests/src/com/android/providers/contacts/ContactAggregatorTest.java index 551550a..d8197bb 100644 --- a/tests/src/com/android/providers/contacts/ContactAggregatorTest.java +++ b/tests/src/com/android/providers/contacts/ContactAggregatorTest.java @@ -33,6 +33,7 @@ import android.provider.ContactsContract.Data; import android.provider.ContactsContract.RawContacts; import android.provider.ContactsContract.CommonDataKinds.Organization; import android.provider.ContactsContract.CommonDataKinds.StructuredName; +import android.provider.ContactsContract.StatusUpdates; import android.test.suitebuilder.annotation.LargeTest; /** @@ -994,6 +995,32 @@ public class ContactAggregatorTest extends BaseContactsProvider2Test { + "&query=nickname%3Anickname1", uri.toString()); } + public void testAggregatedStatusUpdate() { + long rawContactId1 = createRawContact(); + Uri dataUri1 = insertStructuredName(rawContactId1, "john", "doe"); + insertStatusUpdate(ContentUris.parseId(dataUri1), StatusUpdates.AWAY, "Green", 100, + StatusUpdates.CAPABILITY_HAS_CAMERA); + long rawContactId2 = createRawContact(); + Uri dataUri2 = insertStructuredName(rawContactId2, "john", "doe"); + insertStatusUpdate(ContentUris.parseId(dataUri2), StatusUpdates.AVAILABLE, "Red", 50, + StatusUpdates.CAPABILITY_HAS_CAMERA); + setAggregationException( + AggregationExceptions.TYPE_KEEP_TOGETHER, rawContactId1, rawContactId2); + + assertStoredValue(getContactUriForRawContact(rawContactId1), + Contacts.CONTACT_STATUS, "Green"); + + // When we split these two raw contacts, their respective statuses should be restored + setAggregationException( + AggregationExceptions.TYPE_KEEP_SEPARATE, rawContactId1, rawContactId2); + + assertStoredValue(getContactUriForRawContact(rawContactId1), + Contacts.CONTACT_STATUS, "Green"); + + assertStoredValue(getContactUriForRawContact(rawContactId2), + Contacts.CONTACT_STATUS, "Red"); + } + public void testAggregationSuggestionsByName() throws Exception { long rawContactId1 = createRawContactWithName("first1", "last1"); long rawContactId2 = createRawContactWithName("first2", "last2"); |