Index: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineGenericTest.java |
diff --git a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineGenericTest.java b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineGenericTest.java |
index 92a098f916017356fff71803647749eab2eefed4..242e1a94ab958405663a7a2aa9f61d125ce1ae4b 100644 |
--- a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineGenericTest.java |
+++ b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineGenericTest.java |
@@ -17,6 +17,7 @@ |
package org.adblockplus.libadblockplus.tests; |
+import org.adblockplus.libadblockplus.FileSystem; |
import org.adblockplus.libadblockplus.FilterEngine; |
import org.adblockplus.libadblockplus.LazyWebRequest; |
@@ -24,6 +25,74 @@ public abstract class FilterEngineGenericTest extends BaseJsTest |
{ |
protected FilterEngine filterEngine; |
+ private static final class PatternsIniStubFileSystem extends FileSystem |
+ { |
+ private static final String PATTERNS_INI = "patterns.ini"; |
+ |
+ private boolean patternsIniExists = true; |
+ |
+ public boolean isPatternsIniExists() |
+ { |
+ return patternsIniExists; |
+ } |
+ |
+ public void setPatternsIniExists(boolean patternsIniExists) |
+ { |
+ this.patternsIniExists = patternsIniExists; |
+ } |
+ |
+ @Override |
+ public byte[] read(String path) |
+ { |
+ String result; |
+ if (path.equals(PATTERNS_INI)) |
+ { |
+ result = "# Adblock Plus preferences\n[Subscription]\nurl=~fl~"; |
+ } |
+ else if (path.equals("prefs.json")) |
+ { |
+ result = "{}"; |
+ } |
+ else |
+ { |
+ result = ""; |
+ } |
+ return result.getBytes(); |
+ } |
+ |
+ @Override |
+ public void write(String path, byte[] data) |
+ { |
+ |
+ } |
+ |
+ @Override |
+ public void move(String fromPath, String toPath) |
+ { |
+ |
+ } |
+ |
+ @Override |
+ public void remove(String path) |
+ { |
+ |
+ } |
+ |
+ @Override |
+ public FileSystem.StatResult stat(String path) |
+ { |
+ return path.equals(PATTERNS_INI) |
+ ? new FileSystem.StatResult(patternsIniExists, false, true, 0) |
+ : new FileSystem.StatResult(false, false, false, 0); |
+ } |
+ |
+ @Override |
+ public String resolve(String path) |
+ { |
+ return path; |
+ } |
+ } |
+ |
@Override |
protected void setUp() throws Exception |
{ |
@@ -31,6 +100,7 @@ public abstract class FilterEngineGenericTest extends BaseJsTest |
jsEngine.setWebRequest(new LazyWebRequest()); |
jsEngine.setDefaultLogSystem(); |
+ jsEngine.setFileSystem(new PatternsIniStubFileSystem()); |
filterEngine = new FilterEngine(jsEngine); |
} |