Making sure that tests click on preference, not preferenceCategory
This commit is contained in:
parent
92c3287651
commit
369b89f1db
|
@ -35,6 +35,8 @@ out
|
||||||
#transifex downloads
|
#transifex downloads
|
||||||
contributers.py
|
contributers.py
|
||||||
|
|
||||||
|
# View hierarchy captures
|
||||||
|
captures
|
||||||
# other
|
# other
|
||||||
*.odg#
|
*.odg#
|
||||||
proguard
|
proguard
|
||||||
|
|
|
@ -116,7 +116,9 @@ public class EspressoTestUtils {
|
||||||
|
|
||||||
public static void clickPreference(@StringRes int title) {
|
public static void clickPreference(@StringRes int title) {
|
||||||
onView(withId(R.id.recycler_view)).perform(
|
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()));
|
click()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,8 @@ public abstract class PlaybackTest {
|
||||||
uiTestUtils.tearDown();
|
uiTestUtils.tearDown();
|
||||||
|
|
||||||
// shut down playback service
|
// shut down playback service
|
||||||
skipEpisode();
|
|
||||||
context.sendBroadcast(new Intent(PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE));
|
context.sendBroadcast(new Intent(PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE));
|
||||||
|
Awaitility.await().until(() -> !PlaybackService.isRunning);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -49,6 +49,7 @@ public class PreferencesTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
EspressoTestUtils.clearDatabase();
|
||||||
EspressoTestUtils.clearPreferences();
|
EspressoTestUtils.clearPreferences();
|
||||||
mActivityRule.launchActivity(new Intent());
|
mActivityRule.launchActivity(new Intent());
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivityRule.getActivity());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivityRule.getActivity());
|
||||||
|
@ -103,10 +104,9 @@ public class PreferencesTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetLockscreenButtons() {
|
public void testSetLockscreenButtons() {
|
||||||
onView(withText(R.string.user_interface_label)).perform(click());
|
clickPreference(R.string.user_interface_label);
|
||||||
solo.scrollDown();
|
|
||||||
String[] buttons = res.getStringArray(R.array.compact_notification_buttons_options);
|
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);
|
solo.waitForDialogToOpen(1000);
|
||||||
// First uncheck checkbox
|
// First uncheck checkbox
|
||||||
onView(withText(buttons[2])).perform(click());
|
onView(withText(buttons[2])).perform(click());
|
||||||
|
@ -127,13 +127,11 @@ public class PreferencesTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEnqueueAtFront() {
|
public void testEnqueueAtFront() {
|
||||||
onView(withText(R.string.playback_pref)).perform(click());
|
clickPreference(R.string.playback_pref);
|
||||||
final boolean enqueueAtFront = UserPreferences.enqueueAtFront();
|
final boolean enqueueAtFront = UserPreferences.enqueueAtFront();
|
||||||
solo.scrollDown();
|
clickPreference(R.string.pref_queueAddToFront_title);
|
||||||
solo.scrollDown();
|
|
||||||
onView(withText(R.string.pref_queueAddToFront_title)).perform(click());
|
|
||||||
assertTrue(solo.waitForCondition(() -> enqueueAtFront != UserPreferences.enqueueAtFront(), Timeout.getLargeTimeout()));
|
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()));
|
assertTrue(solo.waitForCondition(() -> enqueueAtFront == UserPreferences.enqueueAtFront(), Timeout.getLargeTimeout()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,13 +175,11 @@ public class PreferencesTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testContinuousPlayback() {
|
public void testContinuousPlayback() {
|
||||||
onView(withText(R.string.playback_pref)).perform(click());
|
clickPreference(R.string.playback_pref);
|
||||||
final boolean continuousPlayback = UserPreferences.isFollowQueue();
|
final boolean continuousPlayback = UserPreferences.isFollowQueue();
|
||||||
solo.scrollDown();
|
clickPreference(R.string.pref_followQueue_title);
|
||||||
solo.scrollDown();
|
|
||||||
onView(withText(R.string.pref_followQueue_title)).perform(click());
|
|
||||||
assertTrue(solo.waitForCondition(() -> continuousPlayback != UserPreferences.isFollowQueue(), Timeout.getLargeTimeout()));
|
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()));
|
assertTrue(solo.waitForCondition(() -> continuousPlayback == UserPreferences.isFollowQueue(), Timeout.getLargeTimeout()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue