diff options
Diffstat (limited to 'tests/src/com/android/providers/downloads')
-rw-r--r-- | tests/src/com/android/providers/downloads/FakeSystemFacade.java | 15 | ||||
-rw-r--r-- | tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java | 19 |
2 files changed, 25 insertions, 9 deletions
diff --git a/tests/src/com/android/providers/downloads/FakeSystemFacade.java b/tests/src/com/android/providers/downloads/FakeSystemFacade.java index c48f815d..4ff313ab 100644 --- a/tests/src/com/android/providers/downloads/FakeSystemFacade.java +++ b/tests/src/com/android/providers/downloads/FakeSystemFacade.java @@ -2,12 +2,11 @@ package com.android.providers.downloads; import android.net.ConnectivityManager; -import java.util.BitSet; - public class FakeSystemFacade implements SystemFacade { long mTimeMillis = 0; Integer mActiveNetworkType = ConnectivityManager.TYPE_WIFI; boolean mIsRoaming = false; + Integer mMaxBytesOverMobile = null; void incrementTimeMillis(long delta) { mTimeMillis += delta; @@ -17,15 +16,15 @@ public class FakeSystemFacade implements SystemFacade { return mTimeMillis; } - public BitSet getConnectedNetworkTypes() { - BitSet connectedTypes = new BitSet(); - if (mActiveNetworkType != null) { - connectedTypes.set(mActiveNetworkType); - } - return connectedTypes; + public Integer getActiveNetworkType() { + return mActiveNetworkType; } public boolean isNetworkRoaming() { return mIsRoaming; } + + public Integer getMaxBytesOverMobile() { + return mMaxBytesOverMobile ; + } } diff --git a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java index e9195609..a9810fc1 100644 --- a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java +++ b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java @@ -17,10 +17,11 @@ package com.android.providers.downloads; import android.database.Cursor; +import android.net.ConnectivityManager; import android.net.DownloadManager; import android.net.Uri; import android.os.Environment; -import android.util.Log; +import android.test.suitebuilder.annotation.LargeTest; import tests.http.RecordedRequest; import java.io.File; @@ -28,6 +29,7 @@ import java.io.FileInputStream; import java.io.InputStream; import java.net.MalformedURLException; +@LargeTest public class PublicApiFunctionalTest extends AbstractDownloadManagerFunctionalTest { private static final String REQUEST_PATH = "/path"; @@ -293,6 +295,21 @@ public class PublicApiFunctionalTest extends AbstractDownloadManagerFunctionalTe } } + public void testSizeLimitOverMobile() throws Exception { + mSystemFacade.mMaxBytesOverMobile = FILE_CONTENT.length() - 1; + + mSystemFacade.mActiveNetworkType = ConnectivityManager.TYPE_MOBILE; + enqueueResponse(HTTP_OK, FILE_CONTENT); + Download download = enqueueRequest(getRequest()); + download.runUntilStatus(DownloadManager.STATUS_PAUSED); + + mSystemFacade.mActiveNetworkType = ConnectivityManager.TYPE_WIFI; + // first response was read, but aborted after the DL manager processed the Content-Length + // header, so we need to enqueue a second one + enqueueResponse(HTTP_OK, FILE_CONTENT); + download.runUntilStatus(DownloadManager.STATUS_SUCCESSFUL); + } + private DownloadManager.Request getRequest() throws MalformedURLException { return getRequest(getServerUri(REQUEST_PATH)); } |