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

Unified Diff: test/FilterEngine.cpp

Issue 29508555: Issue 5450 - move FilterEngine into Platform (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created Aug. 7, 2017, 8:28 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
Index: test/FilterEngine.cpp
diff --git a/test/FilterEngine.cpp b/test/FilterEngine.cpp
index e10d804716db3d84aa3b70a143b279f8a45a9414..fc4a789826699f0f7e2ab2d49fb01e3d20db8c27 100644
--- a/test/FilterEngine.cpp
+++ b/test/FilterEngine.cpp
@@ -63,7 +63,7 @@ namespace
platformParams.fileSystem.reset(fileSystem = new LazyFileSystemT());
platformParams.webRequest.reset(new NoopWebRequest());
platform.reset(new Platform(std::move(platformParams)));
- filterEngine = CreateFilterEngine(*fileSystem, platform->GetJsEngine());
+ filterEngine = CreateFilterEngine(*fileSystem, *platform);
}
};
@@ -76,7 +76,6 @@ namespace
std::unique_ptr<Platform> platform;
FileSystemPtr fileSystem;
std::list<SchedulerTask> fileSystemTasks;
- std::weak_ptr<JsEngine> weakJsEngine;
void SetUp() override
{
@@ -89,7 +88,7 @@ namespace
removeFileIfExists("patterns.ini");
removeFileIfExists("prefs.json");
}
- JsEnginePtr CreateJsEngine(const AppInfo& appInfo = AppInfo())
+ void InitPlatformAndAppInfo(const AppInfo& appInfo = AppInfo())
{
ThrowingPlatformCreationParameters platformParams;
platformParams.logSystem.reset(new LazyLogSystem());
@@ -98,19 +97,15 @@ namespace
platformParams.webRequest.reset(new NoopWebRequest());
platform.reset(new Platform(std::move(platformParams)));
platform->SetUpJsEngine(appInfo);
- auto jsEngine = platform->GetJsEngine();
- weakJsEngine = jsEngine;
- return jsEngine;
}
- FilterEnginePtr CreateFilterEngine(const JsEnginePtr& jsEngine,
- const FilterEngine::CreationParameters& creationParams = FilterEngine::CreationParameters())
+ FilterEnginePtr CreateFilterEngine(const FilterEngine::CreationParameters& creationParams = FilterEngine::CreationParameters())
{
FilterEnginePtr retValue;
- FilterEngine::CreateAsync(jsEngine, [&retValue](const FilterEnginePtr& filterEngine)
+ platform->CreateFilterEngineAsync(creationParams, [&retValue](const FilterEnginePtr& filterEngine)
{
retValue = filterEngine;
- }, creationParams);
+ });
while (!retValue && !fileSystemTasks.empty())
{
(*fileSystemTasks.begin())();
@@ -198,7 +193,7 @@ namespace
bool isSubscriptionDownloadStatusReceived = false;
if (!filterEngine)
{
- filterEngine = CreateFilterEngine(*fileSystem, platform->GetJsEngine(), createParams);
+ filterEngine = CreateFilterEngine(*fileSystem, *platform, createParams);
filterEngine->SetFilterChangeCallback([&isSubscriptionDownloadStatusReceived, &subscriptionUrl](const std::string& action, JsValue&& item)
{
if (action == "subscription.downloadStatus" && item.GetProperty("url").AsString() == subscriptionUrl)
@@ -688,8 +683,8 @@ TEST_F(FilterEngineWithFreshFolder, LangAndAASubscriptionsAreChosenOnFirstRun)
AppInfo appInfo;
appInfo.locale = "zh";
const std::string langSubscriptionUrl = "https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt";
- auto jsEngine = CreateJsEngine(appInfo);
- auto filterEngine = CreateFilterEngine(jsEngine);
+ InitPlatformAndAppInfo(appInfo);
+ auto filterEngine = CreateFilterEngine();
const auto subscriptions = filterEngine->GetListedSubscriptions();
ASSERT_EQ(2u, subscriptions.size());
std::unique_ptr<Subscription> aaSubscription;
@@ -712,10 +707,10 @@ TEST_F(FilterEngineWithFreshFolder, LangAndAASubscriptionsAreChosenOnFirstRun)
TEST_F(FilterEngineWithFreshFolder, DisableSubscriptionsAutoSelectOnFirstRun)
{
- auto jsEngine = CreateJsEngine();
+ InitPlatformAndAppInfo();
FilterEngine::CreationParameters createParams;
- createParams.preconfiguredPrefs.emplace("first_run_subscription_auto_select", jsEngine->NewValue(false));
- auto filterEngine = CreateFilterEngine(jsEngine, createParams);
+ createParams.preconfiguredPrefs.emplace("first_run_subscription_auto_select", platform->GetJsEngine()->NewValue(false));
+ auto filterEngine = CreateFilterEngine(createParams);
const auto subscriptions = filterEngine->GetListedSubscriptions();
EXPECT_EQ(0u, subscriptions.size());
EXPECT_FALSE(filterEngine->IsAAEnabled());
« test/BaseJsTest.cpp ('K') | « test/BaseJsTest.cpp ('k') | test/Notification.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld