Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/BaseJsTest.h

Issue 29433591: Issue 5180 - start to inject implementation of WebRequest into JsEngine::ctr (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created May 8, 2017, 11:59 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/BaseJsTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/BaseJsTest.h
diff --git a/test/BaseJsTest.h b/test/BaseJsTest.h
index 99b958a9f9c61fd3b8c8d0cceb6f556ce267c588..dc83a3785fa511e0c06546d08f78b06b62f16f87 100644
--- a/test/BaseJsTest.h
+++ b/test/BaseJsTest.h
@@ -22,6 +22,21 @@
#include <gtest/gtest.h>
#include "../src/Thread.h"
+class ThrowingTimer : public AdblockPlus::ITimer
+{
+ void SetTimer(const std::chrono::milliseconds& timeout, const TimerCallback& timerCallback) override
+ {
+ throw std::runtime_error("Unexpected timer: " + std::to_string(timeout.count()));
+ }
+};
+
+class NoopTimer : public AdblockPlus::ITimer
+{
+ void SetTimer(const std::chrono::milliseconds& timeout, const TimerCallback& timerCallback) override
+ {
+ }
+};
+
class ThrowingLogSystem : public AdblockPlus::LogSystem
{
public:
@@ -133,6 +148,14 @@ public:
}
};
+class NoopWebRequest : public AdblockPlus::IWebRequest
+{
+public:
+ void GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders, const GetCallback& callback) override
+ {
+ }
+};
+
class LazyLogSystem : public AdblockPlus::LogSystem
{
public:
@@ -142,8 +165,18 @@ public:
}
};
-AdblockPlus::JsEnginePtr CreateJsEngine(const AdblockPlus::AppInfo& appInfo = AdblockPlus::AppInfo(),
- AdblockPlus::WebRequestPtr webRequest = AdblockPlus::WebRequestPtr(new ThrowingWebRequest()));
+struct JsEngineCreationParameters
+{
+ JsEngineCreationParameters();
+
+ AdblockPlus::AppInfo appInfo;
+ AdblockPlus::LogSystemPtr logSystem;
+ AdblockPlus::TimerPtr timer;
+ AdblockPlus::WebRequestPtr webRequest;
+ AdblockPlus::FileSystemPtr fileSystem;
+};
+
+AdblockPlus::JsEnginePtr CreateJsEngine(JsEngineCreationParameters&& jsEngineCreationParameters = JsEngineCreationParameters());
class BaseJsTest : public ::testing::Test
{
@@ -153,9 +186,6 @@ protected:
virtual void SetUp()
{
jsEngine = CreateJsEngine();
- jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new ThrowingLogSystem));
- jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new ThrowingFileSystem));
- jsEngine->SetWebRequest(std::make_shared<ThrowingWebRequest>());
}
};
« no previous file with comments | « no previous file | test/BaseJsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld