| 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 c089ae7353706f34fa2c16e19d871e8692a2b30e..3a62b26ea7c28811caf1dc705c7fc67f32b65f60 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
|
| @@ -140,7 +140,7 @@ public class DownloadNotificationServiceTest extends
|
| DownloadResumptionScheduler.setDownloadResumptionScheduler(scheduler);
|
| setupService();
|
| Set<String> notifications = new HashSet<String>();
|
| - notifications.add(new DownloadSharedPreferenceEntry(1, true, true,
|
| + notifications.add(new DownloadSharedPreferenceEntry(1, false, true,
|
| UUID.randomUUID().toString(), "test1").getSharedPreferenceString());
|
| SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences();
|
| SharedPreferences.Editor editor = sharedPrefs.edit();
|
| @@ -183,9 +183,9 @@ public class DownloadNotificationServiceTest extends
|
| Context mockContext = new AdvancedMockContext(getSystemContext());
|
| getService().setContext(mockContext);
|
| Set<String> notifications = new HashSet<String>();
|
| - notifications.add(new DownloadSharedPreferenceEntry(1, true, true,
|
| + notifications.add(new DownloadSharedPreferenceEntry(1, false, true,
|
| UUID.randomUUID().toString(), "test1").getSharedPreferenceString());
|
| - notifications.add(new DownloadSharedPreferenceEntry(2, true, true,
|
| + notifications.add(new DownloadSharedPreferenceEntry(2, false, true,
|
| UUID.randomUUID().toString(), "test2").getSharedPreferenceString());
|
| SharedPreferences sharedPrefs =
|
| ContextUtils.getAppSharedPreferences();
|
| @@ -213,10 +213,10 @@ public class DownloadNotificationServiceTest extends
|
| getService().setContext(mockContext);
|
| Set<String> notifications = new HashSet<String>();
|
| String guid1 = UUID.randomUUID().toString();
|
| - notifications.add(new DownloadSharedPreferenceEntry(3, true, true, guid1, "success")
|
| + notifications.add(new DownloadSharedPreferenceEntry(3, false, true, guid1, "success")
|
| .getSharedPreferenceString());
|
| String guid2 = UUID.randomUUID().toString();
|
| - notifications.add(new DownloadSharedPreferenceEntry(4, true, true, guid2, "failed")
|
| + notifications.add(new DownloadSharedPreferenceEntry(4, false, true, guid2, "failed")
|
| .getSharedPreferenceString());
|
| SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences();
|
| SharedPreferences.Editor editor = sharedPrefs.edit();
|
| @@ -277,10 +277,10 @@ public class DownloadNotificationServiceTest extends
|
| getService().setContext(mockContext);
|
| Set<String> notifications = new HashSet<String>();
|
| String guid1 = UUID.randomUUID().toString();
|
| - notifications.add(new DownloadSharedPreferenceEntry(3, true, false, guid1, "success")
|
| + notifications.add(new DownloadSharedPreferenceEntry(3, false, false, guid1, "success")
|
| .getSharedPreferenceString());
|
| String guid2 = UUID.randomUUID().toString();
|
| - notifications.add(new DownloadSharedPreferenceEntry(4, true, true, guid2, "failed")
|
| + notifications.add(new DownloadSharedPreferenceEntry(4, false, true, guid2, "failed")
|
| .getSharedPreferenceString());
|
| SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences();
|
| SharedPreferences.Editor editor = sharedPrefs.edit();
|
| @@ -311,6 +311,32 @@ public class DownloadNotificationServiceTest extends
|
| assertEquals(manager.mDownloads.get(0).getDownloadInfo().getDownloadGuid(), guid1);
|
| }
|
|
|
| + /**
|
| + * Tests incognito download fails when browser gets killed.
|
| + */
|
| + @SmallTest
|
| + @Feature({"Download"})
|
| + public void testIncognitoDownloadFailsOnBrowserKill() throws Exception {
|
| + setupService();
|
| + Context mockContext = new AdvancedMockContext(getSystemContext());
|
| + getService().setContext(mockContext);
|
| + Set<String> notifications = new HashSet<String>();
|
| + String uuid = UUID.randomUUID().toString();
|
| + notifications.add(new DownloadSharedPreferenceEntry(1, true, true, uuid, "test1")
|
| + .getSharedPreferenceString());
|
| + SharedPreferences sharedPrefs =
|
| + ContextUtils.getAppSharedPreferences();
|
| + SharedPreferences.Editor editor = sharedPrefs.edit();
|
| + editor.putStringSet(
|
| + DownloadNotificationService.PENDING_DOWNLOAD_NOTIFICATIONS, notifications);
|
| + editor.apply();
|
| + startNotificationService();
|
| + assertTrue(getService().isPaused());
|
| + assertFalse(sharedPrefs.contains(
|
| + DownloadNotificationService.PENDING_DOWNLOAD_NOTIFICATIONS));
|
| + assertEquals(uuid, getService().getFailedDownloadGuid());
|
| + }
|
| +
|
| @SmallTest
|
| @Feature({"Download"})
|
| public void testParseDownloadNotifications() {
|
| @@ -321,15 +347,19 @@ public class DownloadNotificationServiceTest extends
|
| DownloadSharedPreferenceEntry.parseFromString(notification);
|
| assertEquals(1, entry.notificationId);
|
| assertEquals("test.pdf", entry.fileName);
|
| - assertFalse(entry.isResumable);
|
| + assertFalse(entry.isOffTheRecord);
|
| assertEquals(uuid, entry.downloadGuid);
|
|
|
| notification = DownloadSharedPreferenceEntry.VERSION + ",2,1,1," + uuid + ",test,2.pdf";
|
| entry = DownloadSharedPreferenceEntry.parseFromString(notification);
|
| assertEquals(2, entry.notificationId);
|
| assertEquals("test,2.pdf", entry.fileName);
|
| - assertTrue(entry.isResumable);
|
| + assertTrue(entry.isOffTheRecord);
|
| assertEquals(uuid, entry.downloadGuid);
|
| +
|
| + notification = "1,2,1,1," + uuid + ",test,2.pdf";
|
| + entry = DownloadSharedPreferenceEntry.parseFromString(notification);
|
| + assertFalse(entry.isOffTheRecord);
|
| }
|
|
|
| @SmallTest
|
|
|