OLD | NEW |
1 #ifndef MOCKS_H | 1 #ifndef MOCKS_H |
2 #define MOCKS_H | 2 #define MOCKS_H |
3 | 3 |
4 #include <AdblockPlus.h> | 4 #include <AdblockPlus.h> |
5 #include <gtest/gtest.h> | 5 #include <gtest/gtest.h> |
6 #include "../src/Thread.h" | 6 #include "../src/Thread.h" |
7 | 7 |
8 class ThrowingErrorCallback : public AdblockPlus::ErrorCallback | 8 class ThrowingErrorCallback : public AdblockPlus::ErrorCallback |
9 { | 9 { |
10 public: | 10 public: |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 StatResult Stat(const std::string& path) const | 40 StatResult Stat(const std::string& path) const |
41 { | 41 { |
42 throw std::runtime_error("Not implemented"); | 42 throw std::runtime_error("Not implemented"); |
43 } | 43 } |
44 | 44 |
45 std::string Resolve(const std::string& path) const | 45 std::string Resolve(const std::string& path) const |
46 { | 46 { |
47 throw std::runtime_error("Not implemented"); | 47 throw std::runtime_error("Not implemented"); |
48 } | 48 } |
49 | |
50 void SetBasePath(const std::string& path) | |
51 { | |
52 throw std::runtime_error("Not implemented"); | |
53 } | |
54 | 49 |
55 }; | 50 }; |
56 | 51 |
57 class ThrowingWebRequest : public AdblockPlus::WebRequest | 52 class ThrowingWebRequest : public AdblockPlus::WebRequest |
58 { | 53 { |
59 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea
derList& requestHeaders) const | 54 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea
derList& requestHeaders) const |
60 { | 55 { |
61 throw std::runtime_error("Unexpected GET: " + url); | 56 throw std::runtime_error("Unexpected GET: " + url); |
62 } | 57 } |
63 }; | 58 }; |
(...skipping 28 matching lines...) Expand all Loading... |
92 | 87 |
93 StatResult Stat(const std::string& path) const | 88 StatResult Stat(const std::string& path) const |
94 { | 89 { |
95 while (true) | 90 while (true) |
96 AdblockPlus::Sleep(100000); | 91 AdblockPlus::Sleep(100000); |
97 return StatResult(); | 92 return StatResult(); |
98 } | 93 } |
99 | 94 |
100 std::string Resolve(const std::string& path) const | 95 std::string Resolve(const std::string& path) const |
101 { | 96 { |
102 while (true) | |
103 AdblockPlus::Sleep(100000); | |
104 return std::string(); | 97 return std::string(); |
105 } | 98 } |
106 | |
107 void SetBasePath(const std::string& path) | |
108 { | |
109 while (true) | |
110 AdblockPlus::Sleep(100000); | |
111 } | |
112 }; | 99 }; |
113 | 100 |
114 class LazyWebRequest : public AdblockPlus::WebRequest | 101 class LazyWebRequest : public AdblockPlus::WebRequest |
115 { | 102 { |
116 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea
derList& requestHeaders) const | 103 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea
derList& requestHeaders) const |
117 { | 104 { |
118 while (true) | 105 while (true) |
119 AdblockPlus::Sleep(100000); | 106 AdblockPlus::Sleep(100000); |
120 return AdblockPlus::ServerResponse(); | 107 return AdblockPlus::ServerResponse(); |
121 } | 108 } |
122 }; | 109 }; |
123 | 110 |
124 | 111 |
125 class BaseJsTest : public ::testing::Test | 112 class BaseJsTest : public ::testing::Test |
126 { | 113 { |
127 protected: | 114 protected: |
128 AdblockPlus::JsEnginePtr jsEngine; | 115 AdblockPlus::JsEnginePtr jsEngine; |
129 | 116 |
130 virtual void SetUp() | 117 virtual void SetUp() |
131 { | 118 { |
132 jsEngine = AdblockPlus::JsEngine::New(); | 119 jsEngine = AdblockPlus::JsEngine::New(); |
133 jsEngine->SetErrorCallback(AdblockPlus::ErrorCallbackPtr(new ThrowingErrorCa
llback)); | 120 jsEngine->SetErrorCallback(AdblockPlus::ErrorCallbackPtr(new ThrowingErrorCa
llback)); |
134 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem)); | 121 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem)); |
135 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new ThrowingWebRequest)); | 122 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(new ThrowingWebRequest)); |
136 } | 123 } |
137 }; | 124 }; |
138 | 125 |
139 #endif | 126 #endif |
OLD | NEW |