Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f584f12b authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Fix DownloadManager tests.

ERROR_CANNOT_RESUME is the correct code for one, and relative paths
are supported by the RFC, so change the test to check for success.

Bug: 27580939
Change-Id: Ife99c22a44dd71232466e35d38a2441c16a558f7
parent 7732e1e5
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -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());
    }

    /**