diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-03-19 20:27:12 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-03-19 21:05:15 +0100 |
commit | e8b9e49ee9527f4e533c08cb7ac39d1dc8a19b6b (patch) | |
tree | 84387048022e9c9453f0ec53daec029219e529ff /src/instrumentationTest/de/test/antennapod | |
parent | b9ab10253ab04bacd7d27ab7a7aecd561f7efbc2 (diff) | |
download | AntennaPod-e8b9e49ee9527f4e533c08cb7ac39d1dc8a19b6b.zip |
Added support for images in itunes:image tags.
Diffstat (limited to 'src/instrumentationTest/de/test/antennapod')
-rw-r--r-- | src/instrumentationTest/de/test/antennapod/AntennaPodTestRunner.java | 3 | ||||
-rw-r--r-- | src/instrumentationTest/de/test/antennapod/storage/DBWriterTest.java | 78 |
2 files changed, 70 insertions, 11 deletions
diff --git a/src/instrumentationTest/de/test/antennapod/AntennaPodTestRunner.java b/src/instrumentationTest/de/test/antennapod/AntennaPodTestRunner.java index e1699139d..35ecf86dc 100644 --- a/src/instrumentationTest/de/test/antennapod/AntennaPodTestRunner.java +++ b/src/instrumentationTest/de/test/antennapod/AntennaPodTestRunner.java @@ -12,7 +12,8 @@ public class AntennaPodTestRunner extends InstrumentationTestRunner { @Override public TestSuite getAllTests() { - return new TestSuiteBuilder(AntennaPodTestRunner.class).includeAllPackagesUnderHere() + return new TestSuiteBuilder(AntennaPodTestRunner.class).includePackages("instrumentationTest.de.test.antennapod.storage") + //.includeAllPackagesUnderHere() // .excludePackages("instrumentationTest.de.test.antennapod.syndication.handler") // .excludePackages("instrumentationTest.de.test.antennapod.gpodnet") .build(); diff --git a/src/instrumentationTest/de/test/antennapod/storage/DBWriterTest.java b/src/instrumentationTest/de/test/antennapod/storage/DBWriterTest.java index 679ae1ad3..67d99f9fc 100644 --- a/src/instrumentationTest/de/test/antennapod/storage/DBWriterTest.java +++ b/src/instrumentationTest/de/test/antennapod/storage/DBWriterTest.java @@ -95,7 +95,7 @@ public class DBWriterTest extends InstrumentationTestCase { File imgFile = new File(destFolder, "image"); assertTrue(imgFile.createNewFile()); FeedImage image = new FeedImage(0, "image", imgFile.getAbsolutePath(), "url", true); - image.setFeed(feed); + image.setOwner(feed); feed.setImage(image); List<File> itemFiles = new ArrayList<File>(); @@ -137,7 +137,7 @@ public class DBWriterTest extends InstrumentationTestCase { Cursor c = adapter.getFeedCursor(feed.getId()); assertTrue(c.getCount() == 0); c.close(); - c = adapter.getImageOfFeedCursor(image.getId()); + c = adapter.getImageCursor(image.getId()); assertTrue(c.getCount() == 0); c.close(); for (FeedItem item : feed.getItems()) { @@ -217,7 +217,7 @@ public class DBWriterTest extends InstrumentationTestCase { File imgFile = new File(destFolder, "image"); assertTrue(imgFile.createNewFile()); FeedImage image = new FeedImage(0, "image", imgFile.getAbsolutePath(), "url", true); - image.setFeed(feed); + image.setOwner(feed); feed.setImage(image); PodDBAdapter adapter = new PodDBAdapter(getInstrumentation().getContext()); @@ -238,7 +238,7 @@ public class DBWriterTest extends InstrumentationTestCase { Cursor c = adapter.getFeedCursor(feed.getId()); assertTrue(c.getCount() == 0); c.close(); - c = adapter.getImageOfFeedCursor(image.getId()); + c = adapter.getImageCursor(image.getId()); assertTrue(c.getCount() == 0); c.close(); } @@ -254,7 +254,7 @@ public class DBWriterTest extends InstrumentationTestCase { File imgFile = new File(destFolder, "image"); assertTrue(imgFile.createNewFile()); FeedImage image = new FeedImage(0, "image", imgFile.getAbsolutePath(), "url", true); - image.setFeed(feed); + image.setOwner(feed); feed.setImage(image); // create items @@ -285,7 +285,7 @@ public class DBWriterTest extends InstrumentationTestCase { Cursor c = adapter.getFeedCursor(feed.getId()); assertTrue(c.getCount() == 0); c.close(); - c = adapter.getImageOfFeedCursor(image.getId()); + c = adapter.getImageCursor(image.getId()); assertTrue(c.getCount() == 0); c.close(); for (FeedItem item : feed.getItems()) { @@ -295,6 +295,64 @@ public class DBWriterTest extends InstrumentationTestCase { } } + public void testDeleteFeedWithItemImages() throws InterruptedException, ExecutionException, TimeoutException, IOException { + File destFolder = getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER); + assertNotNull(destFolder); + + Feed feed = new Feed("url", new Date(), "title"); + feed.setItems(new ArrayList<FeedItem>()); + + // create Feed image + File imgFile = new File(destFolder, "image"); + assertTrue(imgFile.createNewFile()); + FeedImage image = new FeedImage(0, "image", imgFile.getAbsolutePath(), "url", true); + image.setOwner(feed); + feed.setImage(image); + + // create items with images + for (int i = 0; i < 10; i++) { + FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), true, feed); + feed.getItems().add(item); + File itemImageFile = new File(destFolder, "item-image-" + i); + FeedImage itemImage = new FeedImage(0, "item-image" + i, itemImageFile.getAbsolutePath(), "url", true); + item.setImage(itemImage); + } + + PodDBAdapter adapter = new PodDBAdapter(getInstrumentation().getContext()); + adapter.open(); + adapter.setCompleteFeed(feed); + adapter.close(); + + assertTrue(feed.getId() != 0); + assertTrue(feed.getImage().getId() != 0); + for (FeedItem item : feed.getItems()) { + assertTrue(item.getId() != 0); + assertTrue(item.getImage().getId() != 0); + } + + DBWriter.deleteFeed(getInstrumentation().getTargetContext(), feed.getId()).get(TIMEOUT, TimeUnit.SECONDS); + + // check if files still exist + assertFalse(imgFile.exists()); + + adapter = new PodDBAdapter(getInstrumentation().getContext()); + adapter.open(); + Cursor c = adapter.getFeedCursor(feed.getId()); + assertTrue(c.getCount() == 0); + c.close(); + c = adapter.getImageCursor(image.getId()); + assertTrue(c.getCount() == 0); + c.close(); + for (FeedItem item : feed.getItems()) { + c = adapter.getFeedItemCursor(String.valueOf(item.getId())); + assertTrue(c.getCount() == 0); + c.close(); + c = adapter.getImageCursor(item.getImage().getId()); + assertEquals(0, c.getCount()); + c.close(); + } + } + public void testDeleteFeedWithQueueItems() throws ExecutionException, InterruptedException, TimeoutException { File destFolder = getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER); assertNotNull(destFolder); @@ -305,7 +363,7 @@ public class DBWriterTest extends InstrumentationTestCase { // create Feed image File imgFile = new File(destFolder, "image"); FeedImage image = new FeedImage(0, "image", imgFile.getAbsolutePath(), "url", true); - image.setFeed(feed); + image.setOwner(feed); feed.setImage(image); List<File> itemFiles = new ArrayList<File>(); @@ -350,7 +408,7 @@ public class DBWriterTest extends InstrumentationTestCase { Cursor c = adapter.getFeedCursor(feed.getId()); assertTrue(c.getCount() == 0); c.close(); - c = adapter.getImageOfFeedCursor(image.getId()); + c = adapter.getImageCursor(image.getId()); assertTrue(c.getCount() == 0); c.close(); for (FeedItem item : feed.getItems()) { @@ -377,7 +435,7 @@ public class DBWriterTest extends InstrumentationTestCase { // create Feed image File imgFile = new File(destFolder, "image"); FeedImage image = new FeedImage(0, "image", imgFile.getAbsolutePath(), "url", true); - image.setFeed(feed); + image.setOwner(feed); feed.setImage(image); List<File> itemFiles = new ArrayList<File>(); @@ -412,7 +470,7 @@ public class DBWriterTest extends InstrumentationTestCase { Cursor c = adapter.getFeedCursor(feed.getId()); assertTrue(c.getCount() == 0); c.close(); - c = adapter.getImageOfFeedCursor(image.getId()); + c = adapter.getImageCursor(image.getId()); assertTrue(c.getCount() == 0); c.close(); for (FeedItem item : feed.getItems()) { |