use of android.test.FlakyTest in project AntennaPod by AntennaPod.
the class DBCleanupTests method testPerformAutoCleanupShouldNotDeleteBecauseInQueue.
@FlakyTest(tolerance = 3)
public void testPerformAutoCleanupShouldNotDeleteBecauseInQueue() throws IOException {
final int NUM_ITEMS = EPISODE_CACHE_SIZE * 2;
Feed feed = new Feed("url", null, "title");
List<FeedItem> items = new ArrayList<>();
feed.setItems(items);
List<File> files = new ArrayList<>();
populateItems(NUM_ITEMS, feed, items, files, FeedItem.PLAYED, true, false);
DBTasks.performAutoCleanup(context);
for (File file : files) {
assertTrue(file.exists());
}
}
use of android.test.FlakyTest in project AntennaPod by AntennaPod.
the class DBNullCleanupAlgorithmTest method testPerformAutoCleanupShouldNotDelete.
/**
* A test with no items in the queue, but multiple items downloaded.
* The null algorithm should never delete any items, even if they're played and not in the queue.
* @throws IOException
*/
@FlakyTest(tolerance = 3)
public void testPerformAutoCleanupShouldNotDelete() throws IOException {
final int NUM_ITEMS = EPISODE_CACHE_SIZE * 2;
Feed feed = new Feed("url", null, "title");
List<FeedItem> items = new ArrayList<>();
feed.setItems(items);
List<File> files = new ArrayList<>();
for (int i = 0; i < NUM_ITEMS; i++) {
FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), FeedItem.PLAYED, feed);
File f = new File(destFolder, "file " + i);
assertTrue(f.createNewFile());
files.add(f);
item.setMedia(new FeedMedia(0, item, 1, 0, 1L, "m", f.getAbsolutePath(), "url", true, new Date(NUM_ITEMS - i), 0, 0));
items.add(item);
}
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
adapter.setCompleteFeed(feed);
adapter.close();
assertTrue(feed.getId() != 0);
for (FeedItem item : items) {
assertTrue(item.getId() != 0);
assertTrue(item.getMedia().getId() != 0);
}
DBTasks.performAutoCleanup(context);
for (int i = 0; i < files.size(); i++) {
assertTrue(files.get(i).exists());
}
}
use of android.test.FlakyTest in project AntennaPod by AntennaPod.
the class DBQueueCleanupAlgorithmTest method testPerformAutoCleanupHandleUnplayed.
/**
* For APQueueCleanupAlgorithm we expect even unplayed episodes to be deleted if needed
* if they aren't in the queue
*/
@FlakyTest(tolerance = 3)
public void testPerformAutoCleanupHandleUnplayed() throws IOException {
final int NUM_ITEMS = EPISODE_CACHE_SIZE * 2;
Feed feed = new Feed("url", null, "title");
List<FeedItem> items = new ArrayList<>();
feed.setItems(items);
List<File> files = new ArrayList<>();
populateItems(NUM_ITEMS, feed, items, files, FeedItem.UNPLAYED, false, false);
DBTasks.performAutoCleanup(context);
for (int i = 0; i < files.size(); i++) {
if (i < EPISODE_CACHE_SIZE) {
assertTrue(files.get(i).exists());
} else {
assertFalse(files.get(i).exists());
}
}
}
use of android.test.FlakyTest in project AntennaPod by AntennaPod.
the class PlaybackSonicTest method testContinousPlaybackOffMultipleEpisodes.
@FlakyTest(tolerance = 3)
public void testContinousPlaybackOffMultipleEpisodes() throws Exception {
setContinuousPlaybackPreference(false);
uiTestUtils.addLocalFeedData(true);
List<FeedItem> queue = DBReader.getQueue();
final FeedItem first = queue.get(0);
startLocalPlaybackFromQueue();
boolean stopped = solo.waitForCondition(() -> {
if (uiTestUtils.getPlaybackController(getActivity()).getStatus() != PlayerStatus.PLAYING) {
return true;
} else if (uiTestUtils.getCurrentMedia(getActivity()) != null) {
return uiTestUtils.getCurrentMedia(getActivity()).getId() != first.getMedia().getId();
} else {
return true;
}
}, Timeout.getSmallTimeout());
assertTrue(stopped);
Thread.sleep(1000);
PlayerStatus status = uiTestUtils.getPlaybackController(getActivity()).getStatus();
assertFalse(status.equals(PlayerStatus.PLAYING));
}
use of android.test.FlakyTest in project AntennaPod by AntennaPod.
the class PlaybackSonicTest method testContinuousPlaybackOnMultipleEpisodes.
@FlakyTest(tolerance = 3)
public void testContinuousPlaybackOnMultipleEpisodes() throws Exception {
setContinuousPlaybackPreference(true);
uiTestUtils.addLocalFeedData(true);
List<FeedItem> queue = DBReader.getQueue();
final FeedItem first = queue.get(0);
final FeedItem second = queue.get(1);
startLocalPlaybackFromQueue();
boolean firstPlaying = solo.waitForCondition(() -> {
if (uiTestUtils.getCurrentMedia(getActivity()) != null) {
return uiTestUtils.getCurrentMedia(getActivity()).getId() == first.getMedia().getId();
} else {
return false;
}
}, Timeout.getSmallTimeout());
assertTrue(firstPlaying);
boolean secondPlaying = solo.waitForCondition(() -> {
if (uiTestUtils.getCurrentMedia(getActivity()) != null) {
return uiTestUtils.getCurrentMedia(getActivity()).getId() == second.getMedia().getId();
} else {
return false;
}
}, Timeout.getLargeTimeout());
assertTrue(secondPlaying);
}
Aggregations