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

Delta Between Two Patch Sets: test/FilterEngine.cpp

Issue 29417605: Issue 5034 - Part 3: Create plain JsValue instead of JsValuePtr (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Created April 19, 2017, 5:54 p.m.
Right Patch Set: Pass JsEngine by ref Created April 20, 2017, 1:01 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/WebRequestJsObject.cpp ('k') | test/JsEngine.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new LazyFileSystem())); 221 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new LazyFileSystem()));
222 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(webRequest = new MockWe bRequest())); 222 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(webRequest = new MockWe bRequest()));
223 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new LazyLogSystem())); 223 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new LazyLogSystem()));
224 224
225 subscriptionUrlPrefix = "http://example"; 225 subscriptionUrlPrefix = "http://example";
226 ServerResponse exampleSubscriptionResponse; 226 ServerResponse exampleSubscriptionResponse;
227 exampleSubscriptionResponse.responseStatus = 200; 227 exampleSubscriptionResponse.responseStatus = 200;
228 exampleSubscriptionResponse.status = WebRequest::NS_OK; 228 exampleSubscriptionResponse.status = WebRequest::NS_OK;
229 exampleSubscriptionResponse.responseText = "[Adblock Plus 2.0]\n||example. com"; 229 exampleSubscriptionResponse.responseText = "[Adblock Plus 2.0]\n||example. com";
230 webRequest->responses.emplace(subscriptionUrlPrefix, exampleSubscriptionRe sponse); 230 webRequest->responses.emplace(subscriptionUrlPrefix, exampleSubscriptionRe sponse);
231 createParams.preconfiguredPrefs.insert( 231 createParams.preconfiguredPrefs.emplace("first_run_subscription_auto_selec t", jsEngine->NewValue(false));
232 std::make_pair("first_run_subscription_auto_select", jsEngine->NewValue( false)));
sergei 2017/04/19 18:56:52 here and below what about using of emplace method
hub 2017/04/19 21:56:49 good idea.
233 isConnectionAllowed = true; 232 isConnectionAllowed = true;
234 createParams.isConnectionAllowedCallback = [this](const std::string* allow edConnectionType)->bool{ 233 createParams.isConnectionAllowedCallback = [this](const std::string* allow edConnectionType)->bool{
235 capturedConnectionTypes.Add(allowedConnectionType); 234 capturedConnectionTypes.Add(allowedConnectionType);
236 return isConnectionAllowed; 235 return isConnectionAllowed;
237 }; 236 };
238 jsEngine->SetEventCallback("filterChange", [this](const JsValueList& param s/*action, item*/) 237 jsEngine->SetEventCallback("filterChange", [this](const JsValueList& param s/*action, item*/)
239 { 238 {
240 ASSERT_EQ(2u, params.size()); 239 ASSERT_EQ(2u, params.size());
241 if (params[0].AsString() == "subscription.downloadStatus") 240 if (params[0].AsString() == "subscription.downloadStatus")
242 { 241 {
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 ASSERT_NE(nullptr, aaSubscription); 743 ASSERT_NE(nullptr, aaSubscription);
745 ASSERT_NE(nullptr, langSubscription); 744 ASSERT_NE(nullptr, langSubscription);
746 EXPECT_EQ(langSubscriptionUrl, langSubscription->GetProperty("url").AsString() ); 745 EXPECT_EQ(langSubscriptionUrl, langSubscription->GetProperty("url").AsString() );
747 EXPECT_TRUE(filterEngine->IsAAEnabled()); 746 EXPECT_TRUE(filterEngine->IsAAEnabled());
748 } 747 }
749 748
750 TEST_F(FilterEngineWithFreshFolder, DisableSubscriptionsAutoSelectOnFirstRun) 749 TEST_F(FilterEngineWithFreshFolder, DisableSubscriptionsAutoSelectOnFirstRun)
751 { 750 {
752 auto jsEngine = createJsEngine(); 751 auto jsEngine = createJsEngine();
753 FilterEngine::CreationParameters createParams; 752 FilterEngine::CreationParameters createParams;
754 createParams.preconfiguredPrefs.insert( 753 createParams.preconfiguredPrefs.emplace("first_run_subscription_auto_select", jsEngine->NewValue(false));
755 std::make_pair("first_run_subscription_auto_select", jsEngine->NewValue(fals e)));
756 auto filterEngine = AdblockPlus::FilterEngine::Create(jsEngine, createParams); 754 auto filterEngine = AdblockPlus::FilterEngine::Create(jsEngine, createParams);
757 const auto subscriptions = filterEngine->GetListedSubscriptions(); 755 const auto subscriptions = filterEngine->GetListedSubscriptions();
758 EXPECT_EQ(0u, subscriptions.size()); 756 EXPECT_EQ(0u, subscriptions.size());
759 EXPECT_FALSE(filterEngine->IsAAEnabled()); 757 EXPECT_FALSE(filterEngine->IsAAEnabled());
760 } 758 }
761 759
762 namespace AA_ApiTest 760 namespace AA_ApiTest
763 { 761 {
764 const std::string kOtherSubscriptionUrl = "https://non-existing-subscription.t xt"; 762 const std::string kOtherSubscriptionUrl = "https://non-existing-subscription.t xt";
765 enum class AAStatus 763 enum class AAStatus
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 filterEngine->SetAllowedConnectionType(&testConnection); 1088 filterEngine->SetAllowedConnectionType(&testConnection);
1091 auto subscription = EnsureExampleSubscriptionAndForceUpdate("subB"); 1089 auto subscription = EnsureExampleSubscriptionAndForceUpdate("subB");
1092 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus").AsSt ring()); 1090 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus").AsSt ring());
1093 EXPECT_EQ(1u, subscription->GetProperty("filters").AsList().size()); 1091 EXPECT_EQ(1u, subscription->GetProperty("filters").AsList().size());
1094 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings(); 1092 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
1095 ASSERT_EQ(1u, capturedConnectionTypes.size()); 1093 ASSERT_EQ(1u, capturedConnectionTypes.size());
1096 EXPECT_TRUE(capturedConnectionTypes[0].first); 1094 EXPECT_TRUE(capturedConnectionTypes[0].first);
1097 EXPECT_EQ(testConnection, capturedConnectionTypes[0].second); 1095 EXPECT_EQ(testConnection, capturedConnectionTypes[0].second);
1098 } 1096 }
1099 } 1097 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld