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

Side by Side Diff: test/FilterEngine.cpp

Issue 29416579: Issue 5034 - Part 1: Pass a JsValue directly to SetProperty() and return from GetProperty() (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Remove JsValue test Created April 19, 2017, 2:46 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/WebRequestJsObject.cpp ('k') | test/JsEngine.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 capturedConnectionTypes.Add(allowedConnectionType); 234 capturedConnectionTypes.Add(allowedConnectionType);
235 return isConnectionAllowed; 235 return isConnectionAllowed;
236 }; 236 };
237 jsEngine->SetEventCallback("filterChange", [this](const JsConstValueList& params/*action, item*/) 237 jsEngine->SetEventCallback("filterChange", [this](const JsConstValueList& params/*action, item*/)
238 { 238 {
239 ASSERT_EQ(2u, params.size()); 239 ASSERT_EQ(2u, params.size());
240 if (params[0]->AsString() == "subscription.downloadStatus") 240 if (params[0]->AsString() == "subscription.downloadStatus")
241 { 241 {
242 { 242 {
243 std::lock_guard<std::mutex> lock(downloadStatusChanged.mutex); 243 std::lock_guard<std::mutex> lock(downloadStatusChanged.mutex);
244 downloadStatusChanged.url = params[1]->GetProperty("url")->AsString( ); 244 downloadStatusChanged.url = params[1]->GetProperty("url").AsString() ;
245 } 245 }
246 downloadStatusChanged.cv.notify_one(); 246 downloadStatusChanged.cv.notify_one();
247 } 247 }
248 }); 248 });
249 } 249 }
250 250
251 SubscriptionPtr EnsureExampleSubscriptionAndForceUpdate(const std::string& a pppendToUrl = std::string()) 251 SubscriptionPtr EnsureExampleSubscriptionAndForceUpdate(const std::string& a pppendToUrl = std::string())
252 { 252 {
253 if (!filterEngine) 253 if (!filterEngine)
254 filterEngine = FilterEngine::Create(jsEngine, createParams); 254 filterEngine = FilterEngine::Create(jsEngine, createParams);
255 auto subscriptionUrl = subscriptionUrlPrefix + apppendToUrl; 255 auto subscriptionUrl = subscriptionUrlPrefix + apppendToUrl;
256 auto subscription = filterEngine->GetSubscription(subscriptionUrl); 256 auto subscription = filterEngine->GetSubscription(subscriptionUrl);
257 EXPECT_EQ(0u, subscription->GetProperty("filters")->AsList().size()) << su bscriptionUrl; 257 EXPECT_EQ(0u, subscription->GetProperty("filters").AsList().size()) << sub scriptionUrl;
258 EXPECT_TRUE(subscription->GetProperty("downloadStatus")->IsNull()) << subs criptionUrl; 258 EXPECT_TRUE(subscription->GetProperty("downloadStatus").IsNull()) << subsc riptionUrl;
259 subscription->UpdateFilters(); 259 subscription->UpdateFilters();
260 { 260 {
261 std::unique_lock<std::mutex> lock(downloadStatusChanged.mutex); 261 std::unique_lock<std::mutex> lock(downloadStatusChanged.mutex);
262 downloadStatusChanged.cv.wait_for(lock, 262 downloadStatusChanged.cv.wait_for(lock,
263 /*don't block tests forever*/std::chrono::seconds(5), 263 /*don't block tests forever*/std::chrono::seconds(5),
264 [this, subscriptionUrl]()->bool 264 [this, subscriptionUrl]()->bool
265 { 265 {
266 return subscriptionUrl == downloadStatusChanged.url; 266 return subscriptionUrl == downloadStatusChanged.url;
267 }); 267 });
268 // Basically it's enough to wait only for downloadStatus although there 268 // Basically it's enough to wait only for downloadStatus although there
(...skipping 17 matching lines...) Expand all
286 AdblockPlus::FilterPtr filter4 = filterEngine->GetFilter("example.com#@#foo"); 286 AdblockPlus::FilterPtr filter4 = filterEngine->GetFilter("example.com#@#foo");
287 ASSERT_EQ(AdblockPlus::Filter::TYPE_ELEMHIDE_EXCEPTION, filter4->GetType()); 287 ASSERT_EQ(AdblockPlus::Filter::TYPE_ELEMHIDE_EXCEPTION, filter4->GetType());
288 AdblockPlus::FilterPtr filter5 = filterEngine->GetFilter(" foo "); 288 AdblockPlus::FilterPtr filter5 = filterEngine->GetFilter(" foo ");
289 ASSERT_EQ(*filter1, *filter5); 289 ASSERT_EQ(*filter1, *filter5);
290 } 290 }
291 291
292 TEST_F(FilterEngineTest, FilterProperties) 292 TEST_F(FilterEngineTest, FilterProperties)
293 { 293 {
294 AdblockPlus::FilterPtr filter = filterEngine->GetFilter("foo"); 294 AdblockPlus::FilterPtr filter = filterEngine->GetFilter("foo");
295 295
296 ASSERT_TRUE(filter->GetProperty("stringFoo")->IsUndefined()); 296 ASSERT_TRUE(filter->GetProperty("stringFoo").IsUndefined());
297 ASSERT_TRUE(filter->GetProperty("intFoo")->IsUndefined()); 297 ASSERT_TRUE(filter->GetProperty("intFoo").IsUndefined());
298 ASSERT_TRUE(filter->GetProperty("boolFoo")->IsUndefined()); 298 ASSERT_TRUE(filter->GetProperty("boolFoo").IsUndefined());
299 299
300 filter->SetProperty("stringFoo", "y"); 300 filter->SetProperty("stringFoo", "y");
301 filter->SetProperty("intFoo", 24); 301 filter->SetProperty("intFoo", 24);
302 filter->SetProperty("boolFoo", true); 302 filter->SetProperty("boolFoo", true);
303 ASSERT_EQ("y", filter->GetProperty("stringFoo")->AsString()); 303 ASSERT_EQ("y", filter->GetProperty("stringFoo").AsString());
304 ASSERT_EQ(24, filter->GetProperty("intFoo")->AsInt()); 304 ASSERT_EQ(24, filter->GetProperty("intFoo").AsInt());
305 ASSERT_TRUE(filter->GetProperty("boolFoo")->AsBool()); 305 ASSERT_TRUE(filter->GetProperty("boolFoo").AsBool());
306 } 306 }
307 307
308 TEST_F(FilterEngineTest, AddRemoveFilters) 308 TEST_F(FilterEngineTest, AddRemoveFilters)
309 { 309 {
310 ASSERT_EQ(0u, filterEngine->GetListedFilters().size()); 310 ASSERT_EQ(0u, filterEngine->GetListedFilters().size());
311 AdblockPlus::FilterPtr filter = filterEngine->GetFilter("foo"); 311 AdblockPlus::FilterPtr filter = filterEngine->GetFilter("foo");
312 ASSERT_EQ(0u, filterEngine->GetListedFilters().size()); 312 ASSERT_EQ(0u, filterEngine->GetListedFilters().size());
313 ASSERT_FALSE(filter->IsListed()); 313 ASSERT_FALSE(filter->IsListed());
314 filter->AddToList(); 314 filter->AddToList();
315 ASSERT_EQ(1u, filterEngine->GetListedFilters().size()); 315 ASSERT_EQ(1u, filterEngine->GetListedFilters().size());
316 ASSERT_EQ(*filter, *filterEngine->GetListedFilters()[0]); 316 ASSERT_EQ(*filter, *filterEngine->GetListedFilters()[0]);
317 ASSERT_TRUE(filter->IsListed()); 317 ASSERT_TRUE(filter->IsListed());
318 filter->AddToList(); 318 filter->AddToList();
319 ASSERT_EQ(1u, filterEngine->GetListedFilters().size()); 319 ASSERT_EQ(1u, filterEngine->GetListedFilters().size());
320 ASSERT_EQ(*filter, *filterEngine->GetListedFilters()[0]); 320 ASSERT_EQ(*filter, *filterEngine->GetListedFilters()[0]);
321 ASSERT_TRUE(filter->IsListed()); 321 ASSERT_TRUE(filter->IsListed());
322 filter->RemoveFromList(); 322 filter->RemoveFromList();
323 ASSERT_EQ(0u, filterEngine->GetListedFilters().size()); 323 ASSERT_EQ(0u, filterEngine->GetListedFilters().size());
324 ASSERT_FALSE(filter->IsListed()); 324 ASSERT_FALSE(filter->IsListed());
325 filter->RemoveFromList(); 325 filter->RemoveFromList();
326 ASSERT_EQ(0u, filterEngine->GetListedFilters().size()); 326 ASSERT_EQ(0u, filterEngine->GetListedFilters().size());
327 ASSERT_FALSE(filter->IsListed()); 327 ASSERT_FALSE(filter->IsListed());
328 } 328 }
329 329
330 TEST_F(FilterEngineTest, SubscriptionProperties) 330 TEST_F(FilterEngineTest, SubscriptionProperties)
331 { 331 {
332 AdblockPlus::SubscriptionPtr subscription = filterEngine->GetSubscription("foo "); 332 AdblockPlus::SubscriptionPtr subscription = filterEngine->GetSubscription("foo ");
333 333
334 ASSERT_TRUE(subscription->GetProperty("stringFoo")->IsUndefined()); 334 ASSERT_TRUE(subscription->GetProperty("stringFoo").IsUndefined());
335 ASSERT_TRUE(subscription->GetProperty("intFoo")->IsUndefined()); 335 ASSERT_TRUE(subscription->GetProperty("intFoo").IsUndefined());
336 ASSERT_TRUE(subscription->GetProperty("boolFoo")->IsUndefined()); 336 ASSERT_TRUE(subscription->GetProperty("boolFoo").IsUndefined());
337 337
338 subscription->SetProperty("stringFoo", "y"); 338 subscription->SetProperty("stringFoo", "y");
339 subscription->SetProperty("intFoo", 24); 339 subscription->SetProperty("intFoo", 24);
340 subscription->SetProperty("boolFoo", true); 340 subscription->SetProperty("boolFoo", true);
341 ASSERT_EQ("y", subscription->GetProperty("stringFoo")->AsString()); 341 ASSERT_EQ("y", subscription->GetProperty("stringFoo").AsString());
342 ASSERT_EQ(24, subscription->GetProperty("intFoo")->AsInt()); 342 ASSERT_EQ(24, subscription->GetProperty("intFoo").AsInt());
343 ASSERT_TRUE(subscription->GetProperty("boolFoo")->AsBool()); 343 ASSERT_TRUE(subscription->GetProperty("boolFoo").AsBool());
344 } 344 }
345 345
346 TEST_F(FilterEngineTest, AddRemoveSubscriptions) 346 TEST_F(FilterEngineTest, AddRemoveSubscriptions)
347 { 347 {
348 ASSERT_EQ(0u, filterEngine->GetListedSubscriptions().size()); 348 ASSERT_EQ(0u, filterEngine->GetListedSubscriptions().size());
349 AdblockPlus::SubscriptionPtr subscription = filterEngine->GetSubscription("foo "); 349 AdblockPlus::SubscriptionPtr subscription = filterEngine->GetSubscription("foo ");
350 ASSERT_EQ(0u, filterEngine->GetListedSubscriptions().size()); 350 ASSERT_EQ(0u, filterEngine->GetListedSubscriptions().size());
351 ASSERT_FALSE(subscription->IsListed()); 351 ASSERT_FALSE(subscription->IsListed());
352 subscription->AddToList(); 352 subscription->AddToList();
353 ASSERT_EQ(1u, filterEngine->GetListedSubscriptions().size()); 353 ASSERT_EQ(1u, filterEngine->GetListedSubscriptions().size());
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 aaSubscription = subscriptions[0]; 735 aaSubscription = subscriptions[0];
736 langSubscription = subscriptions[1]; 736 langSubscription = subscriptions[1];
737 } 737 }
738 else if (subscriptions[1]->IsAA()) 738 else if (subscriptions[1]->IsAA())
739 { 739 {
740 aaSubscription = subscriptions[1]; 740 aaSubscription = subscriptions[1];
741 langSubscription = subscriptions[0]; 741 langSubscription = subscriptions[0];
742 } 742 }
743 ASSERT_NE(nullptr, aaSubscription); 743 ASSERT_NE(nullptr, aaSubscription);
744 ASSERT_NE(nullptr, langSubscription); 744 ASSERT_NE(nullptr, langSubscription);
745 EXPECT_EQ(langSubscriptionUrl, langSubscription->GetProperty("url")->AsString( )); 745 EXPECT_EQ(langSubscriptionUrl, langSubscription->GetProperty("url").AsString() );
746 EXPECT_TRUE(filterEngine->IsAAEnabled()); 746 EXPECT_TRUE(filterEngine->IsAAEnabled());
747 } 747 }
748 748
749 TEST_F(FilterEngineWithFreshFolder, DisableSubscriptionsAutoSelectOnFirstRun) 749 TEST_F(FilterEngineWithFreshFolder, DisableSubscriptionsAutoSelectOnFirstRun)
750 { 750 {
751 auto jsEngine = createJsEngine(); 751 auto jsEngine = createJsEngine();
752 FilterEngine::CreationParameters createParams; 752 FilterEngine::CreationParameters createParams;
753 createParams.preconfiguredPrefs["first_run_subscription_auto_select"] = jsEngi ne->NewValue(false); 753 createParams.preconfiguredPrefs["first_run_subscription_auto_select"] = jsEngi ne->NewValue(false);
754 auto filterEngine = AdblockPlus::FilterEngine::Create(jsEngine, createParams); 754 auto filterEngine = AdblockPlus::FilterEngine::Create(jsEngine, createParams);
755 const auto subscriptions = filterEngine->GetListedSubscriptions(); 755 const auto subscriptions = filterEngine->GetListedSubscriptions();
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 EXPECT_FALSE(filterEngine->IsAAEnabled()); 908 EXPECT_FALSE(filterEngine->IsAAEnabled());
909 } 909 }
910 if (otherSubscriptionsNumber == 1u) 910 if (otherSubscriptionsNumber == 1u)
911 { 911 {
912 auto subscription = filterEngine->GetSubscription(kOtherSubscriptionUrl) ; 912 auto subscription = filterEngine->GetSubscription(kOtherSubscriptionUrl) ;
913 ASSERT_TRUE(subscription); 913 ASSERT_TRUE(subscription);
914 subscription->AddToList(); 914 subscription->AddToList();
915 const auto subscriptions = filterEngine->GetListedSubscriptions(); 915 const auto subscriptions = filterEngine->GetListedSubscriptions();
916 ASSERT_EQ(1u, subscriptions.size()); 916 ASSERT_EQ(1u, subscriptions.size());
917 EXPECT_FALSE(subscriptions[0]->IsAA()); 917 EXPECT_FALSE(subscriptions[0]->IsAA());
918 EXPECT_EQ(kOtherSubscriptionUrl, subscriptions[0]->GetProperty("url")->A sString()); 918 EXPECT_EQ(kOtherSubscriptionUrl, subscriptions[0]->GetProperty("url").As String());
919 } 919 }
920 if (isAASatusPresent(aaStatus)) 920 if (isAASatusPresent(aaStatus))
921 { 921 {
922 filterEngine->SetAAEnabled(true); // add AA by enabling it 922 filterEngine->SetAAEnabled(true); // add AA by enabling it
923 if (aaStatus == AAStatus::disabled_present) 923 if (aaStatus == AAStatus::disabled_present)
924 { 924 {
925 filterEngine->SetAAEnabled(false); 925 filterEngine->SetAAEnabled(false);
926 } 926 }
927 testSubscriptionState(aaStatus, otherSubscriptionsNumber); 927 testSubscriptionState(aaStatus, otherSubscriptionsNumber);
928 } 928 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 } 1004 }
1005 1005
1006 testSubscriptionState(parameter.expectedAAStatus, otherSubscriptionsNumber); 1006 testSubscriptionState(parameter.expectedAAStatus, otherSubscriptionsNumber);
1007 } 1007 }
1008 } 1008 }
1009 1009
1010 TEST_F(FilterEngineIsAllowedConnectionTest, AbsentCallbackAllowsUpdating) 1010 TEST_F(FilterEngineIsAllowedConnectionTest, AbsentCallbackAllowsUpdating)
1011 { 1011 {
1012 createParams.isConnectionAllowedCallback = FilterEngine::IsConnectionAllowedCa llback(); 1012 createParams.isConnectionAllowedCallback = FilterEngine::IsConnectionAllowedCa llback();
1013 auto subscription = EnsureExampleSubscriptionAndForceUpdate(); 1013 auto subscription = EnsureExampleSubscriptionAndForceUpdate();
1014 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus")->AsStr ing()); 1014 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus").AsStri ng());
1015 EXPECT_EQ(1u, subscription->GetProperty("filters")->AsList().size()); 1015 EXPECT_EQ(1u, subscription->GetProperty("filters").AsList().size());
1016 } 1016 }
1017 1017
1018 TEST_F(FilterEngineIsAllowedConnectionTest, AllowingCallbackAllowsUpdating) 1018 TEST_F(FilterEngineIsAllowedConnectionTest, AllowingCallbackAllowsUpdating)
1019 { 1019 {
1020 // no stored allowed_connection_type preference 1020 // no stored allowed_connection_type preference
1021 auto subscription = EnsureExampleSubscriptionAndForceUpdate(); 1021 auto subscription = EnsureExampleSubscriptionAndForceUpdate();
1022 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus")->AsStr ing()); 1022 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus").AsStri ng());
1023 EXPECT_EQ(1u, subscription->GetProperty("filters")->AsList().size()); 1023 EXPECT_EQ(1u, subscription->GetProperty("filters").AsList().size());
1024 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings(); 1024 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
1025 ASSERT_EQ(1u, capturedConnectionTypes.size()); 1025 ASSERT_EQ(1u, capturedConnectionTypes.size());
1026 EXPECT_FALSE(capturedConnectionTypes[0].first); 1026 EXPECT_FALSE(capturedConnectionTypes[0].first);
1027 } 1027 }
1028 1028
1029 TEST_F(FilterEngineIsAllowedConnectionTest, NotAllowingCallbackDoesNotAllowUpdat ing) 1029 TEST_F(FilterEngineIsAllowedConnectionTest, NotAllowingCallbackDoesNotAllowUpdat ing)
1030 { 1030 {
1031 isConnectionAllowed = false; 1031 isConnectionAllowed = false;
1032 // no stored allowed_connection_type preference 1032 // no stored allowed_connection_type preference
1033 auto subscription = EnsureExampleSubscriptionAndForceUpdate(); 1033 auto subscription = EnsureExampleSubscriptionAndForceUpdate();
1034 EXPECT_EQ("synchronize_connection_error", subscription->GetProperty("downloadS tatus")->AsString()); 1034 EXPECT_EQ("synchronize_connection_error", subscription->GetProperty("downloadS tatus").AsString());
1035 EXPECT_EQ(0u, subscription->GetProperty("filters")->AsList().size()); 1035 EXPECT_EQ(0u, subscription->GetProperty("filters").AsList().size());
1036 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings(); 1036 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
1037 EXPECT_EQ(1u, capturedConnectionTypes.size()); 1037 EXPECT_EQ(1u, capturedConnectionTypes.size());
1038 } 1038 }
1039 1039
1040 TEST_F(FilterEngineIsAllowedConnectionTest, PredefinedAllowedConnectionTypeIsPas sedToCallback) 1040 TEST_F(FilterEngineIsAllowedConnectionTest, PredefinedAllowedConnectionTypeIsPas sedToCallback)
1041 { 1041 {
1042 std::string predefinedAllowedConnectionType = "non-metered"; 1042 std::string predefinedAllowedConnectionType = "non-metered";
1043 createParams.preconfiguredPrefs["allowed_connection_type"] = jsEngine->NewValu e(predefinedAllowedConnectionType); 1043 createParams.preconfiguredPrefs["allowed_connection_type"] = jsEngine->NewValu e(predefinedAllowedConnectionType);
1044 auto subscription = EnsureExampleSubscriptionAndForceUpdate(); 1044 auto subscription = EnsureExampleSubscriptionAndForceUpdate();
1045 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus")->AsStr ing()); 1045 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus").AsStri ng());
1046 EXPECT_EQ(1u, subscription->GetProperty("filters")->AsList().size()); 1046 EXPECT_EQ(1u, subscription->GetProperty("filters").AsList().size());
1047 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings(); 1047 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
1048 ASSERT_EQ(1u, capturedConnectionTypes.size()); 1048 ASSERT_EQ(1u, capturedConnectionTypes.size());
1049 EXPECT_TRUE(capturedConnectionTypes[0].first); 1049 EXPECT_TRUE(capturedConnectionTypes[0].first);
1050 EXPECT_EQ(predefinedAllowedConnectionType, capturedConnectionTypes[0].second); 1050 EXPECT_EQ(predefinedAllowedConnectionType, capturedConnectionTypes[0].second);
1051 } 1051 }
1052 1052
1053 TEST_F(FilterEngineIsAllowedConnectionTest, ConfiguredConnectionTypeIsPassedToCa llback) 1053 TEST_F(FilterEngineIsAllowedConnectionTest, ConfiguredConnectionTypeIsPassedToCa llback)
1054 { 1054 {
1055 // FilterEngine->RemoveSubscription is not usable here because subscriptions 1055 // FilterEngine->RemoveSubscription is not usable here because subscriptions
1056 // are cached internally by URL. So, different URLs are used in diffirent 1056 // are cached internally by URL. So, different URLs are used in diffirent
1057 // checks. 1057 // checks.
1058 { 1058 {
1059 std::string predefinedAllowedConnectionType = "non-metered"; 1059 std::string predefinedAllowedConnectionType = "non-metered";
1060 createParams.preconfiguredPrefs["allowed_connection_type"] = jsEngine->NewVa lue(predefinedAllowedConnectionType); 1060 createParams.preconfiguredPrefs["allowed_connection_type"] = jsEngine->NewVa lue(predefinedAllowedConnectionType);
1061 auto subscription = EnsureExampleSubscriptionAndForceUpdate(); 1061 auto subscription = EnsureExampleSubscriptionAndForceUpdate();
1062 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus")->AsS tring()); 1062 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus").AsSt ring());
1063 EXPECT_EQ(1u, subscription->GetProperty("filters")->AsList().size()); 1063 EXPECT_EQ(1u, subscription->GetProperty("filters").AsList().size());
1064 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings(); 1064 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
1065 ASSERT_EQ(1u, capturedConnectionTypes.size()); 1065 ASSERT_EQ(1u, capturedConnectionTypes.size());
1066 EXPECT_TRUE(capturedConnectionTypes[0].first); 1066 EXPECT_TRUE(capturedConnectionTypes[0].first);
1067 EXPECT_EQ(predefinedAllowedConnectionType, capturedConnectionTypes[0].second ); 1067 EXPECT_EQ(predefinedAllowedConnectionType, capturedConnectionTypes[0].second );
1068 } 1068 }
1069 capturedConnectionTypes.Clear(); 1069 capturedConnectionTypes.Clear();
1070 { 1070 {
1071 // set no value 1071 // set no value
1072 filterEngine->SetAllowedConnectionType(nullptr); 1072 filterEngine->SetAllowedConnectionType(nullptr);
1073 auto subscription = EnsureExampleSubscriptionAndForceUpdate("subA"); 1073 auto subscription = EnsureExampleSubscriptionAndForceUpdate("subA");
1074 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus")->AsS tring()); 1074 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus").AsSt ring());
1075 EXPECT_EQ(1u, subscription->GetProperty("filters")->AsList().size()); 1075 EXPECT_EQ(1u, subscription->GetProperty("filters").AsList().size());
1076 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings(); 1076 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
1077 ASSERT_EQ(1u, capturedConnectionTypes.size()); 1077 ASSERT_EQ(1u, capturedConnectionTypes.size());
1078 EXPECT_FALSE(capturedConnectionTypes[0].first); 1078 EXPECT_FALSE(capturedConnectionTypes[0].first);
1079 subscription->RemoveFromList(); 1079 subscription->RemoveFromList();
1080 this->capturedConnectionTypes.Clear(); 1080 this->capturedConnectionTypes.Clear();
1081 } 1081 }
1082 capturedConnectionTypes.Clear(); 1082 capturedConnectionTypes.Clear();
1083 { 1083 {
1084 // set some value 1084 // set some value
1085 std::string testConnection = "test connection"; 1085 std::string testConnection = "test connection";
1086 filterEngine->SetAllowedConnectionType(&testConnection); 1086 filterEngine->SetAllowedConnectionType(&testConnection);
1087 auto subscription = EnsureExampleSubscriptionAndForceUpdate("subB"); 1087 auto subscription = EnsureExampleSubscriptionAndForceUpdate("subB");
1088 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus")->AsS tring()); 1088 EXPECT_EQ("synchronize_ok", subscription->GetProperty("downloadStatus").AsSt ring());
1089 EXPECT_EQ(1u, subscription->GetProperty("filters")->AsList().size()); 1089 EXPECT_EQ(1u, subscription->GetProperty("filters").AsList().size());
1090 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings(); 1090 auto capturedConnectionTypes = this->capturedConnectionTypes.GetStrings();
1091 ASSERT_EQ(1u, capturedConnectionTypes.size()); 1091 ASSERT_EQ(1u, capturedConnectionTypes.size());
1092 EXPECT_TRUE(capturedConnectionTypes[0].first); 1092 EXPECT_TRUE(capturedConnectionTypes[0].first);
1093 EXPECT_EQ(testConnection, capturedConnectionTypes[0].second); 1093 EXPECT_EQ(testConnection, capturedConnectionTypes[0].second);
1094 } 1094 }
1095 } 1095 }
OLDNEW
« 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