| 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 android.os.SystemClock; | 20 import android.os.SystemClock; |
| 21 | 21 |
| 22 import org.adblockplus.libadblockplus.AppInfo; | |
| 23 import org.adblockplus.libadblockplus.FilterEngine; | 22 import org.adblockplus.libadblockplus.FilterEngine; |
| 24 import org.adblockplus.libadblockplus.HeaderEntry; | 23 import org.adblockplus.libadblockplus.HeaderEntry; |
| 25 import org.adblockplus.libadblockplus.IsAllowedConnectionCallback; | 24 import org.adblockplus.libadblockplus.IsAllowedConnectionCallback; |
| 26 import org.adblockplus.libadblockplus.JsEngine; | 25 import org.adblockplus.libadblockplus.Platform; |
| 27 import org.adblockplus.libadblockplus.ServerResponse; | 26 import org.adblockplus.libadblockplus.ServerResponse; |
| 28 import org.adblockplus.libadblockplus.Subscription; | 27 import org.adblockplus.libadblockplus.Subscription; |
| 29 import org.adblockplus.libadblockplus.WebRequest; | 28 import org.adblockplus.libadblockplus.WebRequest; |
| 30 import org.adblockplus.libadblockplus.android.AndroidWebRequest; | 29 import org.adblockplus.libadblockplus.android.AndroidWebRequest; |
| 31 import org.junit.Test; | 30 import org.junit.Test; |
| 32 | 31 |
| 33 import java.util.LinkedList; | 32 import java.util.LinkedList; |
| 34 import java.util.List; | 33 import java.util.List; |
| 35 | 34 |
| 36 public class IsAllowedConnectionCallbackTest extends BaseFilterEngineTest | 35 public class IsAllowedConnectionCallbackTest extends BaseFilterEngineTest |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 return result; | 88 return result; |
| 90 } | 89 } |
| 91 } | 90 } |
| 92 | 91 |
| 93 private TestRequest request; | 92 private TestRequest request; |
| 94 private TestCallback callback; | 93 private TestCallback callback; |
| 95 | 94 |
| 96 @Override | 95 @Override |
| 97 protected void setUp() throws Exception | 96 protected void setUp() throws Exception |
| 98 { | 97 { |
| 99 jsEngine = new JsEngine(AppInfo.builder().build(), createLogSystem(), create
WebRequest(), | 98 platform = new Platform(createLogSystem(), createWebRequest(), |
| 100 getContext().getFilesDir().getAbsolutePath()); | 99 getContext().getFilesDir().getAbsolutePath()); |
| 101 callback = new TestCallback(); | 100 callback = new TestCallback(); |
| 102 filterEngine = new FilterEngine(jsEngine, callback); | 101 platform.setUpFilterEngine(callback); |
| 102 filterEngine = platform.getFilterEngine(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 @Override | 105 @Override |
| 106 protected WebRequest createWebRequest() | 106 protected WebRequest createWebRequest() |
| 107 { | 107 { |
| 108 return request = new TestRequest(); | 108 return request = new TestRequest(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 private void updateSubscriptions() | 111 private void updateSubscriptions() |
| 112 { | 112 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 updateSubscriptions(); | 155 updateSubscriptions(); |
| 156 SystemClock.sleep(UPDATE_SUBSCRIPTIONS_WAIT_DELAY_MS); | 156 SystemClock.sleep(UPDATE_SUBSCRIPTIONS_WAIT_DELAY_MS); |
| 157 | 157 |
| 158 assertTrue(callback.isInvoked()); | 158 assertTrue(callback.isInvoked()); |
| 159 assertNotNull(callback.getConnectionType()); | 159 assertNotNull(callback.getConnectionType()); |
| 160 assertEquals(allowedConnectionType, callback.getConnectionType()); | 160 assertEquals(allowedConnectionType, callback.getConnectionType()); |
| 161 | 161 |
| 162 assertEquals(0, request.getUrls().size()); | 162 assertEquals(0, request.getUrls().size()); |
| 163 } | 163 } |
| 164 } | 164 } |
| OLD | NEW |