summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSteve Howard <showard@google.com>2010-07-30 18:55:38 -0700
committerSteve Howard <showard@google.com>2010-08-16 14:29:33 -0700
commitadb6887d3270d180c94eaf90878d5b67d74a8f28 (patch)
tree8d0af2656dbf21cbb5b25a19d25e2c86f743e33a /tests
parente61798da80558450f580ed948d0d469bd6423d8e (diff)
downloadandroid_packages_providers_DownloadProvider-adb6887d3270d180c94eaf90878d5b67d74a8f28.tar.gz
android_packages_providers_DownloadProvider-adb6887d3270d180c94eaf90878d5b67d74a8f28.tar.bz2
android_packages_providers_DownloadProvider-adb6887d3270d180c94eaf90878d5b67d74a8f28.zip
Clean up error codes returned by download manager.
This set of changes cleans up the error codes returned by the download manager in various failure cases, aiming for improved consistency. Error codes are part of the public API so it's important to get this right now. The main changes here are: * Refactoring the flow of error status information throughout DownloadThread to make it more explicit, by having StopRequest accept a status code in its constructor and eliminating State.mFinaStatus. * Eliminating the use of valid HTTP 4xx statuses when those statuses weren't actually returned by the server. Now, if the returned error code is a valid HTTP status code, that means it was returned by the server. These cases have been replaced with more sensible artificial error codes, including a new ERROR_CANNOT_RESUME when an interrupted download can't be resumed. * Improvements to some of the error handling code paths -- ensuring we don't clear the cache for external downloads, ensuring we don't fail with CANNOT_RESUME when the download hasn't actually started yet, removing the restriction on acceptable mime types for public API downloads. Change-Id: I0d825845fe0fe7ed5df74bad26e8d34ac0d1cc4e
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
index 840b20ac..6d604778 100644
--- a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
+++ b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
@@ -35,8 +35,6 @@ import java.util.List;
@LargeTest
public class PublicApiFunctionalTest extends AbstractPublicApiTest {
- private static final int HTTP_NOT_ACCEPTABLE = 406;
- private static final int HTTP_LENGTH_REQUIRED = 411;
private static final String REDIRECTED_PATH = "/other_path";
private static final String ETAG = "my_etag";
@@ -305,7 +303,7 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest {
public void testNoEtag() throws Exception {
enqueuePartialResponse(0, 5).removeHeader("Etag");
- runSimpleFailureTest(HTTP_LENGTH_REQUIRED);
+ runSimpleFailureTest(DownloadManager.ERROR_CANNOT_RESUME);
}
public void testSanitizeMediaType() throws Exception {
@@ -317,12 +315,7 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest {
public void testNoContentLength() throws Exception {
enqueueEmptyResponse(HTTP_OK).removeHeader("Content-Length");
- runSimpleFailureTest(HTTP_LENGTH_REQUIRED);
- }
-
- public void testNoContentType() throws Exception {
- enqueueResponse(HTTP_OK, "").removeHeader("Content-Type");
- runSimpleFailureTest(HTTP_NOT_ACCEPTABLE);
+ runSimpleFailureTest(DownloadManager.ERROR_HTTP_DATA_ERROR);
}
public void testInsufficientSpace() throws Exception {
@@ -478,6 +471,17 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest {
checkCompleteDownload(download);
}
+ public void testExistingFile() throws Exception {
+ Uri destination = getExternalUri();
+ new File(destination.getSchemeSpecificPart()).createNewFile();
+
+ enqueueEmptyResponse(HTTP_OK);
+ Download download = enqueueRequest(getRequest().setDestinationUri(destination));
+ download.runUntilStatus(DownloadManager.STATUS_FAILED);
+ assertEquals(DownloadManager.ERROR_FILE_ERROR,
+ download.getLongField(DownloadManager.COLUMN_ERROR_CODE));
+ }
+
private void checkCompleteDownload(Download download) throws Exception {
assertEquals(FILE_CONTENT.length(),
download.getLongField(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR));