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

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

Issue 2861863002: offline_items_collection : Added helper class to determine progress (Closed)
Patch Set: comments Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698