summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/providers
diff options
context:
space:
mode:
authorSteve Howard <showard@google.com>2010-07-27 17:02:14 -0700
committerSteve Howard <showard@google.com>2010-07-27 17:13:15 -0700
commitf6b4c24b4a876daa3f4e91d6da418983222b9dfd (patch)
treeed70f4c5c2d622644dffb5b14a8b96c7626243f7 /tests/src/com/android/providers
parente6a05a1aa4697440e9630d12b741b3bae321fe49 (diff)
downloadandroid_packages_providers_DownloadProvider-f6b4c24b4a876daa3f4e91d6da418983222b9dfd.tar.gz
android_packages_providers_DownloadProvider-f6b4c24b4a876daa3f4e91d6da418983222b9dfd.tar.bz2
android_packages_providers_DownloadProvider-f6b4c24b4a876daa3f4e91d6da418983222b9dfd.zip
Fix bug with closing output stream for external downloads.
I added a unit test to cover this, and it caught another issue with disallowing external destinations outside of the default downloads directory (which are now allowed with the new API). Change-Id: I4df6442bebb06458ad28c85f6bc8cbcbf3ce67a1
Diffstat (limited to 'tests/src/com/android/providers')
-rw-r--r--tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
index ba3059b6..b02844fa 100644
--- a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
+++ b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
@@ -148,6 +148,16 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest {
assertTrue("No ETag header: " + headers, headers.contains("If-Match: " + ETAG));
}
+ public void testInterruptedExternalDownload() throws Exception {
+ enqueueInterruptedDownloadResponses(5);
+ Uri destination = getExternalUri();
+ Download download = enqueueRequest(getRequest().setDestinationUri(destination));
+ download.runUntilStatus(DownloadManager.STATUS_PAUSED);
+ mSystemFacade.incrementTimeMillis(RETRY_DELAY_MILLIS);
+ download.runUntilStatus(DownloadManager.STATUS_SUCCESSFUL);
+ assertEquals(FILE_CONTENT, download.getContents());
+ }
+
private void enqueueInterruptedDownloadResponses(int initialLength) {
int totalLength = FILE_CONTENT.length();
// the first response has normal headers but unexpectedly closes after initialLength bytes
@@ -225,7 +235,7 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest {
public void testDestination() throws Exception {
enqueueResponse(HTTP_OK, FILE_CONTENT);
- Uri destination = Uri.fromFile(mTestDirectory).buildUpon().appendPath("testfile").build();
+ Uri destination = getExternalUri();
Download download = enqueueRequest(getRequest().setDestinationUri(destination));
download.runUntilStatus(DownloadManager.STATUS_SUCCESSFUL);
@@ -240,6 +250,10 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest {
}
}
+ private Uri getExternalUri() {
+ return Uri.fromFile(mTestDirectory).buildUpon().appendPath("testfile").build();
+ }
+
public void testRequestHeaders() throws Exception {
enqueueEmptyResponse(HTTP_OK);
Download download = enqueueRequest(getRequest().setRequestHeader("Header1", "value1")