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

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

Issue 2861863002: offline_items_collection : Added helper class to determine progress (Closed)
Patch Set: findbugs 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadNotificationServiceTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadNotificationServiceTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadNotificationServiceTest.java
index 85650cb5387dcbf774f1f030338b62c0bb84445e..cfb738a2a2ae36622cc47f59b1396f07daf81594 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadNotificationServiceTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadNotificationServiceTest.java
@@ -20,6 +20,8 @@ import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.components.offline_items_collection.ContentId;
import org.chromium.components.offline_items_collection.LegacyHelpers;
+import org.chromium.components.offline_items_collection.OfflineItem.Progress;
+import org.chromium.components.offline_items_collection.OfflineItemProgressUnit;
import java.util.ArrayList;
import java.util.HashSet;
@@ -296,7 +298,9 @@ public class DownloadNotificationServiceTest extends
DownloadNotificationService service = bindNotificationService();
ContentId id3 = LegacyHelpers.buildLegacyContentId(false, UUID.randomUUID().toString());
- service.notifyDownloadProgress(id3, "test", 1, 100L, 1L, 1L, true, true, false, null);
+ service.notifyDownloadProgress(id3, "test",
+ new Progress(1, 100L, OfflineItemProgressUnit.PERCENTAGE), 100L, 1L, 1L, true, true,
+ false, null);
assertEquals(3, getService().getNotificationIds().size());
int lastNotificationId = getService().getLastAddedNotificationId();
Set<String> entries = DownloadManagerService.getStoredDownloadInfo(
@@ -430,27 +434,33 @@ public class DownloadNotificationServiceTest extends
@Feature({"Download"})
public void testFormatRemainingTime() {
David Trainor- moved to gerrit 2017/05/09 05:36:01 Should we add a test validating the new DownloadUt
shaktisahu 2017/05/09 19:04:32 Done.
Context context = getSystemContext().getApplicationContext();
- assertEquals("0 secs left", DownloadNotificationService.formatRemainingTime(context, 0));
- assertEquals("1 sec left", DownloadNotificationService.formatRemainingTime(
- context, MILLIS_PER_SECOND));
- assertEquals("1 min left", DownloadNotificationService.formatRemainingTime(context,
- DownloadNotificationService.SECONDS_PER_MINUTE * MILLIS_PER_SECOND));
- assertEquals("2 mins left", DownloadNotificationService.formatRemainingTime(context,
- 149 * MILLIS_PER_SECOND));
- assertEquals("3 mins left", DownloadNotificationService.formatRemainingTime(context,
- 150 * MILLIS_PER_SECOND));
- assertEquals("1 hour left", DownloadNotificationService.formatRemainingTime(context,
- DownloadNotificationService.SECONDS_PER_HOUR * MILLIS_PER_SECOND));
- assertEquals("2 hours left", DownloadNotificationService.formatRemainingTime(context,
- 149 * DownloadNotificationService.SECONDS_PER_MINUTE * MILLIS_PER_SECOND));
- assertEquals("3 hours left", DownloadNotificationService.formatRemainingTime(context,
- 150 * DownloadNotificationService.SECONDS_PER_MINUTE * MILLIS_PER_SECOND));
- assertEquals("1 day left", DownloadNotificationService.formatRemainingTime(context,
- DownloadNotificationService.SECONDS_PER_DAY * MILLIS_PER_SECOND));
- assertEquals("2 days left", DownloadNotificationService.formatRemainingTime(context,
- 59 * DownloadNotificationService.SECONDS_PER_HOUR * MILLIS_PER_SECOND));
- assertEquals("3 days left", DownloadNotificationService.formatRemainingTime(context,
- 60 * DownloadNotificationService.SECONDS_PER_HOUR * MILLIS_PER_SECOND));
+ assertEquals("0 secs left", DownloadUtils.formatRemainingTime(context, 0));
+ assertEquals("1 sec left", DownloadUtils.formatRemainingTime(context, MILLIS_PER_SECOND));
+ assertEquals("1 min left",
+ DownloadUtils.formatRemainingTime(
+ context, DownloadUtils.SECONDS_PER_MINUTE * MILLIS_PER_SECOND));
+ assertEquals(
+ "2 mins left", DownloadUtils.formatRemainingTime(context, 149 * MILLIS_PER_SECOND));
+ assertEquals(
+ "3 mins left", DownloadUtils.formatRemainingTime(context, 150 * MILLIS_PER_SECOND));
+ assertEquals("1 hour left",
+ DownloadUtils.formatRemainingTime(
+ context, DownloadUtils.SECONDS_PER_HOUR * MILLIS_PER_SECOND));
+ assertEquals("2 hours left",
+ DownloadUtils.formatRemainingTime(
+ context, 149 * DownloadUtils.SECONDS_PER_MINUTE * MILLIS_PER_SECOND));
+ assertEquals("3 hours left",
+ DownloadUtils.formatRemainingTime(
+ context, 150 * DownloadUtils.SECONDS_PER_MINUTE * MILLIS_PER_SECOND));
+ assertEquals("1 day left",
+ DownloadUtils.formatRemainingTime(
+ context, DownloadUtils.SECONDS_PER_DAY * MILLIS_PER_SECOND));
+ assertEquals("2 days left",
+ DownloadUtils.formatRemainingTime(
+ context, 59 * DownloadUtils.SECONDS_PER_HOUR * MILLIS_PER_SECOND));
+ assertEquals("3 days left",
+ DownloadUtils.formatRemainingTime(
+ context, 60 * DownloadUtils.SECONDS_PER_HOUR * MILLIS_PER_SECOND));
}
// Tests that the downloaded bytes on the notification is correct.

Powered by Google App Engine
This is Rietveld 408576698