| OLD | NEW |
| 1 #include "BaseJsTest.h" | 1 #include "BaseJsTest.h" |
| 2 #include "../src/Thread.h" | 2 #include "../src/Thread.h" |
| 3 #include "../src/Utils.h" | 3 #include "../src/Utils.h" |
| 4 | 4 |
| 5 namespace | 5 namespace |
| 6 { | 6 { |
| 7 class MockFileSystem : public AdblockPlus::FileSystem | 7 class MockFileSystem : public AdblockPlus::FileSystem |
| 8 { | 8 { |
| 9 public: | 9 public: |
| 10 bool success; | 10 bool success; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 return result; | 70 return result; |
| 71 } | 71 } |
| 72 | 72 |
| 73 std::string Resolve(const std::string& path) const | 73 std::string Resolve(const std::string& path) const |
| 74 { | 74 { |
| 75 if (!success) | 75 if (!success) |
| 76 throw std::runtime_error("Unable to stat " + path); | 76 throw std::runtime_error("Unable to stat " + path); |
| 77 return path; | 77 return path; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void SetBasePath(const std::string& path) |
| 81 { |
| 82 basePath = ""; |
| 83 return; |
| 84 } |
| 85 |
| 80 }; | 86 }; |
| 81 | 87 |
| 82 void ReadFile(AdblockPlus::JsEnginePtr jsEngine, std::string& content, | 88 void ReadFile(AdblockPlus::JsEnginePtr jsEngine, std::string& content, |
| 83 std::string& error) | 89 std::string& error) |
| 84 { | 90 { |
| 85 jsEngine->Evaluate("_fileSystem.read('', function(r) {result = r})"); | 91 jsEngine->Evaluate("_fileSystem.read('', function(r) {result = r})"); |
| 86 AdblockPlus::Sleep(50); | 92 AdblockPlus::Sleep(50); |
| 87 content = jsEngine->Evaluate("result.content")->AsString(); | 93 content = jsEngine->Evaluate("result.content")->AsString(); |
| 88 error = jsEngine->Evaluate("result.error")->AsString(); | 94 error = jsEngine->Evaluate("result.error")->AsString(); |
| 89 } | 95 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat('', '')")); | 226 ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat('', '')")); |
| 221 } | 227 } |
| 222 | 228 |
| 223 TEST_F(FileSystemJsObjectTest, StatError) | 229 TEST_F(FileSystemJsObjectTest, StatError) |
| 224 { | 230 { |
| 225 mockFileSystem->success = false; | 231 mockFileSystem->success = false; |
| 226 jsEngine->Evaluate("_fileSystem.stat('foo', function(r) {result = r})"); | 232 jsEngine->Evaluate("_fileSystem.stat('foo', function(r) {result = r})"); |
| 227 AdblockPlus::Sleep(50); | 233 AdblockPlus::Sleep(50); |
| 228 ASSERT_NE("", jsEngine->Evaluate("result.error")->AsString()); | 234 ASSERT_NE("", jsEngine->Evaluate("result.error")->AsString()); |
| 229 } | 235 } |
| OLD | NEW |