summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/providers/downloads/FakeSystemFacade.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/FakeSystemFacade.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/FakeSystemFacade.java')
-rw-r--r--tests/src/com/android/providers/downloads/FakeSystemFacade.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/src/com/android/providers/downloads/FakeSystemFacade.java b/tests/src/com/android/providers/downloads/FakeSystemFacade.java
index 0f8a9801..d35b558b 100644
--- a/tests/src/com/android/providers/downloads/FakeSystemFacade.java
+++ b/tests/src/com/android/providers/downloads/FakeSystemFacade.java
@@ -1,11 +1,15 @@
package com.android.providers.downloads;
+import android.app.Notification;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.ConnectivityManager;
+import android.test.AssertionFailedError;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
public class FakeSystemFacade implements SystemFacade {
long mTimeMillis = 0;
@@ -13,6 +17,8 @@ public class FakeSystemFacade implements SystemFacade {
boolean mIsRoaming = false;
Integer mMaxBytesOverMobile = null;
List<Intent> mBroadcastsSent = new ArrayList<Intent>();
+ Map<Integer,Notification> mActiveNotifications = new HashMap<Integer,Notification>();
+ List<Notification> mCanceledNotifications = new ArrayList<Notification>();
void incrementTimeMillis(long delta) {
mTimeMillis += delta;
@@ -43,4 +49,27 @@ public class FakeSystemFacade implements SystemFacade {
public boolean userOwnsPackage(int uid, String pckg) throws NameNotFoundException {
return true;
}
+
+ @Override
+ public void postNotification(int id, Notification notification) {
+ if (notification == null) {
+ throw new AssertionFailedError("Posting null notification");
+ }
+ mActiveNotifications.put(id, notification);
+ }
+
+ @Override
+ public void cancelNotification(int id) {
+ Notification notification = mActiveNotifications.remove(id);
+ if (notification != null) {
+ mCanceledNotifications.add(notification);
+ }
+ }
+
+ @Override
+ public void cancelAllNotifications() {
+ for (int id : mActiveNotifications.keySet()) {
+ cancelNotification(id);
+ }
+ }
}