From 6f3d748aa0a8d35f43adb68796428c7ae37fe51e Mon Sep 17 00:00:00 2001 From: Tom Hennen Date: Fri, 2 Oct 2015 16:50:08 -0400 Subject: [PATCH] episode cleanup preferences tests --- .../test/antennapod/ui/PreferencesTest.java | 42 +++++++++++++++++++ app/src/main/res/xml/preferences.xml | 4 +- .../core/storage/APCleanupAlgorithm.java | 2 + 3 files changed, 46 insertions(+), 2 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 8a9e230fe..fc1eb4e56 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java @@ -19,6 +19,10 @@ import java.util.concurrent.TimeUnit; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.PreferenceActivity; import de.danoeh.antennapod.core.preferences.UserPreferences; +import de.danoeh.antennapod.core.storage.APCleanupAlgorithm; +import de.danoeh.antennapod.core.storage.APNullCleanupAlgorithm; +import de.danoeh.antennapod.core.storage.APQueueCleanupAlgorithm; +import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithm; public class PreferencesTest extends ActivityInstrumentationTestCase2 { @@ -265,4 +269,42 @@ public class PreferencesTest extends ActivityInstrumentationTestCase2 enableWifiFilter == UserPreferences.isEnableAutodownloadWifiFilter(), Timeout.getLargeTimeout())); } + + public void testEpisodeCleanupQueueOnly() { + solo.clickOnText(solo.getString(R.string.pref_episode_cleanup_title)); + solo.waitForText(solo.getString(R.string.episode_cleanup_queue_removal)); + solo.clickOnText(solo.getString(R.string.episode_cleanup_queue_removal)); + assertTrue(solo.waitForCondition(() -> { + EpisodeCleanupAlgorithm alg = UserPreferences.getEpisodeCleanupAlgorithm(); + return alg instanceof APQueueCleanupAlgorithm; + }, + Timeout.getLargeTimeout())); + } + + public void testEpisodeCleanupNeverAlg() { + solo.clickOnText(solo.getString(R.string.pref_episode_cleanup_title)); + solo.waitForText(solo.getString(R.string.episode_cleanup_never)); + solo.clickOnText(solo.getString(R.string.episode_cleanup_never)); + assertTrue(solo.waitForCondition(() -> { + EpisodeCleanupAlgorithm alg = UserPreferences.getEpisodeCleanupAlgorithm(); + return alg instanceof APNullCleanupAlgorithm; + }, + Timeout.getLargeTimeout())); + } + + public void testEpisodeCleanupClassic() { + solo.clickOnText(solo.getString(R.string.pref_episode_cleanup_title)); + solo.waitForText(solo.getString(R.string.episode_cleanup_after_listening)); + solo.clickOnText(solo.getString(R.string.episode_cleanup_after_listening)); + assertTrue(solo.waitForCondition(() -> { + EpisodeCleanupAlgorithm alg = UserPreferences.getEpisodeCleanupAlgorithm(); + if (alg instanceof APCleanupAlgorithm) { + APCleanupAlgorithm cleanupAlg = (APCleanupAlgorithm)alg; + return cleanupAlg.getNumberOfDaysAfterPlayback() == 0; + } + return false; + }, + Timeout.getLargeTimeout())); + } + } diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 6f058b257..d97b7c5bf 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -139,12 +139,12 @@ android:title="@string/pref_mobileUpdate_title"/> + android:entryValues="@array/episode_cleanup_values"/>