summaryrefslogtreecommitdiff
path: root/app/src/androidTest/java/de/test
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/androidTest/java/de/test')
-rw-r--r--app/src/androidTest/java/de/test/antennapod/ui/FeedSettingsTest.java56
-rw-r--r--app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java2
2 files changed, 57 insertions, 1 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/ui/FeedSettingsTest.java b/app/src/androidTest/java/de/test/antennapod/ui/FeedSettingsTest.java
index bae12936f..f3cd99b2c 100644
--- a/app/src/androidTest/java/de/test/antennapod/ui/FeedSettingsTest.java
+++ b/app/src/androidTest/java/de/test/antennapod/ui/FeedSettingsTest.java
@@ -6,7 +6,9 @@ import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
+import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.model.feed.Feed;
+import de.danoeh.antennapod.model.feed.FeedPreferences;
import de.test.antennapod.EspressoTestUtils;
import org.junit.After;
import org.junit.Before;
@@ -16,6 +18,8 @@ import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
+import static androidx.test.espresso.action.ViewActions.pressBack;
+import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
@@ -24,6 +28,10 @@ import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static de.test.antennapod.EspressoTestUtils.clickPreference;
import static de.test.antennapod.EspressoTestUtils.waitForView;
import static org.hamcrest.Matchers.allOf;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
@RunWith(AndroidJUnit4.class)
public class FeedSettingsTest {
@@ -76,4 +84,52 @@ public class FeedSettingsTest {
clickPreference(R.string.feed_volume_reduction);
onView(withText(R.string.cancel_label)).perform(click());
}
+
+ /**
+ * Test that modifying a feed's authentication settings results in proper behavior.
+ * Expect:
+ * - Feed is refreshed automatically
+ * - Database has updated username and password
+ */
+ @Test
+ public void testAuthenticationSettingsUpdate() throws IOException {
+ onView(isRoot()).perform(waitForView(allOf(isDescendantOfA(withId(R.id.appBar)),
+ withText(feed.getTitle()), isDisplayed()), 1000));
+
+ String updatedTitle = "modified episode title";
+ String username = "username";
+ String password = "password";
+
+ // update feed hosted on server
+ feed.getItems().get(0).setTitle(updatedTitle);
+ uiTestUtils.hostFeed(feed);
+
+ // interact with UI to update authentication settings
+ updateAuthenticationSettings(username, password);
+
+ // expect feed to have refreshed and be showing new episode title
+ onView(isRoot()).perform(waitForView(withText(updatedTitle), 5000));
+
+ // expect database to be updated with correct username and password
+ Feed updatedFeed = DBReader.getFeed(feed.getId());
+ assertNotNull(updatedFeed);
+
+ FeedPreferences updatedFeedPreferences = updatedFeed.getPreferences();
+ assertNotNull(updatedFeedPreferences);
+
+ assertEquals("database updated with username", username, updatedFeedPreferences.getUsername());
+ assertEquals("database updated with password", password, updatedFeedPreferences.getPassword());
+ }
+
+ private void updateAuthenticationSettings(String username, String password) {
+ onView(withId(R.id.butShowSettings)).perform(click());
+
+ clickPreference(R.string.authentication_label);
+ onView(withId(R.id.usernameEditText)).perform(typeText(username));
+ onView(withId(R.id.passwordEditText)).perform(typeText(password));
+ onView(withText(R.string.confirm_label)).perform(click());
+
+ onView(isRoot()).perform(pressBack());
+ }
+
}
diff --git a/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java b/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java
index 44a11d9cf..c03480fc6 100644
--- a/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java
+++ b/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java
@@ -78,7 +78,7 @@ public class UITestUtils {
}
}
- private String hostFeed(Feed feed) throws IOException {
+ public String hostFeed(Feed feed) throws IOException {
File feedFile = new File(hostedFeedDir, feed.getTitle());
FileOutputStream out = new FileOutputStream(feedFile);
Rss2Generator generator = new Rss2Generator();