| 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); |
| } |