| LEFT | RIGHT |
| (no file at all) | |
| 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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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.os.SystemClock; |
| 20 import android.util.Log; | 21 import android.util.Log; |
| 21 import org.adblockplus.libadblockplus.Filter; | 22 import org.adblockplus.libadblockplus.Filter; |
| 22 import org.adblockplus.libadblockplus.FilterEngine; | 23 import org.adblockplus.libadblockplus.FilterEngine; |
| 23 import org.adblockplus.libadblockplus.MockFilterChangeCallback; | 24 import org.adblockplus.libadblockplus.MockFilterChangeCallback; |
| 24 import org.adblockplus.libadblockplus.Subscription; | 25 import org.adblockplus.libadblockplus.Subscription; |
| 25 | 26 |
| 26 import org.junit.Test; | 27 import org.junit.Test; |
| 27 | 28 |
| 28 public class FilterEngineTest extends FilterEngineGenericTest | 29 public class FilterEngineTest extends FilterEngineGenericTest |
| 29 { | 30 { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 325 |
| 325 @Test | 326 @Test |
| 326 public void testFirstRunFlag() | 327 public void testFirstRunFlag() |
| 327 { | 328 { |
| 328 assertFalse(filterEngine.isFirstRun()); | 329 assertFalse(filterEngine.isFirstRun()); |
| 329 } | 330 } |
| 330 | 331 |
| 331 @Test | 332 @Test |
| 332 public void testSetRemoveFilterChangeCallback() | 333 public void testSetRemoveFilterChangeCallback() |
| 333 { | 334 { |
| 335 // avoid callback with action "load" |
| 336 while (filterEngine.getListedFilters().size() > 0) |
| 337 { |
| 338 filterEngine.getListedFilters().get(0).removeFromList(); |
| 339 } |
| 340 |
| 334 MockFilterChangeCallback mockFilterChangeCallback = new MockFilterChangeCall
back(0); | 341 MockFilterChangeCallback mockFilterChangeCallback = new MockFilterChangeCall
back(0); |
| 335 | 342 |
| 336 filterEngine.setFilterChangeCallback(mockFilterChangeCallback); | 343 filterEngine.setFilterChangeCallback(mockFilterChangeCallback); |
| 337 filterEngine.getFilter("foo").addToList(); | 344 filterEngine.getFilter("foo").addToList(); |
| 338 assertEquals(1, mockFilterChangeCallback.getTimesCalled()); | 345 assertEquals(1, mockFilterChangeCallback.getTimesCalled()); |
| 339 | 346 |
| 340 filterEngine.removeFilterChangeCallback(); | 347 filterEngine.removeFilterChangeCallback(); |
| 341 filterEngine.getFilter("foo").removeFromList(); | 348 filterEngine.getFilter("foo").removeFromList(); |
| 342 assertEquals(1, mockFilterChangeCallback.getTimesCalled()); | 349 assertEquals(1, mockFilterChangeCallback.getTimesCalled()); |
| 343 } | 350 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 assertFalse(filterEngine.isElemhideWhitelisted("http://example.com", emptyAr
ray)); | 386 assertFalse(filterEngine.isElemhideWhitelisted("http://example.com", emptyAr
ray)); |
| 380 | 387 |
| 381 String[] documentUrls1 = new String[] | 388 String[] documentUrls1 = new String[] |
| 382 { | 389 { |
| 383 "http://example.de" | 390 "http://example.de" |
| 384 }; | 391 }; |
| 385 assertTrue(filterEngine.isElemhideWhitelisted("http://example.com", document
Urls1)); | 392 assertTrue(filterEngine.isElemhideWhitelisted("http://example.com", document
Urls1)); |
| 386 assertFalse(filterEngine.isElemhideWhitelisted("http://example.co.uk", docum
entUrls1)); | 393 assertFalse(filterEngine.isElemhideWhitelisted("http://example.co.uk", docum
entUrls1)); |
| 387 } | 394 } |
| 388 } | 395 } |
| LEFT | RIGHT |