diff options
author | Steve Howard <showard@google.com> | 2010-09-08 17:15:27 -0700 |
---|---|---|
committer | Steve Howard <showard@google.com> | 2010-09-10 16:27:51 -0700 |
commit | 71e7fda9135a0915af1fd419d07ebf85ad09beb4 (patch) | |
tree | 965315a68abef66c21b154856923e35b9eab4b74 /tests/src/com | |
parent | f8ccad3e970434111b3920dc639e05ca48ca66c2 (diff) | |
download | android_packages_providers_DownloadProvider-71e7fda9135a0915af1fd419d07ebf85ad09beb4.tar.gz android_packages_providers_DownloadProvider-71e7fda9135a0915af1fd419d07ebf85ad09beb4.tar.bz2 android_packages_providers_DownloadProvider-71e7fda9135a0915af1fd419d07ebf85ad09beb4.zip |
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 "<Unknown>" 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
Diffstat (limited to 'tests/src/com')
-rw-r--r-- | tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java | 54 |
1 files changed, 54 insertions, 0 deletions
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)); |