diff --git a/.gitignore b/.gitignore index 9ae18e7ea..d4be5aef9 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,8 @@ out #transifex downloads contributers.py +# View hierarchy captures +captures # other *.odg# proguard 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())); }