OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.download; | 5 package org.chromium.chrome.browser.download; |
6 | 6 |
7 import android.app.Notification; | 7 import android.app.Notification; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
10 import android.util.Pair; | 10 import android.util.Pair; |
11 | 11 |
12 import org.chromium.base.ThreadUtils; | 12 import org.chromium.base.ThreadUtils; |
13 import org.chromium.components.offline_items_collection.ContentId; | 13 import org.chromium.components.offline_items_collection.ContentId; |
| 14 import org.chromium.components.offline_items_collection.OfflineItem.Progress; |
14 | 15 |
15 import java.util.ArrayList; | 16 import java.util.ArrayList; |
16 import java.util.List; | 17 import java.util.List; |
17 import java.util.concurrent.Callable; | 18 import java.util.concurrent.Callable; |
18 | 19 |
19 /** | 20 /** |
20 * Mock class to DownloadNotificationService for testing purpose. | 21 * Mock class to DownloadNotificationService for testing purpose. |
21 */ | 22 */ |
22 public class MockDownloadNotificationService extends DownloadNotificationService
{ | 23 public class MockDownloadNotificationService extends DownloadNotificationService
{ |
23 private final List<Integer> mNotificationIds = new ArrayList<Integer>(); | 24 private final List<Integer> mNotificationIds = new ArrayList<Integer>(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 public Integer call() throws Exception { | 104 public Integer call() throws Exception { |
104 return MockDownloadNotificationService.super.notifyDownloadSucce
ssful(id, filePath, | 105 return MockDownloadNotificationService.super.notifyDownloadSucce
ssful(id, filePath, |
105 fileName, systemDownloadId, isOffTheRecord, isSupportedM
imeType, isOpenable, | 106 fileName, systemDownloadId, isOffTheRecord, isSupportedM
imeType, isOpenable, |
106 icon); | 107 icon); |
107 } | 108 } |
108 }); | 109 }); |
109 } | 110 } |
110 | 111 |
111 @Override | 112 @Override |
112 public void notifyDownloadProgress(final ContentId id, final String fileName
, | 113 public void notifyDownloadProgress(final ContentId id, final String fileName
, |
113 final int percentage, final long bytesReceived, final long timeRemai
ningInMillis, | 114 final Progress progress, final long bytesReceived, final long timeRe
mainingInMillis, |
114 final long startTime, final boolean isOffTheRecord, | 115 final long startTime, final boolean isOffTheRecord, |
115 final boolean canDownloadWhileMetered, final boolean isTransient, fi
nal Bitmap icon) { | 116 final boolean canDownloadWhileMetered, final boolean isTransient, fi
nal Bitmap icon) { |
116 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 117 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
117 @Override | 118 @Override |
118 public void run() { | 119 public void run() { |
119 MockDownloadNotificationService.super.notifyDownloadProgress(id,
fileName, | 120 MockDownloadNotificationService.super.notifyDownloadProgress(id,
fileName, progress, |
120 percentage, bytesReceived, timeRemainingInMillis, startT
ime, isOffTheRecord, | 121 bytesReceived, timeRemainingInMillis, startTime, isOffTh
eRecord, |
121 canDownloadWhileMetered, isTransient, icon); | 122 canDownloadWhileMetered, isTransient, icon); |
122 } | 123 } |
123 }); | 124 }); |
124 } | 125 } |
125 | 126 |
126 @Override | 127 @Override |
127 public void notifyDownloadFailed(final ContentId id, final String fileName,
final Bitmap icon) { | 128 public void notifyDownloadFailed(final ContentId id, final String fileName,
final Bitmap icon) { |
128 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 129 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
129 @Override | 130 @Override |
130 public void run() { | 131 public void run() { |
131 MockDownloadNotificationService.super.notifyDownloadFailed(id, f
ileName, icon); | 132 MockDownloadNotificationService.super.notifyDownloadFailed(id, f
ileName, icon); |
132 } | 133 } |
133 }); | 134 }); |
134 } | 135 } |
135 | 136 |
136 @Override | 137 @Override |
137 public void notifyDownloadCanceled(final ContentId id) { | 138 public void notifyDownloadCanceled(final ContentId id) { |
138 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 139 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
139 @Override | 140 @Override |
140 public void run() { | 141 public void run() { |
141 MockDownloadNotificationService.super.notifyDownloadCanceled(id)
; | 142 MockDownloadNotificationService.super.notifyDownloadCanceled(id)
; |
142 } | 143 } |
143 }); | 144 }); |
144 } | 145 } |
145 } | 146 } |
146 | 147 |
OLD | NEW |