summaryrefslogtreecommitdiff
path: root/app/src/androidTest
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/androidTest')
-rw-r--r--app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java54
1 files changed, 34 insertions, 20 deletions
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 bba546a88..d51ae63ba 100644
--- a/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java
+++ b/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java
@@ -3,10 +3,21 @@ package de.test.antennapod.ui;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
-import androidx.preference.PreferenceManager;
+
import androidx.annotation.StringRes;
+import androidx.preference.PreferenceManager;
+import androidx.test.espresso.matcher.RootMatchers;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
+
+import org.awaitility.Awaitility;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
+
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.PreferenceActivity;
import de.danoeh.antennapod.core.preferences.UserPreferences;
@@ -20,14 +31,8 @@ import de.danoeh.antennapod.fragment.EpisodesFragment;
import de.danoeh.antennapod.fragment.QueueFragment;
import de.danoeh.antennapod.fragment.SubscriptionFragment;
import de.test.antennapod.EspressoTestUtils;
-import org.awaitility.Awaitility;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.concurrent.TimeUnit;
+import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.replaceText;
@@ -44,6 +49,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static de.test.antennapod.EspressoTestUtils.clickPreference;
import static de.test.antennapod.EspressoTestUtils.waitForView;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.hamcrest.Matchers.anything;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertTrue;
@@ -53,18 +59,22 @@ public class PreferencesTest {
private Resources res;
@Rule
- public ActivityTestRule<PreferenceActivity> mActivityRule = new ActivityTestRule<>(PreferenceActivity.class, false, false);
+ public ActivityTestRule<PreferenceActivity> activityTestRule =
+ new ActivityTestRule<>(PreferenceActivity.class,
+ false,
+ false);
+
@Before
public void setUp() {
EspressoTestUtils.clearDatabase();
EspressoTestUtils.clearPreferences();
- mActivityRule.launchActivity(new Intent());
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivityRule.getActivity());
+ activityTestRule.launchActivity(new Intent());
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activityTestRule.getActivity());
prefs.edit().putBoolean(UserPreferences.PREF_ENABLE_AUTODL, true).commit();
- res = mActivityRule.getActivity().getResources();
- UserPreferences.init(mActivityRule.getActivity());
+ res = activityTestRule.getActivity().getResources();
+ UserPreferences.init(activityTestRule.getActivity());
}
@Test
@@ -254,8 +264,10 @@ public class PreferencesTest {
@Test
public void testDisableUpdateInterval() {
clickPreference(R.string.network_pref);
- onView(withText(R.string.pref_autoUpdateIntervallOrTime_title)).perform(click());
- onView(withText(R.string.pref_autoUpdateIntervallOrTime_Disable)).perform(click());
+ clickPreference(R.string.feed_refresh_title);
+ onView(withText(R.string.feed_refresh_never)).perform(click());
+ onView(withId(R.id.disableRadioButton)).perform(click());
+ onView(withText(R.string.confirm_label)).perform(click());
Awaitility.await().atMost(1000, MILLISECONDS)
.until(() -> UserPreferences.getUpdateInterval() == 0);
}
@@ -263,12 +275,14 @@ public class PreferencesTest {
@Test
public void testSetUpdateInterval() {
clickPreference(R.string.network_pref);
- clickPreference(R.string.pref_autoUpdateIntervallOrTime_title);
- onView(withText(R.string.pref_autoUpdateIntervallOrTime_Interval)).perform(click());
- String search = "12 " + res.getString(R.string.pref_update_interval_hours_plural);
- onView(withText(search)).perform(click());
+ clickPreference(R.string.feed_refresh_title);
+ onView(withId(R.id.intervalRadioButton)).perform(click());
+ onView(withId(R.id.spinner)).perform(click());
+ int position = 1; // an arbitrary position
+ onData(anything()).inRoot(RootMatchers.isPlatformPopup()).atPosition(position).perform(click());
+ onView(withText(R.string.confirm_label)).perform(click());
Awaitility.await().atMost(1000, MILLISECONDS)
- .until(() -> UserPreferences.getUpdateInterval() == TimeUnit.HOURS.toMillis(12));
+ .until(() -> UserPreferences.getUpdateInterval() == TimeUnit.HOURS.toMillis(2));
}
@Test