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.Platform; |
21 import org.adblockplus.libadblockplus.JsEngine; | |
22 import org.adblockplus.libadblockplus.LazyLogSystem; | |
23 import org.adblockplus.libadblockplus.LogSystem; | 21 import org.adblockplus.libadblockplus.LogSystem; |
24 import org.adblockplus.libadblockplus.ThrowingWebRequest; | 22 import org.adblockplus.libadblockplus.ThrowingWebRequest; |
25 import org.adblockplus.libadblockplus.WebRequest; | 23 import org.adblockplus.libadblockplus.WebRequest; |
26 | 24 |
27 import android.content.Context; | 25 import android.content.Context; |
28 import android.test.InstrumentationTestCase; | 26 import android.test.InstrumentationTestCase; |
29 | 27 |
30 public abstract class BaseJsEngineTest extends InstrumentationTestCase | 28 public abstract class BasePlatformTest extends InstrumentationTestCase |
31 { | 29 { |
32 protected JsEngine jsEngine; | 30 protected Platform platform; |
33 | 31 |
34 @Override | 32 @Override |
35 protected void setUp() throws Exception | 33 protected void setUp() throws Exception |
36 { | 34 { |
37 super.setUp(); | 35 super.setUp(); |
38 | 36 platform = new Platform(createLogSystem(), createWebRequest(), |
39 jsEngine = new JsEngine(AppInfo.builder().build(), createLogSystem(), create
WebRequest(), | |
40 getContext().getFilesDir().getAbsolutePath()); | 37 getContext().getFilesDir().getAbsolutePath()); |
41 } | 38 } |
42 | 39 |
43 @Override | 40 @Override |
44 protected void tearDown() throws Exception | 41 protected void tearDown() throws Exception |
45 { | 42 { |
46 if (jsEngine != null) | 43 if (platform != null) |
47 { | 44 { |
48 jsEngine.dispose(); | 45 platform.dispose(); |
49 jsEngine = null; | 46 platform = null; |
50 } | 47 } |
| 48 super.tearDown(); |
51 } | 49 } |
52 | 50 |
53 // If the method returns null then a default implementation of the Log System | 51 // If the method returns null then a default implementation of the Log System |
54 // provided by libadblockplus is used. | 52 // provided by libadblockplus is used. |
55 protected LogSystem createLogSystem() | 53 protected LogSystem createLogSystem() |
56 { | 54 { |
57 return null; | 55 return null; |
58 } | 56 } |
59 | 57 |
60 protected WebRequest createWebRequest() | 58 protected WebRequest createWebRequest() |
61 { | 59 { |
62 return new ThrowingWebRequest(); | 60 return new ThrowingWebRequest(); |
63 } | 61 } |
64 | 62 |
65 protected Context getContext() | 63 protected Context getContext() |
66 { | 64 { |
67 return getInstrumentation().getTargetContext(); | 65 return getInstrumentation().getTargetContext(); |
68 } | 66 } |
69 } | 67 } |
OLD | NEW |