Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/download/MockDownloadNotificationService.java

Issue 2726423002: Fix DownloadNotificationService foreground state (Closed)
Patch Set: Fix spelling mistake Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/download/MockDownloadNotificationService.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/download/MockDownloadNotificationService.java b/chrome/android/javatests/src/org/chromium/chrome/browser/download/MockDownloadNotificationService.java
index d54713749b27c8402a132b6db8bc585d3b92f12a..b5499a0ab414e722267d244f99373adb04552d12 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/download/MockDownloadNotificationService.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/download/MockDownloadNotificationService.java
@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.download;
import android.app.Notification;
import android.content.Context;
+import org.chromium.base.BuildInfo;
import org.chromium.base.ThreadUtils;
import java.util.ArrayList;
@@ -27,10 +28,13 @@ public class MockDownloadNotificationService extends DownloadNotificationService
}
@Override
- public void stopForeground() {}
+ public void stopForegroundInternal(boolean killNotification) {
+ if (!BuildInfo.isAtLeastO()) return;
+ if (killNotification) mNotificationIds.clear();
+ }
@Override
- public void startForeground() {}
+ public void startForegroundInternal() {}
@Override
public void cancelOffTheRecordDownloads() {
@@ -39,6 +43,21 @@ public class MockDownloadNotificationService extends DownloadNotificationService
}
@Override
+ boolean hasDownloadNotifications(Integer notificationIdToIgnore) {
+ if (!BuildInfo.isAtLeastO()) return false;
+ // Cancelling notifications here is synchronous, so we don't really have to worry about
+ // {@code notificationIdToIgnore}, but address it properly anyway.
+ if (mNotificationIds.size() == 1 && notificationIdToIgnore != null) {
+ return !mNotificationIds.contains(notificationIdToIgnore);
+ }
+
+ return !mNotificationIds.isEmpty();
+ }
+
+ @Override
+ void cancelSummaryNotification() {}
+
+ @Override
void updateNotification(int id, Notification notification) {
if (!mNotificationIds.contains(id)) {
mNotificationIds.add(id);
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698