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

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

Issue 2070713002: Format remaining download time in java code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix findbugs warning Created 4 years, 6 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 b6881c6ec8c06eb45a15c43db70063fa8e5946df..36d829e44737a8ae91cbc5d92128b945bdf85092 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
@@ -29,6 +29,8 @@ import java.util.UUID;
*/
public class DownloadNotificationServiceTest extends
ServiceTestCase<MockDownloadNotificationService> {
+ private static final int MILLIS_PER_SECOND = 1000;
+
private static class MockDownloadManagerService extends DownloadManagerService {
final List<DownloadItem> mDownloads = new ArrayList<DownloadItem>();
@@ -256,4 +258,31 @@ public class DownloadNotificationServiceTest extends
assertTrue(entry.isResumable);
assertEquals(uuid, entry.downloadGuid);
}
+
+ @SmallTest
+ @Feature({"Download"})
+ public void testFormatRemainingTime() {
+ 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));
+ }
}

Powered by Google App Engine
This is Rietveld 408576698