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: Created April 7, 2017, 7:03 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..16dd10083857a9c1390249096b01e4a839e2a5a3 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,62 @@ 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());
+
+ List<Subscription> listedSubscriptions = filterEngine.getListedSubscriptions();
+ for (Subscription eachSubscription : listedSubscriptions)
+ {
+ if (eachSubscription.isAcceptableAds())
+ {
+ return;
+ }
+ }
+ fail("AA subscription not found in listed subscriptions when enabled");
+ }
+
+ @Test
+ public void testIsAcceptableAdsIfDisabled()
+ {
+ if (filterEngine.isAcceptableAdsEnabled())
+ {
+ filterEngine.setAcceptableAdsEnabled(false);
+ }
+ assertFalse(filterEngine.isAcceptableAdsEnabled());
+
+ List<Subscription> listedSubscriptions = filterEngine.getListedSubscriptions();
+ for (Subscription eachSubscription : listedSubscriptions)
+ {
+ if (eachSubscription.isAcceptableAds())
+ {
+ fail("AA subscription found in listed subscriptions when disabled");
anton 2017/04/07 07:08:17 for some reason the test fails for now
sergei 2017/04/07 08:01:22 You need to also check whether it's disabled. The
anton 2017/04/07 08:06:49 there is (and there were) no 'disabled' property i
sergei 2017/04/07 09:51:03 Actually it's a good point, I think we need either
+ }
+ }
+ }
}

Powered by Google App Engine
This is Rietveld