| 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-present eyeo GmbH | 3  * Copyright (C) 2006-present 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.AppInfo; | 20 import org.adblockplus.libadblockplus.AppInfo; | 
| 21 import org.adblockplus.libadblockplus.EventCallback; | 21 import org.adblockplus.libadblockplus.EventCallback; | 
| 22 import org.adblockplus.libadblockplus.FilterEngine; | 22 import org.adblockplus.libadblockplus.FilterEngine; | 
| 23 import org.adblockplus.libadblockplus.HeaderEntry; | 23 import org.adblockplus.libadblockplus.HeaderEntry; | 
| 24 import org.adblockplus.libadblockplus.JsEngine; | 24 import org.adblockplus.libadblockplus.JsEngine; | 
| 25 import org.adblockplus.libadblockplus.JsValue; | 25 import org.adblockplus.libadblockplus.JsValue; | 
| 26 import org.adblockplus.libadblockplus.LazyLogSystem; | 26 import org.adblockplus.libadblockplus.LazyLogSystem; | 
| 27 import org.adblockplus.libadblockplus.LazyWebRequest; | 27 import org.adblockplus.libadblockplus.LazyWebRequest; | 
|  | 28 import org.adblockplus.libadblockplus.Platform; | 
| 28 import org.adblockplus.libadblockplus.ServerResponse; | 29 import org.adblockplus.libadblockplus.ServerResponse; | 
| 29 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; | 30 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; | 
| 30 | 31 | 
| 31 import org.junit.Test; | 32 import org.junit.Test; | 
| 32 | 33 | 
| 33 import java.util.List; | 34 import java.util.List; | 
| 34 | 35 | 
| 35 public class UpdateCheckTest extends BaseFilterEngineTest | 36 public class UpdateCheckTest extends BaseFilterEngineTest | 
| 36 { | 37 { | 
| 37   protected String previousRequestUrl; | 38   protected String previousRequestUrl; | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 77     public void updateCheckDoneCallback(String error) | 78     public void updateCheckDoneCallback(String error) | 
| 78     { | 79     { | 
| 79       updateCallbackCalled = true; | 80       updateCallbackCalled = true; | 
| 80       updateError = error; | 81       updateError = error; | 
| 81     } | 82     } | 
| 82   }; | 83   }; | 
| 83 | 84 | 
| 84   public void reset() throws InterruptedException | 85   public void reset() throws InterruptedException | 
| 85   { | 86   { | 
| 86     disposeFilterEngine(); | 87     disposeFilterEngine(); | 
| 87     if (jsEngine != null) | 88     if (platform != null) | 
| 88     { | 89     { | 
| 89       jsEngine.dispose(); | 90       platform.dispose(); | 
| 90     } | 91     } | 
| 91     jsEngine = new JsEngine(appInfo, new LazyLogSystem(), webRequest, | 92     platform = new Platform(new LazyLogSystem(), webRequest, | 
| 92         getContext().getFilesDir().getAbsolutePath()); | 93         getContext().getFilesDir().getAbsolutePath()); | 
| 93     jsEngine.setEventCallback("updateAvailable", eventCallback); | 94     platform.setUpJsEngine(appInfo); | 
| 94     filterEngine = new FilterEngine(jsEngine); | 95     platform.getJsEngine().setEventCallback("updateAvailable", eventCallback); | 
|  | 96     filterEngine = platform.getFilterEngine(); | 
| 95   } | 97   } | 
| 96 | 98 | 
| 97   @Override | 99   @Override | 
| 98   protected void setUp() throws Exception | 100   protected void setUp() throws Exception | 
| 99   { | 101   { | 
| 100     appInfo = AppInfo.builder().build(); | 102     appInfo = AppInfo.builder().build(); | 
| 101     webRequest = new TestWebRequest(); | 103     webRequest = new TestWebRequest(); | 
| 102     eventCallbackCalled = false; | 104     eventCallbackCalled = false; | 
| 103     updateCallbackCalled = false; | 105     updateCallbackCalled = false; | 
| 104     reset(); | 106     reset(); | 
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 256     reset(); | 258     reset(); | 
| 257     forceUpdateCheck(); | 259     forceUpdateCheck(); | 
| 258 | 260 | 
| 259     Thread.sleep(1000); | 261     Thread.sleep(1000); | 
| 260 | 262 | 
| 261     assertFalse(eventCallbackCalled); | 263     assertFalse(eventCallbackCalled); | 
| 262     assertTrue(updateCallbackCalled); | 264     assertTrue(updateCallbackCalled); | 
| 263     assertTrue(updateError.length() > 0); | 265     assertTrue(updateError.length() > 0); | 
| 264   } | 266   } | 
| 265 } | 267 } | 
| OLD | NEW | 
|---|