diff options
author | Dmitri Plotnikov <dplotnikov@google.com> | 2010-09-22 17:25:30 -0700 |
---|---|---|
committer | Dmitri Plotnikov <dplotnikov@google.com> | 2010-09-22 17:25:30 -0700 |
commit | 6c47e208236a62c55f396116e087331e05e148f3 (patch) | |
tree | dc6ef1dbca64f7eb161499fd43ff60007ffa5ed0 /tests | |
parent | 3d67ff829e8acb0f650f155c3c0d377c0f46507a (diff) | |
download | packages_providers_ContactsProvider-6c47e208236a62c55f396116e087331e05e148f3.zip packages_providers_ContactsProvider-6c47e208236a62c55f396116e087331e05e148f3.tar.gz packages_providers_ContactsProvider-6c47e208236a62c55f396116e087331e05e148f3.tar.bz2 |
Fixing Directory.DEFAULT update logic
After refactoring the code a few times I ended up
with selection parameters that did not match
the selection itself. Oops.
The test also needed to be fixed and upgraded.
Change-Id: Ie2ad3e75c2ed3a5df142d15943ffca67e6c634d4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/providers/contacts/DirectoryTest.java | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/src/com/android/providers/contacts/DirectoryTest.java b/tests/src/com/android/providers/contacts/DirectoryTest.java index 5fcc1ae..5831612 100644 --- a/tests/src/com/android/providers/contacts/DirectoryTest.java +++ b/tests/src/com/android/providers/contacts/DirectoryTest.java @@ -22,7 +22,9 @@ import android.content.ContentValues; import android.database.Cursor; import android.net.Uri; import android.provider.ContactsContract; +import android.provider.ContactsContract.CommonDataKinds.GroupMembership; import android.provider.ContactsContract.Contacts; +import android.provider.ContactsContract.Data; import android.provider.ContactsContract.Directory; import android.test.suitebuilder.annotation.LargeTest; @@ -90,13 +92,12 @@ public class DirectoryTest extends BaseContactsProvider2Test { public void testForwardingToLocalInvisibleContacts() { // Visible because there is no account - long visibleContactId = queryContactId(createRawContactWithName("Bob", "Parr")); + long contactId1 = queryContactId(createRawContactWithName("Bob", "Parr")); Account account = new Account("accountName", "accountType"); long groupId = createGroup(account, "sid", "def", 0 /* visible */, true /* auto-add */, false /* fav */); - // Hidden because not member of default group - long hiddenContactId = queryContactId(createRawContactWithName("Helen", "Parr", + long contactId2 = queryContactId(createRawContactWithName("Helen", "Parr", account)); Uri contentUri = Contacts.CONTENT_URI.buildUpon().appendQueryParameter( @@ -105,10 +106,20 @@ public class DirectoryTest extends BaseContactsProvider2Test { Cursor cursor = mResolver.query(contentUri, new String[]{Contacts._ID, Contacts.DISPLAY_NAME}, null, null, null); + assertEquals(0, cursor.getCount()); + cursor.close(); + + // Hide by removing from the default group + mResolver.delete(Data.CONTENT_URI, + Data.MIMETYPE + "=? AND " + GroupMembership.GROUP_ROW_ID + "=?", + new String[] { GroupMembership.CONTENT_ITEM_TYPE, String.valueOf(groupId) }); + + cursor = mResolver.query(contentUri, + new String[]{Contacts._ID, Contacts.DISPLAY_NAME}, null, null, null); assertNotNull(cursor); assertEquals(1, cursor.getCount()); cursor.moveToFirst(); - assertEquals(hiddenContactId, cursor.getLong(0)); + assertEquals(contactId2, cursor.getLong(0)); assertEquals("Helen Parr", cursor.getString(1)); cursor.close(); @@ -121,7 +132,7 @@ public class DirectoryTest extends BaseContactsProvider2Test { assertNotNull(cursor); assertEquals(1, cursor.getCount()); cursor.moveToFirst(); - assertEquals(hiddenContactId, cursor.getLong(0)); + assertEquals(contactId2, cursor.getLong(0)); assertEquals("Helen Parr", cursor.getString(1)); cursor.close(); } |