diff options
author | Dmitri Plotnikov <dplotnikov@google.com> | 2010-11-17 18:27:44 -0800 |
---|---|---|
committer | Dmitri Plotnikov <dplotnikov@google.com> | 2010-11-17 18:27:44 -0800 |
commit | 3826a44d8de41e9c148dd6a967392ea5af478085 (patch) | |
tree | 8e1d86af0790354270a3a26fcd22274770b4bbff /tests | |
parent | 6b759a2b977a29c3c4abe1eb6d2ba242f937a923 (diff) | |
download | packages_providers_ContactsProvider-3826a44d8de41e9c148dd6a967392ea5af478085.zip packages_providers_ContactsProvider-3826a44d8de41e9c148dd6a967392ea5af478085.tar.gz packages_providers_ContactsProvider-3826a44d8de41e9c148dd6a967392ea5af478085.tar.bz2 |
Adding support for a new ProviderStatus
Change-Id: I76da184b794ea7727b9109e693fbf8834c9450b6
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/providers/contacts/ContactsProvider2Test.java | 24 | ||||
-rw-r--r-- | tests/src/com/android/providers/contacts/SynchronousContactsProvider2.java | 7 |
2 files changed, 28 insertions, 3 deletions
diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java index 18dec64..de1f304 100644 --- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java +++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java @@ -3155,12 +3155,32 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test { } } - public void testProviderStatus() throws Exception { + public void testProviderStatusNoContactsNoAccounts() throws Exception { + assertProviderStatus(ProviderStatus.STATUS_NO_ACCOUNTS_NO_CONTACTS); + } + + public void testProviderStatusOnlyLocalContacts() throws Exception { + long rawContactId = createRawContact(); + assertProviderStatus(ProviderStatus.STATUS_NORMAL); + mResolver.delete( + ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), null, null); + assertProviderStatus(ProviderStatus.STATUS_NO_ACCOUNTS_NO_CONTACTS); + } + + public void testProviderStatusWithAccounts() throws Exception { + assertProviderStatus(ProviderStatus.STATUS_NO_ACCOUNTS_NO_CONTACTS); + ((ContactsProvider2)getProvider()).onAccountsUpdated(new Account[]{ACCOUNT_1}); + assertProviderStatus(ProviderStatus.STATUS_NORMAL); + ((ContactsProvider2)getProvider()).onAccountsUpdated(new Account[0]); + assertProviderStatus(ProviderStatus.STATUS_NO_ACCOUNTS_NO_CONTACTS); + } + + private void assertProviderStatus(int expectedProviderStatus) { Cursor cursor = mResolver.query(ProviderStatus.CONTENT_URI, new String[]{ProviderStatus.DATA1, ProviderStatus.STATUS}, null, null, null); assertTrue(cursor.moveToFirst()); assertEquals(0, cursor.getLong(0)); - assertEquals(ProviderStatus.STATUS_NORMAL, cursor.getInt(1)); + assertEquals(expectedProviderStatus, cursor.getInt(1)); cursor.close(); } diff --git a/tests/src/com/android/providers/contacts/SynchronousContactsProvider2.java b/tests/src/com/android/providers/contacts/SynchronousContactsProvider2.java index a280bb2..3c3e1b5 100644 --- a/tests/src/com/android/providers/contacts/SynchronousContactsProvider2.java +++ b/tests/src/com/android/providers/contacts/SynchronousContactsProvider2.java @@ -86,7 +86,7 @@ public class SynchronousContactsProvider2 extends ContactsProvider2 { } @Override - protected void verifyAccounts() { + protected void updateAccounts() { } @Override @@ -105,6 +105,11 @@ public class SynchronousContactsProvider2 extends ContactsProvider2 { return mAccount; } + @Override + protected boolean isContactsAccount(Account account) { + return true; + } + /** * Creates a mock PhotoPriorityResolver */ |