From fa1789b7dc1997cf933c7cfa3edb891cbd9cedf6 Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Tue, 11 Feb 2014 20:28:04 +0100 Subject: Make sort order in feed list case-insensitive. closes issue #339 --- .../de/test/antennapod/storage/DBReaderTest.java | 41 +++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'src/instrumentationTest/de/test/antennapod') diff --git a/src/instrumentationTest/de/test/antennapod/storage/DBReaderTest.java b/src/instrumentationTest/de/test/antennapod/storage/DBReaderTest.java index 594950b62..a214e55bc 100644 --- a/src/instrumentationTest/de/test/antennapod/storage/DBReaderTest.java +++ b/src/instrumentationTest/de/test/antennapod/storage/DBReaderTest.java @@ -7,9 +7,13 @@ import de.danoeh.antennapod.feed.FeedItem; import de.danoeh.antennapod.feed.FeedMedia; import de.danoeh.antennapod.storage.DBReader; import de.danoeh.antennapod.storage.PodDBAdapter; -import static instrumentationTest.de.test.antennapod.storage.DBTestUtils.*; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Random; + +import static instrumentationTest.de.test.antennapod.storage.DBTestUtils.saveFeedlist; /** * Test class for DBReader @@ -66,7 +70,6 @@ public class DBReaderTest extends InstrumentationTestCase { } - public void testGetFeedList() { final Context context = getInstrumentation().getTargetContext(); List feeds = saveFeedlist(context, 10, 0, false); @@ -78,6 +81,36 @@ public class DBReaderTest extends InstrumentationTestCase { } } + public void testGetFeedListSortOrder() { + final Context context = getInstrumentation().getTargetContext(); + PodDBAdapter adapter = new PodDBAdapter(context); + adapter.open(); + + Feed feed1 = new Feed(0, new Date(), "A", "link", "d", null, null, null, "rss", "A", null, "", "", true); + Feed feed2 = new Feed(0, new Date(), "b", "link", "d", null, null, null, "rss", "b", null, "", "", true); + Feed feed3 = new Feed(0, new Date(), "C", "link", "d", null, null, null, "rss", "C", null, "", "", true); + Feed feed4 = new Feed(0, new Date(), "d", "link", "d", null, null, null, "rss", "d", null, "", "", true); + adapter.setCompleteFeed(feed1); + adapter.setCompleteFeed(feed2); + adapter.setCompleteFeed(feed3); + adapter.setCompleteFeed(feed4); + assertTrue(feed1.getId() != 0); + assertTrue(feed2.getId() != 0); + assertTrue(feed3.getId() != 0); + assertTrue(feed4.getId() != 0); + + adapter.close(); + + List saved = DBReader.getFeedList(context); + assertNotNull(saved); + assertEquals("Wrong size: ", 4, saved.size()); + + assertEquals("Wrong id of feed 1: ", feed1.getId(), saved.get(0).getId()); + assertEquals("Wrong id of feed 2: ", feed2.getId(), saved.get(1).getId()); + assertEquals("Wrong id of feed 3: ", feed3.getId(), saved.get(2).getId()); + assertEquals("Wrong id of feed 4: ", feed4.getId(), saved.get(3).getId()); + } + public void testFeedListDownloadUrls() { final Context context = getInstrumentation().getTargetContext(); List feeds = saveFeedlist(context, 10, 0, false); @@ -301,7 +334,7 @@ public class DBReaderTest extends InstrumentationTestCase { adapter.open(); for (int i = 0; i < playedItems; i++) { FeedMedia m = feed.getItems().get(i).getMedia(); - m.setPlaybackCompletionDate(new Date(i+1)); + m.setPlaybackCompletionDate(new Date(i + 1)); adapter.setFeedMediaPlaybackCompletionDate(m); ids[ids.length - 1 - i] = m.getItem().getId(); } -- cgit v1.2.3