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: using method from c++ utils Created April 28, 2017, 10:44 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..e18d62760ba33e0f180f3851edf8e9dcbcdf43f1 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,72 @@ 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 String read(String path)
+ {
+ if (path.equals(PATTERNS_INI))
+ {
+ return "# Adblock Plus preferences\n[Subscription]\nurl=~fl~";
+ }
+ else if (path.equals("prefs.json"))
+ {
+ return "{}";
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ @Override
+ public void write(String path, String 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 +98,7 @@ public abstract class FilterEngineGenericTest extends BaseJsTest
jsEngine.setWebRequest(new LazyWebRequest());
jsEngine.setDefaultLogSystem();
+ jsEngine.setFileSystem(new PatternsIniStubFileSystem());
sergei 2017/05/22 12:09:06 Just for reference, I would expect that the propos
anton 2017/05/22 13:04:37 Acknowledged.
filterEngine = new FilterEngine(jsEngine);
}

Powered by Google App Engine
This is Rietveld