OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 package org.adblockplus.libadblockplus.tests; | 18 package org.adblockplus.libadblockplus.tests; |
19 | 19 |
20 import android.util.Log; | |
21 import org.adblockplus.libadblockplus.Filter; | 20 import org.adblockplus.libadblockplus.Filter; |
22 import org.adblockplus.libadblockplus.FilterEngine; | 21 import org.adblockplus.libadblockplus.FilterEngine; |
23 import org.adblockplus.libadblockplus.MockFilterChangeCallback; | 22 import org.adblockplus.libadblockplus.MockFilterChangeCallback; |
24 import org.adblockplus.libadblockplus.Subscription; | 23 import org.adblockplus.libadblockplus.Subscription; |
25 | 24 |
26 import org.junit.Test; | 25 import org.junit.Test; |
27 | 26 |
| 27 import java.util.List; |
| 28 |
28 public class FilterEngineTest extends FilterEngineGenericTest | 29 public class FilterEngineTest extends FilterEngineGenericTest |
29 { | 30 { |
30 @Test | 31 @Test |
31 public void testFilterCreation() | 32 public void testFilterCreation() |
32 { | 33 { |
33 Filter filter1 = filterEngine.getFilter("foo"); | 34 Filter filter1 = filterEngine.getFilter("foo"); |
34 assertEquals(Filter.Type.BLOCKING, filter1.getType()); | 35 assertEquals(Filter.Type.BLOCKING, filter1.getType()); |
35 Filter filter2 = filterEngine.getFilter("@@foo"); | 36 Filter filter2 = filterEngine.getFilter("@@foo"); |
36 assertEquals(Filter.Type.EXCEPTION, filter2.getType()); | 37 assertEquals(Filter.Type.EXCEPTION, filter2.getType()); |
37 Filter filter3 = filterEngine.getFilter("example.com##foo"); | 38 Filter filter3 = filterEngine.getFilter("example.com##foo"); |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 assertFalse(filterEngine.isElemhideWhitelisted("http://example.co.uk", empty
Array)); | 379 assertFalse(filterEngine.isElemhideWhitelisted("http://example.co.uk", empty
Array)); |
379 assertFalse(filterEngine.isElemhideWhitelisted("http://example.com", emptyAr
ray)); | 380 assertFalse(filterEngine.isElemhideWhitelisted("http://example.com", emptyAr
ray)); |
380 | 381 |
381 String[] documentUrls1 = new String[] | 382 String[] documentUrls1 = new String[] |
382 { | 383 { |
383 "http://example.de" | 384 "http://example.de" |
384 }; | 385 }; |
385 assertTrue(filterEngine.isElemhideWhitelisted("http://example.com", document
Urls1)); | 386 assertTrue(filterEngine.isElemhideWhitelisted("http://example.com", document
Urls1)); |
386 assertFalse(filterEngine.isElemhideWhitelisted("http://example.co.uk", docum
entUrls1)); | 387 assertFalse(filterEngine.isElemhideWhitelisted("http://example.co.uk", docum
entUrls1)); |
387 } | 388 } |
| 389 |
| 390 @Test |
| 391 public void testGetAcceptableAdsSubscriptionUrl() |
| 392 { |
| 393 String url = filterEngine.getAcceptableAdsSubscriptionURL(); |
| 394 assertNotNull(url); |
| 395 } |
| 396 |
| 397 @Test |
| 398 public void testSetGetAcceptableAds() |
| 399 { |
| 400 boolean isAA = filterEngine.isAcceptableAdsEnabled(); |
| 401 isAA = !isAA; |
| 402 filterEngine.setAcceptableAdsEnabled(isAA); |
| 403 assertEquals(isAA, filterEngine.isAcceptableAdsEnabled()); |
| 404 isAA = !isAA; |
| 405 filterEngine.setAcceptableAdsEnabled(isAA); |
| 406 assertEquals(isAA, filterEngine.isAcceptableAdsEnabled()); |
| 407 } |
| 408 |
| 409 @Test |
| 410 public void testIsAcceptableAdsIfEnabled() |
| 411 { |
| 412 if (!filterEngine.isAcceptableAdsEnabled()) |
| 413 { |
| 414 filterEngine.setAcceptableAdsEnabled(true); |
| 415 } |
| 416 assertTrue(filterEngine.isAcceptableAdsEnabled()); |
| 417 |
| 418 List<Subscription> listedSubscriptions = filterEngine.getListedSubscriptions
(); |
| 419 for (Subscription eachSubscription : listedSubscriptions) |
| 420 { |
| 421 if (eachSubscription.isAcceptableAds()) |
| 422 { |
| 423 return; |
| 424 } |
| 425 } |
| 426 fail("AA subscription not found in listed subscriptions when enabled"); |
| 427 } |
388 } | 428 } |
OLD | NEW |