diff options
author | ByteHamster <info@bytehamster.com> | 2019-12-20 00:03:07 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2019-12-20 00:03:07 +0100 |
commit | b5f15c6fe71087443483dbf340c5febbfc166cf8 (patch) | |
tree | c7f81c40b4e4d8b7ff9df84ff120d7961ddf2b33 /app | |
parent | 19890afc663d067f70e0286eeaa73cb8cb7acbad (diff) | |
download | AntennaPod-b5f15c6fe71087443483dbf340c5febbfc166cf8.zip |
Fixed mark played button not working
Diffstat (limited to 'app')
3 files changed, 85 insertions, 6 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/ui/TextOnlyFeedsTest.java b/app/src/androidTest/java/de/test/antennapod/ui/TextOnlyFeedsTest.java new file mode 100644 index 000000000..7ba7a57f2 --- /dev/null +++ b/app/src/androidTest/java/de/test/antennapod/ui/TextOnlyFeedsTest.java @@ -0,0 +1,71 @@ +package de.test.antennapod.ui; + +import android.content.Intent; +import androidx.test.espresso.intent.rule.IntentsTestRule; +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; +import de.danoeh.antennapod.R; +import de.danoeh.antennapod.activity.MainActivity; +import de.danoeh.antennapod.core.feed.Feed; +import de.test.antennapod.EspressoTestUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.io.IOException; + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.scrollTo; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; +import static androidx.test.espresso.matcher.ViewMatchers.withText; +import static de.test.antennapod.EspressoTestUtils.onDrawerItem; +import static de.test.antennapod.EspressoTestUtils.openNavDrawer; +import static de.test.antennapod.EspressoTestUtils.waitForView; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.CoreMatchers.not; + +/** + * Test UI for feeds that do not have media files + */ +@RunWith(AndroidJUnit4.class) +public class TextOnlyFeedsTest { + + private UITestUtils uiTestUtils; + + @Rule + public IntentsTestRule<MainActivity> activityRule = new IntentsTestRule<>(MainActivity.class, false, false); + + @Before + public void setUp() throws IOException { + EspressoTestUtils.clearPreferences(); + EspressoTestUtils.makeNotFirstRun(); + EspressoTestUtils.clearDatabase(); + + uiTestUtils = new UITestUtils(InstrumentationRegistry.getInstrumentation().getTargetContext()); + uiTestUtils.setHostTextOnlyFeeds(true); + uiTestUtils.setup(); + + activityRule.launchActivity(new Intent()); + } + + @After + public void tearDown() throws Exception { + uiTestUtils.tearDown(); + } + + @Test + public void testMarkAsPlayedList() throws Exception { + uiTestUtils.addLocalFeedData(false); + final Feed feed = uiTestUtils.hostedFeeds.get(0); + openNavDrawer(); + onDrawerItem(withText(feed.getTitle())).perform(scrollTo(), click()); + onView(withText(feed.getItemAtIndex(0).getTitle())).perform(click()); + onView(withText(R.string.mark_read_label)).perform(click()); + onView(isRoot()).perform(waitForView(allOf(withText(R.string.mark_read_label), not(isDisplayed())), 3000)); + } + +} 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 66404e2a8..a7bdc36e5 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java @@ -42,6 +42,7 @@ public class UITestUtils { private static final int NUM_ITEMS_PER_FEED = 10; private String testFileName = "3sec.mp3"; + private boolean hostTextOnlyFeeds = false; private final Context context; private final HTTPBin server = new HTTPBin(); private File destDir; @@ -141,9 +142,10 @@ public class UITestUtils { "http://example.com/feed" + i + "/item/" + j, new Date(), FeedItem.UNPLAYED, feed); items.add(item); - File mediaFile = newMediaFile("feed-" + i + "-episode-" + j + ".mp3"); - item.setMedia(new FeedMedia(j, item, 0, 0, mediaFile.length(), "audio/mp3", null, hostFile(mediaFile), false, null, 0, 0)); - + if (!hostTextOnlyFeeds) { + File mediaFile = newMediaFile("feed-" + i + "-episode-" + j + ".mp3"); + item.setMedia(new FeedMedia(j, item, 0, 0, mediaFile.length(), "audio/mp3", null, hostFile(mediaFile), false, null, 0, 0)); + } } feed.setItems(items); feed.setDownload_url(hostFeed(feed)); @@ -190,7 +192,9 @@ public class UITestUtils { } queue.add(feed.getItems().get(0)); - feed.getItems().get(1).getMedia().setPlaybackCompletionDate(new Date()); + if (feed.getItems().get(1).hasMedia()) { + feed.getItems().get(1).getMedia().setPlaybackCompletionDate(new Date()); + } } localFeedDataAdded = true; @@ -215,4 +219,8 @@ public class UITestUtils { public void setMediaFileName(String filename) { testFileName = filename; } + + public void setHostTextOnlyFeeds(boolean hostTextOnlyFeeds) { + this.hostTextOnlyFeeds = hostTextOnlyFeeds; + } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java index 9a88441e0..2806f48ba 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java @@ -235,7 +235,7 @@ public class ItemFragment extends Fragment { @Override public void onResume() { super.onResume(); - if(itemsLoaded) { + if (itemsLoaded) { progbarLoading.setVisibility(View.GONE); updateAppearance(); } @@ -459,7 +459,7 @@ public class ItemFragment extends Fragment { } } - @Subscribe + @Subscribe(threadMode = ThreadMode.MAIN) public void onUnreadItemsChanged(UnreadItemsUpdateEvent event) { load(); } |