diff options
-rw-r--r-- | src/de/danoeh/antennapod/storage/PodDBAdapter.java | 2 | ||||
-rw-r--r-- | src/instrumentationTest/de/test/antennapod/storage/DBReaderTest.java | 41 |
2 files changed, 38 insertions, 5 deletions
diff --git a/src/de/danoeh/antennapod/storage/PodDBAdapter.java b/src/de/danoeh/antennapod/storage/PodDBAdapter.java index 2da835511..049b78dc0 100644 --- a/src/de/danoeh/antennapod/storage/PodDBAdapter.java +++ b/src/de/danoeh/antennapod/storage/PodDBAdapter.java @@ -711,7 +711,7 @@ public class PodDBAdapter { */ public final Cursor getAllFeedsCursor() { Cursor c = db.query(TABLE_NAME_FEEDS, FEED_SEL_STD, null, null, null, null, - KEY_TITLE + " ASC"); + KEY_TITLE + " COLLATE NOCASE ASC"); return c; } 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<Feed> 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<Feed> 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<Feed> 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(); } |