From a788f61a6acb45227b5b15b5d37dadfdee115e1c Mon Sep 17 00:00:00 2001 From: eraymond Date: Wed, 28 Sep 2016 19:37:08 -0700 Subject: [PATCH] Added tests for preference settings to customize fastforward and rewind delta. --- .../test/antennapod/ui/PreferencesTest.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) 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 040f4150b..8d8d727bd 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,12 @@ package de.test.antennapod.ui; import android.content.Context; import android.content.res.Resources; import android.test.ActivityInstrumentationTestCase2; +import android.util.Log; import com.robotium.solo.Solo; import com.robotium.solo.Timeout; +import java.util.Arrays; import java.util.concurrent.TimeUnit; import de.danoeh.antennapod.R; @@ -362,4 +364,57 @@ public class PreferencesTest extends ActivityInstrumentationTestCase2= 0 && currentIndex < deltas.length); // found? + + // Find next value (wrapping around to next) + int newIndex = (currentIndex + 1) % deltas.length; + + solo.clickOnText(String.valueOf(deltas[newIndex]) + " seconds"); + solo.clickOnButton("Confirm"); + + solo.waitForDialogToClose(); + assertTrue(solo.waitForCondition(() -> UserPreferences.getRewindSecs() == deltas[newIndex], + Timeout.getLargeTimeout())); + + //Log.d("PreferencesTest", "After rewind secs: " + UserPreferences.getRewindSecs()); + + } + + public void testFastForwardChange() { + for (int i = 2; i > 0; i--) { // repeat twice to catch any error where fastforward is tracking rewind + int seconds = UserPreferences.getFastForwardSecs(); + int deltas[] = res.getIntArray(R.array.seek_delta_values); + + //Log.d("PreferencesTest", "Before fastForward secs: " + UserPreferences.getFastForwardSecs()); + + solo.clickOnText(solo.getString(R.string.pref_fast_forward)); + solo.waitForDialogToOpen(); + + int currentIndex = Arrays.binarySearch(deltas, seconds); + assertTrue(currentIndex >= 0 && currentIndex < deltas.length); // found? + + // Find next value (wrapping around to next) + int newIndex = (currentIndex + 1) % deltas.length; + + solo.clickOnText(String.valueOf(deltas[newIndex]) + " seconds"); + solo.clickOnButton("Confirm"); + + solo.waitForDialogToClose(); + assertTrue(solo.waitForCondition(() -> UserPreferences.getFastForwardSecs() == deltas[newIndex], + Timeout.getLargeTimeout())); + + //Log.d("PreferencesTest", "After fastForward secs: " + UserPreferences.getFastForwardSecs()); + } + } }