summaryrefslogtreecommitdiff
path: root/app/src/androidTest/java/de/test/antennapod
diff options
context:
space:
mode:
authorH. Lehmann <ByteHamster@users.noreply.github.com>2020-07-11 17:50:00 +0200
committerGitHub <noreply@github.com>2020-07-11 17:50:00 +0200
commitd110b1818bbfb0bbc9677b9fc44860c2a1a870ea (patch)
tree04e2e79a44af02bdf8808fa60a57f27a5e025fbb /app/src/androidTest/java/de/test/antennapod
parentc353cf79ec67be8d6404193ceb9d0af3eceee84c (diff)
parent9d2c2d8f370af84922f8197e252ee4474d0c3acb (diff)
downloadAntennaPod-d110b1818bbfb0bbc9677b9fc44860c2a1a870ea.zip
Merge pull request #4260 from gerardolgvr/replace-share-menu-by-dialog
fixes #1215 replacing share menu by dialog
Diffstat (limited to 'app/src/androidTest/java/de/test/antennapod')
-rw-r--r--app/src/androidTest/java/de/test/antennapod/dialogs/ShareDialogTest.java92
1 files changed, 92 insertions, 0 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/dialogs/ShareDialogTest.java b/app/src/androidTest/java/de/test/antennapod/dialogs/ShareDialogTest.java
new file mode 100644
index 000000000..3f90f9ce8
--- /dev/null
+++ b/app/src/androidTest/java/de/test/antennapod/dialogs/ShareDialogTest.java
@@ -0,0 +1,92 @@
+package de.test.antennapod.dialogs;
+
+import android.content.Context;
+import android.content.Intent;
+import android.view.View;
+
+import org.hamcrest.Matcher;
+import org.hamcrest.Matchers;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.List;
+
+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.FeedItem;
+import de.danoeh.antennapod.core.storage.DBReader;
+import de.danoeh.antennapod.fragment.EpisodesFragment;
+import de.test.antennapod.EspressoTestUtils;
+import de.test.antennapod.ui.UITestUtils;
+
+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.assertion.ViewAssertions.matches;
+import static androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition;
+import static androidx.test.espresso.matcher.ViewMatchers.hasMinimumChildCount;
+import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
+import static androidx.test.espresso.matcher.ViewMatchers.withId;
+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 de.test.antennapod.NthMatcher.first;
+import static org.hamcrest.CoreMatchers.allOf;
+
+/**
+ * User interface tests for share dialog.
+ */
+@RunWith(AndroidJUnit4.class)
+public class ShareDialogTest {
+
+ @Rule
+ public IntentsTestRule<MainActivity> activityRule = new IntentsTestRule<>(MainActivity.class, false, false);
+
+ private UITestUtils uiTestUtils;
+ protected Context context;
+
+ @Before
+ public void setUp() throws Exception {
+ context = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ EspressoTestUtils.clearPreferences();
+ EspressoTestUtils.clearDatabase();
+ EspressoTestUtils.setLastNavFragment(EpisodesFragment.TAG);
+ uiTestUtils = new UITestUtils(context);
+ uiTestUtils.setup();
+ uiTestUtils.addLocalFeedData(true);
+
+ activityRule.launchActivity(new Intent());
+
+ openNavDrawer();
+ onDrawerItem(withText(R.string.episodes_label)).perform(click());
+ onView(isRoot()).perform(waitForView(withText(R.string.all_episodes_short_label), 1000));
+ onView(withText(R.string.all_episodes_short_label)).perform(click());
+
+ Matcher<View> allEpisodesMatcher;
+ final List<FeedItem> episodes = DBReader.getRecentlyPublishedEpisodes(0, 10);
+ allEpisodesMatcher = Matchers.allOf(withId(android.R.id.list), isDisplayed(), hasMinimumChildCount(2));
+ onView(isRoot()).perform(waitForView(allEpisodesMatcher, 1000));
+ onView(allEpisodesMatcher).perform(actionOnItemAtPosition(0, click()));
+ onView(first(EspressoTestUtils.actionBarOverflow())).perform(click());
+ }
+
+ @Test
+ public void testShareDialogDisplayed() throws InterruptedException {
+ onView(withText(R.string.share_label_with_ellipses)).perform(click());
+ onView(allOf(isDisplayed(), withText(R.string.share_label)));
+ }
+
+ @Test
+ public void testShareDialogCancelButton() {
+ onView(withText(R.string.share_label_with_ellipses)).perform(scrollTo()).perform(click());
+ onView(withText(R.string.cancel_label)).check(matches(isDisplayed())).perform(scrollTo()).perform(click());
+ }
+
+}