From 71e7fda9135a0915af1fd419d07ebf85ad09beb4 Mon Sep 17 00:00:00 2001 From: Steve Howard Date: Wed, 8 Sep 2010 17:15:27 -0700 Subject: Further work on the new downloads UI. * add support for downloads not visible in the UI * add support for restarting failed downloads and downloads for which the file is missing * add "clear selection" button to selection menu * fix DateSortedExpandableListAdapter to ensure the view refreshes properly anytime the underlying data changes * make DownloadList handle when a selected download gets deleted by another app * make DownloadList close a dialog for a pending download when the download starts * show a dialog when the user tries to open a download but the file is missing * display "" when no title is provided for a download * add a test case for DownloadManager.orderBy() (should've gone in the previous commit) Change-Id: Ibf3062e8228e7f2c1270be24d8d5527dfb064658 --- .../downloads/PublicApiFunctionalTest.java | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'tests') diff --git a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java index cf2b990c..e48ce22e 100644 --- a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java +++ b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java @@ -205,6 +205,48 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest { cursor = mManager.query(new DownloadManager.Query() .setFilterByStatus(DownloadManager.STATUS_RUNNING)); checkAndCloseCursor(cursor); + + mSystemFacade.incrementTimeMillis(1); + Download invisibleDownload = enqueueRequest(getRequest().setVisibleInDownloadsUi(false)); + cursor = mManager.query(new DownloadManager.Query()); + checkAndCloseCursor(cursor, invisibleDownload, download3, download2, download1); + cursor = mManager.query(new DownloadManager.Query().setOnlyIncludeVisibleInDownloadsUi(true)); + checkAndCloseCursor(cursor, download3, download2, download1); + } + + public void testOrdering() throws Exception { + enqueueResponse(HTTP_OK, "small contents"); + Download download1 = enqueueRequest(getRequest()); + download1.runUntilStatus(DownloadManager.STATUS_SUCCESSFUL); + + mSystemFacade.incrementTimeMillis(1); + enqueueResponse(HTTP_OK, "large contents large contents"); + Download download2 = enqueueRequest(getRequest()); + download2.runUntilStatus(DownloadManager.STATUS_SUCCESSFUL); + + mSystemFacade.incrementTimeMillis(1); + enqueueEmptyResponse(HTTP_NOT_FOUND); + Download download3 = enqueueRequest(getRequest()); + download3.runUntilStatus(DownloadManager.STATUS_FAILED); + + // default ordering -- by timestamp descending + Cursor cursor = mManager.query(new DownloadManager.Query()); + checkAndCloseCursor(cursor, download3, download2, download1); + + cursor = mManager.query(new DownloadManager.Query() + .orderBy(DownloadManager.COLUMN_LAST_MODIFIED_TIMESTAMP, + DownloadManager.Query.ORDER_ASCENDING)); + checkAndCloseCursor(cursor, download1, download2, download3); + + cursor = mManager.query(new DownloadManager.Query() + .orderBy(DownloadManager.COLUMN_TOTAL_SIZE_BYTES, + DownloadManager.Query.ORDER_DESCENDING)); + checkAndCloseCursor(cursor, download2, download1, download3); + + cursor = mManager.query(new DownloadManager.Query() + .orderBy(DownloadManager.COLUMN_TOTAL_SIZE_BYTES, + DownloadManager.Query.ORDER_ASCENDING)); + checkAndCloseCursor(cursor, download3, download1, download2); } private void checkAndCloseCursor(Cursor cursor, Download... downloads) { @@ -494,6 +536,18 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest { download.getLongField(DownloadManager.COLUMN_ERROR_CODE); } + public void testRestart() throws Exception { + enqueueEmptyResponse(HTTP_NOT_FOUND); + Download download = enqueueRequest(getRequest()); + download.runUntilStatus(DownloadManager.STATUS_FAILED); + + enqueueEmptyResponse(HTTP_OK); + mManager.restartDownload(download.mId); + assertEquals(DownloadManager.STATUS_PENDING, + download.getLongField(DownloadManager.COLUMN_STATUS)); + download.runUntilStatus(DownloadManager.STATUS_SUCCESSFUL); + } + private void checkCompleteDownload(Download download) throws Exception { assertEquals(FILE_CONTENT.length(), download.getLongField(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)); -- cgit v1.2.3