| Index: chrome/android/junit/src/org/chromium/chrome/browser/download/DownloadSharedPreferenceEntryTest.java
|
| diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/download/DownloadSharedPreferenceEntryTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/download/DownloadSharedPreferenceEntryTest.java
|
| index 81737ded357b8656710089859f46862996751048..03be14670a50f911a67d8895dfebfaf349df9fbb 100644
|
| --- a/chrome/android/junit/src/org/chromium/chrome/browser/download/DownloadSharedPreferenceEntryTest.java
|
| +++ b/chrome/android/junit/src/org/chromium/chrome/browser/download/DownloadSharedPreferenceEntryTest.java
|
| @@ -38,18 +38,22 @@ public class DownloadSharedPreferenceEntryTest {
|
| DownloadSharedPreferenceEntry entry =
|
| DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| assertEquals(2, entry.notificationId);
|
| + assertEquals(LegacyHelpers.buildLegacyContentId(false, uuid), entry.id);
|
| assertFalse(entry.isOffTheRecord);
|
| assertTrue(entry.canDownloadWhileMetered);
|
| - assertEquals(LegacyHelpers.buildLegacyContentId(false, uuid), entry.id);
|
| + assertTrue(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| assertEquals("test,2.pdf", entry.fileName);
|
|
|
| String uuid2 = newUUID();
|
| notificationString = "1,3,0,0," + uuid2 + ",test,4.pdf";
|
| entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| assertEquals(3, entry.notificationId);
|
| + assertEquals(LegacyHelpers.buildLegacyContentId(false, uuid2), entry.id);
|
| assertTrue(entry.isOffTheRecord);
|
| assertFalse(entry.canDownloadWhileMetered);
|
| - assertEquals(LegacyHelpers.buildLegacyContentId(false, uuid2), entry.id);
|
| + assertTrue(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| assertEquals("test,4.pdf", entry.fileName);
|
| }
|
|
|
| @@ -61,18 +65,22 @@ public class DownloadSharedPreferenceEntryTest {
|
| DownloadSharedPreferenceEntry entry =
|
| DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| assertEquals(2, entry.notificationId);
|
| + assertEquals(LegacyHelpers.buildLegacyContentId(false, uuid), entry.id);
|
| assertFalse(entry.isOffTheRecord);
|
| assertTrue(entry.canDownloadWhileMetered);
|
| - assertEquals(LegacyHelpers.buildLegacyContentId(false, uuid), entry.id);
|
| + assertTrue(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| assertEquals("test,2.pdf", entry.fileName);
|
|
|
| String uuid2 = newUUID();
|
| notificationString = "2,3,1,0," + uuid2 + ",test,4.pdf";
|
| entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| assertEquals(3, entry.notificationId);
|
| + assertEquals(LegacyHelpers.buildLegacyContentId(false, uuid2), entry.id);
|
| assertTrue(entry.isOffTheRecord);
|
| assertFalse(entry.canDownloadWhileMetered);
|
| - assertEquals(LegacyHelpers.buildLegacyContentId(false, uuid2), entry.id);
|
| + assertTrue(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| assertEquals("test,4.pdf", entry.fileName);
|
| }
|
|
|
| @@ -84,9 +92,11 @@ public class DownloadSharedPreferenceEntryTest {
|
| DownloadSharedPreferenceEntry entry =
|
| DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| assertEquals(2, entry.notificationId);
|
| + assertEquals(LegacyHelpers.buildLegacyContentId(false, uuid), entry.id);
|
| assertFalse(entry.isOffTheRecord);
|
| assertTrue(entry.canDownloadWhileMetered);
|
| - assertEquals(LegacyHelpers.buildLegacyContentId(false, uuid), entry.id);
|
| + assertTrue(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| assertEquals("test,2.pdf", entry.fileName);
|
|
|
| String uuid2 = newUUID();
|
| @@ -96,6 +106,8 @@ public class DownloadSharedPreferenceEntryTest {
|
| assertEquals(LegacyHelpers.buildLegacyContentId(false, uuid2), entry.id);
|
| assertTrue(entry.isOffTheRecord);
|
| assertFalse(entry.canDownloadWhileMetered);
|
| + assertTrue(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| assertEquals("test,4.pdf", entry.fileName);
|
| }
|
|
|
| @@ -110,6 +122,8 @@ public class DownloadSharedPreferenceEntryTest {
|
| assertEquals(LegacyHelpers.buildLegacyContentId(true, uuid), entry.id);
|
| assertFalse(entry.isOffTheRecord);
|
| assertTrue(entry.canDownloadWhileMetered);
|
| + assertTrue(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| assertEquals("test,2.pdf", entry.fileName);
|
|
|
| String uuid2 = newUUID();
|
| @@ -119,6 +133,8 @@ public class DownloadSharedPreferenceEntryTest {
|
| assertEquals(LegacyHelpers.buildLegacyContentId(true, uuid2), entry.id);
|
| assertTrue(entry.isOffTheRecord);
|
| assertFalse(entry.canDownloadWhileMetered);
|
| + assertTrue(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| assertEquals("test,4.pdf", entry.fileName);
|
| }
|
|
|
| @@ -134,6 +150,7 @@ public class DownloadSharedPreferenceEntryTest {
|
| assertFalse(entry.isOffTheRecord);
|
| assertTrue(entry.canDownloadWhileMetered);
|
| assertTrue(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| assertEquals("test,2.pdf", entry.fileName);
|
|
|
| String uuid2 = newUUID();
|
| @@ -144,6 +161,7 @@ public class DownloadSharedPreferenceEntryTest {
|
| assertTrue(entry.isOffTheRecord);
|
| assertFalse(entry.canDownloadWhileMetered);
|
| assertFalse(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| assertEquals("test,4.pdf", entry.fileName);
|
| }
|
|
|
| @@ -160,6 +178,7 @@ public class DownloadSharedPreferenceEntryTest {
|
| assertFalse(entry.isOffTheRecord);
|
| assertTrue(entry.canDownloadWhileMetered);
|
| assertTrue(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| assertEquals("test,2.pdf", entry.fileName);
|
|
|
| String uuid2 = newUUID();
|
| @@ -171,6 +190,7 @@ public class DownloadSharedPreferenceEntryTest {
|
| assertTrue(entry.isOffTheRecord);
|
| assertFalse(entry.canDownloadWhileMetered);
|
| assertFalse(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| assertEquals("test,4.pdf", entry.fileName);
|
|
|
| String uuid3 = newUUID();
|
| @@ -182,6 +202,7 @@ public class DownloadSharedPreferenceEntryTest {
|
| assertTrue(entry.isOffTheRecord);
|
| assertFalse(entry.canDownloadWhileMetered);
|
| assertFalse(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| assertEquals("test,4.pdf", entry.fileName);
|
|
|
| String uuid4 = newUUID();
|
| @@ -192,6 +213,34 @@ public class DownloadSharedPreferenceEntryTest {
|
| assertTrue(entry.isOffTheRecord);
|
| assertFalse(entry.canDownloadWhileMetered);
|
| assertFalse(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| + assertEquals("test,4.pdf", entry.fileName);
|
| + }
|
| +
|
| + @Test
|
| + @Feature({"Download"})
|
| + public void testParseFromStringVersion6() {
|
| + String uuid = newUUID();
|
| + String notificationString = "6,2,test_namespace," + uuid + ",0,1,1,1,test,2.pdf";
|
| + DownloadSharedPreferenceEntry entry =
|
| + DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| + assertEquals(2, entry.notificationId);
|
| + assertEquals(new ContentId("test_namespace", uuid), entry.id);
|
| + assertFalse(entry.isOffTheRecord);
|
| + assertTrue(entry.canDownloadWhileMetered);
|
| + assertTrue(entry.isAutoResumable);
|
| + assertTrue(entry.isTransient);
|
| + assertEquals("test,2.pdf", entry.fileName);
|
| +
|
| + String uuid2 = newUUID();
|
| + notificationString = "6,3,test_namespace," + uuid + ",1,0,0,0,test,4.pdf";
|
| + entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| + assertEquals(3, entry.notificationId);
|
| + assertEquals(new ContentId("test_namespace", uuid), entry.id);
|
| + assertTrue(entry.isOffTheRecord);
|
| + assertFalse(entry.canDownloadWhileMetered);
|
| + assertFalse(entry.isAutoResumable);
|
| + assertFalse(entry.isTransient);
|
| assertEquals("test,4.pdf", entry.fileName);
|
| }
|
|
|
| @@ -199,15 +248,15 @@ public class DownloadSharedPreferenceEntryTest {
|
| @Feature({"Download"})
|
| public void testGetSharedPreferencesString() {
|
| String uuid = newUUID();
|
| - String notificationString = "5,2," + LegacyHelpers.LEGACY_OFFLINE_PAGE_NAMESPACE + ","
|
| - + uuid + ",0,1,1,test,2.pdf";
|
| + String notificationString = "6,2," + LegacyHelpers.LEGACY_OFFLINE_PAGE_NAMESPACE + ","
|
| + + uuid + ",0,1,1,1,test,2.pdf";
|
| DownloadSharedPreferenceEntry entry =
|
| DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| assertEquals(notificationString, entry.getSharedPreferenceString());
|
|
|
| String uuid2 = newUUID();
|
| - notificationString = "5,3," + LegacyHelpers.LEGACY_OFFLINE_PAGE_NAMESPACE + "," + uuid2
|
| - + ",1,0,0,test,4.pdf";
|
| + notificationString = "6,3," + LegacyHelpers.LEGACY_OFFLINE_PAGE_NAMESPACE + "," + uuid2
|
| + + ",1,0,0,0,test,4.pdf";
|
| entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| assertEquals(notificationString, entry.getSharedPreferenceString());
|
| }
|
| @@ -264,7 +313,12 @@ public class DownloadSharedPreferenceEntryTest {
|
| assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
|
|
| // Version 5 requires at least 8.
|
| - notificationString = "5,2,2,0,1," + uuid + ",test.pdf";
|
| + notificationString = "5,2,test_namespace," + uuid + "0,1,test.pdf";
|
| + entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| + assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
| +
|
| + // Version 6 requires at least 9.
|
| + notificationString = "6,2,test_namespace," + uuid + "0,1,1,test.pdf";
|
| entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
| }
|
| @@ -294,6 +348,16 @@ public class DownloadSharedPreferenceEntryTest {
|
| entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
|
|
| + // Notification ID missing in version 5.
|
| + notificationString = "5,,test_namespace," + uuid + ",0,1,1,test,2.pdf";
|
| + entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| + assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
| +
|
| + // Notification ID missing in version 6.
|
| + notificationString = "6,,test_namespace," + uuid + ",0,1,1,1,test,2.pdf";
|
| + entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| + assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
| +
|
| // Not able to parse notification ID in version 1.
|
| notificationString = "1,xxx,0,1," + uuid + ",test,2.pdf";
|
| entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| @@ -314,6 +378,15 @@ public class DownloadSharedPreferenceEntryTest {
|
| entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
|
|
| + // Not able to parse notification ID in version 5.
|
| + notificationString = "5,xxx,test_namespace," + uuid + ",0,1,1,test,2.pdf";
|
| + entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| + assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
| +
|
| + // Not able to parse notification ID in version 6.
|
| + notificationString = "6,xxx,test_namespace," + uuid + ",0,1,1,1,test,2.pdf";
|
| + entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| + assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
| }
|
|
|
| @Test
|
| @@ -367,6 +440,16 @@ public class DownloadSharedPreferenceEntryTest {
|
| entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
|
|
| + // GUID missing in version 5.
|
| + notificationString = "5,2,test_namespace,,0,1,1,test,2.pdf";
|
| + entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| + assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
| +
|
| + // GUID missing in version 6.
|
| + notificationString = "6,2,test_namespace,,0,1,1,1,test,2.pdf";
|
| + entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| + assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
| +
|
| // Not able to parse GUID in version 1.
|
| notificationString = "1,2,0,1,xxx,test,2.pdf";
|
| entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| @@ -386,13 +469,23 @@ public class DownloadSharedPreferenceEntryTest {
|
| notificationString = "4,2,2,0,1,1,xxx,test,2.pdf";
|
| entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
| +
|
| + // Not able to parse GUID in version 5.
|
| + notificationString = "5,2,test_namespace,xxx,0,1,1,test,2.pdf";
|
| + entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| + assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
| +
|
| + // Not able to parse GUID in version 6.
|
| + notificationString = "6,2,test_namespace,xxx,0,1,1,1,test,2.pdf";
|
| + entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| + assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
| }
|
|
|
| @Test
|
| @Feature({"Download"})
|
| public void testParseFromStringMissingNamespace() {
|
| // Not able to parse namespace in version 5.
|
| - String notificationString = "5,3,," + newUUID() + ",1,0,0,test,4.pdf";
|
| + String notificationString = "6,3,," + newUUID() + ",1,0,0,0,test,4.pdf";
|
| DownloadSharedPreferenceEntry entry =
|
| DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| assertEquals(DownloadSharedPreferenceEntry.INVALID_ENTRY, entry);
|
| @@ -404,31 +497,37 @@ public class DownloadSharedPreferenceEntryTest {
|
| // Convert from version 1.
|
| String uuid = newUUID();
|
| String notificationString = "1,1,1,0," + uuid + ",test.pdf";
|
| - String v5NotificationString =
|
| - "5,1," + LegacyHelpers.LEGACY_DOWNLOAD_NAMESPACE + "," + uuid + ",0,0,1,test.pdf";
|
| + String v6NotificationString =
|
| + "6,1," + LegacyHelpers.LEGACY_DOWNLOAD_NAMESPACE + "," + uuid + ",0,0,1,0,test.pdf";
|
| DownloadSharedPreferenceEntry entry =
|
| DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| - assertEquals(v5NotificationString, entry.getSharedPreferenceString());
|
| + assertEquals(v6NotificationString, entry.getSharedPreferenceString());
|
|
|
| // Convert from version 2.
|
| notificationString = "2,1,1,0," + uuid + ",test.pdf";
|
| - v5NotificationString =
|
| - "5,1," + LegacyHelpers.LEGACY_DOWNLOAD_NAMESPACE + "," + uuid + ",1,0,1,test.pdf";
|
| + v6NotificationString =
|
| + "6,1," + LegacyHelpers.LEGACY_DOWNLOAD_NAMESPACE + "," + uuid + ",1,0,1,0,test.pdf";
|
| entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| - assertEquals(v5NotificationString, entry.getSharedPreferenceString());
|
| + assertEquals(v6NotificationString, entry.getSharedPreferenceString());
|
|
|
| // Convert from version 3.
|
| notificationString = "3,2,2,1,0," + uuid + ",test.pdf";
|
| - v5NotificationString = "5,2," + LegacyHelpers.LEGACY_OFFLINE_PAGE_NAMESPACE + "," + uuid
|
| - + ",1,0,1,test.pdf";
|
| + v6NotificationString = "6,2," + LegacyHelpers.LEGACY_OFFLINE_PAGE_NAMESPACE + "," + uuid
|
| + + ",1,0,1,0,test.pdf";
|
| entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| - assertEquals(v5NotificationString, entry.getSharedPreferenceString());
|
| + assertEquals(v6NotificationString, entry.getSharedPreferenceString());
|
|
|
| // Convert from version 4.
|
| notificationString = "4,2,2,1,0,0," + uuid + ",test.pdf";
|
| - v5NotificationString = "5,2," + LegacyHelpers.LEGACY_OFFLINE_PAGE_NAMESPACE + "," + uuid
|
| - + ",1,0,0,test.pdf";
|
| + v6NotificationString = "6,2," + LegacyHelpers.LEGACY_OFFLINE_PAGE_NAMESPACE + "," + uuid
|
| + + ",1,0,0,0,test.pdf";
|
| + entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| + assertEquals(v6NotificationString, entry.getSharedPreferenceString());
|
| +
|
| + // Convert from version 5.
|
| + notificationString = "5,2,test_namespace," + uuid + ",1,0,0,test.pdf";
|
| + v6NotificationString = "6,2,test_namespace," + uuid + ",1,0,0,0,test.pdf";
|
| entry = DownloadSharedPreferenceEntry.parseFromString(notificationString);
|
| - assertEquals(v5NotificationString, entry.getSharedPreferenceString());
|
| + assertEquals(v6NotificationString, entry.getSharedPreferenceString());
|
| }
|
| }
|
|
|