History log of /packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
6baceb7073ed7858d3424ccf774e5f6a946bec59 10-Mar-2011 Vasu Nori <vnori@google.com> (master) bug:3204324 allow no more than certain number of concurrent downloads

Change-Id: Ibbce0782fcf7649209d6f56be240209cebd9045b
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
c0f732bad06924bc4ef1652ace35d9b0ffc93e2e 08-Jan-2011 Vasu Nori <vnori@google.com> Revert "Merge "downloadmanager should use "files" dir - not "cache" dir to store its files" into honeycomb"

This reverts commit 7d96bafa59111d9ca735e5ef86dc0598f946b2be, reversing
changes made to 2ce876d2d7000b0c3a1430c5f4932568090f5170.
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
f5699308bc41c39ccbb388feb00a248304f30c54 07-Jan-2011 Vasu Nori <vnori@google.com> downloadmanager should use "files" dir - not "cache" dir to store its files

data/data/com.android.providers.downlaods/cache is being used
to store the downloaded files, when the user doesn't specify the
destination path.
but system seems to remove files from this dir EVEN when space is
running low. bug:3324673
instead, let DownloadManager use
data/data/com.android.providers.downlaods/files dir
Downlaodmanager manages its space anyway.

Change-Id: I2eb15570395a214477891f50f635fada0b466544
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
5218d33d57990c3e3549c58bd3f0ac244dfc3d59 17-Dec-2010 Vasu Nori <vnori@google.com> bug:3286430 set quota on downloads data dir

make sure the doanloads data dir size is limited by some quote -
100MB default and 200MB for SR.
bug:3286430

tests are in Change-Id: I688f7e058511089bec7fa21e972e23780604d98a

Change-Id: Iba7fab9fa91ea018f35e1c3ef5ec0e6b03cba650
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
a1cbbb41a7423c6f87b2f461075aad4c665f19dd 15-Dec-2010 Vasu Nori <vnori@google.com> fix downloadmanager tests. again.

Change-Id: I61c6020017a300076ab2a5901ab87eabb1e0d0b7
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
9aadb4b3f2b3c914166ebfae8851fbecaf536f4f 14-Dec-2010 Vasu Nori <vnori@google.com> Download dir: /data/data/com.android.providers.downloads/cache NOT /cache

bug:3264401
still to do:
make sure only N bytes are taken up by downloads dir
N = a value specific to each device.
default = 100MB.

Change-Id: I2a49f4b3831d3a8d7be13b5fd46d85d56e831e38
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
5d217003acf21aea852975af0dff3b398cea6768 07-Dec-2010 Vasu Nori <vnori@google.com> fix broken DownloadManager tests

one big change in this CL is addition of a new feature to MockWebServer.
It can now play a long response to the Downloading thread to keep it busy
while something - such as cancel/remove - can be done to that Download Request.

Also, added changes to FakeSystemFacade to start threads in normal fashion
instead of queuing them up and later running just their run() methods.

the following tests should work now
packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/
DownloadManagerFunctionalTest.java
PublicApiFunctionalTest.java
ThreadingTest.java
PublicApiAccessTest.java
DownloadProviderPermissionsTest.java

the following are flaky. they need to be split up into smaller tests.
frameworks/base/core/tests/coretests/src/android/app/
DownloadManagerIntegrationTest.java
DownloadManagerStressTest.java

Change-Id: Ia0b11963f92e8f8365f701761dcbce467be3ee9b
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
04f09085f85d094207d22ae8969102bd48178180 20-Oct-2010 Vasu Nori <vnori@google.com> remove usage of hidden public constants.

Change-Id: I2edf1bef5e741de8193cb293807e3ace42003b0c
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
b108a273b150e81bf26553b8851d6241bc711f98 30-Sep-2010 Steve Howard <showard@google.com> Improve how the download manager reports paused statuses.

This change makes the download manager report more detail when a
download is paused. Rather than always reporting status
RUNNING_PAUSED, there are now four different statuses:

* paused by the app
* waiting to retry after a network error
* waiting for network connectivity
* queued for wifi due to size limits

This allows a few improvements:

* code deciding when to run a download can be improved and cleaned up
(I've taken some extra steps in cleaning up this particular code)
* notification code no longer has to rely on the in-memory-only
"mPausedReason" member of DownloadInfo; instead, it knows from the
status that the download is queued for wifi, and can display the
appropriate string. This moves the string fetching out into the
UI-specific logic and is a sign that this is really the right way
to do things.

And finally, the real motivation for this change: I've changed the
meaning of "Queued" in the downloads UI so it now means "Queued for
WiFi'. This is what was originally intended, I'd misunderstood. What
was formerly known as "Queued", a download that hadn't started, is now
displayed as "In progress" (it's always a transient state so it's
basically meaningless anyway). Otherwise it remains the same (in
particular, downloads paused for other reasons are still reported as
"In progress").

I've also increased some of the logging in DownloadThread a bit, as
this change initally introduced some bugs that were impossible to
track down without that logging. There have been other bug reports
that were impossible to diagnose and these few extra log statements
should really help, without cluttering logs too much. I've taken care
to avoid potentially introducing any PII into the logs.

Change-Id: Id0b8d65fc8e4406ad7ffa1439ffc22a0281b051f
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
e6a05a1aa4697440e9630d12b741b3bae321fe49 27-Jul-2010 Steve Howard <showard@google.com> Serialize threading for download manager testing.

The download manager uses threading in a simple way -- it launches two
threads, UpdateThread and DownloadThread, and both are "fire and
forget". This is fortunate for testing, since it means we can
eliminate multithreading and simply run each thread in order, and
everything still works.

This change does just that, abstracting Thread.start() behind
SystemFacade and making FakeSystemFacade put new threads into a queue
and then run through them serially. This simplifies much of the test
code and makes it all much more predictable.

I've simplified the test code as much as possible here and moved a few
more tests over to PublicApiFunctionalTest, leaving only a minimum in
DownloadManagerFunctionalTest, which will eventually be deleted
altogether. I've also improved testing in some areas -- for example,
we can now test that running notifications get cancelled after the
download completes in a robust way.

There is one test case that checks for race conditions and requires
multithreading. I've moved this into a new ThreadingTest class, which
uses a custom FakeSystemFacade that allows multithreading. I've
extracted AbstractPublicApiTest for the newly shared code.

Change-Id: Ic1d5c76bfa9913fe053174c3d8b516790ca8b25f
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
b5629da794cb3c1ca1970d206343743b165b9644 16-Jul-2010 Steve Howard <showard@google.com> Major refactoring of DownloadThread.run().

Motivation: I need to fix the handling of 302s, so that after a
disconnect, subsequent retries will use the original URI, not the
redirected one. Rather than store extra information in the DB, I'd
like to just keep the redirected URI in memory and make the redirected
request within the same DownloadThread. This involves working with
the large-scale structure of DownloadThread.run(). Since run() was a
~700 line method, I didn't feel comfortable making such changes.

So this change refactors run() into a ~80 line method which calls into
a collection of ~20 other short methods. The state previously kept in
local variables has been pulled into a couple of state-only inner
classes. The error-handling control flow, formerly handled by "break
http_request_loop" statements, is now handled by throwing a
"StopRequest" exception. The remaining structure of run() has been
simplified -- the outermost for loop, for example, could never
actually repeat and has been removed for now. Some other bits of code
have been cleaned up a bit, but the functionality has not been
modified.

There are many good next steps to this refactoring. Besides various
other cleanup bits, a major improvement would be to consolidate the
State/InnerState classes, move some functionality to this new class
(there are many functions of the form "void foo(State)" which would be
good candidates), and promote it to a top-level class. But I want to
take things one step at a time, and I think what I've got here is a
major improvement and should be enough to allow me to safely implement
the changes to redirection handling.

In the process of doing this refactoring I added many test cases to
PublicApiFunctionalTest to exercise some of the pieces of code I was
moving around. I also moved some test cases from
DownloadManagerFunctionalTest. Over time I'd like to move everything
over to use the PublicApiFunctionalTest approach, and then I may break
that into some smaller suites.

Other minor changes:
* use longs instead of ints to track file sizes, as these may be
getting quite large in the future
* provide a default DB value of -1 for COLUMN_TOTAL_BYTES, as this
simplifies some logic in DownloadThread
* small extensions to MockResponse to faciliate new test cases

Change-Id: If7862349296ad79ff6cdc97e554ad14c01ce1f49
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
af28400b74de05862b470412a5c92f68e99f59f8 16-Jul-2010 Steve Howard <showard@google.com> Introduce a seam to ConnectivityManager and TelephonyManager

This change abstracts access to ConnectivityManager and
TelephonyManager behind methods on SystemFacade, moving the code from
Helpers into RealSystemFacade and adding fake implementations to
FakeSystemFacade. This facilitates new connectivity tests.

Change-Id: Id6c6b861e1d4ca45b3c1572bfb8ae0aa26af756b
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
df71633a02ce2f1b6228dad1ba3198185edf6107 02-Jul-2010 Steve Howard <showard@google.com> New functional test for download manager public API.

I refactored a lot of the logic from DownloadManagerFunctionalTest
into a new abstract class so that it could be shared with the new
PublicApiFunctionalTest. There could be even more sharing, but it's
not entirely clear it'd be worthwhile at this point. The new test
covers most features of the new public API.

Change-Id: I8c6859411f44b6430f8b348cf26a61225f5768cb
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
23357198c440e6872d3aef3e608295db7f8273bc 23-Jun-2010 Steve Howard <showard@google.com> Stub out the system clock in the download manager, add tests

Introduce SystemFacade, an interface that allows us to stub out the
system clock for testing the download manager. This allows us to test
retrying a failed download without having the test wait 60 seconds.
This interface can include other dependencies in the future as well.

I've also used this to add tests for 503 (retry-after) and 301
(redirect), and I've added a test for download to the cache partition.

Other changes:
* made MockWebServer capable of checking + rethrowing exceptions from child threads
* refactoring + cleanup of DownloadManagerFunctionalTest
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
d6f9b5e72a135365f2358d79b3ea3c9f7cb99c8e 10-Jun-2010 Steve Howard <showard@google.com> First pass at a functional test for the Download Manager.

This "Large" test sets up an HTTP server on the device using
MockWebServer and then initiates downloads from that server through
the download manager. It uses ServiceTestCase to control the
construction and execution of the DownloadService, and it uses some
logic from ProviderTestCase2 to construct a DownloadProvider and a
ContentResolver that uses it.

This setup gives us some ability to mock dependencies. This commit
includes use of a fake ConnectivityManager to test responses to
connectivity changes, and use of some customizations to MockWebServer
to test resuming an interrupted download. This test is disabled,
though, since it requires a very long sleep.

Avoiding that, and achieving certain other things, will require
changes to the Download Manager code itself to introduce new seams. I
wanted to check this in before I started such changes.

Change-Id: Iefb13b3c3cccdc13fabe5cc18703e13244805539
/packages/providers/DownloadProvider/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java