From 93155e1da7e89d4925e244f5afa94afb8ada7381 Mon Sep 17 00:00:00 2001 From: Steve Howard Date: Fri, 23 Jul 2010 20:32:21 -0700 Subject: 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 --- .../providers/downloads/RealSystemFacade.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/com/android/providers/downloads/RealSystemFacade.java') diff --git a/src/com/android/providers/downloads/RealSystemFacade.java b/src/com/android/providers/downloads/RealSystemFacade.java index f89f1659..1d9e64a9 100644 --- a/src/com/android/providers/downloads/RealSystemFacade.java +++ b/src/com/android/providers/downloads/RealSystemFacade.java @@ -1,5 +1,7 @@ package com.android.providers.downloads; +import android.app.Notification; +import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager.NameNotFoundException; @@ -10,9 +12,12 @@ import android.util.Log; class RealSystemFacade implements SystemFacade { private Context mContext; + private NotificationManager mNotificationManager; public RealSystemFacade(Context context) { mContext = context; + mNotificationManager = (NotificationManager) + mContext.getSystemService(Context.NOTIFICATION_SERVICE); } public long currentTimeMillis() { @@ -67,4 +72,19 @@ class RealSystemFacade implements SystemFacade { public boolean userOwnsPackage(int uid, String packageName) throws NameNotFoundException { return mContext.getPackageManager().getApplicationInfo(packageName, 0).uid == uid; } + + @Override + public void postNotification(int id, Notification notification) { + mNotificationManager.notify(id, notification); + } + + @Override + public void cancelNotification(int id) { + mNotificationManager.cancel(id); + } + + @Override + public void cancelAllNotifications() { + mNotificationManager.cancelAll(); + } } -- cgit v1.2.3