diff options
author | orionlee <orionlee@yahoo.com> | 2018-05-18 13:21:36 -0700 |
---|---|---|
committer | orionlee <orionlee@yahoo.com> | 2018-05-18 13:21:36 -0700 |
commit | 46ae3e0b00a3b3ec8ef7ba01efad8bcfb1a79398 (patch) | |
tree | 9467bb3db44be725d2fc56092f98f602d2face42 /core/src/androidTest/java/de | |
parent | f05c7e23efce568b830d000df773209640028d7c (diff) | |
download | AntennaPod-46ae3e0b00a3b3ec8ef7ba01efad8bcfb1a79398.zip |
core tests: Convert tests that are effectively unit tests to be one
(standard android junit tests). Provides implementations for
android platform utils needed (in unit test environment):
1. android.util.Log, 2. android.text.TextUtils.isEmpty()
Diffstat (limited to 'core/src/androidTest/java/de')
6 files changed, 0 insertions, 255 deletions
diff --git a/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedImageMother.java b/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedImageMother.java deleted file mode 100644 index 0fb4992ba..000000000 --- a/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedImageMother.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.danoeh.antennapod.core.feed; - -class FeedImageMother { - - public static FeedImage anyFeedImage() { - return new FeedImage(0, "image", null, "http://example.com/picture", false); - } - -} diff --git a/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedItemMother.java b/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedItemMother.java deleted file mode 100644 index 3d7c4fe5f..000000000 --- a/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedItemMother.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.danoeh.antennapod.core.feed; - -import java.util.Date; - -import static de.danoeh.antennapod.core.feed.FeedImageMother.anyFeedImage; -import static de.danoeh.antennapod.core.feed.FeedMother.anyFeed; - -class FeedItemMother { - - static FeedItem anyFeedItemWithImage() { - FeedItem item = new FeedItem(0, "Item", "Item", "url", new Date(), FeedItem.PLAYED, anyFeed()); - item.setImage(anyFeedImage()); - return item; - } - -} diff --git a/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedItemTest.java b/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedItemTest.java deleted file mode 100644 index 9e12e8ae0..000000000 --- a/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedItemTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package de.danoeh.antennapod.core.feed; - -import android.test.AndroidTestCase; - -import static de.danoeh.antennapod.core.feed.FeedItemMother.anyFeedItemWithImage; - -public class FeedItemTest extends AndroidTestCase { - - private FeedItem original; - private FeedImage originalImage; - private FeedItem changedFeedItem; - - @Override - protected void setUp() { - original = anyFeedItemWithImage(); - originalImage = original.getImage(); - changedFeedItem = anyFeedItemWithImage(); - } - - public void testUpdateFromOther_feedItemImageDownloadUrlChanged() throws Exception { - setNewFeedItemImageDownloadUrl(); - - original.updateFromOther(changedFeedItem); - - feedItemImageWasUpdated(); - } - - public void testUpdateFromOther_feedItemImageRemoved() throws Exception { - feedItemImageRemoved(); - - original.updateFromOther(changedFeedItem); - - feedItemImageWasNotUpdated(); - } - - public void testUpdateFromOther_feedItemImageAdded() throws Exception { - feedItemHadNoImage(); - setNewFeedItemImageDownloadUrl(); - - original.updateFromOther(changedFeedItem); - - feedItemImageWasUpdated(); - } - - private void feedItemHadNoImage() { - original.setImage(null); - } - - private void setNewFeedItemImageDownloadUrl() { - changedFeedItem.getImage().setDownload_url("http://example.com/new_picture"); - } - - private void feedItemImageRemoved() { - changedFeedItem.setImage(null); - } - - private void feedItemImageWasUpdated() { - assertEquals(original.getImage().getDownload_url(), changedFeedItem.getImage().getDownload_url()); - } - - private void feedItemImageWasNotUpdated() { - assertTrue(originalImage == original.getImage()); - } - -}
\ No newline at end of file diff --git a/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedMother.java b/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedMother.java deleted file mode 100644 index fecc8e377..000000000 --- a/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedMother.java +++ /dev/null @@ -1,14 +0,0 @@ -package de.danoeh.antennapod.core.feed; - -import static de.danoeh.antennapod.core.feed.FeedImageMother.anyFeedImage; - -class FeedMother { - - public static Feed anyFeed() { - FeedImage image = anyFeedImage(); - return new Feed(0, null, "title", "http://example.com", "This is the description", - "http://example.com/payment", "Daniel", "en", null, "http://example.com/feed", image, - null, "http://example.com/feed", true); - } - -} diff --git a/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedTest.java b/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedTest.java deleted file mode 100644 index 8067ec93f..000000000 --- a/core/src/androidTest/java/de/danoeh/antennapod/core/feed/FeedTest.java +++ /dev/null @@ -1,92 +0,0 @@ -package de.danoeh.antennapod.core.feed; - -import android.test.AndroidTestCase; - -import static de.danoeh.antennapod.core.feed.FeedImageMother.anyFeedImage; -import static de.danoeh.antennapod.core.feed.FeedMother.anyFeed; - -public class FeedTest extends AndroidTestCase { - - private Feed original; - private FeedImage originalImage; - private Feed changedFeed; - - @Override - protected void setUp() { - original = anyFeed(); - originalImage = original.getImage(); - changedFeed = anyFeed(); - } - - public void testCompareWithOther_feedImageDownloadUrlChanged() throws Exception { - setNewFeedImageDownloadUrl(); - - feedHasChanged(); - } - - public void testCompareWithOther_sameFeedImage() throws Exception { - changedFeed.setImage(anyFeedImage()); - - feedHasNotChanged(); - } - - public void testCompareWithOther_feedImageRemoved() throws Exception { - feedImageRemoved(); - - feedHasNotChanged(); - } - - public void testUpdateFromOther_feedImageDownloadUrlChanged() throws Exception { - setNewFeedImageDownloadUrl(); - - original.updateFromOther(changedFeed); - - feedImageWasUpdated(); - } - - public void testUpdateFromOther_feedImageRemoved() throws Exception { - feedImageRemoved(); - - original.updateFromOther(changedFeed); - - feedImageWasNotUpdated(); - } - - public void testUpdateFromOther_feedImageAdded() throws Exception { - feedHadNoImage(); - setNewFeedImageDownloadUrl(); - - original.updateFromOther(changedFeed); - - feedImageWasUpdated(); - } - - private void feedHasNotChanged() { - assertFalse(original.compareWithOther(changedFeed)); - } - - private void feedHadNoImage() { - original.setImage(null); - } - - private void setNewFeedImageDownloadUrl() { - changedFeed.getImage().setDownload_url("http://example.com/new_picture"); - } - - private void feedHasChanged() { - assertTrue(original.compareWithOther(changedFeed)); - } - - private void feedImageRemoved() { - changedFeed.setImage(null); - } - - private void feedImageWasUpdated() { - assertEquals(original.getImage().getDownload_url(), changedFeed.getImage().getDownload_url()); - } - - private void feedImageWasNotUpdated() { - assertTrue(originalImage == original.getImage()); - } - -}
\ No newline at end of file diff --git a/core/src/androidTest/java/de/danoeh/antennapod/core/util/LongLongMapTest.java b/core/src/androidTest/java/de/danoeh/antennapod/core/util/LongLongMapTest.java deleted file mode 100644 index d75cd5c77..000000000 --- a/core/src/androidTest/java/de/danoeh/antennapod/core/util/LongLongMapTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package de.danoeh.antennapod.core.util; - -import android.test.AndroidTestCase; - -public class LongLongMapTest extends AndroidTestCase { - - public void testEmptyMap() { - LongIntMap map = new LongIntMap(); - assertEquals(0, map.size()); - assertEquals("LongLongMap{}", map.toString()); - assertEquals(0, map.get(42)); - assertEquals(-1, map.get(42, -1)); - assertEquals(false, map.delete(42)); - assertEquals(-1, map.indexOfKey(42)); - assertEquals(-1, map.indexOfValue(42)); - assertEquals(1, map.hashCode()); - } - - public void testSingleElement() { - LongIntMap map = new LongIntMap(); - map.put(17, 42); - assertEquals(1, map.size()); - assertEquals("LongLongMap{17=42}", map.toString()); - assertEquals(42, map.get(17)); - assertEquals(42, map.get(17, -1)); - assertEquals(0, map.indexOfKey(17)); - assertEquals(0, map.indexOfValue(42)); - assertEquals(true, map.delete(17)); - } - - public void testAddAndDelete() { - LongIntMap map = new LongIntMap(); - for(int i=0; i < 100; i++) { - map.put(i * 17, i * 42); - } - assertEquals(100, map.size()); - assertEquals(0, map.get(0)); - assertEquals(42, map.get(17)); - assertEquals(42, map.get(17, -1)); - assertEquals(1, map.indexOfKey(17)); - assertEquals(1, map.indexOfValue(42)); - for(int i=0; i < 100; i++) { - assertEquals(true, map.delete(i * 17)); - } - } - - public void testOverwrite() { - LongIntMap map = new LongIntMap(); - map.put(17, 42); - assertEquals(1, map.size()); - assertEquals("LongLongMap{17=42}", map.toString()); - assertEquals(42, map.get(17)); - map.put(17, 23); - assertEquals(1, map.size()); - assertEquals("LongLongMap{17=23}", map.toString()); - assertEquals(23, map.get(17)); - } - -} |