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: now using smart_ptr, changed impl for reading file as string, minor changes Created May 22, 2017, 1:03 p.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());
filterEngine = new FilterEngine(jsEngine);
}

Powered by Google App Engine
This is Rietveld