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

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

Issue 2631933002: Adding status info to DownloadUIItem and piping it through. (Closed)
Patch Set: fix chrome_test_java Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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.ui; 5 package org.chromium.chrome.browser.download.ui;
6 6
7 import static junit.framework.Assert.assertEquals; 7 import static junit.framework.Assert.assertEquals;
8 import static junit.framework.Assert.assertNull; 8 import static junit.framework.Assert.assertNull;
9 9
10 import android.content.ComponentName; 10 import android.content.ComponentName;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 DownloadItem item = new DownloadItem(false, builder.build()); 309 DownloadItem item = new DownloadItem(false, builder.build());
310 item.setStartTime(dateToEpoch(date)); 310 item.setStartTime(dateToEpoch(date));
311 return item; 311 return item;
312 } 312 }
313 313
314 /** Creates a new OfflinePageDownloadItem with pre-defined values. */ 314 /** Creates a new OfflinePageDownloadItem with pre-defined values. */
315 public static OfflinePageDownloadItem createOfflineItem(int which, String da te) 315 public static OfflinePageDownloadItem createOfflineItem(int which, String da te)
316 throws Exception { 316 throws Exception {
317 long startTime = dateToEpoch(date); 317 long startTime = dateToEpoch(date);
318 int downloadState = org.chromium.components.offlinepages.downloads.Downl oadState.COMPLETE;
318 if (which == 0) { 319 if (which == 0) {
319 return new OfflinePageDownloadItem("offline_guid_1", "https://url.co m", 320 return new OfflinePageDownloadItem("offline_guid_1", "https://url.co m",
320 "page 1", "/data/fake_path/Downloads/first_file", startTime, 1000); 321 downloadState, 0, "page 1",
322 "/data/fake_path/Downloads/first_file", startTime, 1000);
321 } else if (which == 1) { 323 } else if (which == 1) {
322 return new OfflinePageDownloadItem("offline_guid_2", "http://stuff_a nd_things.com", 324 return new OfflinePageDownloadItem("offline_guid_2", "http://stuff_a nd_things.com",
323 "page 2", "/data/fake_path/Downloads/file_two", startTime, 1 0000); 325 downloadState, 0, "page 2",
326 "/data/fake_path/Downloads/file_two", startTime, 10000);
324 } else if (which == 2) { 327 } else if (which == 2) {
325 return new OfflinePageDownloadItem("offline_guid_3", "https://url.co m", 328 return new OfflinePageDownloadItem("offline_guid_3", "https://url.co m",
326 "page 3", "/data/fake_path/Downloads/3_file", startTime, 100 000); 329 downloadState, 100, "page 3",
330 "/data/fake_path/Downloads/3_file", startTime, 100000);
327 } else if (which == 3) { 331 } else if (which == 3) {
328 return new OfflinePageDownloadItem("offline_guid_4", "https://thangs .com", 332 return new OfflinePageDownloadItem("offline_guid_4", "https://thangs .com",
329 "page 4", "/data/fake_path/Downloads/4", startTime, ONE_GIGA BYTE * 5L); 333 downloadState, 1024, "page 4",
334 "/data/fake_path/Downloads/4", startTime, ONE_GIGABYTE * 5L) ;
330 } else { 335 } else {
331 return null; 336 return null;
332 } 337 }
333 } 338 }
334 339
335 /** Converts a date string to a timestamp. */ 340 /** Converts a date string to a timestamp. */
336 private static long dateToEpoch(String dateStr) throws Exception { 341 private static long dateToEpoch(String dateStr) throws Exception {
337 return new SimpleDateFormat("yyyyMMdd HH:mm", Locale.getDefault()).parse (dateStr).getTime(); 342 return new SimpleDateFormat("yyyyMMdd HH:mm", Locale.getDefault()).parse (dateStr).getTime();
338 } 343 }
339 344
340 } 345 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698