Loading core/tests/coretests/src/android/app/DownloadManagerBaseTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase { protected static final int WAIT_FOR_DOWNLOAD_POLL_TIME = 1 * 1000; // 1 second protected static final int MAX_WAIT_FOR_DOWNLOAD_TIME = 5 * 60 * 1000; // 5 minutes protected static final int MAX_WAIT_FOR_LARGE_DOWNLOAD_TIME = 15 * 60 * 1000; // 15 minutes // Just a few popular file types used to return from a download protected enum DownloadFileType { Loading Loading @@ -180,7 +181,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase { * @return A Set<Long> with the ids of the completed downloads. */ public Set<Long> getDownloadIds() { synchronized(downloadIds) { synchronized(this) { Set<Long> returnIds = new HashSet<Long>(downloadIds); return returnIds; } Loading Loading @@ -224,6 +225,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase { ConnectivityManager connManager = (ConnectivityManager)mContext.getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo info = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); Log.i(LOG_TAG, "WiFi Connection state is currently: " + info.isConnected()); return info.isConnected(); } } Loading Loading @@ -511,6 +513,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase { * @param enable true if it should be enabled, false if it should be disabled */ protected void setWiFiStateOn(boolean enable) throws Exception { Log.i(LOG_TAG, "Setting WiFi State to: " + enable); WifiManager manager = (WifiManager)mContext.getSystemService(Context.WIFI_SERVICE); manager.setWifiEnabled(enable); Loading @@ -528,7 +531,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase { while (receiver.getWiFiIsOn() != enable && !timedOut) { try { receiver.wait(DEFAULT_MAX_WAIT_TIME); receiver.wait(DEFAULT_WAIT_POLL_TIME); if (SystemClock.elapsedRealtime() > timeoutTime) { timedOut = true; Loading core/tests/coretests/src/android/app/DownloadManagerStressTest.java +6 −4 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.app.DownloadManager.Request; import android.database.Cursor; import android.net.Uri; import android.os.ParcelFileDescriptor; import android.test.suitebuilder.annotation.LargeTest; import android.util.Log; Loading @@ -38,6 +37,7 @@ public class DownloadManagerStressTest extends DownloadManagerBaseTest { public void setUp() throws Exception { super.setUp(); mServer.play(0); setWiFiStateOn(true); removeAllCurrentDownloads(); } Loading Loading @@ -71,7 +71,8 @@ public class DownloadManagerStressTest extends DownloadManagerBaseTest { } // wait for the download to complete or timeout waitForDownloadsOrTimeout(WAIT_FOR_DOWNLOAD_POLL_TIME, MAX_WAIT_FOR_DOWNLOAD_TIME); waitForDownloadsOrTimeout(WAIT_FOR_DOWNLOAD_POLL_TIME, MAX_WAIT_FOR_LARGE_DOWNLOAD_TIME); cursor = mDownloadManager.query(new Query()); assertEquals(NUM_FILES, cursor.getCount()); Log.i(LOG_TAG, "Verified number of downloads in download manager is what we expect."); Loading Loading @@ -130,10 +131,11 @@ public class DownloadManagerStressTest extends DownloadManagerBaseTest { } /** * Tests trying to download a large file (~300M bytes) when there's not enough space in cache * Tests trying to download a large file (~600M bytes) when there's not enough space in cache */ public void testInsufficientSpace() throws Exception { long fileSize = 300000000L; // @TODO: Rework this to fill up cache partition with a dynamically calculated size long fileSize = 600000000L; File largeFile = createFileOnSD(null, fileSize, DataType.TEXT, null); Cursor cursor = null; Loading Loading
core/tests/coretests/src/android/app/DownloadManagerBaseTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase { protected static final int WAIT_FOR_DOWNLOAD_POLL_TIME = 1 * 1000; // 1 second protected static final int MAX_WAIT_FOR_DOWNLOAD_TIME = 5 * 60 * 1000; // 5 minutes protected static final int MAX_WAIT_FOR_LARGE_DOWNLOAD_TIME = 15 * 60 * 1000; // 15 minutes // Just a few popular file types used to return from a download protected enum DownloadFileType { Loading Loading @@ -180,7 +181,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase { * @return A Set<Long> with the ids of the completed downloads. */ public Set<Long> getDownloadIds() { synchronized(downloadIds) { synchronized(this) { Set<Long> returnIds = new HashSet<Long>(downloadIds); return returnIds; } Loading Loading @@ -224,6 +225,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase { ConnectivityManager connManager = (ConnectivityManager)mContext.getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo info = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); Log.i(LOG_TAG, "WiFi Connection state is currently: " + info.isConnected()); return info.isConnected(); } } Loading Loading @@ -511,6 +513,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase { * @param enable true if it should be enabled, false if it should be disabled */ protected void setWiFiStateOn(boolean enable) throws Exception { Log.i(LOG_TAG, "Setting WiFi State to: " + enable); WifiManager manager = (WifiManager)mContext.getSystemService(Context.WIFI_SERVICE); manager.setWifiEnabled(enable); Loading @@ -528,7 +531,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase { while (receiver.getWiFiIsOn() != enable && !timedOut) { try { receiver.wait(DEFAULT_MAX_WAIT_TIME); receiver.wait(DEFAULT_WAIT_POLL_TIME); if (SystemClock.elapsedRealtime() > timeoutTime) { timedOut = true; Loading
core/tests/coretests/src/android/app/DownloadManagerStressTest.java +6 −4 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.app.DownloadManager.Request; import android.database.Cursor; import android.net.Uri; import android.os.ParcelFileDescriptor; import android.test.suitebuilder.annotation.LargeTest; import android.util.Log; Loading @@ -38,6 +37,7 @@ public class DownloadManagerStressTest extends DownloadManagerBaseTest { public void setUp() throws Exception { super.setUp(); mServer.play(0); setWiFiStateOn(true); removeAllCurrentDownloads(); } Loading Loading @@ -71,7 +71,8 @@ public class DownloadManagerStressTest extends DownloadManagerBaseTest { } // wait for the download to complete or timeout waitForDownloadsOrTimeout(WAIT_FOR_DOWNLOAD_POLL_TIME, MAX_WAIT_FOR_DOWNLOAD_TIME); waitForDownloadsOrTimeout(WAIT_FOR_DOWNLOAD_POLL_TIME, MAX_WAIT_FOR_LARGE_DOWNLOAD_TIME); cursor = mDownloadManager.query(new Query()); assertEquals(NUM_FILES, cursor.getCount()); Log.i(LOG_TAG, "Verified number of downloads in download manager is what we expect."); Loading Loading @@ -130,10 +131,11 @@ public class DownloadManagerStressTest extends DownloadManagerBaseTest { } /** * Tests trying to download a large file (~300M bytes) when there's not enough space in cache * Tests trying to download a large file (~600M bytes) when there's not enough space in cache */ public void testInsufficientSpace() throws Exception { long fileSize = 300000000L; // @TODO: Rework this to fill up cache partition with a dynamically calculated size long fileSize = 600000000L; File largeFile = createFileOnSD(null, fileSize, DataType.TEXT, null); Cursor cursor = null; Loading