FeedStatistics list was not sorted correctly

This commit is contained in:
daniel oeh 2014-02-17 22:05:47 +01:00
parent f67d9a1369
commit 2afcb580bf
2 changed files with 15 additions and 1 deletions

View File

@ -1199,7 +1199,7 @@ public class PodDBAdapter {
" COUNT(CASE WHEN position>0 THEN 1 END) AS in_progress," +
" COUNT(CASE WHEN downloaded=1 THEN 1 END) AS episodes_downloaded " +
" FROM FeedItems LEFT JOIN FeedMedia ON FeedItems.id=FeedMedia.feeditem GROUP BY FeedItems.feed)" +
" ON Feeds.id = feed ORDER BY Feeds.title;";
" ON Feeds.id = feed ORDER BY Feeds.title COLLATE NOCASE ASC;";
public Cursor getFeedStatisticsCursor() {
return db.rawQuery(FEED_STATISTICS_QUERY, null);

View File

@ -6,6 +6,7 @@ import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedItem;
import de.danoeh.antennapod.feed.FeedMedia;
import de.danoeh.antennapod.storage.DBReader;
import de.danoeh.antennapod.storage.FeedItemStatistics;
import de.danoeh.antennapod.storage.PodDBAdapter;
import de.danoeh.antennapod.util.flattr.FlattrStatus;
import static instrumentationTest.de.test.antennapod.storage.DBTestUtils.*;
@ -351,4 +352,17 @@ public class DBReaderTest extends InstrumentationTestCase {
assertEquals("Wrong sort order: ", item.getId(), ids[i]);
}
}
public void testGetFeedStatisticsCheckOrder() {
final Context context = getInstrumentation().getTargetContext();
final int NUM_FEEDS = 10;
final int NUM_ITEMS = 10;
List<Feed> feeds = DBTestUtils.saveFeedlist(context, NUM_FEEDS, NUM_ITEMS, false);
List<FeedItemStatistics> statistics = DBReader.getFeedStatisticsList(context);
assertNotNull(statistics);
assertEquals(feeds.size(), statistics.size());
for (int i = 0; i < NUM_FEEDS; i++) {
assertEquals("Wrong entry at index " + i, feeds.get(i).getId(), statistics.get(i).getFeedID());
}
}
}