summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
diff options
context:
space:
mode:
authorSteve Howard <showard@google.com>2010-07-23 20:32:21 -0700
committerSteve Howard <showard@google.com>2010-07-23 20:32:21 -0700
commit93155e1da7e89d4925e244f5afa94afb8ada7381 (patch)
treea5cafd34f505277bf760162711eda1d90d9e0d4a /tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
parent691fc58e9a61d99ab5018c5ddc8349ed413e4470 (diff)
downloadandroid_packages_providers_DownloadProvider-93155e1da7e89d4925e244f5afa94afb8ada7381.tar.gz
android_packages_providers_DownloadProvider-93155e1da7e89d4925e244f5afa94afb8ada7381.tar.bz2
android_packages_providers_DownloadProvider-93155e1da7e89d4925e244f5afa94afb8ada7381.zip
Stub out and test system notifications.
This change abstracts NotificationManager interactions behind SystemFacade and takes advantage of that to test notifications, to a limited degree. It also fixes a silly typo in AbstractDownloadManagerFunctionalTest, and it introduces an extra sleep between tests to avoid some flakiness. I'll look for a better solution to that problem after this change goes in. Change-Id: I3a0307f828955cd45b0e3581ad499da28cc0556e
Diffstat (limited to 'tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java')
-rw-r--r--tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
index 3d32ae3c..00419a3d 100644
--- a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
+++ b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
@@ -485,6 +485,24 @@ public class PublicApiFunctionalTest extends AbstractDownloadManagerFunctionalTe
assertTrue(mResolver.mNotifyWasCalled);
}
+ public void testNotifications() throws Exception {
+ enqueueEmptyResponse(HTTP_OK);
+ Download download = enqueueRequest(getRequest()); // no visibility requested
+ download.runUntilStatus(DownloadManager.STATUS_SUCCESSFUL);
+ assertEquals(0, mSystemFacade.mActiveNotifications.size());
+ assertEquals(0, mSystemFacade.mCanceledNotifications.size());
+
+ enqueueEmptyResponse(HTTP_OK);
+ download = enqueueRequest(
+ getRequest()
+ .setShowNotification(DownloadManager.Request.NOTIFICATION_WHEN_RUNNING));
+ download.runUntilStatus(DownloadManager.STATUS_SUCCESSFUL);
+ assertEquals(1, mSystemFacade.mActiveNotifications.size());
+ // The notification doesn't actually get canceled until the UpdateThread runs again, which
+ // gets triggered by the DownloadThread updating the status in the provider. This is
+ // tough to test right now, so I'll leave it until the overall structure is changed.
+ }
+
private void runSimpleFailureTest(int expectedErrorCode) throws Exception {
Download download = enqueueRequest(getRequest());
download.runUntilStatus(DownloadManager.STATUS_FAILED);