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 org.adblockplus.libadblockplus.Filter; | 20 import org.adblockplus.libadblockplus.Filter; |
21 import org.adblockplus.libadblockplus.FilterEngine; | 21 import org.adblockplus.libadblockplus.FilterEngine; |
| 22 import org.adblockplus.libadblockplus.LazyWebRequest; |
22 import org.adblockplus.libadblockplus.MockFilterChangeCallback; | 23 import org.adblockplus.libadblockplus.MockFilterChangeCallback; |
23 import org.adblockplus.libadblockplus.Subscription; | 24 import org.adblockplus.libadblockplus.Subscription; |
24 | 25 |
25 import org.junit.Test; | 26 import org.junit.Test; |
26 | 27 |
27 public class FilterEngineTest extends FilterEngineGenericTest | 28 public class FilterEngineTest extends FilterEngineGenericTest |
28 { | 29 { |
29 @Test | 30 @Test |
30 public void testFilterCreation() | 31 public void testFilterCreation() |
31 { | 32 { |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 "http://example.org/", | 314 "http://example.org/", |
314 "http://example.com/" | 315 "http://example.com/" |
315 }); | 316 }); |
316 assertNotNull(match5); | 317 assertNotNull(match5); |
317 assertEquals(Filter.Type.EXCEPTION, match5.getType()); | 318 assertEquals(Filter.Type.EXCEPTION, match5.getType()); |
318 } | 319 } |
319 | 320 |
320 @Test | 321 @Test |
321 public void testFirstRunFlag() | 322 public void testFirstRunFlag() |
322 { | 323 { |
323 assertFalse(filterEngine.isFirstRun()); | 324 jsEngine.setWebRequest(new LazyWebRequest()); |
| 325 jsEngine.setDefaultLogSystem(); |
| 326 |
| 327 LazyFileSystem lazyFileSystem = new LazyFileSystem(); |
| 328 lazyFileSystem.setPatternsIniExists(false); |
| 329 jsEngine.setFileSystem(lazyFileSystem); |
| 330 |
| 331 filterEngine = new FilterEngine(jsEngine); |
| 332 assertTrue(filterEngine.isFirstRun()); |
324 } | 333 } |
325 | 334 |
326 @Test | 335 @Test |
327 public void testSetRemoveFilterChangeCallback() | 336 public void testSetRemoveFilterChangeCallback() |
328 { | 337 { |
329 MockFilterChangeCallback mockFilterChangeCallback = new MockFilterChange
Callback(0); | 338 MockFilterChangeCallback mockFilterChangeCallback = new MockFilterChange
Callback(0); |
330 | 339 |
331 filterEngine.setFilterChangeCallback(mockFilterChangeCallback); | 340 filterEngine.setFilterChangeCallback(mockFilterChangeCallback); |
332 filterEngine.getFilter("foo").addToList(); | 341 filterEngine.getFilter("foo").addToList(); |
333 assertEquals(1, mockFilterChangeCallback.getTimesCalled()); | 342 assertEquals(1, mockFilterChangeCallback.getTimesCalled()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 assertFalse(filterEngine.isElemhideWhitelisted("http://example.com", emp
tyArray)); | 383 assertFalse(filterEngine.isElemhideWhitelisted("http://example.com", emp
tyArray)); |
375 | 384 |
376 String[] documentUrls1 = new String[] | 385 String[] documentUrls1 = new String[] |
377 { | 386 { |
378 "http://example.de" | 387 "http://example.de" |
379 }; | 388 }; |
380 assertTrue(filterEngine.isElemhideWhitelisted("http://example.com", docu
mentUrls1)); | 389 assertTrue(filterEngine.isElemhideWhitelisted("http://example.com", docu
mentUrls1)); |
381 assertFalse(filterEngine.isElemhideWhitelisted("http://example.co.uk", d
ocumentUrls1)); | 390 assertFalse(filterEngine.isElemhideWhitelisted("http://example.co.uk", d
ocumentUrls1)); |
382 } | 391 } |
383 } | 392 } |
OLD | NEW |