Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineGenericTest.java

Issue 29424615: Issue 4231 - Fix unstable FilterEngineTest.testSetRemoveFilterChangeCallback (Closed)
Patch Set: changed impl for reading file as bytes array, modified test. AndroidFileSystem now does not resolveā€¦ Created May 29, 2017, 11:26 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
}

Powered by Google App Engine
This is Rietveld