summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSteve Howard <showard@google.com>2010-08-02 11:52:16 -0700
committerSteve Howard <showard@google.com>2010-08-16 11:54:30 -0700
commite61798da80558450f580ed948d0d469bd6423d8e (patch)
tree76cbd7d08222baf2fdc2307f4821c2d7a8d7d631 /tests
parent99de0992f03c5b4a1611d25db1df0773433dea7c (diff)
downloadandroid_packages_providers_DownloadProvider-e61798da80558450f580ed948d0d469bd6423d8e.tar.gz
android_packages_providers_DownloadProvider-e61798da80558450f580ed948d0d469bd6423d8e.tar.bz2
android_packages_providers_DownloadProvider-e61798da80558450f580ed948d0d469bd6423d8e.zip
Extend PublicApiAccessTest to exercise DownloadManager.
This change adds a new test case to PublicApiAccessTest to enqueue a request through DownloadManager, ensuring that the values constructed by DownloadManager fit within the allowed bounds. It also fixes a bug with allowing http header values exposed by the new test. Change-Id: I94fec57d7a41298ac42ddaab338516e6a60c4e75
Diffstat (limited to 'tests')
-rw-r--r--tests/public_api_access/src/com/android/providers/downloads/public_api_access_tests/PublicApiAccessTest.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/public_api_access/src/com/android/providers/downloads/public_api_access_tests/PublicApiAccessTest.java b/tests/public_api_access/src/com/android/providers/downloads/public_api_access_tests/PublicApiAccessTest.java
index 4b2ae092..3929c59e 100644
--- a/tests/public_api_access/src/com/android/providers/downloads/public_api_access_tests/PublicApiAccessTest.java
+++ b/tests/public_api_access/src/com/android/providers/downloads/public_api_access_tests/PublicApiAccessTest.java
@@ -18,6 +18,8 @@ package com.android.providers.downloads.public_api_access_tests;
import android.content.ContentResolver;
import android.content.ContentValues;
+import android.net.DownloadManager;
+import android.net.Uri;
import android.provider.Downloads;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
@@ -43,11 +45,13 @@ public class PublicApiAccessTest extends AndroidTestCase {
};
private ContentResolver mContentResolver;
+ private DownloadManager mManager;
@Override
protected void setUp() throws Exception {
super.setUp();
mContentResolver = getContext().getContentResolver();
+ mManager = new DownloadManager(mContentResolver, getContext().getPackageName());
}
@Override
@@ -70,6 +74,7 @@ public class PublicApiAccessTest extends AndroidTestCase {
values.put(Downloads.Impl.COLUMN_NOTIFICATION_PACKAGE, "foo");
values.put(Downloads.Impl.COLUMN_ALLOWED_NETWORK_TYPES, 0);
values.put(Downloads.Impl.COLUMN_ALLOW_ROAMING, true);
+ values.put(Downloads.Impl.RequestHeaders.INSERT_KEY_PREFIX + "0", "X-Some-Header: value");
mContentResolver.insert(Downloads.Impl.CONTENT_URI, values);
}
@@ -133,4 +138,19 @@ public class PublicApiAccessTest extends AndroidTestCase {
// expected
}
}
+
+ public void testDownloadManagerRequest() {
+ // first try a minimal request
+ DownloadManager.Request request = new DownloadManager.Request(Uri.parse("http://localhost/path"));
+ mManager.enqueue(request);
+
+ // now set everything we can, save for external destintion (for which we lack permission)
+ request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
+ request.setAllowedOverRoaming(false);
+ request.setTitle("test");
+ request.setDescription("test");
+ request.setMediaType("text/html");
+ request.setRequestHeader("X-Some-Header", "value");
+ mManager.enqueue(request);
+ }
}