Add new test for Download Request equals (#5183)

This commit is contained in:
gregoryjtom 2021-05-29 00:47:10 -07:00 committed by GitHub
parent ea47118a98
commit 426283109a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import java.util.ArrayList;
import de.danoeh.antennapod.model.feed.FeedFile; import de.danoeh.antennapod.model.feed.FeedFile;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class DownloadRequestTest { public class DownloadRequestTest {
@ -34,6 +35,36 @@ public class DownloadRequestTest {
null, null, "usr2", "pass2"); 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 // Test to ensure parcel using put/getParcelableArrayList() API work
// based on: https://stackoverflow.com/a/13507191 // based on: https://stackoverflow.com/a/13507191
private void doTestParcelInArrayList(String message, private void doTestParcelInArrayList(String message,