diff options
author | Rahmat Ramadhan <rahmat.rama98@gmail.com> | 2023-09-28 02:59:58 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-27 21:59:58 +0200 |
commit | 922395a4489c8a9387319bcaf515dea58c4914e4 (patch) | |
tree | 9aa752154b88a9e0716b661f043d87144ec35153 /core/src/test | |
parent | 7229cb40e946a895cdd804cb344aae440dbbe816 (diff) | |
download | AntennaPod-922395a4489c8a9387319bcaf515dea58c4914e4.zip |
Sort downloads by size (#6659)
Diffstat (limited to 'core/src/test')
-rw-r--r-- | core/src/test/java/de/danoeh/antennapod/core/util/FeedItemPermutorsTest.java | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemPermutorsTest.java b/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemPermutorsTest.java index 9c48f8df7..be4012cb6 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemPermutorsTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemPermutorsTest.java @@ -113,6 +113,26 @@ public class FeedItemPermutorsTest { } @Test + public void testPermutorForRule_size_asc() { + Permutor<FeedItem> permutor = FeedItemPermutors.getPermutor(SortOrder.SIZE_SMALL_LARGE); + + List<FeedItem> itemList = getTestList(); + assertTrue(checkIdOrder(itemList, 1, 3, 2)); // before sorting + permutor.reorder(itemList); + assertTrue(checkIdOrder(itemList, 1, 2, 3)); // after sorting + } + + @Test + public void testPermutorForRule_size_desc() { + Permutor<FeedItem> permutor = FeedItemPermutors.getPermutor(SortOrder.SIZE_LARGE_SMALL); + + List<FeedItem> itemList = getTestList(); + assertTrue(checkIdOrder(itemList, 1, 3, 2)); // before sorting + permutor.reorder(itemList); + assertTrue(checkIdOrder(itemList, 3, 2, 1)); // after sorting + } + + @Test public void testPermutorForRule_DURATION_DESC_NullMedia() { Permutor<FeedItem> permutor = FeedItemPermutors.getPermutor(SortOrder.DURATION_LONG_SHORT); @@ -166,21 +186,21 @@ public class FeedItemPermutorsTest { calendar.set(2019, 0, 1); // January 1st Feed feed1 = new Feed(null, null, "Feed title 1"); FeedItem feedItem1 = new FeedItem(1, "Title 1", null, null, calendar.getTime(), 0, feed1); - FeedMedia feedMedia1 = new FeedMedia(0, feedItem1, 1000, 0, 0, null, null, null, true, null, 0, 0); + FeedMedia feedMedia1 = new FeedMedia(0, feedItem1, 1000, 0, 100, null, null, null, true, null, 0, 0); feedItem1.setMedia(feedMedia1); itemList.add(feedItem1); calendar.set(2019, 2, 1); // March 1st Feed feed2 = new Feed(null, null, "Feed title 3"); FeedItem feedItem2 = new FeedItem(3, "Title 3", null, null, calendar.getTime(), 0, feed2); - FeedMedia feedMedia2 = new FeedMedia(0, feedItem2, 3000, 0, 0, null, null, null, true, null, 0, 0); + FeedMedia feedMedia2 = new FeedMedia(0, feedItem2, 3000, 0, 300, null, null, null, true, null, 0, 0); feedItem2.setMedia(feedMedia2); itemList.add(feedItem2); calendar.set(2019, 1, 1); // February 1st Feed feed3 = new Feed(null, null, "Feed title 2"); FeedItem feedItem3 = new FeedItem(2, "Title 2", null, null, calendar.getTime(), 0, feed3); - FeedMedia feedMedia3 = new FeedMedia(0, feedItem3, 2000, 0, 0, null, null, null, true, null, 0, 0); + FeedMedia feedMedia3 = new FeedMedia(0, feedItem3, 2000, 0, 200, null, null, null, true, null, 0, 0); feedItem3.setMedia(feedMedia3); itemList.add(feedItem3); |