OLD | NEW |
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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 102 } |
103 }; | 103 }; |
104 | 104 |
105 class ThrowingFileSystem : public AdblockPlus::FileSystem | 105 class ThrowingFileSystem : public AdblockPlus::FileSystem |
106 { | 106 { |
107 public: | 107 public: |
108 std::shared_ptr<std::istream> Read(const std::string& path) const | 108 std::shared_ptr<std::istream> Read(const std::string& path) const |
109 { | 109 { |
110 throw std::runtime_error("Not implemented"); | 110 throw std::runtime_error("Not implemented"); |
111 } | 111 } |
| 112 void Read(const std::string& path, |
| 113 const ReadCallback& callback) const |
| 114 { |
| 115 throw std::runtime_error("Not implemented"); |
| 116 } |
112 | 117 |
113 void Write(const std::string& path, std::istream& content) | 118 void Write(const std::string& path, std::istream& content) |
114 { | 119 { |
115 throw std::runtime_error("Not implemented"); | 120 throw std::runtime_error("Not implemented"); |
116 } | 121 } |
| 122 void Write(const std::string& path, std::istream& data, |
| 123 const Callback& callback) |
| 124 { |
| 125 throw std::runtime_error("Not implemented"); |
| 126 } |
117 | 127 |
118 void Move(const std::string& fromPath, const std::string& toPath) | 128 void Move(const std::string& fromPath, const std::string& toPath) |
119 { | 129 { |
120 throw std::runtime_error("Not implemented"); | 130 throw std::runtime_error("Not implemented"); |
121 } | 131 } |
| 132 void Move(const std::string& fromPath, const std::string& toPath, |
| 133 const Callback& callback) |
| 134 { |
| 135 throw std::runtime_error("Not implemented"); |
| 136 } |
122 | 137 |
123 void Remove(const std::string& path) | 138 void Remove(const std::string& path) |
124 { | 139 { |
125 throw std::runtime_error("Not implemented"); | 140 throw std::runtime_error("Not implemented"); |
126 } | 141 } |
| 142 void Remove(const std::string& path, const Callback& callback) |
| 143 { |
| 144 throw std::runtime_error("Not implemented"); |
| 145 } |
127 | 146 |
128 StatResult Stat(const std::string& path) const | 147 StatResult Stat(const std::string& path) const |
129 { | 148 { |
130 throw std::runtime_error("Not implemented"); | 149 throw std::runtime_error("Not implemented"); |
131 } | 150 } |
| 151 void Stat(const std::string& path, |
| 152 const StatCallback& callback) const |
| 153 { |
| 154 throw std::runtime_error("Not implemented"); |
| 155 } |
132 | 156 |
133 std::string Resolve(const std::string& path) const | 157 std::string Resolve(const std::string& path) const |
134 { | 158 { |
135 throw std::runtime_error("Not implemented"); | 159 throw std::runtime_error("Not implemented"); |
136 } | 160 } |
137 | 161 void Resolve(const std::string& path, |
| 162 const ResolveCallback& callback) const |
| 163 { |
| 164 throw std::runtime_error("Not implemented"); |
| 165 } |
138 }; | 166 }; |
139 | 167 |
140 class ThrowingWebRequest : public AdblockPlus::IWebRequest | 168 class ThrowingWebRequest : public AdblockPlus::IWebRequest |
141 { | 169 { |
142 public: | 170 public: |
143 void GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders
, const GetCallback&) override | 171 void GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders
, const GetCallback&) override |
144 { | 172 { |
145 throw std::runtime_error("Unexpected GET: " + url); | 173 throw std::runtime_error("Unexpected GET: " + url); |
146 } | 174 } |
147 }; | 175 }; |
148 | 176 |
149 class LazyFileSystem : public AdblockPlus::FileSystem | 177 class LazyFileSystem : public AdblockPlus::FileSystem |
150 { | 178 { |
151 public: | 179 public: |
152 std::shared_ptr<std::istream> Read(const std::string& path) const | 180 std::shared_ptr<std::istream> Read(const std::string& path) const |
153 { | 181 { |
154 std::string dummyData(""); | 182 std::string dummyData(""); |
155 if (path == "patterns.ini") | 183 if (path == "patterns.ini") |
156 dummyData = "# Adblock Plus preferences\n[Subscription]\nurl=~fl~"; | 184 dummyData = "# Adblock Plus preferences\n[Subscription]\nurl=~fl~"; |
157 else if (path == "prefs.json") | 185 else if (path == "prefs.json") |
158 dummyData = "{}"; | 186 dummyData = "{}"; |
159 return std::shared_ptr<std::istream>(new std::istringstream(dummyData)); | 187 return std::shared_ptr<std::istream>(new std::istringstream(dummyData)); |
160 } | 188 } |
161 | 189 |
| 190 void Read(const std::string& path, const ReadCallback& callback) const |
| 191 { |
| 192 } |
| 193 |
162 void Write(const std::string& path, std::istream& content) | 194 void Write(const std::string& path, std::istream& content) |
163 { | 195 { |
164 } | 196 } |
165 | 197 |
| 198 void Write(const std::string& path, std::istream& data, |
| 199 const Callback& callback) |
| 200 { |
| 201 } |
| 202 |
166 void Move(const std::string& fromPath, const std::string& toPath) | 203 void Move(const std::string& fromPath, const std::string& toPath) |
167 { | 204 { |
168 } | 205 } |
169 | 206 |
| 207 void Move(const std::string& fromPath, const std::string& toPath, |
| 208 const Callback& callback) |
| 209 { |
| 210 } |
| 211 |
170 void Remove(const std::string& path) | 212 void Remove(const std::string& path) |
171 { | 213 { |
172 } | 214 } |
173 | 215 |
| 216 void Remove(const std::string& path, const Callback& callback) |
| 217 { |
| 218 } |
| 219 |
174 StatResult Stat(const std::string& path) const | 220 StatResult Stat(const std::string& path) const |
175 { | 221 { |
176 StatResult result; | 222 StatResult result; |
177 if (path == "patterns.ini") | 223 if (path == "patterns.ini") |
178 { | 224 { |
179 result.exists = true; | 225 result.exists = true; |
180 result.isFile = true; | 226 result.isFile = true; |
181 } | 227 } |
182 return result; | 228 return result; |
183 } | 229 } |
184 | 230 |
| 231 void Stat(const std::string& path, |
| 232 const StatCallback& callback) const |
| 233 { |
| 234 } |
| 235 |
185 std::string Resolve(const std::string& path) const | 236 std::string Resolve(const std::string& path) const |
186 { | 237 { |
187 return path; | 238 return path; |
188 } | 239 } |
| 240 |
| 241 void Resolve(const std::string& path, |
| 242 const ResolveCallback& callback) const |
| 243 { |
| 244 } |
189 }; | 245 }; |
190 | 246 |
191 class NoopWebRequest : public AdblockPlus::IWebRequest | 247 class NoopWebRequest : public AdblockPlus::IWebRequest |
192 { | 248 { |
193 public: | 249 public: |
194 void GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders
, const GetCallback& callback) override | 250 void GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders
, const GetCallback& callback) override |
195 { | 251 { |
196 } | 252 } |
197 }; | 253 }; |
198 | 254 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 protected: | 296 protected: |
241 AdblockPlus::JsEnginePtr jsEngine; | 297 AdblockPlus::JsEnginePtr jsEngine; |
242 | 298 |
243 virtual void SetUp() | 299 virtual void SetUp() |
244 { | 300 { |
245 jsEngine = CreateJsEngine(); | 301 jsEngine = CreateJsEngine(); |
246 } | 302 } |
247 }; | 303 }; |
248 | 304 |
249 #endif | 305 #endif |
OLD | NEW |