summaryrefslogtreecommitdiff
path: root/app/src/androidTest/java/de/test
diff options
context:
space:
mode:
authororionlee <orionlee@yahoo.com>2019-10-06 15:09:47 -0700
committerorionlee <orionlee@yahoo.com>2019-10-06 15:09:47 -0700
commit27f8e9e9bf78cd550a8261190bd4c1718d1bf6c6 (patch)
treefb8d0f0e3a543c72256347905a30437dda2572ac /app/src/androidTest/java/de/test
parent1ab39fee3ceb84cadee3eaeee9603b2cd16a75e1 (diff)
downloadAntennaPod-27f8e9e9bf78cd550a8261190bd4c1718d1bf6c6.zip
test speedup - replace hardcoded Thread.sleep() with Awaitability
Diffstat (limited to 'app/src/androidTest/java/de/test')
-rw-r--r--app/src/androidTest/java/de/test/antennapod/ui/PlaybackTest.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/ui/PlaybackTest.java b/app/src/androidTest/java/de/test/antennapod/ui/PlaybackTest.java
index f1b17efd5..57a1a4f80 100644
--- a/app/src/androidTest/java/de/test/antennapod/ui/PlaybackTest.java
+++ b/app/src/androidTest/java/de/test/antennapod/ui/PlaybackTest.java
@@ -13,6 +13,7 @@ import android.widget.ListView;
import com.robotium.solo.Solo;
import com.robotium.solo.Timeout;
+import org.awaitility.Awaitility;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -30,6 +31,7 @@ import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.storage.PodDBAdapter;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
@@ -332,11 +334,14 @@ public class PlaybackTest {
playFromQueue(fiIdx);
skipEpisode();
- Thread.sleep(1000); // ensure the skip is processed
- // assert item no longer in queue
- assertThat("Ensure smart mark as play will lead to the item removed from the queue",
- DBReader.getQueue(), not(hasItems(feedItem)));
+ // assert item no longer in queue (needs to wait till skip is asynchronously processed)
+ Awaitility.await()
+ .atMost(1000, MILLISECONDS)
+ .untilAsserted(() -> {
+ assertThat("Ensure smart mark as play will lead to the item removed from the queue",
+ DBReader.getQueue(), not(hasItems(feedItem)));
+ });
assertThat(DBReader.getFeedItem(feedItem.getId()).isPlayed(), is(true));
}
@@ -353,11 +358,14 @@ public class PlaybackTest {
playFromQueue(fiIdx);
// let playback run a bit then pause
- Thread.sleep(500);
+ Awaitility.await()
+ .atMost(1000, MILLISECONDS)
+ .until(() -> PlayerStatus.PLAYING == uiTestUtils.getPlaybackController(getActivity()).getStatus());
pauseEpisode();
- Thread.sleep(1000); // ensure the pause is processed
+ Awaitility.await()
+ .atMost(1000, MILLISECONDS)
+ .until(() -> PlayerStatus.PAUSED == uiTestUtils.getPlaybackController(getActivity()).getStatus());
- // assert item no longer in queue
assertThat("Ensure even with smart mark as play, after pause, the item remains in the queue.",
DBReader.getQueue(), hasItems(feedItem));
assertThat("Ensure even with smart mark as play, after pause, the item played status remains false.",