diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/public_api_access/AndroidManifest.xml | 3 | ||||
-rw-r--r-- | tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java | 15 |
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/public_api_access/AndroidManifest.xml b/tests/public_api_access/AndroidManifest.xml index 01048460..bec636be 100644 --- a/tests/public_api_access/AndroidManifest.xml +++ b/tests/public_api_access/AndroidManifest.xml @@ -23,6 +23,9 @@ </application> <uses-permission android:name="android.permission.INTERNET"/> + <!-- The tests in this package can access /cache. so they need the following permission --> + <uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED"/> + <uses-permission android:name="android.permission.ACCESS_CACHE_FILESYSTEM"/> <!-- The test declared in this instrumentation can be run via this command diff --git a/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java b/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java index 7a2bfdff..a5bae8ba 100644 --- a/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java +++ b/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java @@ -69,6 +69,21 @@ public class DownloadManagerFunctionalTest extends AbstractDownloadManagerFuncti getDownloadFilename(downloadUri)); } + /** + * downloading to system cache should succeed because this tests package has + * the permission android.permission.ACCESS_CACHE_FILESYSTEM + */ + public void testDownloadToSystemCache() throws Exception { + enqueueResponse(HTTP_OK, FILE_CONTENT); + Uri downloadUri = requestDownload("/path"); + updateDownload(downloadUri, Downloads.Impl.COLUMN_DESTINATION, + Integer.toString(Downloads.Impl.DESTINATION_SYSTEMCACHE_PARTITION)); + runUntilStatus(downloadUri, Downloads.Impl.STATUS_SUCCESS); + assertEquals(FILE_CONTENT, getDownloadContents(downloadUri)); + assertStartsWith(Environment.getDownloadCacheDirectory().getPath(), + getDownloadFilename(downloadUri)); + } + public void testRoaming() throws Exception { mSystemFacade.mActiveNetworkType = ConnectivityManager.TYPE_MOBILE; mSystemFacade.mIsRoaming = true; |