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

Delta Between Two Patch Sets: test/FilterEngine.cpp

Issue 29366747: Issue 4657 - Add Acceptable Ads API (Closed)
Left Patch Set: address comments and rebase Created March 17, 2017, 3:49 p.m.
Right Patch Set: fix typo Created April 5, 2017, 4:53 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/FilterEngine.cpp ('k') | no next file » | 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-2016 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include "BaseJsTest.h" 18 #include "BaseJsTest.h"
19 #include <thread> 19 #include <thread>
20 #include <condition_variable>
20 21
21 using namespace AdblockPlus; 22 using namespace AdblockPlus;
23
24 namespace AdblockPlus
25 {
26 namespace Utils
27 {
28 inline bool BeginsWith(const std::string& str, const std::string& beginning)
29 {
30 return 0 == str.compare(0, beginning.size(), beginning);
31 }
32 }
33 }
22 34
23 namespace 35 namespace
24 { 36 {
25 class VeryLazyFileSystem : public LazyFileSystem 37 class VeryLazyFileSystem : public LazyFileSystem
26 { 38 {
27 public: 39 public:
28 StatResult Stat(const std::string& path) const 40 StatResult Stat(const std::string& path) const
29 { 41 {
30 return StatResult(); 42 return StatResult();
31 } 43 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 AdblockPlus::AppInfo appInfo; 98 AdblockPlus::AppInfo appInfo;
87 appInfo.name = "test"; 99 appInfo.name = "test";
88 appInfo.version = "1.0.1"; 100 appInfo.version = "1.0.1";
89 AdblockPlus::JsEnginePtr jsEngine = CreateJsEngine(appInfo); 101 AdblockPlus::JsEnginePtr jsEngine = CreateJsEngine(appInfo);
90 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new LazyFileSystem)); 102 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new LazyFileSystem));
91 mockWebRequest = new MockWebRequest; 103 mockWebRequest = new MockWebRequest;
92 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(mockWebRequest)); 104 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(mockWebRequest));
93 filterEngine = AdblockPlus::FilterEngine::Create(jsEngine); 105 filterEngine = AdblockPlus::FilterEngine::Create(jsEngine);
94 } 106 }
95 }; 107 };
96
97 struct MockUpdateAvailableCallback
98 {
99 MockUpdateAvailableCallback(int& timesCalled) : timesCalled(timesCalled) {}
100
101 void operator()(const std::string&)
102 {
103 timesCalled++;
104 }
105
106 private:
107 // We currently cannot store timesCalled in the functor, see:
108 // https://issues.adblockplus.org/ticket/1378.
109 int& timesCalled;
110 };
111
112 // Workaround for https://issues.adblockplus.org/ticket/1397.
113 void NoOpUpdaterCallback(const std::string&) {}
114 108
115 class FilterEngineWithFreshFolder : public ::testing::Test 109 class FilterEngineWithFreshFolder : public ::testing::Test
116 { 110 {
117 protected: 111 protected:
118 FileSystemPtr fileSystem; 112 FileSystemPtr fileSystem;
119 std::weak_ptr<JsEngine> weakJsEngine; 113 std::weak_ptr<JsEngine> weakJsEngine;
120 114
121 void SetUp() override 115 void SetUp() override
122 { 116 {
123 fileSystem.reset(new DefaultFileSystem()); 117 fileSystem.reset(new DefaultFileSystem());
(...skipping 30 matching lines...) Expand all
154 return true; 148 return true;
155 } 149 }
156 catch (...) 150 catch (...)
157 { 151 {
158 return false; 152 return false;
159 } 153 }
160 }; 154 };
161 int i = 5; 155 int i = 5;
162 while ((i-- > 0 && weakJsEngine.lock()) || !safeRemove()) 156 while ((i-- > 0 && weakJsEngine.lock()) || !safeRemove())
163 std::this_thread::sleep_for(std::chrono::seconds(2)); 157 std::this_thread::sleep_for(std::chrono::seconds(2));
158 }
159 };
160
161 class FilterEngineIsAllowedConnectionTest : public BaseJsTest
162 {
163 class MockWebRequest : public LazyWebRequest
164 {
165 public:
166 std::map</*beginning of url*/std::string, AdblockPlus::ServerResponse> res ponses;
167
168 AdblockPlus::ServerResponse GET(const std::string& url,
169 const AdblockPlus::HeaderList& requestHeaders) const
170 {
171 for (const auto& response : responses)
172 {
173 if (Utils::BeginsWith(url, response.first))
174 {
175 return response.second;
176 }
177 }
178 return LazyWebRequest::GET(url, requestHeaders);
179 }
180 };
181 class SyncStrings
182 {
183 public:
184 void Add(const std::string* value)
185 {
186 std::lock_guard<std::mutex> lock(mutex);
187 strings.emplace_back(!!value, value ? *value : "");
188 }
189 std::vector<std::pair<bool, std::string>> GetStrings() const
190 {
191 std::lock_guard<std::mutex> lock(mutex);
192 return strings;
193 }
194 void Clear()
195 {
196 std::lock_guard<std::mutex> lock(mutex);
197 strings.clear();
198 }
199 private:
200 mutable std::mutex mutex;
201 std::vector<std::pair<bool, std::string>> strings;
202 };
203 protected:
204 MockWebRequest* webRequest;
205 std::string subscriptionUrlPrefix;
206 FilterEngine::CreationParameters createParams;
207 SyncStrings capturedConnectionTypes;
208 bool isConnectionAllowed;
209 FilterEnginePtr filterEngine;
210
211 struct
212 {
213 std::string url;
214 std::mutex mutex;
215 std::condition_variable cv;
216 } downloadStatusChanged;
217
218 void SetUp()
219 {
220 BaseJsTest::SetUp();
221 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(new LazyFileSystem()));
222 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(webRequest = new MockWe bRequest()));
223 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(new LazyLogSystem()));
224
225 subscriptionUrlPrefix = "http://example";
226 ServerResponse exampleSubscriptionResponse;
227 exampleSubscriptionResponse.responseStatus = 200;
228 exampleSubscriptionResponse.status = WebRequest::NS_OK;
229 exampleSubscriptionResponse.responseText = "[Adblock Plus 2.0]\n||example. com";
230 webRequest->responses.emplace(subscriptionUrlPrefix, exampleSubscriptionRe sponse);
231 createParams.preconfiguredPrefs["first_run_subscription_auto_select"] = js Engine->NewValue(false);
232 isConnectionAllowed = true;
233 createParams.isConnectionAllowedCallback = [this](const std::string* allow edConnectionType)->bool{
234 capturedConnectionTypes.Add(allowedConnectionType);
235 return isConnectionAllowed;
236 };
237 jsEngine->SetEventCallback("filterChange", [this](const JsValueList& param s/*action, item*/)
238 {
239 ASSERT_EQ(2u, params.size());
240 if (params[0]->AsString() == "subscription.downloadStatus")
241 {
242 {
243 std::lock_guard<std::mutex> lock(downloadStatusChanged.mutex);
244 downloadStatusChanged.url = params[1]->GetProperty("url")->AsString( );
245 }
246 downloadStatusChanged.cv.notify_one();
247 }
248 });
249 }
250
251 SubscriptionPtr EnsureExampleSubscriptionAndForceUpdate(const std::string& a pppendToUrl = std::string())
252 {
253 if (!filterEngine)
254 filterEngine = FilterEngine::Create(jsEngine, createParams);
255 auto subscriptionUrl = subscriptionUrlPrefix + apppendToUrl;
256 auto subscription = filterEngine->GetSubscription(subscriptionUrl);
257 EXPECT_EQ(0u, subscription->GetProperty("filters")->AsList().size()) << su bscriptionUrl;
258 EXPECT_TRUE(subscription->GetProperty("downloadStatus")->IsNull()) << subs criptionUrl;
259 subscription->UpdateFilters();
260 {
261 std::unique_lock<std::mutex> lock(downloadStatusChanged.mutex);
262 downloadStatusChanged.cv.wait_for(lock,
263 /*don't block tests forever*/std::chrono::seconds(5),
264 [this, subscriptionUrl]()->bool
265 {
266 return subscriptionUrl == downloadStatusChanged.url;
267 });
268 // Basically it's enough to wait only for downloadStatus although there
269 // is still some JS code being executed. Any following attempt to work
270 // with subscription object will result in execution of JS, which will
271 // be blocked until finishing of currently running code.
272 }
273 return subscription;
164 } 274 }
165 }; 275 };
166 } 276 }
167 277
168 TEST_F(FilterEngineTest, FilterCreation) 278 TEST_F(FilterEngineTest, FilterCreation)
169 { 279 {
170 AdblockPlus::FilterPtr filter1 = filterEngine->GetFilter("foo"); 280 AdblockPlus::FilterPtr filter1 = filterEngine->GetFilter("foo");
171 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, filter1->GetType()); 281 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, filter1->GetType());
172 AdblockPlus::FilterPtr filter2 = filterEngine->GetFilter("@@foo"); 282 AdblockPlus::FilterPtr filter2 = filterEngine->GetFilter("@@foo");
173 ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, filter2->GetType()); 283 ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, filter2->GetType());
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 mockWebRequest->response.responseStatus = 200; 619 mockWebRequest->response.responseStatus = 200;
510 mockWebRequest->response.responseText = "\ 620 mockWebRequest->response.responseText = "\
511 {\ 621 {\
512 \"test\": {\ 622 \"test\": {\
513 \"version\": \"1.0.2\",\ 623 \"version\": \"1.0.2\",\
514 \"url\": \"https://downloads.adblockplus.org/test-1.0.2.tar.gz?update\"\ 624 \"url\": \"https://downloads.adblockplus.org/test-1.0.2.tar.gz?update\"\
515 }\ 625 }\
516 }"; 626 }";
517 627
518 int timesCalled = 0; 628 int timesCalled = 0;
519 MockUpdateAvailableCallback mockUpdateAvailableCallback(timesCalled); 629 filterEngine->SetUpdateAvailableCallback([&timesCalled](const std::string&)->v oid
520 630 {
521 filterEngine->SetUpdateAvailableCallback(mockUpdateAvailableCallback); 631 ++timesCalled;
522 filterEngine->ForceUpdateCheck(&NoOpUpdaterCallback); 632 });
633 filterEngine->ForceUpdateCheck();
523 AdblockPlus::Sleep(100); 634 AdblockPlus::Sleep(100);
524 ASSERT_EQ(1, timesCalled); 635 EXPECT_EQ(1, timesCalled);
525 636
526 filterEngine->RemoveUpdateAvailableCallback(); 637 filterEngine->RemoveUpdateAvailableCallback();
527 filterEngine->ForceUpdateCheck(&NoOpUpdaterCallback); 638 filterEngine->ForceUpdateCheck();
528 AdblockPlus::Sleep(100); 639 AdblockPlus::Sleep(100);
529 ASSERT_EQ(1, timesCalled); 640 EXPECT_EQ(1, timesCalled);
641 }
642
643 TEST_F(UpdaterTest, ForceUpdateCheck)
644 {
645 mockWebRequest->response.status = 0;
646 mockWebRequest->response.responseStatus = 200;
647 mockWebRequest->response.responseText = "\
648 {\
649 \"test\": {\
650 \"version\": \"1.0.2\",\
651 \"url\": \"https://downloads.adblockplus.org/test-1.0.2.tar.gz?update\"\
652 }\
653 }";
654
655 int called = 0; // 0 - not called; 1 - once, no error; 2 - error
656 filterEngine->ForceUpdateCheck([&called](const std::string& error)->void
657 {
658 called = error.empty() ? 1 : 2;
659 });
660 AdblockPlus::Sleep(100);
661 EXPECT_EQ(1, called);
530 } 662 }
531 663
532 TEST_F(FilterEngineTest, DocumentWhitelisting) 664 TEST_F(FilterEngineTest, DocumentWhitelisting)
533 { 665 {
534 filterEngine->GetFilter("@@||example.org^$document")->AddToList(); 666 filterEngine->GetFilter("@@||example.org^$document")->AddToList();
535 filterEngine->GetFilter("@@||example.com^$document,domain=example.de")->AddToL ist(); 667 filterEngine->GetFilter("@@||example.com^$document,domain=example.de")->AddToL ist();
536 668
537 ASSERT_TRUE(filterEngine->IsDocumentWhitelisted( 669 ASSERT_TRUE(filterEngine->IsDocumentWhitelisted(
538 "http://example.org", 670 "http://example.org",
539 std::vector<std::string>())); 671 std::vector<std::string>()));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 auto jsEngine = createJsEngine(appInfo); 727 auto jsEngine = createJsEngine(appInfo);
596 auto filterEngine = AdblockPlus::FilterEngine::Create(jsEngine); 728 auto filterEngine = AdblockPlus::FilterEngine::Create(jsEngine);
597 const auto subscriptions = filterEngine->GetListedSubscriptions(); 729 const auto subscriptions = filterEngine->GetListedSubscriptions();
598 ASSERT_EQ(2u, subscriptions.size()); 730 ASSERT_EQ(2u, subscriptions.size());
599 SubscriptionPtr aaSubscription; 731 SubscriptionPtr aaSubscription;
600 SubscriptionPtr langSubscription; 732 SubscriptionPtr langSubscription;
601 if (subscriptions[0]->IsAA()) 733 if (subscriptions[0]->IsAA())
602 { 734 {
603 aaSubscription = subscriptions[0]; 735 aaSubscription = subscriptions[0];
604 langSubscription = subscriptions[1]; 736 langSubscription = subscriptions[1];
605 } else if (subscriptions[1]->IsAA()) 737 }
738 else if (subscriptions[1]->IsAA())
606 { 739 {
607 aaSubscription = subscriptions[1]; 740 aaSubscription = subscriptions[1];
608 langSubscription = subscriptions[0]; 741 langSubscription = subscriptions[0];
609 } 742 }
610 ASSERT_NE(nullptr, aaSubscription); 743 ASSERT_NE(nullptr, aaSubscription);
611 ASSERT_NE(nullptr, langSubscription); 744 ASSERT_NE(nullptr, langSubscription);
612 EXPECT_EQ(langSubscriptionUrl, langSubscription->GetProperty("url")->AsString( )); 745 EXPECT_EQ(langSubscriptionUrl, langSubscription->GetProperty("url")->AsString( ));
613 EXPECT_TRUE(filterEngine->IsAAEnabled()); 746 EXPECT_TRUE(filterEngine->IsAAEnabled());
614 } 747 }
615 748
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 { 902 {
770 // no subscription (because of preconfigured prefs.json and patterns.ini ), 903 // no subscription (because of preconfigured prefs.json and patterns.ini ),
771 // though it should be enabled by default in a non-test environment, it' s tested in 904 // though it should be enabled by default in a non-test environment, it' s tested in
772 // corresponding tests. 905 // corresponding tests.
773 const auto subscriptions = filterEngine->GetListedSubscriptions(); 906 const auto subscriptions = filterEngine->GetListedSubscriptions();
774 EXPECT_EQ(0u, subscriptions.size()); // no any subscription including AA 907 EXPECT_EQ(0u, subscriptions.size()); // no any subscription including AA
775 EXPECT_FALSE(filterEngine->IsAAEnabled()); 908 EXPECT_FALSE(filterEngine->IsAAEnabled());
776 } 909 }
777 if (otherSubscriptionsNumber == 1u) 910 if (otherSubscriptionsNumber == 1u)
778 { 911 {
779 auto subscruption = filterEngine->GetSubscription(kOtherSubscriptionUrl) ; 912 auto subscription = filterEngine->GetSubscription(kOtherSubscriptionUrl) ;
780 ASSERT_TRUE(subscruption); 913 ASSERT_TRUE(subscription);
781 subscruption->AddToList(); 914 subscription->AddToList();
782 const auto subscriptions = filterEngine->GetListedSubscriptions(); 915 const auto subscriptions = filterEngine->GetListedSubscriptions();
783 ASSERT_EQ(1u, subscriptions.size()); 916 ASSERT_EQ(1u, subscriptions.size());
784 EXPECT_FALSE(subscriptions[0]->IsAA()); 917 EXPECT_FALSE(subscriptions[0]->IsAA());
785 EXPECT_EQ(kOtherSubscriptionUrl, subscriptions[0]->GetProperty("url")->A sString()); 918 EXPECT_EQ(kOtherSubscriptionUrl, subscriptions[0]->GetProperty("url")->A sString());
786 } 919 }
787 if (isAASatusPresent(aaStatus)) 920 if (isAASatusPresent(aaStatus))
788 { 921 {
789 filterEngine->SetAAEnabled(true); // add AA by enabling it 922 filterEngine->SetAAEnabled(true); // add AA by enabling it
790 if (aaStatus == AAStatus::disabled_present) 923 if (aaStatus == AAStatus::disabled_present)
791 { 924 {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 aaSubscription = subscription; 998 aaSubscription = subscription;
866 break; 999 break;
867 } 1000 }
868 } 1001 }
869 ASSERT_TRUE(aaSubscription); 1002 ASSERT_TRUE(aaSubscription);
870 aaSubscription->RemoveFromList(); 1003 aaSubscription->RemoveFromList();
871 } 1004 }
872 1005
873 testSubscriptionState(parameter.expectedAAStatus, otherSubscriptionsNumber); 1006 testSubscriptionState(parameter.expectedAAStatus, otherSubscriptionsNumber);
874 } 1007 }
1008 }
1009
1010 TEST_F(FilterEngineIsAllowedConnectionTest, AbsentCallbackAllowsUpdating)
1011 {
1012 createParams.isConnectionAllowedCallback = FilterEngine::IsConnectionAllowedCa llback();
1013 auto subscription = EnsureExampleSubscriptionAndForceUpdate();
1014 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus")->AsStr ing());
1015 EXPECT_EQ(1u, subscription->GetProperty("filters")->AsList().size());
1016 }
1017
1018 TEST_F(FilterEngineIsAllowedConnectionTest, AllowingCallbackAllowsUpdating)
1019 {
1020 // no stored allowed_connection_type preference
1021 auto subscription = EnsureExampleSubscriptionAndForceUpdate();
1022 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus")->AsStr ing());
1023 EXPECT_EQ(1u, subscription->GetProperty("filters")->AsList().size());
1024 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
1025 ASSERT_EQ(1u, capturedConnectionTypes.size());
1026 EXPECT_FALSE(capturedConnectionTypes[0].first);
1027 }
1028
1029 TEST_F(FilterEngineIsAllowedConnectionTest, NotAllowingCallbackDoesNotAllowUpdat ing)
1030 {
1031 isConnectionAllowed = false;
1032 // no stored allowed_connection_type preference
1033 auto subscription = EnsureExampleSubscriptionAndForceUpdate();
1034 EXPECT_EQ("synchronize_connection_error", subscription->GetProperty("downloadS tatus")->AsString());
1035 EXPECT_EQ(0u, subscription->GetProperty("filters")->AsList().size());
1036 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
1037 EXPECT_EQ(1u, capturedConnectionTypes.size());
1038 }
1039
1040 TEST_F(FilterEngineIsAllowedConnectionTest, PredefinedAllowedConnectionTypeIsPas sedToCallback)
1041 {
1042 std::string predefinedAllowedConnectionType = "non-metered";
1043 createParams.preconfiguredPrefs["allowed_connection_type"] = jsEngine->NewValu e(predefinedAllowedConnectionType);
1044 auto subscription = EnsureExampleSubscriptionAndForceUpdate();
1045 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus")->AsStr ing());
1046 EXPECT_EQ(1u, subscription->GetProperty("filters")->AsList().size());
1047 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
1048 ASSERT_EQ(1u, capturedConnectionTypes.size());
1049 EXPECT_TRUE(capturedConnectionTypes[0].first);
1050 EXPECT_EQ(predefinedAllowedConnectionType, capturedConnectionTypes[0].second);
1051 }
1052
1053 TEST_F(FilterEngineIsAllowedConnectionTest, ConfiguredConnectionTypeIsPassedToCa llback)
1054 {
1055 // FilterEngine->RemoveSubscription is not usable here because subscriptions
1056 // are cached internally by URL. So, different URLs are used in diffirent
1057 // checks.
1058 {
1059 std::string predefinedAllowedConnectionType = "non-metered";
1060 createParams.preconfiguredPrefs["allowed_connection_type"] = jsEngine->NewVa lue(predefinedAllowedConnectionType);
1061 auto subscription = EnsureExampleSubscriptionAndForceUpdate();
1062 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus")->AsS tring());
1063 EXPECT_EQ(1u, subscription->GetProperty("filters")->AsList().size());
1064 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
1065 ASSERT_EQ(1u, capturedConnectionTypes.size());
1066 EXPECT_TRUE(capturedConnectionTypes[0].first);
1067 EXPECT_EQ(predefinedAllowedConnectionType, capturedConnectionTypes[0].second );
1068 }
1069 capturedConnectionTypes.Clear();
1070 {
1071 // set no value
1072 filterEngine->SetAllowedConnectionType(nullptr);
1073 auto subscription = EnsureExampleSubscriptionAndForceUpdate("subA");
1074 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus")->AsS tring());
1075 EXPECT_EQ(1u, subscription->GetProperty("filters")->AsList().size());
1076 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
1077 ASSERT_EQ(1u, capturedConnectionTypes.size());
1078 EXPECT_FALSE(capturedConnectionTypes[0].first);
1079 subscription->RemoveFromList();
1080 this->capturedConnectionTypes.Clear();
1081 }
1082 capturedConnectionTypes.Clear();
1083 {
1084 // set some value
1085 std::string testConnection = "test connection";
1086 filterEngine->SetAllowedConnectionType(&testConnection);
1087 auto subscription = EnsureExampleSubscriptionAndForceUpdate("subB");
1088 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus")->AsS tring());
1089 EXPECT_EQ(1u, subscription->GetProperty("filters")->AsList().size());
1090 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
1091 ASSERT_EQ(1u, capturedConnectionTypes.size());
1092 EXPECT_TRUE(capturedConnectionTypes[0].first);
1093 EXPECT_EQ(testConnection, capturedConnectionTypes[0].second);
1094 }
875 } 1095 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld