diff options
author | Vinit Deshpande <vinitd@google.com> | 2015-03-16 00:14:20 -0700 |
---|---|---|
committer | Vinit Deshpande <vinitd@google.com> | 2015-03-16 00:14:20 -0700 |
commit | fd8de127afaadccb3106609e203e9bf9f7c9deb9 (patch) | |
tree | c42cce20f6d4fcac1047e4d57794ba64086ac729 /tests | |
parent | 410c29fe803c63342ee73168cd27f4bf7eda1c0e (diff) | |
parent | 0f74e8600ad744f2e4ba9c6a4cdadf5da5a20e83 (diff) | |
download | packages_providers_ContactsProvider-fd8de127afaadccb3106609e203e9bf9f7c9deb9.zip packages_providers_ContactsProvider-fd8de127afaadccb3106609e203e9bf9f7c9deb9.tar.gz packages_providers_ContactsProvider-fd8de127afaadccb3106609e203e9bf9f7c9deb9.tar.bz2 |
Merge remote-tracking branch 'goog/mirror-m-wireless-internal-release'
Change-Id: I439330f8c022ce85005d84fd4286f4f1ffdced1c
Diffstat (limited to 'tests')
3 files changed, 45 insertions, 8 deletions
diff --git a/tests/src/com/android/providers/contacts/BaseVoicemailProviderTest.java b/tests/src/com/android/providers/contacts/BaseVoicemailProviderTest.java index 547eafa..8e4121d 100644 --- a/tests/src/com/android/providers/contacts/BaseVoicemailProviderTest.java +++ b/tests/src/com/android/providers/contacts/BaseVoicemailProviderTest.java @@ -98,6 +98,11 @@ public abstract class BaseVoicemailProviderTest extends BaseContactsProvider2Tes public File getDir(String name, int mode) { return getTestDirectory(); } + + @Override + public PackageManager getPackageManager() { + return new MockPackageManager(mActor.getProviderContext().getPackageName()); + } }; } @@ -145,6 +150,7 @@ public abstract class BaseVoicemailProviderTest extends BaseContactsProvider2Tes private interface VvmProviderCalls { public void sendOrderedBroadcast(Intent intent, String receiverPermission); public File getDir(String name, int mode); + public PackageManager getPackageManager(); } public static class TestVoicemailProvider extends VoicemailContentProvider { @@ -171,7 +177,7 @@ public abstract class BaseVoicemailProviderTest extends BaseContactsProvider2Tes } @Override public PackageManager getPackageManager() { - return new MockPackageManager("com.test.package1", "com.test.package2"); + return mDelegate.getPackageManager(); } }; } diff --git a/tests/src/com/android/providers/contacts/CallLogProviderTest.java b/tests/src/com/android/providers/contacts/CallLogProviderTest.java index b8233f6..ea436d8 100644 --- a/tests/src/com/android/providers/contacts/CallLogProviderTest.java +++ b/tests/src/com/android/providers/contacts/CallLogProviderTest.java @@ -60,7 +60,9 @@ public class CallLogProviderTest extends BaseContactsProvider2Test { Voicemails.MIME_TYPE, Voicemails.SOURCE_PACKAGE, Voicemails.SOURCE_DATA, - Voicemails.STATE}; + Voicemails.STATE, + Voicemails.DIRTY, + Voicemails.DELETED}; /** Total number of columns exposed by call_log provider. */ private static final int NUM_CALLLOG_FIELDS = 25; diff --git a/tests/src/com/android/providers/contacts/VoicemailProviderTest.java b/tests/src/com/android/providers/contacts/VoicemailProviderTest.java index 4fe1907..1d3ac8a 100644 --- a/tests/src/com/android/providers/contacts/VoicemailProviderTest.java +++ b/tests/src/com/android/providers/contacts/VoicemailProviderTest.java @@ -58,7 +58,7 @@ public class VoicemailProviderTest extends BaseVoicemailProviderTest { Calls.COUNTRY_ISO }; /** Total number of columns exposed by voicemail provider. */ - private static final int NUM_VOICEMAIL_FIELDS = 14; + private static final int NUM_VOICEMAIL_FIELDS = 16; @Override protected void setUp() throws Exception { @@ -120,6 +120,28 @@ public class VoicemailProviderTest extends BaseVoicemailProviderTest { assertStoredValues(uri, values); } + public void testUpdateOwnPackageVoicemail_NotDirty() { + final Uri uri = mResolver.insert(voicemailUri(), getTestVoicemailValues()); + mResolver.update(uri, new ContentValues(), null, null); + + // Updating a package's own voicemail should not make the voicemail dirty. + ContentValues values = getTestVoicemailValues(); + values.put(Voicemails.DIRTY, "0"); + assertStoredValues(uri, values); + } + + public void testUpdateOwnPackageVoicemail_RemovesDirtyStatus() { + ContentValues values = getTestVoicemailValues(); + values.put(Voicemails.DIRTY, "1"); + final Uri uri = mResolver.insert(voicemailUri(), getTestVoicemailValues()); + + mResolver.update(uri, new ContentValues(), null, null); + // At this point, the voicemail should be set back to not dirty. + ContentValues newValues = getTestVoicemailValues(); + newValues.put(Voicemails.DIRTY, "0"); + assertStoredValues(uri, newValues); + } + public void testDelete() { Uri uri = insertVoicemail(); int count = mResolver.delete(voicemailUri(), Voicemails._ID + "=" @@ -240,8 +262,10 @@ public class VoicemailProviderTest extends BaseVoicemailProviderTest { } }); - // If we have the manage voicemail permission, we should be able to both update and delete - // voicemails from all packages + // If we have the manage voicemail permission, we should be able to both update voicemails + // from all packages. However, when updating or deleting a voicemail from a different + // package, the "dirty" flag must be set on updates and "dirty" and "delete" flags must be + // set on deletion. setUpForNoPermission(); mActor.addPermissions(WRITE_VOICEMAIL_PERMISSION); mResolver.update(anotherVoicemail, getTestVoicemailValues(), null, null); @@ -254,10 +278,15 @@ public class VoicemailProviderTest extends BaseVoicemailProviderTest { mResolver.delete(anotherVoicemail, null, null); - // Now add the read voicemail permission temporarily to verify that the delete actually - // worked + // Now add the read voicemail permission temporarily to verify that the delete flag is set. mActor.addPermissions(READ_VOICEMAIL_PERMISSION); - assertEquals(0, getCount(anotherVoicemail, null, null)); + + ContentValues values = getTestVoicemailValues(); + values.put(Voicemails.DIRTY, "1"); + values.put(Voicemails.DELETED, "1"); + + assertEquals(1, getCount(anotherVoicemail, null, null)); + assertStoredValues(anotherVoicemail, values); } private Uri withSourcePackageParam(Uri uri) { |