Search in sources :

Example 6 with FeedFilter

use of de.danoeh.antennapod.model.feed.FeedFilter in project AntennaPod by AntennaPod.

the class FeedFilterTest method testComplexExcludeFilter.

@Test
public void testComplexExcludeFilter() {
    String excludeFilter = "Hello \"Two words\"";
    FeedFilter filter = new FeedFilter("", excludeFilter);
    FeedItem item = new FeedItem();
    item.setTitle("hello world");
    FeedItem item2 = new FeedItem();
    item2.setTitle("One three words");
    FeedItem item3 = new FeedItem();
    item3.setTitle("One two words");
    assertTrue(filter.excludeOnly());
    assertFalse(filter.includeOnly());
    assertEquals(excludeFilter, filter.getExcludeFilter());
    assertEquals("", filter.getIncludeFilter());
    assertFalse(filter.shouldAutoDownload(item));
    assertTrue(filter.shouldAutoDownload(item2));
    assertFalse(filter.shouldAutoDownload(item3));
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedFilter(de.danoeh.antennapod.model.feed.FeedFilter) Test(org.junit.Test)

Example 7 with FeedFilter

use of de.danoeh.antennapod.model.feed.FeedFilter in project AntennaPod by AntennaPod.

the class FeedFilterTest method testMinimalDurationFilter.

@Test
public void testMinimalDurationFilter() {
    FeedItem download = new FeedItem();
    download.setTitle("Hello friend!");
    FeedMedia downloadMedia = FeedMediaMother.anyFeedMedia();
    downloadMedia.setDuration(Converter.durationStringShortToMs("05:00", false));
    download.setMedia(downloadMedia);
    // because duration of the media in unknown
    FeedItem download2 = new FeedItem();
    download2.setTitle("Hello friend!");
    FeedMedia unknownDurationMedia = FeedMediaMother.anyFeedMedia();
    download2.setMedia(unknownDurationMedia);
    // because it is not long enough
    FeedItem doNotDownload = new FeedItem();
    doNotDownload.setTitle("Hello friend!");
    FeedMedia doNotDownloadMedia = FeedMediaMother.anyFeedMedia();
    doNotDownloadMedia.setDuration(Converter.durationStringShortToMs("02:00", false));
    doNotDownload.setMedia(doNotDownloadMedia);
    int minimalDurationFilter = 3 * 60;
    FeedFilter filter = new FeedFilter("", "", minimalDurationFilter);
    assertTrue(filter.hasMinimalDurationFilter());
    assertTrue(filter.shouldAutoDownload(download));
    assertFalse(filter.shouldAutoDownload(doNotDownload));
    assertTrue(filter.shouldAutoDownload(download2));
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) FeedFilter(de.danoeh.antennapod.model.feed.FeedFilter) Test(org.junit.Test)

Example 8 with FeedFilter

use of de.danoeh.antennapod.model.feed.FeedFilter in project AntennaPod by AntennaPod.

the class FeedFilterTest method testNullFilter.

@Test
public void testNullFilter() {
    FeedFilter filter = new FeedFilter();
    FeedItem item = new FeedItem();
    item.setTitle("Hello world");
    assertFalse(filter.excludeOnly());
    assertFalse(filter.includeOnly());
    assertEquals("", filter.getExcludeFilter());
    assertEquals("", filter.getIncludeFilter());
    assertTrue(filter.shouldAutoDownload(item));
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedFilter(de.danoeh.antennapod.model.feed.FeedFilter) Test(org.junit.Test)

Aggregations

FeedFilter (de.danoeh.antennapod.model.feed.FeedFilter)8 FeedItem (de.danoeh.antennapod.model.feed.FeedItem)7 Test (org.junit.Test)7 NonNull (androidx.annotation.NonNull)1 FeedMedia (de.danoeh.antennapod.model.feed.FeedMedia)1 FeedPreferences (de.danoeh.antennapod.model.feed.FeedPreferences)1 VolumeAdaptionSetting (de.danoeh.antennapod.model.feed.VolumeAdaptionSetting)1