diff options
author | Danial Klimkin <dklimkin@github.com> | 2017-04-09 22:03:09 +0200 |
---|---|---|
committer | Danial Klimkin <dklimkin@github.com> | 2017-04-10 21:15:01 +0200 |
commit | b34910261c184a51f9de578b364d14e6d486567c (patch) | |
tree | d41e8c8e57ea433ad9c43e67f5400b087bf8be40 /core/src/androidTest/java/de | |
parent | 4d256b7323d5a00b081508b13eb9141ab3aa9035 (diff) | |
download | AntennaPod-b34910261c184a51f9de578b364d14e6d486567c.zip |
Small touches on DownloadService.java
Diffstat (limited to 'core/src/androidTest/java/de')
-rw-r--r-- | core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/service/download/DownloadServiceTest.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/service/download/DownloadServiceTest.java b/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/service/download/DownloadServiceTest.java new file mode 100644 index 000000000..94cfb3278 --- /dev/null +++ b/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/service/download/DownloadServiceTest.java @@ -0,0 +1,35 @@ +package de.danoeh.antennapod.core.tests.util.service.download; + +import android.test.AndroidTestCase; + +import java.util.ArrayList; +import java.util.List; + +import de.danoeh.antennapod.core.feed.Feed; +import de.danoeh.antennapod.core.feed.FeedImage; +import de.danoeh.antennapod.core.feed.FeedItem; +import de.danoeh.antennapod.core.service.download.DownloadService; + +public class DownloadServiceTest extends AndroidTestCase { + + public void testRemoveDuplicateImages() { + List<FeedItem> items = new ArrayList<>(); + for (int i = 0; i < 50; i++) { + FeedItem item = new FeedItem(); + String url = (i % 5 == 0) ? "dupe_url" : String.format("url_%d", i); + item.setImage(new FeedImage(null, url, "")); + items.add(item); + } + Feed feed = new Feed(); + feed.setItems(items); + + DownloadService.removeDuplicateImages(feed); + + assertEquals(50, items.size()); + for (int i = 0; i < items.size(); i++) { + FeedItem item = items.get(i); + String want = (i == 0) ? "dupe_url" : (i % 5 == 0) ? null : String.format("url_%d", i); + assertEquals(want, item.getImageLocation()); + } + } +} |