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

Delta Between Two Patch Sets: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/LazyFileSystem.java

Issue 29347315: Issue 4231 - Fix unstable FilterEngineTest.testSetRemoveFilterChangeCallback (Closed)
Left Patch Set: Introduced file system abstraction to java and using LazyFileSystem for filter tests Created July 10, 2016, 10:47 a.m.
Right Patch Set: made helper methods static, fixed 'remove' for fs callback Created Dec. 13, 2016, 9:32 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 package org.adblockplus.libadblockplus.tests; 18 package org.adblockplus.libadblockplus.tests;
19 19
20 import org.adblockplus.libadblockplus.FileSystem; 20 import org.adblockplus.libadblockplus.FileSystem;
21 21
22 public class LazyFileSystem extends FileSystem 22 public class LazyFileSystem extends FileSystem
23 { 23 {
24 @Override 24 private boolean patternsIniExists = true;
25 public String read(String path) 25
26 public boolean isPatternsIniExists()
27 {
28 return patternsIniExists;
29 }
30
31 public void setPatternsIniExists(boolean patternsIniExists)
32 {
33 this.patternsIniExists = patternsIniExists;
34 }
35
36 @Override
37 public String read(String path)
38 {
39 if (path.equals("patterns.ini"))
26 { 40 {
27 if (path.equals("patterns.ini")) 41 return "# Adblock Plus preferences\n[Subscription]\nurl=~fl~";
28 return "# Adblock Plus preferences\n[Subscription]\nurl=~fl~";
29 else if (path.equals("prefs.json"))
30 return "{}";
31 else
32 return "";
33 } 42 }
43 else if (path.equals("prefs.json"))
44 {
45 return "{}";
46 }
47 else
48 {
49 return "";
50 }
51 }
34 52
35 @Override 53 @Override
36 public void write(String path, String data) 54 public void write(String path, String data)
37 { 55 {
38 56
39 } 57 }
40 58
41 @Override 59 @Override
42 public void move(String fromPath, String toPath) 60 public void move(String fromPath, String toPath)
43 { 61 {
44 62
45 } 63 }
46 64
47 @Override 65 @Override
48 public void remove(String path) 66 public void remove(String path)
49 { 67 {
50 68
51 } 69 }
52 70
53 @Override 71 @Override
54 public StatResult stat(String path) 72 public StatResult stat(String path)
55 { 73 {
56 return path.equals("patterns.ini") 74 return path.equals("patterns.ini")
57 ? new StatResult(true, false, true, 0) 75 ? new StatResult(patternsIniExists, false, true, 0)
58 : new StatResult(false, false, false, 0); 76 : new StatResult(false, false, false, 0);
59 } 77 }
60 78
61 @Override 79 @Override
62 public String resolve(String path) 80 public String resolve(String path)
63 { 81 {
64 return path; 82 return path;
65 } 83 }
66 } 84 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld