| Index: test/BaseJsTest.h |
| =================================================================== |
| --- a/test/BaseJsTest.h |
| +++ b/test/BaseJsTest.h |
| @@ -1,13 +1,14 @@ |
| #ifndef MOCKS_H |
| #define MOCKS_H |
| #include <AdblockPlus.h> |
| #include <gtest/gtest.h> |
| +#include "../src/Thread.h" |
| class ThrowingErrorCallback : public AdblockPlus::ErrorCallback |
| { |
| public: |
| void operator()(const std::string& message) |
| { |
| throw std::runtime_error("Unexpected error: " + message); |
| } |
| @@ -45,16 +46,63 @@ class ThrowingFileSystem : public Adbloc |
| class ThrowingWebRequest : public AdblockPlus::WebRequest |
| { |
| AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders) const |
| { |
| throw std::runtime_error("Unexpected GET: " + url); |
| } |
| }; |
| +class LazyFileSystem : public AdblockPlus::FileSystem |
| +{ |
| + std::tr1::shared_ptr<std::istream> Read(const std::string& path) const |
| + { |
| + while (true) |
| + AdblockPlus::Sleep(100000); |
| + return std::tr1::shared_ptr<std::istream>(); |
| + } |
| + |
| + void Write(const std::string& path, |
| + std::tr1::shared_ptr<std::ostream> content) |
| + { |
| + while (true) |
| + AdblockPlus::Sleep(100000); |
| + } |
| + |
| + void Move(const std::string& fromPath, const std::string& toPath) |
| + { |
| + while (true) |
| + AdblockPlus::Sleep(100000); |
| + } |
| + |
| + void Remove(const std::string& path) |
| + { |
| + while (true) |
| + AdblockPlus::Sleep(100000); |
| + } |
| + |
| + StatResult Stat(const std::string& path) const |
| + { |
| + while (true) |
| + AdblockPlus::Sleep(100000); |
| + return StatResult(); |
| + } |
| +}; |
| + |
| +class LazyWebRequest : public AdblockPlus::WebRequest |
| +{ |
| + AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders) const |
| + { |
| + while (true) |
| + AdblockPlus::Sleep(100000); |
| + return AdblockPlus::ServerResponse(); |
| + } |
| +}; |
| + |
| + |
| class BaseJsTest : public ::testing::Test |
| { |
| protected: |
| AdblockPlus::JsEnginePtr jsEngine; |
| virtual void SetUp() |
| { |
| jsEngine = AdblockPlus::JsEngine::New(); |