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

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

Issue 29347315: Issue 4231 - Fix unstable FilterEngineTest.testSetRemoveFilterChangeCallback (Closed)
Patch Set: Introduced file system abstraction to java and using LazyFileSystem for filter tests Created July 10, 2016, 10:47 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/LazyFileSystem.java
diff --git a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/LazyFileSystem.java b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/LazyFileSystem.java
new file mode 100644
index 0000000000000000000000000000000000000000..7a651a7e1ab728a8f994b7788f7ff47fd3407371
--- /dev/null
+++ b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/LazyFileSystem.java
@@ -0,0 +1,66 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-2016 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.adblockplus.libadblockplus.tests;
+
+import org.adblockplus.libadblockplus.FileSystem;
+
+public class LazyFileSystem extends FileSystem
+{
+ @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 StatResult stat(String path)
+ {
+ return path.equals("patterns.ini")
+ ? new StatResult(true, false, true, 0)
+ : new StatResult(false, false, false, 0);
+ }
+
+ @Override
+ public String resolve(String path)
+ {
+ return path;
+ }
+}

Powered by Google App Engine
This is Rietveld