diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-09-11 13:56:23 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-09-11 13:56:23 +0200 |
commit | 697afbd5a61a2eb217e4b637b4f3dfb02ae0fd67 (patch) | |
tree | b037d778b207f9d3c3abdacc4c149b973af0016d /src/instrumentationTest/de | |
parent | 613fbce28322f71315f3a468c5d3a584c6cd84e9 (diff) | |
download | AntennaPod-697afbd5a61a2eb217e4b637b4f3dfb02ae0fd67.zip |
"markFeedRead" and "markAllItemsRead" did not work correctly
Diffstat (limited to 'src/instrumentationTest/de')
-rw-r--r-- | src/instrumentationTest/de/test/antennapod/storage/DBWriterTest.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/instrumentationTest/de/test/antennapod/storage/DBWriterTest.java b/src/instrumentationTest/de/test/antennapod/storage/DBWriterTest.java index 84ac7a9cc..0483a3084 100644 --- a/src/instrumentationTest/de/test/antennapod/storage/DBWriterTest.java +++ b/src/instrumentationTest/de/test/antennapod/storage/DBWriterTest.java @@ -681,4 +681,58 @@ public class DBWriterTest extends InstrumentationTestCase { } } + public void testMarkFeedRead() throws InterruptedException, ExecutionException, TimeoutException { + final Context context = getInstrumentation().getTargetContext(); + final int NUM_ITEMS = 10; + Feed feed = new Feed("url", new Date(), "title"); + feed.setItems(new ArrayList<FeedItem>()); + for (int i = 0; i < NUM_ITEMS; i++) { + FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), false, feed); + feed.getItems().add(item); + } + + PodDBAdapter adapter = new PodDBAdapter(context); + adapter.open(); + adapter.setCompleteFeed(feed); + adapter.close(); + + assertTrue(feed.getId() != 0); + for (FeedItem item : feed.getItems()) { + assertTrue(item.getId() != 0); + } + + DBWriter.markFeedRead(context, feed.getId()).get(TIMEOUT, TimeUnit.SECONDS); + List<FeedItem> loadedItems = DBReader.getFeedItemList(context, feed); + for (FeedItem item : loadedItems) { + assertTrue(item.isRead()); + } + } + + public void testMarkAllItemsReadSameFeed() { + final Context context = getInstrumentation().getTargetContext(); + final int NUM_ITEMS = 10; + Feed feed = new Feed("url", new Date(), "title"); + feed.setItems(new ArrayList<FeedItem>()); + for (int i = 0; i < NUM_ITEMS; i++) { + FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), false, feed); + feed.getItems().add(item); + } + + PodDBAdapter adapter = new PodDBAdapter(context); + adapter.open(); + adapter.setCompleteFeed(feed); + adapter.close(); + + assertTrue(feed.getId() != 0); + for (FeedItem item : feed.getItems()) { + assertTrue(item.getId() != 0); + } + + DBWriter.markAllItemsRead(context); + List<FeedItem> loadedItems = DBReader.getFeedItemList(context, feed); + for (FeedItem item : loadedItems) { + assertTrue(item.isRead()); + } + } + } |