diff options
author | ByteHamster <info@bytehamster.com> | 2018-06-05 23:52:19 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2018-06-05 23:52:19 +0200 |
commit | ba2233430e96f31de10aa82468529bfd781a742a (patch) | |
tree | a4dc9b8ae7a8a71fe421fc81a30d9cd9c60fb308 /app/src/androidTest | |
parent | fe92c98661e3b0817aed2c26dee258b0a572dd5e (diff) | |
download | AntennaPod-ba2233430e96f31de10aa82468529bfd781a742a.zip |
Removed FeedImage
Diffstat (limited to 'app/src/androidTest')
4 files changed, 9 insertions, 222 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/handler/FeedHandlerTest.java b/app/src/androidTest/java/de/test/antennapod/handler/FeedHandlerTest.java index 39abe4b7a..6908e2ec7 100644 --- a/app/src/androidTest/java/de/test/antennapod/handler/FeedHandlerTest.java +++ b/app/src/androidTest/java/de/test/antennapod/handler/FeedHandlerTest.java @@ -17,7 +17,6 @@ import javax.xml.parsers.ParserConfigurationException; import de.danoeh.antennapod.core.feed.Chapter; import de.danoeh.antennapod.core.feed.Feed; -import de.danoeh.antennapod.core.feed.FeedImage; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.syndication.handler.FeedHandler; @@ -82,15 +81,7 @@ public class FeedHandlerTest extends InstrumentationTestCase { assertEquals(feed.getLink(), parsedFeed.getLink()); assertEquals(feed.getDescription(), parsedFeed.getDescription()); assertEquals(feed.getPaymentLink(), parsedFeed.getPaymentLink()); - - if (feed.getImage() != null) { - FeedImage image = feed.getImage(); - FeedImage parsedImage = parsedFeed.getImage(); - assertNotNull(parsedImage); - - assertEquals(image.getTitle(), parsedImage.getTitle()); - assertEquals(image.getDownload_url(), parsedImage.getDownload_url()); - } + assertEquals(feed.getImageUrl(), parsedFeed.getImageUrl()); if (feed.getItems() != null) { assertNotNull(parsedFeed.getItems()); @@ -119,14 +110,7 @@ public class FeedHandlerTest extends InstrumentationTestCase { assertEquals(media.getMime_type(), parsedMedia.getMime_type()); } - if (item.hasItemImage()) { - assertTrue(parsedItem.hasItemImage()); - FeedImage image = item.getImage(); - FeedImage parsedImage = parsedItem.getImage(); - - assertEquals(image.getTitle(), parsedImage.getTitle()); - assertEquals(image.getDownload_url(), parsedImage.getDownload_url()); - } + assertEquals(item.getImageUrl(), parsedFeed.getImageUrl()); if (item.getChapters() != null) { assertNotNull(parsedItem.getChapters()); @@ -158,12 +142,8 @@ public class FeedHandlerTest extends InstrumentationTestCase { } private Feed createTestFeed(int numItems, boolean withImage, boolean withFeedMedia, boolean withChapters) { - FeedImage image = null; - if (withImage) { - image = new FeedImage(0, "image", null, "http://example.com/picture", false); - } Feed feed = new Feed(0, null, "title", "http://example.com", "This is the description", - "http://example.com/payment", "Daniel", "en", null, "http://example.com/feed", image, file.getAbsolutePath(), + "http://example.com/payment", "Daniel", "en", null, "http://example.com/feed", "http://example.com/picture", file.getAbsolutePath(), "http://example.com/feed", true); feed.setItems(new ArrayList<>()); diff --git a/app/src/androidTest/java/de/test/antennapod/storage/DBWriterTest.java b/app/src/androidTest/java/de/test/antennapod/storage/DBWriterTest.java index b1cc807ea..387ab91b3 100644 --- a/app/src/androidTest/java/de/test/antennapod/storage/DBWriterTest.java +++ b/app/src/androidTest/java/de/test/antennapod/storage/DBWriterTest.java @@ -15,9 +15,7 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import de.danoeh.antennapod.core.feed.Chapter; import de.danoeh.antennapod.core.feed.Feed; -import de.danoeh.antennapod.core.feed.FeedImage; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.feed.SimpleChapter; @@ -124,89 +122,13 @@ public class DBWriterTest extends InstrumentationTestCase { assertNull(media.getFile_url()); } - public void testDeleteFeed() throws IOException, ExecutionException, InterruptedException, TimeoutException { + public void testDeleteFeed() throws ExecutionException, InterruptedException, IOException, TimeoutException { File destFolder = getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER); assertNotNull(destFolder); Feed feed = new Feed("url", null, "title"); feed.setItems(new ArrayList<>()); - // 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); - - List<File> itemFiles = new ArrayList<>(); - // create items with downloaded media files - for (int i = 0; i < 10; i++) { - FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), FeedItem.PLAYED, feed, true); - feed.getItems().add(item); - - File enc = new File(destFolder, "file " + i); - assertTrue(enc.createNewFile()); - itemFiles.add(enc); - - FeedMedia media = new FeedMedia(0, item, 1, 1, 1, "mime_type", enc.getAbsolutePath(), "download_url", true, null, 0, 0); - item.setMedia(media); - - item.setChapters(new ArrayList<>()); - item.getChapters().add(new SimpleChapter(0, "item " + i, item, "example.com")); - } - - PodDBAdapter adapter = PodDBAdapter.getInstance(); - 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.getMedia().getId() != 0); - assertTrue(item.getChapters().get(0).getId() != 0); - } - - DBWriter.deleteFeed(getInstrumentation().getTargetContext(), feed.getId()).get(TIMEOUT, TimeUnit.SECONDS); - - // check if files still exist - assertFalse(imgFile.exists()); - for (File f : itemFiles) { - assertFalse(f.exists()); - } - - adapter = PodDBAdapter.getInstance(); - adapter.open(); - Cursor c = adapter.getFeedCursor(feed.getId()); - assertEquals(0, c.getCount()); - c.close(); - c = adapter.getImageCursor(String.valueOf(image.getId())); - assertEquals(0, c.getCount()); - c.close(); - for (FeedItem item : feed.getItems()) { - c = adapter.getFeedItemCursor(String.valueOf(item.getId())); - assertEquals(0, c.getCount()); - c.close(); - c = adapter.getSingleFeedMediaCursor(item.getMedia().getId()); - assertEquals(0, c.getCount()); - c.close(); - c = adapter.getSimpleChaptersOfFeedItemCursor(item); - assertEquals(0, c.getCount()); - c.close(); - } - adapter.close(); - } - - public void testDeleteFeedNoImage() throws ExecutionException, InterruptedException, IOException, TimeoutException { - File destFolder = getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER); - assertNotNull(destFolder); - - Feed feed = new Feed("url", null, "title"); - feed.setItems(new ArrayList<>()); - - feed.setImage(null); - List<File> itemFiles = new ArrayList<>(); // create items with downloaded media files for (int i = 0; i < 10; i++) { @@ -261,13 +183,7 @@ public class DBWriterTest extends InstrumentationTestCase { Feed feed = new Feed("url", null, "title"); feed.setItems(null); - - // 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); + feed.setImageUrl("url"); PodDBAdapter adapter = PodDBAdapter.getInstance(); adapter.open(); @@ -275,21 +191,14 @@ public class DBWriterTest extends InstrumentationTestCase { adapter.close(); assertTrue(feed.getId() != 0); - assertTrue(feed.getImage().getId() != 0); DBWriter.deleteFeed(getInstrumentation().getTargetContext(), feed.getId()).get(TIMEOUT, TimeUnit.SECONDS); - // check if files still exist - assertFalse(imgFile.exists()); - adapter = PodDBAdapter.getInstance(); adapter.open(); Cursor c = adapter.getFeedCursor(feed.getId()); assertTrue(c.getCount() == 0); c.close(); - c = adapter.getImageCursor(String.valueOf(image.getId())); - assertTrue(c.getCount() == 0); - c.close(); adapter.close(); } @@ -300,12 +209,7 @@ public class DBWriterTest extends InstrumentationTestCase { Feed feed = new Feed("url", null, "title"); feed.setItems(new ArrayList<>()); - // 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); + feed.setImageUrl("url"); // create items for (int i = 0; i < 10; i++) { @@ -320,87 +224,22 @@ public class DBWriterTest extends InstrumentationTestCase { adapter.close(); assertTrue(feed.getId() != 0); - assertTrue(feed.getImage().getId() != 0); - for (FeedItem item : feed.getItems()) { - assertTrue(item.getId() != 0); - } - - DBWriter.deleteFeed(getInstrumentation().getTargetContext(), feed.getId()).get(TIMEOUT, TimeUnit.SECONDS); - - // check if files still exist - assertFalse(imgFile.exists()); - - adapter = PodDBAdapter.getInstance(); - adapter.open(); - Cursor c = adapter.getFeedCursor(feed.getId()); - assertTrue(c.getCount() == 0); - c.close(); - c = adapter.getImageCursor(String.valueOf(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(); - } - adapter.close(); - } - - public void testDeleteFeedWithItemImages() throws InterruptedException, ExecutionException, TimeoutException, IOException { - File destFolder = getInstrumentation().getTargetContext().getExternalFilesDir(TEST_FOLDER); - assertNotNull(destFolder); - - Feed feed = new Feed("url", null, "title"); - feed.setItems(new ArrayList<>()); - - // 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(), FeedItem.PLAYED, 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 = PodDBAdapter.getInstance(); - 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 = PodDBAdapter.getInstance(); adapter.open(); Cursor c = adapter.getFeedCursor(feed.getId()); assertTrue(c.getCount() == 0); c.close(); - c = adapter.getImageCursor(String.valueOf(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(String.valueOf(item.getImage().getId())); - assertEquals(0, c.getCount()); - c.close(); } adapter.close(); } @@ -412,11 +251,7 @@ public class DBWriterTest extends InstrumentationTestCase { Feed feed = new Feed("url", null, "title"); feed.setItems(new ArrayList<>()); - // create Feed image - File imgFile = new File(destFolder, "image"); - FeedImage image = new FeedImage(0, "image", imgFile.getAbsolutePath(), "url", true); - image.setOwner(feed); - feed.setImage(image); + feed.setImageUrl("url"); List<File> itemFiles = new ArrayList<>(); // create items with downloaded media files @@ -437,7 +272,6 @@ public class DBWriterTest extends InstrumentationTestCase { adapter.close(); assertTrue(feed.getId() != 0); - assertTrue(feed.getImage().getId() != 0); for (FeedItem item : feed.getItems()) { assertTrue(item.getId() != 0); assertTrue(item.getMedia().getId() != 0); @@ -460,9 +294,6 @@ public class DBWriterTest extends InstrumentationTestCase { Cursor c = adapter.getFeedCursor(feed.getId()); assertTrue(c.getCount() == 0); c.close(); - c = adapter.getImageCursor(String.valueOf(image.getId())); - assertTrue(c.getCount() == 0); - c.close(); for (FeedItem item : feed.getItems()) { c = adapter.getFeedItemCursor(String.valueOf(item.getId())); assertTrue(c.getCount() == 0); @@ -484,11 +315,7 @@ public class DBWriterTest extends InstrumentationTestCase { Feed feed = new Feed("url", null, "title"); feed.setItems(new ArrayList<>()); - // create Feed image - File imgFile = new File(destFolder, "image"); - FeedImage image = new FeedImage(0, "image", imgFile.getAbsolutePath(), "url", true); - image.setOwner(feed); - feed.setImage(image); + feed.setImageUrl("url"); List<File> itemFiles = new ArrayList<>(); // create items with downloaded media files @@ -509,7 +336,6 @@ public class DBWriterTest extends InstrumentationTestCase { adapter.close(); assertTrue(feed.getId() != 0); - assertTrue(feed.getImage().getId() != 0); for (FeedItem item : feed.getItems()) { assertTrue(item.getId() != 0); assertTrue(item.getMedia().getId() != 0); @@ -522,9 +348,6 @@ public class DBWriterTest extends InstrumentationTestCase { Cursor c = adapter.getFeedCursor(feed.getId()); assertTrue(c.getCount() == 0); c.close(); - c = adapter.getImageCursor(String.valueOf(image.getId())); - assertTrue(c.getCount() == 0); - c.close(); for (FeedItem item : feed.getItems()) { c = adapter.getFeedItemCursor(String.valueOf(item.getId())); assertTrue(c.getCount() == 0); diff --git a/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java b/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java index 3af22af9d..ff5374268 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java @@ -22,7 +22,6 @@ import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.core.event.QueueEvent; import de.danoeh.antennapod.core.feed.EventDistributor; import de.danoeh.antennapod.core.feed.Feed; -import de.danoeh.antennapod.core.feed.FeedImage; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.storage.PodDBAdapter; @@ -136,12 +135,9 @@ class UITestUtils { public void addHostedFeedData() throws IOException { if (feedDataHosted) throw new IllegalStateException("addHostedFeedData was called twice on the same instance"); for (int i = 0; i < NUM_FEEDS; i++) { - File bitmapFile = newBitmapFile("image" + i); - FeedImage image = new FeedImage(0, "image " + i, null, hostFile(bitmapFile), false); Feed feed = new Feed(0, null, "Title " + i, "http://example.com/" + i, "Description of feed " + i, - "http://example.com/pay/feed" + i, "author " + i, "en", Feed.TYPE_RSS2, "feed" + i, image, null, + "http://example.com/pay/feed" + i, "author " + i, "en", Feed.TYPE_RSS2, "feed" + i, null, null, "http://example.com/feed/src/" + i, false); - image.setOwner(feed); // create items List<FeedItem> items = new ArrayList<>(); @@ -187,12 +183,6 @@ class UITestUtils { List<FeedItem> queue = new ArrayList<>(); for (Feed feed : hostedFeeds) { feed.setDownloaded(true); - if (feed.getImage() != null) { - FeedImage image = feed.getImage(); - int fileId = Integer.parseInt(StringUtils.substringAfter(image.getDownload_url(), "files/")); - image.setFile_url(server.accessFile(fileId).getAbsolutePath()); - image.setDownloaded(true); - } if (downloadEpisodes) { for (FeedItem item : feed.getItems()) { if (item.hasMedia()) { diff --git a/app/src/androidTest/java/de/test/antennapod/ui/UITestUtilsTest.java b/app/src/androidTest/java/de/test/antennapod/ui/UITestUtilsTest.java index 53fd7d7fd..45ba472ff 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/UITestUtilsTest.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/UITestUtilsTest.java @@ -38,9 +38,6 @@ public class UITestUtilsTest extends InstrumentationTestCase { for (Feed feed : feeds) { testUrlReachable(feed.getDownload_url()); - if (feed.getImage() != null) { - testUrlReachable(feed.getImage().getDownload_url()); - } for (FeedItem item : feed.getItems()) { if (item.hasMedia()) { testUrlReachable(item.getMedia().getDownload_url()); @@ -66,9 +63,6 @@ public class UITestUtilsTest extends InstrumentationTestCase { for (Feed feed : uiTestUtils.hostedFeeds) { assertTrue(feed.getId() != 0); - if (feed.getImage() != null) { - assertTrue(feed.getImage().getId() != 0); - } for (FeedItem item : feed.getItems()) { assertTrue(item.getId() != 0); if (item.hasMedia()) { |