Index: test/BaseJsTest.cpp |
diff --git a/test/BaseJsTest.cpp b/test/BaseJsTest.cpp |
index 53c80a0c649847534cba510087d29f69ab7e7c00..e8d2dd3f051feeb7328337b87fb349de94eb7929 100644 |
--- a/test/BaseJsTest.cpp |
+++ b/test/BaseJsTest.cpp |
@@ -16,6 +16,9 @@ |
*/ |
#include "BaseJsTest.h" |
+#include <AdblockPlus/FilterEngine.h> |
+ |
+using namespace AdblockPlus; |
void DelayedTimer::ProcessImmediateTimers(DelayedTimer::SharedTasks& timerTasks) |
{ |
@@ -49,3 +52,26 @@ AdblockPlus::JsEnginePtr CreateJsEngine(JsEngineCreationParameters&& jsEngineCre |
std::move(jsEngineCreationParameters.logSystem)); |
return jsEngine; |
} |
+ |
+FilterEnginePtr CreateFilterEngine(LazyFileSystem& fileSystem, |
+ const JsEnginePtr& jsEngine, |
+ const FilterEngine::CreationParameters& creationParams) |
+{ |
+ std::list<LazyFileSystem::Task> fileSystemTasks; |
+ fileSystem.scheduler = [&fileSystemTasks](const LazyFileSystem::Task& task) |
+ { |
+ fileSystemTasks.emplace_back(task); |
+ }; |
+ FilterEnginePtr retValue; |
+ FilterEngine::CreateAsync(jsEngine, [&retValue, &fileSystem](const FilterEnginePtr& filterEngine) |
+ { |
+ retValue = filterEngine; |
+ fileSystem.scheduler = LazyFileSystem::ExecuteImmediately; |
+ }, creationParams); |
+ while (!retValue && !fileSystemTasks.empty()) |
+ { |
+ (*fileSystemTasks.begin())(); |
+ fileSystemTasks.pop_front(); |
+ } |
+ return retValue; |
+} |