diff options
Diffstat (limited to 'tests/src/com/android/providers/downloads/AbstractDownloadManagerFunctionalTest.java')
-rw-r--r-- | tests/src/com/android/providers/downloads/AbstractDownloadManagerFunctionalTest.java | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/tests/src/com/android/providers/downloads/AbstractDownloadManagerFunctionalTest.java b/tests/src/com/android/providers/downloads/AbstractDownloadManagerFunctionalTest.java index d04fd2de..5283d425 100644 --- a/tests/src/com/android/providers/downloads/AbstractDownloadManagerFunctionalTest.java +++ b/tests/src/com/android/providers/downloads/AbstractDownloadManagerFunctionalTest.java @@ -59,6 +59,14 @@ public abstract class AbstractDownloadManagerFunctionalTest extends protected MockContentResolverWithNotify mResolver; protected TestContext mTestContext; protected FakeSystemFacade mSystemFacade; + protected static String STRING_1K; + static { + StringBuilder buff = new StringBuilder(); + for (int i = 0; i < 1024; i++) { + buff.append("a" + i % 26); + } + STRING_1K = buff.toString(); + } static class MockContentResolverWithNotify extends MockContentResolver { public boolean mNotifyWasCalled = false; @@ -161,6 +169,7 @@ public abstract class AbstractDownloadManagerFunctionalTest extends @Override protected void tearDown() throws Exception { cleanUpDownloads(); + mServer.shutdown(); super.tearDown(); } @@ -189,8 +198,8 @@ public abstract class AbstractDownloadManagerFunctionalTest extends if (mResolver == null) { return; } - String[] columns = new String[] {Downloads._DATA}; - Cursor cursor = mResolver.query(Downloads.CONTENT_URI, columns, null, null, null); + String[] columns = new String[] {Downloads.Impl._DATA}; + Cursor cursor = mResolver.query(Downloads.Impl.CONTENT_URI, columns, null, null, null); try { for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { String filePath = cursor.getString(0); @@ -201,11 +210,11 @@ public abstract class AbstractDownloadManagerFunctionalTest extends } finally { cursor.close(); } - mResolver.delete(Downloads.CONTENT_URI, null, null); + mResolver.delete(Downloads.Impl.CONTENT_URI, null, null); } /** - * Enqueue a response from the MockWebServer. + * Enqueue a String response from the MockWebServer. */ MockResponse enqueueResponse(int status, String body) { MockResponse response = new MockResponse() @@ -216,6 +225,18 @@ public abstract class AbstractDownloadManagerFunctionalTest extends mServer.enqueue(response); return response; } + /** + * Enqueue a byte[] response from the MockWebServer. + */ + MockResponse enqueueResponse(int status, byte[] body) { + MockResponse response = new MockResponse() + .setResponseCode(status) + .setBody(body) + .addHeader("Content-type", "text/plain") + .setCloseConnectionAfter(true); + mServer.enqueue(response); + return response; + } MockResponse enqueueEmptyResponse(int status) { return enqueueResponse(status, ""); |