diff options
author | Sarmad Hashmi <mhashmi@google.com> | 2016-03-11 21:23:24 -0800 |
---|---|---|
committer | Sarmad Hashmi <mhashmi@google.com> | 2016-03-13 17:43:49 -0700 |
commit | 25cfc81d829ccd7e0774862451089a4925adf932 (patch) | |
tree | 2d68a64bb29ef2b5ecc85c77c9cffc5891bd80c5 /tests/src/com/android/dialer/database | |
parent | c70343becd3734fd380e0d20f05b7605e6233d43 (diff) |
Add share voicemail functionality.
+Send intent to other applications with temporary file permission
granted
+Add voicemails folder to FileProvider paths
+When creating file in VoicemailArchiveProvider, append extension to
file name
+Check voicemail content exists before archiving it
+Refactor voicemail code
+Add tests for checking file extension
+Add tests for archiving and sharing vociemails
+Archive tab should not archive on share button press
BUG=22798485
Change-Id: Id8068aba92f7f1ca58532dca6c405cb2908841a3
Diffstat (limited to 'tests/src/com/android/dialer/database')
-rw-r--r-- | tests/src/com/android/dialer/database/VoicemailArchiveProviderTest.java | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/src/com/android/dialer/database/VoicemailArchiveProviderTest.java b/tests/src/com/android/dialer/database/VoicemailArchiveProviderTest.java index cec7e050d..abc2dc5b0 100644 --- a/tests/src/com/android/dialer/database/VoicemailArchiveProviderTest.java +++ b/tests/src/com/android/dialer/database/VoicemailArchiveProviderTest.java @@ -79,6 +79,33 @@ public class VoicemailArchiveProviderTest extends assertTrue(doesFileExist()); } + public void testQuery_createFileMimeTypeIsAMR() throws Exception { + insertVoicemailWithMimeType("audio/amr"); + assertTrue(doesRowExist()); + assertFalse(doesFileExist()); + createFile(); + assertTrue(doesFileExist()); + assertEquals("amr", getFileExtension(getFilePath())); + } + + public void testQuery_createFileMimeTypeIsMP3() throws Exception { + insertVoicemailWithMimeType("audio/mpeg"); + assertTrue(doesRowExist()); + assertFalse(doesFileExist()); + createFile(); + assertTrue(doesFileExist()); + assertEquals("mp3", getFileExtension(getFilePath())); + } + + public void testQuery_createFileMimeTypeNotExists() throws Exception { + insertVoicemailWithMimeType(TEST_STRING); + assertTrue(doesRowExist()); + assertFalse(doesFileExist()); + createFile(); + assertTrue(doesFileExist()); + assertEquals("", getFileExtension(getFilePath())); + } + public void testQuery() { insertVoicemail(); updateCursor(); @@ -179,6 +206,13 @@ public class VoicemailArchiveProviderTest extends return voicemailFile.exists(); } + private static String getFileExtension(String filePath) { + File file = new File(filePath); + String fileName = file.getName(); + int index = fileName.lastIndexOf("."); + return index > 0 ? fileName.substring(index + 1) : ""; + } + private void assertCursorCount(int count) { assertEquals(count, mCursor.getCount()); } @@ -196,6 +230,12 @@ public class VoicemailArchiveProviderTest extends mVoicemailUri = mResolver.insert(VoicemailArchive.CONTENT_URI, getTestValues()); } + private void insertVoicemailWithMimeType(String mimeType) { + ContentValues values = getTestValues(); + values.put(VoicemailArchive.MIME_TYPE, mimeType); + mVoicemailUri = mResolver.insert(VoicemailArchive.CONTENT_URI, values); + } + private void updateCursor() { mCursor = mResolver.query(mVoicemailUri, null, null, null, null); assertEquals(true, mCursor.getCount() > 0); @@ -226,7 +266,7 @@ public class VoicemailArchiveProviderTest extends return mCursor.getString(mCursor.getColumnIndex(VoicemailArchive._DATA)); } - private ContentValues getTestValues() { + private static ContentValues getTestValues() { ContentValues values = new ContentValues(); values.put(VoicemailArchive.NUMBER, TEST_NUMBER); values.put(VoicemailArchive.MIME_TYPE, TEST_MIME_TYPE); |