diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-09-11 14:11:26 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-09-11 14:11:26 +0200 |
commit | 4c1d210274f66bd4969d467233ad8e69b55b8642 (patch) | |
tree | ccc3cb7268026633ba9e962a0f4f9499fb6d42bc /src/instrumentationTest/de/test/antennapod | |
parent | 02926a6e5ffa968d08efeae5012a0ecf41a6f33a (diff) | |
parent | 30c681d1cf5e0d33b716f6c8885ab92f46efbaa3 (diff) | |
download | AntennaPod-4c1d210274f66bd4969d467233ad8e69b55b8642.zip |
Merge branch 'release-0975' into develop
Diffstat (limited to 'src/instrumentationTest/de/test/antennapod')
-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()); + } + } + } |