diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-01-29 14:48:46 -0800 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2013-01-29 15:36:51 -0800 |
commit | 58eee87b70862a7ced85eabc3c225fad24664065 (patch) | |
tree | 306bd82ba9eab04c2e2a4936a406651c08675a7b /tests/src/com/android/providers/downloads/AbstractPublicApiTest.java | |
parent | 38648831a92295e9a11831e19e5a9dab4cbd939e (diff) | |
download | android_packages_providers_DownloadProvider-58eee87b70862a7ced85eabc3c225fad24664065.tar.gz android_packages_providers_DownloadProvider-58eee87b70862a7ced85eabc3c225fad24664065.tar.bz2 android_packages_providers_DownloadProvider-58eee87b70862a7ced85eabc3c225fad24664065.zip |
Tests for max retries/redirects, ETag switches.
Verify that servers responding with many retries or redirects result
in failed download, instead of spinning out of control. Test to
verify that changed ETag results in download failing.
Also fix handling of HTTP 301 to update Uri in database.
Change-Id: Iff2948d79961a245b7900117d107edaa356618c9
Diffstat (limited to 'tests/src/com/android/providers/downloads/AbstractPublicApiTest.java')
-rw-r--r-- | tests/src/com/android/providers/downloads/AbstractPublicApiTest.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/src/com/android/providers/downloads/AbstractPublicApiTest.java b/tests/src/com/android/providers/downloads/AbstractPublicApiTest.java index e7f08c90..bff9333a 100644 --- a/tests/src/com/android/providers/downloads/AbstractPublicApiTest.java +++ b/tests/src/com/android/providers/downloads/AbstractPublicApiTest.java @@ -27,7 +27,6 @@ import android.os.ParcelFileDescriptor; import android.os.SystemClock; import android.util.Log; -import java.io.FileInputStream; import java.io.InputStream; import java.net.MalformedURLException; import java.net.UnknownHostException; @@ -49,6 +48,10 @@ public abstract class AbstractPublicApiTest extends AbstractDownloadProviderFunc return (int) getLongField(DownloadManager.COLUMN_STATUS); } + public int getReason() { + return (int) getLongField(DownloadManager.COLUMN_REASON); + } + public int getStatusIfExists() { Cursor cursor = mManager.query(new DownloadManager.Query().setFilterById(mId)); try { @@ -91,7 +94,8 @@ public abstract class AbstractPublicApiTest extends AbstractDownloadProviderFunc ParcelFileDescriptor downloadedFile = mManager.openDownloadedFile(mId); assertTrue("Invalid file descriptor: " + downloadedFile, downloadedFile.getFileDescriptor().valid()); - InputStream stream = new FileInputStream(downloadedFile.getFileDescriptor()); + final InputStream stream = new ParcelFileDescriptor.AutoCloseInputStream( + downloadedFile); try { return readStream(stream); } finally { |