Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineTest.java

Issue 29405564: Issue 5121 - Use Acceptable Ads API in libadblockplus (Closed)
Patch Set: removed comment Created April 28, 2017, 6:20 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineTest.java
diff --git a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineTest.java b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineTest.java
index 23952b6201679804d9b05910abbd033db0817edf..a7136778e703e7a29f172eebd154eb725b5a3fb7 100644
--- a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineTest.java
+++ b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineTest.java
@@ -17,7 +17,6 @@
package org.adblockplus.libadblockplus.tests;
-import android.util.Log;
import org.adblockplus.libadblockplus.Filter;
import org.adblockplus.libadblockplus.FilterEngine;
import org.adblockplus.libadblockplus.MockFilterChangeCallback;
@@ -25,6 +24,8 @@ import org.adblockplus.libadblockplus.Subscription;
import org.junit.Test;
+import java.util.List;
+
public class FilterEngineTest extends FilterEngineGenericTest
{
@Test
@@ -385,4 +386,43 @@ public class FilterEngineTest extends FilterEngineGenericTest
assertTrue(filterEngine.isElemhideWhitelisted("http://example.com", documentUrls1));
assertFalse(filterEngine.isElemhideWhitelisted("http://example.co.uk", documentUrls1));
}
+
+ @Test
+ public void testGetAcceptableAdsSubscriptionUrl()
+ {
+ String url = filterEngine.getAcceptableAdsSubscriptionURL();
+ assertNotNull(url);
+ }
+
+ @Test
+ public void testSetGetAcceptableAds()
+ {
+ boolean isAA = filterEngine.isAcceptableAdsEnabled();
+ isAA = !isAA;
+ filterEngine.setAcceptableAdsEnabled(isAA);
+ assertEquals(isAA, filterEngine.isAcceptableAdsEnabled());
+ isAA = !isAA;
+ filterEngine.setAcceptableAdsEnabled(isAA);
+ assertEquals(isAA, filterEngine.isAcceptableAdsEnabled());
+ }
+
+ @Test
+ public void testIsAcceptableAdsIfEnabled()
+ {
+ if (!filterEngine.isAcceptableAdsEnabled())
+ {
+ filterEngine.setAcceptableAdsEnabled(true);
+ }
+ assertTrue(filterEngine.isAcceptableAdsEnabled());
sergei 2017/05/03 13:58:22 Would it be useful to hard code in tests that by d
anton 2017/05/04 06:20:06 Not sure. Since it's not actually stated anywhere
+
+ List<Subscription> listedSubscriptions = filterEngine.getListedSubscriptions();
+ for (Subscription eachSubscription : listedSubscriptions)
+ {
+ if (eachSubscription.isAcceptableAds())
+ {
+ return;
+ }
+ }
+ fail("AA subscription not found in listed subscriptions when enabled");
+ }
}

Powered by Google App Engine
This is Rietveld