summaryrefslogtreecommitdiff
path: root/app/src/androidTest/java/de/test
diff options
context:
space:
mode:
authorH. Lehmann <ByteHamster@users.noreply.github.com>2020-03-25 22:49:34 +0100
committerGitHub <noreply@github.com>2020-03-25 22:49:34 +0100
commitb5836650d18aa611b2fe2ca73d41ed58342c1e94 (patch)
tree8e427bd10df1ee6422df210910a879acff11dcdb /app/src/androidTest/java/de/test
parentae906de06d1720331be1c64607cdb6011fc66ef5 (diff)
parentd87cc27c9bdfd7fa68df6e09bf184bd75393212b (diff)
downloadAntennaPod-b5836650d18aa611b2fe2ca73d41ed58342c1e94.zip
Merge pull request #3954 from ByteHamster/audioplayer-fragment
Convert AudioPlayer to fragment
Diffstat (limited to 'app/src/androidTest/java/de/test')
-rw-r--r--app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java6
-rw-r--r--app/src/androidTest/java/de/test/antennapod/ui/QueueFragmentTest.java7
-rw-r--r--app/src/androidTest/java/de/test/antennapod/ui/SpeedChangeTest.java27
3 files changed, 28 insertions, 12 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java b/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java
index 225f07dfd..beb6ad705 100644
--- a/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java
+++ b/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java
@@ -32,7 +32,9 @@ import java.util.concurrent.TimeoutException;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant;
+import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
+import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf;
@@ -193,4 +195,8 @@ public class EspressoTestUtils {
}
androidx.test.platform.app.InstrumentationRegistry.getInstrumentation().waitForIdleSync();
}
+
+ public static Matcher<View> actionBarOverflow() {
+ return allOf(isDisplayed(), withContentDescription("More options"));
+ }
}
diff --git a/app/src/androidTest/java/de/test/antennapod/ui/QueueFragmentTest.java b/app/src/androidTest/java/de/test/antennapod/ui/QueueFragmentTest.java
index 37d76bb6d..ec0d1fa64 100644
--- a/app/src/androidTest/java/de/test/antennapod/ui/QueueFragmentTest.java
+++ b/app/src/androidTest/java/de/test/antennapod/ui/QueueFragmentTest.java
@@ -1,6 +1,7 @@
package de.test.antennapod.ui;
import android.content.Intent;
+import android.view.View;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.intent.rule.IntentsTestRule;
import androidx.test.runner.AndroidJUnit4;
@@ -8,6 +9,7 @@ import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.fragment.QueueFragment;
import de.test.antennapod.EspressoTestUtils;
+import org.hamcrest.Matcher;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -18,6 +20,7 @@ import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.matcher.ViewMatchers.withClassName;
import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
+import static de.test.antennapod.NthMatcher.first;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.endsWith;
@@ -48,14 +51,14 @@ public class QueueFragmentTest {
@Test
public void testSortEmptyQueue() {
- Espresso.openContextualActionModeOverflowMenu();
+ onView(first(EspressoTestUtils.actionBarOverflow())).perform(click());
onView(withText(R.string.sort)).perform(click());
onView(withText(R.string.random)).perform(click());
}
@Test
public void testKeepEmptyQueueSorted() {
- Espresso.openContextualActionModeOverflowMenu();
+ onView(first(EspressoTestUtils.actionBarOverflow())).perform(click());
onView(withText(R.string.sort)).perform(click());
onView(withText(R.string.keep_sorted)).perform(click());
}
diff --git a/app/src/androidTest/java/de/test/antennapod/ui/SpeedChangeTest.java b/app/src/androidTest/java/de/test/antennapod/ui/SpeedChangeTest.java
index 194d51a3c..5565bf474 100644
--- a/app/src/androidTest/java/de/test/antennapod/ui/SpeedChangeTest.java
+++ b/app/src/androidTest/java/de/test/antennapod/ui/SpeedChangeTest.java
@@ -7,12 +7,14 @@ import android.preference.PreferenceManager;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import de.danoeh.antennapod.R;
-import de.danoeh.antennapod.activity.AudioplayerActivity;
+import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.service.playback.PlayerStatus;
import de.danoeh.antennapod.core.storage.DBReader;
+import de.danoeh.antennapod.core.util.playback.PlaybackController;
+import de.danoeh.antennapod.fragment.ExternalPlayerFragment;
import de.danoeh.antennapod.fragment.QueueFragment;
import de.test.antennapod.EspressoTestUtils;
import de.test.antennapod.IgnoreOnCi;
@@ -34,6 +36,8 @@ import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static de.test.antennapod.EspressoTestUtils.waitForView;
+import static de.test.antennapod.NthMatcher.first;
+import static org.hamcrest.Matchers.allOf;
/**
* User interface tests for changing the playback speed.
@@ -43,10 +47,10 @@ import static de.test.antennapod.EspressoTestUtils.waitForView;
public class SpeedChangeTest {
@Rule
- public ActivityTestRule<AudioplayerActivity> activityRule
- = new ActivityTestRule<>(AudioplayerActivity.class, false, false);
+ public ActivityTestRule<MainActivity> activityRule = new ActivityTestRule<>(MainActivity.class, false, false);
private UITestUtils uiTestUtils;
private String[] availableSpeeds;
+ private PlaybackController controller;
@Before
public void setUp() throws Exception {
@@ -70,7 +74,10 @@ public class SpeedChangeTest {
UserPreferences.setPlaybackSpeedArray(availableSpeeds);
EspressoTestUtils.tryKillPlaybackService();
- activityRule.launchActivity(new Intent());
+ activityRule.launchActivity(new Intent().putExtra(MainActivity.EXTRA_OPEN_PLAYER, true));
+ controller = new PlaybackController(activityRule.getActivity(), true);
+ controller.init();
+ controller.getMedia(); // To load media
}
@After
@@ -86,21 +93,21 @@ public class SpeedChangeTest {
@Test
public void testChangeSpeedPlaying() {
onView(isRoot()).perform(waitForView(withId(R.id.butPlay), 1000));
- onView(withId(R.id.butPlay)).perform(click());
+ controller.playPause();
Awaitility.await().atMost(5, TimeUnit.SECONDS).until(()
- -> activityRule.getActivity().getPlaybackController().getStatus() == PlayerStatus.PLAYING);
+ -> controller.getStatus() == PlayerStatus.PLAYING);
clickThroughSpeeds();
}
@Test
public void testChangeSpeedPaused() {
onView(isRoot()).perform(waitForView(withId(R.id.butPlay), 1000));
- onView(withId(R.id.butPlay)).perform(click());
+ controller.playPause();
Awaitility.await().atMost(5, TimeUnit.SECONDS).until(()
- -> activityRule.getActivity().getPlaybackController().getStatus() == PlayerStatus.PLAYING);
- onView(withId(R.id.butPlay)).perform(click());
+ -> controller.getStatus() == PlayerStatus.PLAYING);
+ controller.playPause();
Awaitility.await().atMost(5, TimeUnit.SECONDS).until(()
- -> activityRule.getActivity().getPlaybackController().getStatus() == PlayerStatus.PAUSED);
+ -> controller.getStatus() == PlayerStatus.PAUSED);
clickThroughSpeeds();
}