summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2019-10-25 14:13:25 +0200
committerByteHamster <info@bytehamster.com>2019-10-25 15:29:54 +0200
commit369b89f1db286d6cb5f3b881a0d1eb3662f005ff (patch)
tree11d53945848eb419ebd9b81a63ee07b62cd43aee /app/src
parent92c3287651abf2ffb68bfa59697fa5e5ff9517f3 (diff)
downloadAntennaPod-369b89f1db286d6cb5f3b881a0d1eb3662f005ff.zip
Making sure that tests click on preference, not preferenceCategory
Diffstat (limited to 'app/src')
-rw-r--r--app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java4
-rw-r--r--app/src/androidTest/java/de/test/antennapod/playback/PlaybackTest.java2
-rw-r--r--app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java22
3 files changed, 13 insertions, 15 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java b/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java
index 2ce42be6d..c76cd2032 100644
--- a/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java
+++ b/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java
@@ -116,7 +116,9 @@ public class EspressoTestUtils {
public static void clickPreference(@StringRes int title) {
onView(withId(R.id.recycler_view)).perform(
- RecyclerViewActions.actionOnItem(hasDescendant(withText(title)),
+ RecyclerViewActions.actionOnItem(
+ allOf(hasDescendant(withText(title)),
+ hasDescendant(withId(android.R.id.widget_frame))),
click()));
}
diff --git a/app/src/androidTest/java/de/test/antennapod/playback/PlaybackTest.java b/app/src/androidTest/java/de/test/antennapod/playback/PlaybackTest.java
index 78f1ba7c4..6e044d9c2 100644
--- a/app/src/androidTest/java/de/test/antennapod/playback/PlaybackTest.java
+++ b/app/src/androidTest/java/de/test/antennapod/playback/PlaybackTest.java
@@ -69,8 +69,8 @@ public abstract class PlaybackTest {
uiTestUtils.tearDown();
// shut down playback service
- skipEpisode();
context.sendBroadcast(new Intent(PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE));
+ Awaitility.await().until(() -> !PlaybackService.isRunning);
}
@Test
diff --git a/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java b/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java
index b46af83c8..65bc7d745 100644
--- a/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java
+++ b/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java
@@ -49,6 +49,7 @@ public class PreferencesTest {
@Before
public void setUp() {
+ EspressoTestUtils.clearDatabase();
EspressoTestUtils.clearPreferences();
mActivityRule.launchActivity(new Intent());
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivityRule.getActivity());
@@ -103,10 +104,9 @@ public class PreferencesTest {
@Test
public void testSetLockscreenButtons() {
- onView(withText(R.string.user_interface_label)).perform(click());
- solo.scrollDown();
+ clickPreference(R.string.user_interface_label);
String[] buttons = res.getStringArray(R.array.compact_notification_buttons_options);
- onView(withText(R.string.pref_compact_notification_buttons_title)).perform(click());
+ clickPreference(R.string.pref_compact_notification_buttons_title);
solo.waitForDialogToOpen(1000);
// First uncheck checkbox
onView(withText(buttons[2])).perform(click());
@@ -127,13 +127,11 @@ public class PreferencesTest {
@Test
public void testEnqueueAtFront() {
- onView(withText(R.string.playback_pref)).perform(click());
+ clickPreference(R.string.playback_pref);
final boolean enqueueAtFront = UserPreferences.enqueueAtFront();
- solo.scrollDown();
- solo.scrollDown();
- onView(withText(R.string.pref_queueAddToFront_title)).perform(click());
+ clickPreference(R.string.pref_queueAddToFront_title);
assertTrue(solo.waitForCondition(() -> enqueueAtFront != UserPreferences.enqueueAtFront(), Timeout.getLargeTimeout()));
- onView(withText(R.string.pref_queueAddToFront_title)).perform(click());
+ clickPreference(R.string.pref_queueAddToFront_title);
assertTrue(solo.waitForCondition(() -> enqueueAtFront == UserPreferences.enqueueAtFront(), Timeout.getLargeTimeout()));
}
@@ -177,13 +175,11 @@ public class PreferencesTest {
@Test
public void testContinuousPlayback() {
- onView(withText(R.string.playback_pref)).perform(click());
+ clickPreference(R.string.playback_pref);
final boolean continuousPlayback = UserPreferences.isFollowQueue();
- solo.scrollDown();
- solo.scrollDown();
- onView(withText(R.string.pref_followQueue_title)).perform(click());
+ clickPreference(R.string.pref_followQueue_title);
assertTrue(solo.waitForCondition(() -> continuousPlayback != UserPreferences.isFollowQueue(), Timeout.getLargeTimeout()));
- onView(withText(R.string.pref_followQueue_title)).perform(click());
+ clickPreference(R.string.pref_followQueue_title);
assertTrue(solo.waitForCondition(() -> continuousPlayback == UserPreferences.isFollowQueue(), Timeout.getLargeTimeout()));
}