diff --git a/core/src/test/java/de/danoeh/antennapod/core/service/download/DownloadRequestTest.java b/core/src/test/java/de/danoeh/antennapod/core/service/download/DownloadRequestTest.java index ddf802858..c9c941d38 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/service/download/DownloadRequestTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/service/download/DownloadRequestTest.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import de.danoeh.antennapod.model.feed.FeedFile; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; @RunWith(RobolectricTestRunner.class) public class DownloadRequestTest { @@ -34,6 +35,36 @@ public class DownloadRequestTest { null, null, "usr2", "pass2"); } + @Test + public void downloadRequestTestEquals() { + String destStr = "file://location/media.mp3"; + String username = "testUser"; + String password = "testPassword"; + FeedFile item = createFeedItem(1); + Bundle arg = new Bundle(); + arg.putString("arg1", "value1"); + DownloadRequest request1 = new DownloadRequest.Builder(destStr, item, true) + .deleteOnFailure(true) + .withAuthentication(username, password) + .withArguments(arg) + .build(); + + DownloadRequest request2 = new DownloadRequest.Builder(destStr, item, true) + .deleteOnFailure(true) + .withAuthentication(username, password) + .withArguments(arg) + .build(); + + DownloadRequest request3 = new DownloadRequest.Builder(destStr, item, true) + .deleteOnFailure(true) + .withAuthentication("diffUsername", "diffPassword") + .withArguments(arg) + .build(); + + assertEquals(request1, request2); + assertNotEquals(request1, request3); + } + // Test to ensure parcel using put/getParcelableArrayList() API work // based on: https://stackoverflow.com/a/13507191 private void doTestParcelInArrayList(String message,