summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff Sharkey <jsharkey@google.com> 2016-03-31 02:43:20 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-03-31 02:43:21 +0000
commit4938d6e161733b69a291d2ddf16d25efb41030cb (patch)
tree192f17b09d35bcba59366ab3e9249257d241154f
parent27c49d5790647cc0bb81cc76a999ae65fe4a34cc (diff)
parentf584f12b6b0ab197ef9a9b41d2cf1442c9727002 (diff)
Merge "Fix DownloadManager tests." into nyc-dev
-rw-r--r--core/tests/coretests/src/android/app/DownloadManagerFunctionalTest.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/core/tests/coretests/src/android/app/DownloadManagerFunctionalTest.java b/core/tests/coretests/src/android/app/DownloadManagerFunctionalTest.java
index 4a5385256923..d1a5d281326a 100644
--- a/core/tests/coretests/src/android/app/DownloadManagerFunctionalTest.java
+++ b/core/tests/coretests/src/android/app/DownloadManagerFunctionalTest.java
@@ -284,20 +284,30 @@ public class DownloadManagerFunctionalTest extends DownloadManagerBaseTest {
Uri uri = getServerUri(DEFAULT_FILENAME);
enqueueResponse(buildResponse(HTTP_PARTIAL_CONTENT));
- doErrorTest(uri, DownloadManager.ERROR_UNHANDLED_HTTP_CODE);
+ doErrorTest(uri, DownloadManager.ERROR_CANNOT_RESUME);
}
/**
* Tests the download failure error from an unhandled HTTP status code
*/
@LargeTest
- public void testErrorHttpDataError_invalidRedirect() throws Exception {
+ public void testRelativeRedirect() throws Exception {
Uri uri = getServerUri(DEFAULT_FILENAME);
final MockResponse resp = buildResponse(HTTP_REDIRECT);
- resp.setHeader("Location", "://blah.blah.blah.com");
+ resp.setHeader("Location", ":" + uri.getSchemeSpecificPart());
enqueueResponse(resp);
- doErrorTest(uri, DownloadManager.ERROR_HTTP_DATA_ERROR);
+ byte[] blobData = generateData(DEFAULT_FILE_SIZE, DataType.TEXT);
+ enqueueResponse(buildResponse(HTTP_OK, blobData));
+
+ Request request = new Request(uri);
+ request.setTitle(DEFAULT_FILENAME);
+
+ long dlRequest = mDownloadManager.enqueue(request);
+ waitForDownloadOrTimeout(dlRequest);
+
+ verifyAndCleanupSingleFileDownload(dlRequest, blobData);
+ assertEquals(1, mReceiver.numDownloadsCompleted());
}
/**