| Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
|
| index e8c554e473e8f5806b59ae6ad55f661f6434823a..229273930b93e5c15006387001e4db3943db8ae4 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
|
| @@ -18,6 +18,7 @@ import android.text.TextUtils;
|
| import android.util.Log;
|
|
|
| import org.chromium.base.CalledByNative;
|
| +import org.chromium.base.VisibleForTesting;
|
| import org.chromium.chrome.R;
|
| import org.chromium.chrome.browser.preferences.Preferences;
|
| import org.chromium.chrome.browser.preferences.PreferencesLauncher;
|
| @@ -39,11 +40,12 @@ public class NotificationUIManager {
|
| private static final int NOTIFICATION_TEXT_SIZE_DP = 28;
|
|
|
| private static NotificationUIManager sInstance;
|
| + private static NotificationManagerProxy sNotificationManagerOverride;
|
|
|
| private final long mNativeNotificationManager;
|
|
|
| private final Context mAppContext;
|
| - private final NotificationManager mNotificationManager;
|
| + private final NotificationManagerProxy mNotificationManager;
|
|
|
| private RoundedIconGenerator mIconGenerator;
|
|
|
| @@ -65,12 +67,29 @@ public class NotificationUIManager {
|
| return sInstance;
|
| }
|
|
|
| + /**
|
| + * Overrides the notification manager which is to be used for displaying Notifications on the
|
| + * Android framework. Should only be used for testing. Tests are expected to clean up after
|
| + * themselves by setting this to NULL again.
|
| + *
|
| + * @param proxy The notification manager instance to use instead of the system's.
|
| + */
|
| + @VisibleForTesting
|
| + public static void overrideNotificationManagerForTesting(
|
| + NotificationManagerProxy notificationManager) {
|
| + sNotificationManagerOverride = notificationManager;
|
| + }
|
| +
|
| private NotificationUIManager(long nativeNotificationManager, Context context) {
|
| mNativeNotificationManager = nativeNotificationManager;
|
| mAppContext = context.getApplicationContext();
|
|
|
| - mNotificationManager = (NotificationManager)
|
| - mAppContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
| + if (sNotificationManagerOverride != null) {
|
| + mNotificationManager = sNotificationManagerOverride;
|
| + } else {
|
| + mNotificationManager = new NotificationManagerProxyImpl(
|
| + (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE));
|
| + }
|
|
|
| mLastNotificationId = 0;
|
| }
|
|
|