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

Unified Diff: test/FilterEngine.cpp

Issue 29417605: Issue 5034 - Part 3: Create plain JsValue instead of JsValuePtr (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Pass JsEngine by ref Created April 20, 2017, 1:01 p.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 | « src/WebRequestJsObject.cpp ('k') | test/JsEngine.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/FilterEngine.cpp
===================================================================
--- a/test/FilterEngine.cpp
+++ b/test/FilterEngine.cpp
@@ -223,30 +223,30 @@
jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new LazyLogSystem()));
subscriptionUrlPrefix = "http://example";
ServerResponse exampleSubscriptionResponse;
exampleSubscriptionResponse.responseStatus = 200;
exampleSubscriptionResponse.status = WebRequest::NS_OK;
exampleSubscriptionResponse.responseText = "[Adblock Plus 2.0]\n||example.com";
webRequest->responses.emplace(subscriptionUrlPrefix, exampleSubscriptionResponse);
- createParams.preconfiguredPrefs["first_run_subscription_auto_select"] = jsEngine->NewValue(false);
+ createParams.preconfiguredPrefs.emplace("first_run_subscription_auto_select", jsEngine->NewValue(false));
isConnectionAllowed = true;
createParams.isConnectionAllowedCallback = [this](const std::string* allowedConnectionType)->bool{
capturedConnectionTypes.Add(allowedConnectionType);
return isConnectionAllowed;
};
- jsEngine->SetEventCallback("filterChange", [this](const JsConstValueList& params/*action, item*/)
+ jsEngine->SetEventCallback("filterChange", [this](const JsValueList& params/*action, item*/)
{
ASSERT_EQ(2u, params.size());
- if (params[0]->AsString() == "subscription.downloadStatus")
+ if (params[0].AsString() == "subscription.downloadStatus")
{
{
std::lock_guard<std::mutex> lock(downloadStatusChanged.mutex);
- downloadStatusChanged.url = params[1]->GetProperty("url").AsString();
+ downloadStatusChanged.url = params[1].GetProperty("url").AsString();
}
downloadStatusChanged.cv.notify_one();
}
});
}
SubscriptionPtr EnsureExampleSubscriptionAndForceUpdate(const std::string& apppendToUrl = std::string())
{
@@ -745,17 +745,17 @@
EXPECT_EQ(langSubscriptionUrl, langSubscription->GetProperty("url").AsString());
EXPECT_TRUE(filterEngine->IsAAEnabled());
}
TEST_F(FilterEngineWithFreshFolder, DisableSubscriptionsAutoSelectOnFirstRun)
{
auto jsEngine = createJsEngine();
FilterEngine::CreationParameters createParams;
- createParams.preconfiguredPrefs["first_run_subscription_auto_select"] = jsEngine->NewValue(false);
+ createParams.preconfiguredPrefs.emplace("first_run_subscription_auto_select", jsEngine->NewValue(false));
auto filterEngine = AdblockPlus::FilterEngine::Create(jsEngine, createParams);
const auto subscriptions = filterEngine->GetListedSubscriptions();
EXPECT_EQ(0u, subscriptions.size());
EXPECT_FALSE(filterEngine->IsAAEnabled());
}
namespace AA_ApiTest
{
@@ -1035,34 +1035,36 @@
EXPECT_EQ(0u, subscription->GetProperty("filters").AsList().size());
auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
EXPECT_EQ(1u, capturedConnectionTypes.size());
}
TEST_F(FilterEngineIsAllowedConnectionTest, PredefinedAllowedConnectionTypeIsPassedToCallback)
{
std::string predefinedAllowedConnectionType = "non-metered";
- createParams.preconfiguredPrefs["allowed_connection_type"] = jsEngine->NewValue(predefinedAllowedConnectionType);
+ createParams.preconfiguredPrefs.insert(std::make_pair("allowed_connection_type",
+ jsEngine->NewValue(predefinedAllowedConnectionType)));
auto subscription = EnsureExampleSubscriptionAndForceUpdate();
EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus").AsString());
EXPECT_EQ(1u, subscription->GetProperty("filters").AsList().size());
auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
ASSERT_EQ(1u, capturedConnectionTypes.size());
EXPECT_TRUE(capturedConnectionTypes[0].first);
EXPECT_EQ(predefinedAllowedConnectionType, capturedConnectionTypes[0].second);
}
TEST_F(FilterEngineIsAllowedConnectionTest, ConfiguredConnectionTypeIsPassedToCallback)
{
// FilterEngine->RemoveSubscription is not usable here because subscriptions
// are cached internally by URL. So, different URLs are used in diffirent
// checks.
{
std::string predefinedAllowedConnectionType = "non-metered";
- createParams.preconfiguredPrefs["allowed_connection_type"] = jsEngine->NewValue(predefinedAllowedConnectionType);
+ createParams.preconfiguredPrefs.insert(std::make_pair(
+ "allowed_connection_type", jsEngine->NewValue(predefinedAllowedConnectionType)));
auto subscription = EnsureExampleSubscriptionAndForceUpdate();
EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus").AsString());
EXPECT_EQ(1u, subscription->GetProperty("filters").AsList().size());
auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
ASSERT_EQ(1u, capturedConnectionTypes.size());
EXPECT_TRUE(capturedConnectionTypes[0].first);
EXPECT_EQ(predefinedAllowedConnectionType, capturedConnectionTypes[0].second);
}
« no previous file with comments | « src/WebRequestJsObject.cpp ('k') | test/JsEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld