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: updated dependency to -binaries Created April 7, 2017, 10:14 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
« no previous file with comments | « dependencies ('k') | libadblockplus-android/jni/JniFilterEngine.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9cbfe8ae66d66ec32546b2d9f59aa784e24183e5 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,45 @@ 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()
+ {
+ // `.setAcceptableAdsEnabled(true)` is not required, as we're having
+ // AA subscription listed even if AA is disabled with `filterEngine.setAcceptableAdsEnabled(false);`
sergei 2017/04/07 10:22:39 If there is no AA then `filterEngine.setAcceptable
diegocarloslima 2017/04/27 13:32:01 I think this comment should be removed, since as s
anton 2017/04/28 06:21:36 Done. See updated patch set
+ 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");
+ }
}
« no previous file with comments | « dependencies ('k') | libadblockplus-android/jni/JniFilterEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld